[SandboxVec][LoadStoreVec] Support constant vectors of mixed types
createConstantVector() previously packed the constant store operands
as-is, which only worked when every store had the same element type.
Take the lane type from VecUtils::getCombinedVectorTypeFor() instead and
reinterpret each constant's bits as that type, going through an integer
of matching width via ptrtoint/inttoptr/bitcast. Constants wider than a
lane (e.g. an i64 in an <N x i32>) are split across several lanes in
memory order. Bail out when a constant cannot be reinterpreted, such as
a non-integral pointer or a relocatable address that needs splitting.
Also flatten vector-typed ConstantPointerNull into per-lane nulls, and
bail out on the remaining vector constants such as poison rather than
packing them into the result.
Co-authored-by: Cursor <cursoragent at cursor.com>
[OpenMP][OMPIRBuilder] Allow multi-block bodies in createIteratorLoop
createIteratorLoop requires the body generator to leave a single block that
falls through or branches to the loop latch. A body generator that lowers
expressions with their own control flow cannot meet that requirement. The
upcoming user is omp.iterator translation, once its region can contain
several blocks (#227454).
Allow the body to span several blocks. If exactly one block is left without
a terminator, it is branched to the latch; otherwise some block must already
branch there. Bodies that leave more than one block unterminated, or that
branch out of the loop, are rejected with an error.
Assisted with Copilot and Claude Opus 5.
[InstCombine] Move sext(trunc(lshr(...))) combine before same type combine
The same type sext(trunc(...)) combine will fire on the lshr case, but the lshr produces one less shift. Move it afterwards to give the lshr combine a chance to fire first. Fixes the motivating x264 case
[lld][MachO] Support Objective-C class selector stubs
Support Objective-C class selector stubs in lld's Mach-O backend.
This consumes the class-stub symbols emitted by Clang in [ObjC] Emit class
msgSend stub calls (#186433), using the form
`_objc_msgSendClass$<selector>$_OBJC_CLASS_$_<class>`.
Class stubs load the class object into `x0`, load the selector into `x1`, and
branch to `_objc_msgSend`. Local class symbols are materialized directly with
`adrp`/`add`; dylib or dynamic class symbols are loaded indirectly.
The implementation also tracks the resolved class symbol before dead stripping
so live class stubs can retain the needed class definition without keeping dead
dylib references alive.
[RISCV] Ensure Shadow Stack checks correct RA (#226309)
This primarliy applies to the save-restore case, which was using
`__riscv_restore_<N>` incorrectly, entirely circumventing the software
shadow call stack.
This fix keeps the code size improvements of `__riscv_save_<N>` when
there is a shadow call stack, but it avoids the incorrect use of
`__riscv_restore_<N>`, instead emitting the correct sequence inline.
In the future, when there are better versions of `__riscv_save_<N>` and
`__riscv_restore_<N>` which support the shadow call stack variants (both
hardware and software), then we can revisit this approach and use the
correct pairs in all cases.
WebAssembly: Take the exception model from the module flag
The WebAssembly EH passes chose whether and how to run from
MCAsmInfo::getExceptionHandlingType() and TargetOptions::ExceptionModel,
A module that asked for Wasm EH through the module flag alone would have
its invokes rewritten by LowerInvoke before WasmEHPrepare ran.
Schedule the passes unconditionally and read the module flag inside the
passes instead. Passes for other models can noop on the models they are
not intended for.
Co-authored-by: Claude Opus 5 <noreply at anthropic.com>
AMDGPU: Stop relying on -amdgpu-scalarize-global-loads=false in ALU tests
Convert kernels which loaded operands from pointer arguments into
functions taking the operands as arguments. Scalar kernel arguments become
inreg arguments. Where a kernel is still useful, index the loads by the
workitem id so they remain vector loads. This also fixes a few tests where
the workitem id index was computed but unused, or where the uniform
workgroup id was used for indexing in VALU tests.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR][CodeGen][NFC] Share isEmptyFieldForLayout and isEmptyRecordForLayout (#223424)
Deduplicates `isEmptyFieldForLayout` and `isEmptyRecordForLayout` between CIR
and classic CodeGen into a new `RecordLayoutUtils.h`. The 25 callers now name
them as `CodeGenUtils::isEmptyFieldForLayout` and
`CodeGenUtils::isEmptyRecordForLayout`, like the other shared helpers.
Assisted-by: Claude Code (Claude Fable 5.1).
[alpha.webkit.NoDeleteChecker] Handle CXXStdInitializerListExpr in trivial analysis (#224723)
TrivialFunctionAnalysisVisitor had no handler for
CXXStdInitializerListExpr, so a braced list bound to a
std::initializer_list fell through to VisitStmt and was conservatively
treated as non-trivial. This made any nodelete function containing e.g.
std::min({a, b, c}) report that it "contains code that could destruct an
object".
The backing array of a std::initializer_list is a temporary whose
lifetime ends in the enclosing function, so its elements really are
destructed there. Accept the node when the array's element type is
trivially destructible and recurse into the initializers, and keep
rejecting it otherwise.
[SLP]Vectorize aggregates of bit packs as a single vector
An insertvalue aggregate built of or-packs of zero-extended fields (e.g.
the { i64, i64 } returned for std::array<int16_t, 8>) was vectorized
pack by pack, leaving the vectors half as wide as possible. Vectorize
the fields of all packs as one tree and bitcast the result to the vector
of the packs.
Fixes #48223
Assisted-by: Cursor
Reviewers: bababuck, RKSimon
Pull Request: https://github.com/llvm/llvm-project/pull/228955
[SLP]Keep dbg_value of the lanes replaced by extractelement
Redirect the debug values of an erased scalar to the extract emitted for
its external user. A record placed before the extract is cloned right
after it, unless that passes a record of the same variable. Lanes
without external users still lose their debug values.
Part of #45507.
Assisted-by: Cursor
Reviewers: RKSimon, bababuck
Pull Request: https://github.com/llvm/llvm-project/pull/228937