[X86] Enable SlotIndexes compaction by default
Compacting SlotIndexes before greedy allocation drops the entries of
erased instructions, so live range sizes and instruction distances
reflect the code being allocated rather than how much was erased
before it. AMDGPU has done this since #235806; do the same for X86.
Codegen changes only through allocation: no new crashes, verifier
errors or allocation failures in the lit suites, including
EXPENSIVE_CHECKS, and a stage-2 build of LLVM, clang and lld with
-verify-machineinstrs passes its own tests. On llvm-test-suite at -O3,
spills and reloads drop 0.4% and .text 0.04%, with compile time
unchanged.
Most test updates are regenerated checks. misched-matmul now inserts
20 spills instead of 24. live-debug-vars-stale-slotindexes.mir gets
one more use of %27 so that accumulate_fit still reaches the stale
index path it was written for. reloc-opt.ll gets an NF add that keeps
its source live, because compaction compresses the existing one to the
[3 lines not shown]
[OpenMP] Use device scope for atomic constructs on the device (#240426)
OpenMP 6.0, 17.8.5 specifies that "The memscope clause determines the
binding thread set for an atomic region. If the memscope clause is not
present, the behavior is as if the memscope clause appeared on the
construct with the device scope-specifier."
Thread the sync scopes through codegen amd also add a release note
because this is changing existing behavior.
Existing behavior was overly cautios for OpenMP 5.2, too, though. The
atomic construct never specified the option of having system-level
scope. This only came with the memscope clause and it's "all"
scope-specifier.
Assisted-by: LLM
[DAGCombiner] Fold repeated operands before reassociating constants (#244490)
In reassociateOpsCommutative, check (x ^ y) ^ x -> y and the matching
and/or folds before reassociating constants out. Otherwise
(xor (xor x, C), x) becomes (xor (xor x, x), C), and after legalization
the vector (xor x, x) -> 0 fold can't fire if BUILD_VECTOR is illegal.
[clang][CodeGen] Do not set likely_module_local on local-linkage functions (#248822)
Internal and private functions are already module-local, so setting
likely_module_local on them is redundant.
Assisted-by: Gemini
[Attributor][NFC] Rename CheckPotentiallyDead to IncludeAssumedDead (#249049)
The flag makes the predicate also run on assumed-dead sites, so the old
name read the other way (see #248774 discussion).
Assisted-by: Claude Opus 5.5
[aarch64][win] Fix trap emission for unwinding after noreturn invokes (#249048)
PR #232358 changed the trap emission for Arm64 Windows EH to only insert
traps where the block had no successors and checked only the next block
in layout order. Since a noreturn invoke in a catch funclet can have
exceptional CFG successors and an empty normal-continuation block, this
code would miss the boundary between the catch funclets, causing the
call's return address to point into the next funclet, breaking exception
handling.
The fix is to scan past blocks with no real instructions in layout
order, without requiring an empty successor list, then emit a trap if a
funclet, section, or function boundary comes first.
Fixes #248881
[BPF] Load a 32-bit relocated enum value with a 32-bit immediate (#246702)
Since commit c080a0b9b673 ("[BPF] Support preserve_access_index
attribute
for enum (#232498)"), an enumerator of an enum with the
preserve_access_index attribute is relocated as
__builtin_preserve_enum_value(), whose 64-bit value is then converted to
the type of the enumerator, normally int:
```
enum E { N = 10 } __attribute__((preserve_access_index));
enum U { M = 0x80000000 } __attribute__((preserve_access_index));
long f2(void) { return N; }
unsigned long f3(void) { return M; }
```
is compiled to:
```
f2:
r0 = 0xa ll /* CO-RE <enumval_value> enum E::N */
[43 lines not shown]
AMDGPU: Do not decode inv-2pi inline constant on gfx6/gfx7 (#249034)
The disassembler assumed the inline constant was always available. On
SI/CI the encoding is reserved and decoding it printed a literal which
does not encode back to the same bytes. A literal with that value was
also printed with lit().
Assisted-by: Claude
AMDGPU: Decode gfx/gfx7 special register encodings (#249032)
flat_scratch and xnack_mask do not exist on gfx6. gfx6 and gfx7 have
s102 and s103 where VI has flat_scratch. gfx7 encodes flat_scratch
where gfx8 has xnack_mask.
Assisted-by: Claude
[clang][OpenMP] Extend no-loop promotion to split spellings (#224650)
Widen the no-loop promotion to apply not only to the fused target teams
distribute parallel for but include the same region written as separate
directives, other directives promotable to parallel for, and regions
carrying a schedule clause that asks for a mapping a no-loop kernel
already provides (static or dynamic with a chunk size of 1, and auto).
Fix the visitor that checks whether a teams loop can be promoted to
parallel for. A teams loop with calls to non API routines cannot be
promoted to parallel for, but the visitor overrode such a case when
there was a later call to an API routine.
Assisted by: Claude Opus 5.5
[Flang-RT] Introspect the values of int_fast16_t and int_fast32_t (#248300)
Determine the size of int_fast16_t and int_fast32_t using platform
introspection for the target triple.
Note the offload situation is fragile: Ideally, `int_fast16_t` and
`int_fast32_t` should be the same on the GPU as on the host or we get
data layout mismatches. However, depending on the vendor toolchain, the
compiler used, its flags (`-nostdlibinc`), the way it is compiled
(`FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT` vs `LLVM_RUNTIME_TARGETS`),
installed headers (`gnu/stubs-32.h`) and other factors, you get
different results.
See discussion at
https://discourse.llvm.org/t/rfc-determining-the-size-of-c-interoperable-types/92841
Fixes #208361
Assisted-by AI
[mlir][SPIR-V] Fix duplicate execution mode globals in SPIRVToLLVM (#239337)
Entry point can use the same execution mode twice, like DenormPreserve
for different FP types
Give each one its own global name
[AArch64][GlobalISel] Fold buildvector(unmerge) to shuffle (#243779)
After legalization we can end up with buildvector of unmerge that
permute some of the lanes. This adds a combine that folds the
buildvector of unmerge into a shuffle.
[mlir][arith] Fix addi/subi divisibility inference under wraparound (#248140)
Wrapping only preserves the power-of-two part of the gcd of the operand
divisors. Keep the full unsigned/signed gcd only under nuw/nsw,
otherwise
reduce to the largest power-of-two divisor (v & -v).
Follow-up PR to #237342.
[test][clang] Precommit inline builtin attribute tests (#248821)
Add tests for symbol attributes (used, retain, weak, visibility, global
ctor/dtor) and naked on inline builtins and their .inline clones.
Assisted-by: Gemini
[AMDGPU] Clarify async barrier replay handling (NFC)
Clarify that replay loads and ordinary async loads can appear in the same function,
but only replay loads temporarily clear EXEC, and simplify the EXEC save and restore checks
without changing which instructions are rewritten.
AI assisted.
[RISCV][GISel] Add GlobalISel equivalent of the SplatPat complex pattern (#248600)
Add a GIComplexPatternEquiv for SplatPat and implement selectVSplat in
the GlobalISel instruction selector, mirroring
RISCVDAGToDAGISel::selectVSplat. The importer can now use the patterns
that need it, so vector operations with a splat of an integer scalar
select to the .vx forms, for example vadd.vx instead of vmv.v.x +
vadd.vv. The lookup of the G_SPLAT_VECTOR is factored out into a
findVSplat helper shared with selectVSplatImmHelper.
Part of #246831
[AMDGPU] Fix LDS externalization for object linking (#243337)
With object linking, the backend converts LDS variables and named
barriers to external declarations, and the linker allocates them. There
are two cases that could potentially make invalid IR or cause a crash:
- LDS or a named barrier with vague linkage, for example a shared
variable in an inline function, is in a comdat. The external declaration
kept the comdat, and the verifier rejected the module: "Declaration may
not be in a Comdat!".
- Alloca promotion to LDS runs after LDS lowering. The LDS variable that
it created stayed an internal definition, and the asm printer asserted:
"LDS definitions should have been externalized when object linking is
enabled".
This PR fixes both of them.
This PR was assisted by AI but I reviewed all the changes.