[AMDGPU] Keep soft waitcnts unchanged until SIInsertWaitcnts converges (#244689)
On the first visit to a loop header, a soft waitcnt whose `lgkmcnt`
simplifies away but whose `vmcnt` is still needed was rewritten and
promoted (or merged into a preceding hard wait). The revisit through the
back edge then lost the `lgkmcnt(0)`, so the `s_barrier` after a release
fence no longer waited for the loop's LDS store. Like #220357, keep soft
waitcnts unchanged until the pass converges, and let a hard waitcnt
carry what each visit needs.
gfx950 runtime reproducer: 20/20 launches read stale LDS before, 0/20
after. Other test changes: in 14 tests the wait moves past meta
instructions (emitted code unchanged), and `expand-waitcnt-profiling.ll`
now expands the release-fence wait on gfx9-gfx11.
Fixes: LCOMPILER-3291
Assisted-by: Claude Opus 5.5
[InstSimplify] Avoid unnecessary flag drops in unused select operands (#248387)
In simplifyWithOpsReplaced(), if the select has a constant condition,
don't simplify the non-demanded value operand. This avoid unnecessarily
dropping its flags.
Fixes a regression from
https://github.com/llvm/llvm-project/pull/247632.
[Attributor] Don't seed functions without exact definitions in the light pass (#241934)
attributor-light seeded AAs for every function, including those without
an exact definition (e.g. `linkonce_odr`), which is most functions in
C++ code. Skip them to save compile time, as `FunctionAttrs` does. The
full Attributor still seeds them.
This loses some attributes on these functions and on call sites inside
them (see the `nonnull.ll` change).
CTMark objects are unchanged.
With `-attributor-enable=light`, a full `clang -O3` compile of
tramp3d-v4 takes 12% fewer instructions.
Running only attributor-light on CTMark bitcode: tramp3d-v4 -23%,
kimwitu++ -4%, sqlite3 -0.5%.
Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
Assisted-by: Claude Opus 5.5
[AST] Avoid base-to-derived cast in Redeclarable constructor (#238335)
Redeclarable<decl_type>::Redeclarable previously initialized First by
evaluating static_cast<decl_type *>(this) inside the Redeclarable base
class constructor.
At the point where the Redeclarable base subobject constructor runs, the
derived decl_type constructor has not yet begun execution and the object
vtable pointer has not yet been updated to decl_type. When compiled with
Control Flow Integrity enabled for derived casts
(-fsanitize=cfi-derived-cast), downcasting this from Redeclarable<T> *
to decl_type * during base class construction fails the CFI vtable check
at runtime.
Pass the derived this pointer (which already has static type decl_type
*) directly from each CRTP subclass constructor to Redeclarable(const
ASTContext &Ctx, decl_type *First). This avoids any base-to-derived
downcast during construction while keeping getFirstDecl() a branchless
load. Add a unit test in DeclTest verifying getFirstDecl(),
[2 lines not shown]
[Object][GOFF] Fix sign extension in RLD relocation type (#235719)
`getRldType()` builds the relocation type from RLD bytes 1, 2, 4 and 5.
`Rld[5] << 24` is computed as `int`, so when byte 5 has its top bit set (a bit
length of 4 or more) the result is negative and is sign-extended when converted
to the `uint64_t` return type. The upper 32 bits of `RelType` then become all
ones, and `getRelocationTypeName()` prints `R_ffffffff80040100` instead of
`R_80040100`.
Cast `Rld[5]` to `uint64_t` before shifting. The other bytes are shifted by at
most 16 bits and always fit in a positive `int`.
The field getters (`getRLDBitLength()` etc.) mask their bits, so they were not
affected; only the full value returned by `getRelocationType()` was wrong.
### Testing
The second RLD entry in the `TXTConstruct` unit test now sets byte 5 to `0x80`
and expects `R_80040100`. Without the fix it gets `R_ffffffff80040100`.
Assisted-by: Claude Opus 5.5, OpenAI Codex
powerpc/powernv: byte swap the OPAL async completion token
OPAL messages are big endian, but opal_handle_async_completion() took
the token straight from params[0]. On little endian a token reads as a
huge number that the int then truncates to 0, so every completion was
recorded against token 0. A request that happened to get token 0
worked by luck. Any other one only finished if
OPAL_CHECK_ASYNC_COMPLETION saw the message before the kernel's message
poller took it, and otherwise opal_wait_completion() spun forever.
I hit this on a POWER9 PowerNV machine with a one byte read from an I2C
EEPROM, which never returned. Swap the token, and check that it's in
range before using it as an index.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62361
dtrace/powerpc: decode blr and bctr in the pid provider
OPX() shifted the instruction by two bits instead of one, so the
extended opcode never matched and blr and bctr weren't recognised.
They were treated like any other instruction, which means a single
step that powerpc doesn't have. A return probe on a function that ends
in blr panics an INVARIANTS kernel, and without INVARIANTS the traced
process spins on the tracepoint.
Fix the shift. Two more things were hidden behind it and have to be
fixed with it: bclr was typed as a bctr, so it would have returned
through CTR, and OP_RB() had the wrong mask, so some real or
instructions would have been taken for no-ops.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62360
powerpc: let DTrace decide whether a kernel trap instruction is its probe
trap() tells an fbt probe from a debugger breakpoint by reading the
instruction at the trap address and comparing it with the fbt one. When
a probe is disabled fbt puts the original instruction back, and other
CPUs can already be in the trap for it by then. Such a CPU finds the
original instruction, takes the trap for a breakpoint and drops into
KDB. I've had a guest stop like that twice, both times when dtrace(1)
exited with a probe on a busy function.
DTrace doesn't need the instruction to know its probe. fbt_invop()
looks the address up in its own table, and dtrace_invop_start() returns
-1 when nobody claims it. So ask it for every kernel trap instruction
and go on to KDB only when it says no, like amd64 does.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62358
[SPIRV] Remove the MatrixAAndBTF32ComponentsINTEL cooperative matrix operand (#247691)
Remove MatrixAAndBTF32ComponentsINTEL (0x20) from
SPV_INTEL_joint_matrix. Consumers treat 32-bit floating-point A and B as
TF32 without it, so the value 0x20 is no longer needed.
Note that the operand was removed from the spec in
https://github.com/intel/llvm/pull/23817
Assisted-by: Claude
[DAGCombiner] Match (setcc X, X, uno) in NaN-guard fp-to-int fold (#248004)
performNanGuardFpToSatCombine only matched an isnan check of the form
(setcc X, 0.0, uno/ord). SimplifySetCC canonicalizes that to
(setcc X, X, uno/ord), so the fold was missed if the setcc was
simplified
before the select was visited. That happens when a vector compare is
scalarized, and always with -combiner-topological-sorting.
Assisted-by: Claude Fable 5.2 <noreply at anthropic.com>