[IR] Don't fold all-ones `bitcast` to pointers
`FoldBitCast` folded any all-ones value to `getAllOnesValue(DestTy)`.
That asserts for pointers, which `bitcast bN to ptr` can now produce.
There is no pointer constant for an address without provenance, so keep
the cast.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply at anthropic.com>
[SLP][modularisation][NFC] Move loop trip-count helpers to SLPUtils (#222614)
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
[ELF] Move layout-changing transforms before address assignment (#232189)
finalizeAddressDependentContent assigns addresses, then
--randomize-section-padding and CFI jump table relaxation
(--branch-to-branch, implied by -O2) move input sections, so the first
fixed-point iteration computes address-dependent content from stale
addresses. Since #179089, EhFrameHeader::updateAllocSize caches the
.eh_frame_hdr search table; if no iteration changes anything, the loop
exits and the table keys no longer match the FDEs' initial_location.
Neither transform reads addresses, so run them before the first
assignAddresses. SHF_LINK_ORDER sections are now sorted by the relaxed
layout as well.
LLM-aided. Partially fix #226166
(cherry picked from commit 115554f90f920fc000234c2c247b8318d4e7d2d8)
[PowerPC] Don't let optimizeCompareInstr define CR0 while it is still live (#220999)
This replaces the compare-against-zero in
`PPCInstrInfo::optimizeCompareInstr` with the record form of the
instruction defining the compared register only when CR0 is dead at that
point, checked with `MachineBasicBlock::computeRegisterLiveness`
scanning to the end of the block.
Fixes #220996.
## Why
The conversion makes `MI` define CR0. CR0 can still be live there: the
`ANDI_rec_1_{EQ,GT}_BIT` pseudo expansion emits `ANDI_rec` followed by
COPYs of `$cr0eq`/`$cr0gt`, and nothing keeps those copies adjacent to
their `andi.` once other instructions are scheduled in between. A later
compare candidate sitting between an `andi.` and one of its copies gets
converted, clobbers CR0, and the copy then reads the wrong value — the
two flag tests swap conditions.
[43 lines not shown]
[Clang][counted_by] Load the count through unions by byte offset (#228309)
`getGEPIndicesToField()` indexed into a union with 0 and kept walking the
counter's struct field numbers, but the union's IR type is its largest
member, so the count was loaded from inside that member instead.
In Linux, `landlock_domain` hits this and FORTIFY panics on every nested
`landlock_restrict_self()` on kernel 7.3.0-rc5-next as of this writing.
I ran into this bug when trying to daily drive the aforementioned
kernel.
Below is a reduced version of `landlock_domain`. The `work` member
stands in for the kernel's `struct work_struct`, which is larger than the
anonymous struct holding the count, so it becomes the union's IR type.
```c
struct dom {
void *rules[3];
[21 lines not shown]
[clang] Treat pack-index-specifiers as non-deduced contexts (#232883)
Per C++26 [temp.deduct.type]p5.2, a pack-index-specifier is a
non-deduced context. Deduction against an unresolved PackIndexingType
used to fail with a bare IncompletePack result that carried no
parameter/argument info, so matching an explicit instantiation, explicit
specialization, or address-of against such a function template was
rejected, and emitting the resulting diagnostic crashed in
DiagnoseBadDeduction (assertion "no parameter found for incomplete
deduction result" in +asserts builds, null dereference otherwise).
A pack-index-specifier whose pack and index are fully substituted
canonicalizes to its selected type, so the PackIndexing case in
DeduceTemplateArgumentsByTypeMatch only ever sees unresolved ones;
returning Success there (deducing nothing) is all that is needed.
Fixes #232220
[libc++] Don't claim strong emplace guarantee for vector/deque of throwing-move types (#229686)
`__container_traits<vector>` and `__container_traits<deque>` set
`__emplacement_has_strong_exception_safety_guarantee` whenever `T` is
Cpp17CopyInsertable. [vector.modifiers]/2 and [deque.modifiers]/3 only
guarantee "no effects" for an insertion at the end (or at either end for
deque). An insertion in the middle move-constructs and move-assigns
existing elements, and exceptions from those operations are excluded
from the guarantee.
The flat containers use this trait in `__emplace_exact_pos` to decide
whether to clear themselves when an emplacement throws. Because the
trait
is too optimistic, they skip the clear and are left in a state that
breaks their invariants
This patch reports the strong guarantee only when `T` is nothrow move
constructible and nothrow move assignable. In that case the only
operations that can throw (allocation and constructing the new element)
[11 lines not shown]
[X86] supportedVectorShift - explicitly check vector element types instead of bitwidth bounds (#233218)
MVT has more types now, we can't just rely on the bitwidth - we need to
check the element types properly.
Fixes #233186
[TimeProfiler][Clang] Add zstd-compressed time-trace output support (#228627)
Time trace JSON files can become very large (tens of megabytes) when
profiling with fine granularity (-ftime-trace-granularity=0) or verbose
output (-ftime-trace-verbose), while compressing by ~20x with zstd.
Add support for writing zstd-compressed time-trace output directly using
LLVM's existing llvm::compression facilities:
- Introduce llvm::TimeTraceCompression ({Infer, None, Zstd}) in
TimeProfiler.h and extend llvm::timeTraceProfilerInitialize and
llvm::timeTraceProfilerWrite to infer zstd compression from .zst/.zstd
file extensions via llvm::inferTimeTraceCompressionFromPath when set to
Infer.
- Add -ftime-trace-compress=<none|zstd|infer> driver and CC1 option to
explicitly control compression or infer it from the output filename.
- Update default output filename inference when -ftime-trace is used
without an explicit filename so compressed traces use a .json.zst
extension.
Assisted-by: Antigravity with Gemini
[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
[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>