[FunctionAttrs] Check for overflow when shifting callee initializes ranges (#247677)
When a pointer argument reaches a call through a GEP with a constant
offset, FunctionAttrs shifts the callee's `initializes` ranges by that
offset without checking for overflow. A very large offset produces an
invalid range, which hits the assertion in `ConstantRangeList::insert`.
Check for overflow on both ends of each range and skip any range that
overflows. Dropping a range only means fewer bytes are known to be
initialized, so the result stays conservative. This is the same check
#134115 added for loads and stores and #140345 added for memset and
memcpy.
Fixes #245439
Assisted-by: Claude Code (Opus 5.5)
[AMDGPU][NFC] Pre-commit MIR test for soft waitcnt handling in SIInsertWaitcnts (#247313)
The checks show the current behavior:
two loop-header cases miss the `lgkmcnt(0)` for a DS write that reaches
the header through the back edge.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AArch64] Implement ACLE intrinsics for FPv2 SVE min/max instructions
ACLE PR: https://github.com/ARM-software/acle/pull/480
Implements the following intrinsics:
- svmaxmg / svminmg
- svmaxinm / svmininm
- svmaxmginm / svminmginm
Includes f16, f32, and f64 types, _m, _z, and _x predication and _n variants
AI assistance: Codex used for generating test cases
[clang][NFC] Remove padding from some AST nodes (#246310)
Reorder or pack fields to shrink TemplateTypeParmDecl (80 -> 72 bytes),
FunctionTemplateSpecializationInfo (48 -> 40) and EnumConstantDecl (88
-> 80) on 64-bit Itanium ABI targets. TemplateTypeParmDecl now stores
the number of expanded parameters in a 29-bit bitfield next to its
flags, the same limit as TemplateParameterList::NumParams. On some LLVM
TUs this saves 0.6-0.7% of the Decl memory reported by -print-stats.
Assisted-by: Claude Opus 5.5
Co-authored-by: Gabor Horvath <gaborh at apple.com>
[CIR][OpenMP] Support the 'shared' clause on 'parallel' (#241223)
omp.parallel body already reads and writes the variables of the
enclosing function directly
[CostModel] invalid subindex for negative offset (#248043)
ShuffleVectorInst::isExtractSubvectorMask incorrectly accepts
<poison, 0, 2, 3> as a contiguous extract starting at lane 0. Result
lane 1 reads source lane 0, which implies a start offset of −1. The
matcher then recognises this -1 as "no offset seen yet" and resets the
offset to 0 when it reaches result lane 2.
Bail out as soon as we see a negative offset.
Assisted-by: codex
[X86] isGuaranteedNotToBeUndefOrPoison - enable disabled cases
#245048 left PCMPEQ and some truncation and conversion opcodes
commented out in isGuaranteedNotToBeUndefOrPoisonForTargetNode until
they had test coverage. Since then a VZEXT_MOVL after them is kept,
because the known-zero upper elements aren't proven free of undef or
poison. That costs a movq, or a vpxor and vpblendd for the saturating
truncates.
Enable them. computeKnownBitsForTargetNode already lists the same
truncation and conversion opcodes as zeroing their upper elements, and
PCMPEQ is elementwise like PCMPGT and can't create undef or poison.
Assisted-by: Claude Code (Claude Opus 5.5)
[X86] Add tests for the commented-out undef/poison opcodes (NFC)
#245048 left PCMPEQ and some truncation and conversion opcodes
commented out in isGuaranteedNotToBeUndefOrPoisonForTargetNode until
they have test coverage: VTRUNCS, VTRUNCUS, MCVTPS2PH, MCVTTP2SIS,
MCVTTP2UIS, STRICT_CVTTP2UI, STRICT_CVTSI2P, STRICT_CVTUI2P,
STRICT_VFPROUND and STRICT_CVTPS2PH. Each test shuffles zeros into
upper elements that are already zero.
Assisted-by: Claude Code (Claude Opus 5.5)
[libc] Create AArch64BaremetalTestUtils and refactor existing Arm 32-bit file (#247228)
This patch creates a new AArch64BaremetalTestUtils file to contain the
symbols necessary for baremetal testing on AArch64.
Since most of the functionality is common between AArch64 and Arm, this
patch refactors the common code into a new header file. Only the
definitions of `semihosting_call` and of `__llvm_libc_exit` differ.
In CMake, specific targets are created for each component to make them
follow better the LLVM libc conventions: the new header file is a header
library, and each target-specific source file is a new object library.
[SPIRV] Drop llvm.global_{ctors,dtors} in CtorDtorLowering (#247357)
Before this patch, -spirv-emit-init-fini-kernel=false would leave the
variables around which SPIRVEmitIntrinsics would then emit calls to
llvm.spirv.init.global to, which is illegal (introduces a use of a
global intrinsic which the verifier rejects).
This patch makes it so that we unconditionally delete llvm.global_ctors
and llvm.global_dtors in SPIRVCtorDtorLowering rather than relying on
the massive hack in AsmPrinter where we just hide that the GVs are
global intrinsics by renaming them to skirt the verifier. We do end up
with an output difference (we emitted
llvm.global_ctors/llvm.global_dtors before with
-spirv-emit-init-fini-kernel=false), but I'm pretty sure that was
unintentional behavior picked up by copying the NVPTX version of the
pass.
This fixes one blocker to enabling the NewPM. No new test coverage as
global-var-intrinsics.ll works there.
[CIR][OpenMP] Add support for OpenMP reduction clause
This patch adds support for the OpenMP reduction clause on the teams and for
directives for reductions with built-in identifiers on local scalar integer and
floating-point variables. Other cases, such as user-defined reductions,
modifiers, arrays and globals, are reported as not yet implemented.
Assisted-by: Cursor / Claude Opus 5.5 Medium
[CIR][OpenMP] Add support for 'distribute parallel for' with 'target teams'
Adds support for handling the full '[target] teams distribute parallel for'.
Introduces setting the omp.composite attibute for the 'distribute parallel for'
composite construct.
Assisted-by: Cursor / Claude Sonnet 5 High
[CIR][OpenMP] Add initial support for distribute
This patch adds initial support for the OpenMP 'distribute' directive. Basic
code generation for the standalone and combined cases is introduced. Support
for clauses will be added in the future. The composite 'teams distribute
parallel for' form will be added in a subsequent patch.
Assisted-by: Cursor / Claude Sonnet 5 High
[CIR][OpenMP] Add support for omp teams
This patch adds support for the OpenMP 'teams' directive, both standalone
and as the combined `target teams` construct. isCombinableLeaf now also
recognizes teams, so an explicitly-nested `target` + `teams` pair gets
the same omp.combined marking as the combined case.
Assisted-by: Cursor / Claude Sonnet 5 High
[InstCombine] Fix -X / -Y --> X / Y introducing UB for poison X (#243734)
The known-bits check added in #224025 for `-X / -Y --> X / Y` does not
hold when `X` is poison, so with `Y == -1` it turns `sdiv poison, 1`
into `sdiv poison, -1`, which is immediate UB.
Fix by checking the two conditions of the fold separately. `-X` must not
have the wrong sign, which holds if known bits rule out `X == INT_MIN`
or if `-X` is `nsw`. `X / Y` must not add UB, which holds if `Y` cannot
be -1, or if `X` cannot be `INT_MIN` and is not poison.
Alive2 proof:
https://alive2.llvm.org/ce/z/o5w5Qu
Fixes #243594
Assisted-by: Claude Opus 5.5
[CallSiteSplitting] Don't duplicate convergent/noduplicate calls
When a call-site is split, the instructions that precede it in its block
are duplicated into the predecessors together with the call.
`canSplitCallSite` only checked that the call-site itself is neither
convergent nor noduplicate, but it didn't on calls placed before it.
Do not split a call-site when one of the calls that would be duplicated
with it is convergent or cannot be duplicated.
Co-authored-by: juan.martinezfernandez <juan.martinezfernandez at amd.com>
[InstCombine] Don't widen lanes when moving logic op out of bitcasts (#248056)
`foldBitCastBitwiseLogic` turns `bitcast(logic(bitcast(X), bitcast(Y)))`
into `bitcast(logic(bitcast(X), Y))` when one of X and Y is FP and the
other is an integer. The new logic op works in the integer value's
lanes. When those lanes are wider than both the old op's lanes and the
result's lanes, poison in one lane spreads to neighbouring lanes. In the
issue, a `<2 x i32>` xor becomes an `i64` xor so a poison lane poisons
the whole result.
This only does the fold when each lane of the integer value fits inside
a lane of the old op or of the result. Then a poison lane in the new op
can only cover result lanes that were already poison.
Fixes #247930
Assisted-by: Claude Code (Opus 5.5)