[CodeGen][Objective-C] Add WebAssembly `@finally` support (#218967)
This PR adds `@finally` support for WebAssembly codegen.
We reuse the existing `CodeGenFunction::FinallyInfo` infrastructure,
which essentially creates a catch-all handler around the try/catch. This
needs a slight adaptation for fit WebAssembly's exception model, where
the catch handlers are merged into a single catchpad.
Additionally, we now emit the rethrow function using the
`EmitNoreturnRuntimeCallOrInvoke` which avoids creating an unnecessary
continuation block here.
Co-authored-by: Hendrik Huebner <hhuebner at Hendriks-MacBook-Pro.local>
RegisterPressure: Detect dead physreg defs from LiveIntervals with lane masks
Extend the fix from #225079 to the lane mask tracking path used by
targets with subregister liveness. adjustLaneLiveness also needs to
force the physreg unit ranges to be computed to identify dead defs,
rather than taking the conservative default when they are not cached.
Without this, an overlapping physreg def missing a dead flag is
counted as a live def. Conservatively assuming it is live doesn't work
because PressureDiff disagrees with the tracker and fails the
EXPENSIVE_CHECKS consistency assert.
This avoids an ll asm test failing when LiveVariables removed; #233202
fixes the missing dead flag for that case. I had additional patches
which nearly eliminate all missing dead flags. Unless the verifier
enforces accurate dead flags, we still need to handle this edge case.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AMDGPU: Mark unread physreg defs dead in a scheduler test
These registers defined by IMPLICIT_DEF but never read. Without the
dead flags, the pressure tracker assumes the uncached physreg units
are live out of the region. Ideally physreg dead flags would be
accurate, though this is currently not a verifier enforced rule. This
avoids some test churn in a future pressure tracking commit.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[ExpandIRInsts] Don't take the half fast path for saturating fptoi (#232172)
Saturating conversions previously took the half fast path and now skip
it to use the full expansion.
Fixes #231384
Assisted-by: Claude Opus 5.5
[SLP][modularisation][NFC] Move getReductionInstr to SLPReductionUtils, getAggregateSize to SLPUtils (#222613)
Move the BoUpSLP-independent helpers getReductionInstr and
getAggregateSize
out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPReductionUtils.{h,cpp} module.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
AVR: Run AtomicExpand
Atomics wider than 16 bits were lowered to __sync_* calls. No AVR
runtime provides __sync_* or __atomic_*, but __sync_* requires a
lock-free implementation, which AVR cannot provide at those sizes.
Use the __atomic_* calls instead.
Alternatively it may be appropriate to change getDefaultThreadModel to
singlethread for avr so all atomics are lowered into non-atomic
sequences.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang] Remove unused ASTContext::getInstantiatedFromStaticDataMember (NFC) (#233019)
The last caller was removed on August 6, 2013 in commit
39a1e507ff0bef4bd6b2fdbab4e38583d2679617.
This patch also removes the stale FIXME and the commented-out call in
VarDecl::getMemberSpecializationInfo that referred to it.
Assisted-by: Antigravity
[IR][TableGen] Remove unused ComplexStrAttr (NFC) (#233192)
The last use of ComplexStrAttr was removed on February 5, 2026 in
commit 2502e3b7badcaf2d911410978bf8f8638b363854.
This patch removes the ComplexStrAttr TableGen class along with the
ATTRIBUTE_COMPLEXSTR macro, which became unused as a result.
Assisted-by: Antigravity
[clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast_if_present (NFC) (#233191)
PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present. This patch replaces the
former with llvm::dyn_cast_if_present in
FriendTemplateDecl::getFriendDecl.
This is the only place under clang/ where migrating to llvm::dyn_cast
would trigger an assertion failure during check-clang.
Assisted-by: Antigravity
MCJIT: Set triple in modules without one from the JIT's triple
Fill in the triple when MCJIT takes a module, as is already done for
the data layout.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[SLP][modularisation][NFC] Move getReductionInstr to SLPReductionUtils, getAggregateSize to SLPUtils
Move the reduction-root helper getReductionInstr out of SLPVectorizer.cpp
into the self-contained SLPVectorizer/SLPReductionUtils.{h,cpp} module.
getAggregateSize is not reduction-specific: its only user is
findBuildAggregate and it only computes the element count of a homogeneous
aggregate from its type. Move it to the generic SLPVectorizer/SLPUtils
module instead.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Assisted by AI
[TableGen][NFC] Fix stale header path in Target.td comment (#233015)
`TargetInstrInfo.h` now lives in `llvm/CodeGen/`, not `llvm/Target/`.
Comment-only change.
[utils][UpdateLLCTestChecks] Fix broken update_llc_test_checks.py when trying to emit MIR (#233181)
When llc update checks trying to produce MIR, the script later calls an
assembly-output handler that was never initialized.
This fix will guard such cases, so mir checks will be generated by
`mir.add_mir_checks_for_function`.
Fixes: https://github.com/llvm/llvm-project/issues/233180
Signed-off-by: ZakyHermawan <zaky.hermawan9615 at gmail.com>
SelectionDAG: Mark inline asm clobbers dead when an output covers the read
An inline asm clobber was only marked dead if no glued CopyFromReg
read an overlapping register. A read of an output register that
overlaps a wider clobber kept the whole clobber live, even though the
output def already provides the read value. For example,
"={a1},~{a[0:15]}" left the $agpr0_..._agpr15 clobber live.
Ignore glued reads fully covered by an output def of the asm,
producing the same flags LiveVariables would later add, with a live
def of the output and a dead def of the clobber.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[SLP][modularisation][NFC] Move loop trip-count helpers to SLPUtils
Move the BoUpSLP-independent helpers findInnermostNonInvariantLoop and
getLoopTripCount out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPUtils.{h,cpp} module. getLoopTripCount reads the file-local
LoopAwareTripCount cl::opt, which stays static in SLPVectorizer.cpp and is
passed to the moved helper as an explicit parameter. NFC.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
[SLP][modularisation][NFC] Move getReductionInstr to SLPReductionUtils, getAggregateSize to SLPUtils
Move the reduction-root helper getReductionInstr out of SLPVectorizer.cpp
into the self-contained SLPVectorizer/SLPReductionUtils.{h,cpp} module.
getAggregateSize is not reduction-specific: its only user is
findBuildAggregate and it only computes the element count of a homogeneous
aggregate from its type. Move it to the generic SLPVectorizer/SLPUtils
module instead.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Assisted by AI
SelectionDAG: Mark inline asm clobbers dead when an output covers the read
An inline asm clobber was only marked dead if no glued CopyFromReg
read an overlapping register. A read of an output register that
overlaps a wider clobber kept the whole clobber live, even though the
output def already provides the read value. For example,
"={a1},~{a[0:15]}" left the $agpr0_..._agpr15 clobber live.
Ignore glued reads fully covered by an output def of the asm,
producing the same flags LiveVariables would later add, with a live
def of the output and a dead def of the clobber.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
VE: Stop adding kill flags in setjmp custom inserter (#233201)
There is no reason anymore to set these before register allocation.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[NVPTX] Set default value of nvptx-allow-ftz-atomics to false
This restores the strict FTZ default originally introduced in #200732
and temporarily relaxed in #206154.
Frontends can now explicitly opt in to native FTZ-mismatched atomics on a
per-instruction basis using `!atomic.ignore.denormal.mode` metadata (#217585,
#217586, #217587, #217588, #232725, #232726), which is supported in Clang,
Flang, MLIR, and XLA. Users who need the previous behavior globally can still
pass `-nvptx-allow-ftz-atomics=true`.
Update test cases to verify the new default disallow behavior.
[libc][fuzzing] Re-enable math fuzzing with internal headers (#231744)
Re-enable math fuzzing after header inclusion decoupling.
- Replace `<math.h>` with `"hdr/math_function_macros.h"` across math
fuzzers and add CMake dependencies.
- Re-enable `add_subdirectory(math)` in `libc/fuzzing/CMakeLists.txt`.
- Forward `LINK_LIBRARIES` in `add_libc_fuzzer`.
- Skip comparing unspecified `frexp` side-effects for NaN/Inf in
`SingleInputSingleOutputDiff.h`.
Fixes #85680
Assisted-by: Automated tooling, human reviewed.
[flang][CUDA] Emit ignore_denormal_mode for CUDA Fortran atomicadd (#232726)
CUDA Fortran `atomicadd` has the same device semantics as CUDA C++
`atomicAdd()`, targeting PTX `atom.add` (which flushes f32 denormals to
zero on global memory).
Set `ignore_denormal_mode` on `mlir::LLVM::AtomicRMWOp` when lowering
CUDA Fortran `atomicadd` for floating-point types in `genAtomBinOp`,
matching Clang's CUDA/HIP `atomicAdd` lowering (#217587) so it continues
to emit native `atom.add.f32` when `-nvptx-allow-ftz-atomics` defaults
to `false` (#231429).
[SLP][modularisation][NFC] Move isFirstInsertElement/getDebugLocFromPHI to SLPUtils (#222612)
Move the BoUpSLP-independent helpers isFirstInsertElement and
getDebugLocFromPHI out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPUtils.{h,cpp} module.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
[tools] Parse library options into LLVMContext (#233194)
cl::ParseCommandLineOptions sets library options in T::Global, so IR
options will no longer affect them after LLVMCore migrates off cl::opt.
Switch to cl::parseCommandLineOptions.
[clang][Driver] Use the Windows ARM64 defaults for aarch64-unknown-uefi
Match the Windows ARM64 driver defaults for aarch64-unknown-uefi, which
follows the same ABI:
* char is signed, so do not pass -fno-signed-char,
* the frame chain must stay valid even when frame pointers are omitted,
so -fomit-frame-pointer yields -mframe-pointer=reserved rather than
none, as the backend reserves the frame pointer for UEFI as well,
* -msign-return-address selects the B key, the only one the backend
accepts for Windows and UEFI.
Assisted-by: Claude
[clang] Add aarch64-unknown-uefi target
Add the aarch64-unknown-uefi target to clang, building on the backend
support added in the preceding patches. Like x86_64-unknown-uefi it
follows the Microsoft ABI conventions, matching the Windows ARM64 target
which is the only way EFI applications for AArch64 can be built with
Clang/LLVM today:
* add UEFIAArch64TargetInfo: LLP64 types, Microsoft C++ ABI, char*
based va_list and the Win64 calling convention kind,
* use the Windows AArch64 ABI info in CodeGen for UEFI,
* accept aarch64 for *-uefi triples in the driver.
The UEFI toolchain already handles the linker invocation (lld-link with
/subsystem:efi_application), so no further driver changes are needed.
Assisted-by: Claude
[AArch64] Apply the Windows SEH and CRT codegen constraints to UEFI
aarch64-unknown-uefi uses SEH unwind information and has no C runtime
library, so the remaining Windows specific codegen decisions that follow
from this apply to it too:
* do not align loops or basic blocks, since SEH unwind info generation
needs the exact function layout before alignment padding is inserted,
* sign return addresses with the B key by default and reject A key
signing, matching the pac_sign_lr unwind code used by the unwinder;
the branch protection parser defaults to the B key for UEFI as well,
so that -mbranch-protection=pac-ret keeps working,
* do not lower wide shifts to libcalls at -Oz, as those helpers are not
available.
The corresponding Windows tests gain aarch64-unknown-uefi run lines and
the LLVM release notes announce the new target, which completes the
backend side of aarch64-unknown-uefi support.
Assisted-by: Claude
[SLP][modularisation][NFC] Move getReductionInstr to SLPReductionUtils, getAggregateSize to SLPUtils
Move the reduction-root helper getReductionInstr out of SLPVectorizer.cpp
into the self-contained SLPVectorizer/SLPReductionUtils.{h,cpp} module.
getAggregateSize is not reduction-specific: its only user is
findBuildAggregate and it only computes the element count of a homogeneous
aggregate from its type. Move it to the generic SLPVectorizer/SLPUtils
module instead.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Assisted by AI
[SLP][modularisation][NFC] Move loop trip-count helpers to SLPUtils
Move the BoUpSLP-independent helpers findInnermostNonInvariantLoop and
getLoopTripCount out of SLPVectorizer.cpp into the self-contained
SLPVectorizer/SLPUtils.{h,cpp} module. getLoopTripCount reads the file-local
LoopAwareTripCount cl::opt, which stays static in SLPVectorizer.cpp and is
passed to the moved helper as an explicit parameter. NFC.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
[clang-tidy] Fix readability-redundant-parentheses false positives on decltype (#224715)
Preserve parentheses that affect type deduction in `decltype` operands
and
`decltype(auto)` initializers and return statements. This also covers
dependent operands in templates and their instantiations, and operands
that create temporaries. Continue diagnosing redundant parentheses whose
removal does not affect type deduction, such as those in
`decltype((1))`.
Fixes #223522.