[Mips] Use the local GOT sequence for forward references to local symbols (#242758)
In PIC mode the la and jal macros need to know if the symbol is local
or global. The assembler made that choice while parsing, so a symbol
that is defined later in the file was always treated as global. For
O32 this gave an R_MIPS_GOT16 without the matching R_MIPS_LO16 for la,
and an R_MIPS_CALL16 against a local symbol for jal, which GNU ld
rejects. jal on N32/N64 had the same R_MIPS_CALL16 problem.
GNU as waits until the end of the file to choose. Do the same: if the
symbol is not defined yet and has no explicit binding, emit a
PseudoGOTLoadGlobal. MipsAsmBackend relaxes it to PseudoGOTLoadLocal if
the symbol ends up local, and MipsMCCodeEmitter expands both into the
real instructions.
Symbols that stay undefined or become global get the same code as
before. XGOT and -mrelax-all keep the old behavior.
cplocal.s had a jal to a local symbol defined after it, so it now
[7 lines not shown]
[Mips] Fix MSA constant splats on big endian (#242740)
When selecting a constant BUILD_VECTOR, the splat value was computed in
big endian order on big endian targets. The result is then retyped with
COPY_TO_REGCLASS, which leaves the register as is. MSA lanes are laid
out the same way on both endians, so a v16i8 splat of
<0x11, 0x22, 0x33, 0x44, ...> was built with fill.w 0x11223344, which
puts the bytes in reverse order.
Always compute the splat value in little endian order here.
On O32 this also fixes 64-bit splats that type legalization turns into
v4i32 BUILD_VECTORs, such as <2 x i64> <i64 1, i64 1>, which were
built with the two words swapped. These now use a longer
fill.w/insert.w/splati.d sequence instead of ldi.d.
Fixes #236458
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[VPlan] Only form partial reductions from Add/Sub-like kinds. (#244935)
When forming partial reductions, the kind was never checked, which lead
to partial add reductions being formed for other linds, like
multiply reductions.
Bail out if the kind is not suported and assert at the end that we only
have supported opcodes.
Fixes a miscompile in the added test.
[OpenMP] Remove redundant check in z_Linux_asm.S (#244478)
KMP_ARCH_X86 and KMP_ARCH_PPC64 are never both set, so drop the
!KMP_ARCH_PPC64 check.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[OpenMP] Fix swapped #endif comments in z_Linux_asm.S (#244479)
The #endif comments for the !KMP_ASM_INTRINS and !KMP_MIC blocks
around the x86_64 __kmp_xchg_real32/__kmp_xchg_real64 were swapped.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Add FUNC_ALTERNATE_WAVESIZE for object linking info flag
Add an INFO_FLAGS bit that is set when a function does not use the
default wave size of its target. The default wave size is wave32 if the
target supports wave32, and wave64 otherwise.
So the bit is 0 for a function that uses the default wave size, on
every target. Today only +wavefrontsize64 on a target that supports both
wave sizes sets it. The linker knows the target, so it can get the wave
size of each function from the bit.
[AMDGPU] Add FUNC_HALF_SIMD_MODE for object linking info flag
Add an INFO_FLAGS bit that is set when a function uses half SIMD mode,
where the waves of a workgroup can use only two of the four SIMDs. Today
this is CU mode on a target that supports WGP mode. If the bit is not
set, the function uses full SIMD mode.
Full SIMD mode is the default on every target: a gfx6-gfx9 CU has four
SIMDs, gfx10 and later targets use WGP mode by default, and gfx1250 is
always full SIMD, even in CU mode. So the bit is 0 for a default compile
on every target.
[AMDGPU] Introduce ABI occupancy for object linking
This PR introduces ABI occupancy as the contract used to compile functions under
object linking. The default is the occupancy needed for a 1024 workitem
workgroup. It can be overridden for a module by the `amdgpu_abi_waves_per_eu`
module flag, replaced for a function by `amdgpu-flat-work-group-size`, or
tightened by an accepted `amdgpu-waves-per-eu` hint.
The ABI occupancy replaces the workgroup-derived minimum that an
`amdgpu-waves-per-eu` hint is validated against, so the hint can only make the
contract stricter.
The backend emits the selected occupancy in `.amdgpu.info` and uses it to
enforce the object linking register budget.
[AMDGPU] Remove write-only private member variables (NFC) (#244910)
This patch removes private member variables in AMDGPU that are
initialized or assigned to but never read, along with their
initializers and assignments.
Assisted-by: Antigravity
[CalledValuePropagation] Fix non-deterministic metadata generation (#244837)
Fixes non-deterministic metadata numbers in CVP outputs.
Non-deterministic numbers in CVP outputs make it difficult to trace when
and how two compilations (with two versions of the compiler) start to
diverge by tracing `-print-after-all` outputs.
To repro: copy sqlite3.c from llvm-test-suite and optimize with `opt -O3
-print-after-all -ir-dump-directory=...` and save the outputs of a few
runs in different directories. The outputs start to diverge after CVP
before this change. With this change we reliably get identical IRs
throughout the pipeline.
[AMDGPU] Keep soft waitcnts unchanged until SIInsertWaitcnts converges
On the first visit to a loop header only the preheader state is known.
A soft waitcnt there (e.g. from a release fence) can have some of its
counters simplified away while another counter keeps the instruction
alive: the fence's own vmcnt(0), a preceding wait.asyncmark, or an
explicit s_waitcnt. The soft waitcnt was then rewritten with the
simplified value and promoted to a hard waitcnt, or merged into a
preceding hard one. When the back edge later brought a pending LDS
store, the original lgkmcnt(0) request was gone, and the s_barrier after
the release fence no longer waited for it.
Treat soft waitcnts as requests that depend on the incoming state: never
merge, promote or rewrite them while the analysis iterates. They are
kept unchanged in DeferredErasures, a hard waitcnt (existing or new)
carries what is needed on each visit, and the soft waitcnts are erased
once the analysis converges. This extends #220357, which did the same
only for soft waitcnts that were simplified away entirely.
[11 lines not shown]
[AMDGPU][NFC] Pre-commit tests for soft waitcnt requests lost at a loop header (#244686)
Two cases where a soft waitcnt at a loop header loses its `lgkmcnt(0)`.
On the first visit to the header no LDS operation is pending yet, so the
soft waitcnt's `lgkmcnt` is simplified away, while a `vmcnt` keeps the
instruction alive. That `vmcnt` comes either from the soft waitcnt
itself or from a preceding hard `vmcnt(0)` that it is merged into. The
DS write at the end of the loop is then not waited for before the
`S_BARRIER` on the next iteration.
The checks show the current, incorrect output (`S_WAITCNT .Vmcnt_0`
before `S_BARRIER`).
Assisted-by: Claude Opus 5.5
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
ExpandVariadics: Invalidate function analyses individually
Avoid discarding analyses that never need to be invalidated, such as
TargetLibraryInfo. Clear the analyses of erased functions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AllocToken: Only invalidate analyses of instrumented functions
AllocToken tried to preserve the CFG analyses, but did not preserve the
function analysis manager proxy, so all function analyses were
invalidated.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>