[LLVM] Prune machine IR includes from pass manager interfaces
Move MFPropsModifier into its own header so MachinePassManager.h no
longer needs MachineFunction.h. Extract MachineFunctionProperties into
a lightweight header for pass declarations that only need properties,
and add direct machine-function and machine-instruction includes at
the implementation sites that relied on the old transitive includes.
Move block labels and printed text into a non-template BlockData base
with out-of-line constructors. Keep BlockDataT<T> constructors inline,
so StandardInstrumentations.h does not need MachineBasicBlock.h and
arbitrary data types do not depend on an outlined template constructor.
Remove an unused MachineFunction.h include from Clang's AMDGPU builtin
emitter. Drop the now-unnecessary vt_gen dependencies from clangCodeGen,
clangHandleLLVM and Polly, and include <variant> directly in Polly's
pass registration code.
Validate the rebased integration with CodeGen, AMDGPU, SPIR-V and Passes
[5 lines not shown]
[libc] Bound destination scan and use size_t limits in wcslcat (#247909)
`wcslcat` computed `dstlen` with `internal::string_length(dst)` without
stopping at `dstsize`, and cast `dstsize - dstlen - 1` to `int` before
bounding the copy loop. Scan `dst` up to `dstsize` so calls with
`dstsize == 0` or no null wide character in the first `dstsize` elements
return `dstsize + wcslen(src)` directly, keep `copy_limit` and the loop
index in `size_t` for `dstsize` values above `INT_MAX`, and add
`wcslcat_test` coverage for those cases.
Assisted-By: Gemini
AMDGPU: Don't use PressureDiffs with implicit allocatable physregs
canUsePressureDiffs skipped all implicit operands, so instructions
reading an allocatable physreg implicitly (e.g., vcc on v_cndmask_b32)
used the cached PressureDiff. PressureDiffs assume a single use for
physregs (see the FIXME in ScheduleDAGMILive::updatePressureDiffs), so
the pressure was added for each user. With several users in a region, the
SGPR pressure was overestimated and failed the expensive checks pressure
validation.
Fall back to the RegPressureTracker for implicit operands of
allocatable physregs, which are the ones it tracks.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Flang][CMake] Fix header dependencies and binding header copies
Remove the unused parse-tree.h include from FIRBuilder's
Runtime/Intrinsics.cpp and include the OpenMP pass declarations in
LowerWorkdistribute.cpp. This removes their unnecessary dependencies on
the generated OpenACC headers and FIR transform pass declarations.
ISO_Fortran_binding.h is a checked-in header. Copying it with
configure_file makes CMake emit a phony rule for the input, which
Ninja's missingdeps mistakes for a generated file without a dependency
path to its consumers. Move both copies to build rules using a reusable
helper in AddFlang.cmake. Document the resource-directory copy used by
Flang lit and the prefix include copy used by llvm-test-suite. Build
them by default and before the Flang driver and flang-headers target.
Rebuilt both affected objects, checked their recorded dependencies, and
verified ninja -t missingdeps is clean. Tested initial copies,
incremental header updates, deleted-copy recovery, and paths with spaces
using Ninja, Unix Makefiles, and Ninja Multi-Config.
[2 lines not shown]
[LLVM][CMake] Add generated-header dependencies to pass plugins
The example and unit-test plugins include PassBuilder.h, which pulls in
TargetLibraryInfo.inc and GenVT.inc. They rely on the host process for
LLVM symbols, so linking LLVM component libraries does not order these
headers.
Declare analysis_gen and vt_gen alongside intrinsics_gen. Keep the unit
plugins' prerequisites on their library declarations, so they also apply
to any object libraries created for those targets.
Validated by rebuilding all six reported plugin objects and running
ninja -t missingdeps on them.
Assisted-by: Codex
[CI] Check Linux premerge build dependencies with Ninja
Run missingdeps at the end of monolithic-linux.sh, after project checks
and both runtime reconfigurations, so compiler dependencies have been
recorded. Include the selected check targets alongside all.
Use start-group to give the check a named log section, and capture its
output in ninja_missingdeps.log for artifact collection. Keep the check
in the shared Linux build script rather than a GitHub-only workflow
step.
Validated shell syntax, workflow YAML, and a whole-script harness with
real Ninja dependency checks. The check runs after all build phases,
records diagnostics, fails for a missing generator dependency, and
passes when that dependency is declared.
Assisted-by: Codex
[LLVM] Prune machine IR includes from pass manager interfaces
Move MFPropsModifier into its own header so MachinePassManager.h no
longer needs MachineFunction.h. Extract MachineFunctionProperties into
a lightweight header for pass declarations that only need properties,
and add direct machine-function and machine-instruction includes at
the implementation sites that relied on the old transitive includes.
Move block labels and printed text into a non-template BlockData base
with out-of-line constructors. Keep BlockDataT<T> constructors inline,
so StandardInstrumentations.h does not need MachineBasicBlock.h and
arbitrary data types do not depend on an outlined template constructor.
Remove an unused MachineFunction.h include from Clang's AMDGPU builtin
emitter. Drop the now-unnecessary vt_gen dependencies from clangCodeGen,
clangHandleLLVM and Polly, and include <variant> directly in Polly's
pass registration code.
Validate the CodeGen, AMDGPU, SPIR-V and Passes libraries, 250 object
[6 lines not shown]
[X86] Enable SlotIndexes compaction by default (#237564)
Compacting SlotIndexes before greedy allocation drops the entries of
erased instructions, so live range sizes and instruction distances
reflect the code being allocated rather than how much was erased
before it. AMDGPU has done this since #235806; do the same for X86.
Codegen changes only through allocation: no new crashes, verifier
errors or allocation failures in the lit suites, including
EXPENSIVE_CHECKS, and a stage-2 build of LLVM, clang and lld with
-verify-machineinstrs passes its own tests. On llvm-test-suite at -O3,
spills and reloads drop 0.4% and .text 0.04%, with compile time
unchanged.
Most test updates are regenerated checks. misched-matmul now inserts
20 spills instead of 24. live-debug-vars-stale-slotindexes.mir gets
one more use of %27 so that accumulate_fit still reaches the stale
index path it was written for. reloc-opt.ll gets an NF add that keeps
its source live, because compaction compresses the existing one to the
[2 lines not shown]
[x64][win] Insert WinEH call padding before assembly emission (#245377)
When a `_setjmp` invoke ends a Windows x64 EH region, the padding
emitted by
`X86AsmPrinter` can put the `longjmp` label one byte past the
actual return address. Windows rejects the resulting `longjmp` target.
This change completely refactors the way that we are adding WinEH
padding.
Extend `X86AvoidTrailingCall` to insert the padding as explicit machine
instructions after block layout and before unwind analysis. This pass
handles padding for calls, inline asm and statepoint. Additionally, we
are
now emitted WinEH NOPs for statepoints when they are lowered as NOPs
as we still need that WinEH NOP after the runtime patches in the real
call.
`AsmPrinter` retains the same logic for emitting post-instruction
labels,
[8 lines not shown]
[MemDep] Intersect AATags on cache mismatch (#247967)
getNonLocalPointerDepFromBB() currently clears AATags to empty on any
mismatch, dropping shared metadata such as identical !tbaa when only
!noalias scopes differ. This uses AAMDNodes::intersect() instead to
preserve matching tags without creating new MDNodes, and allows us to
drop the recursive call and the IsIncomplete parameter. When a size
mismatch already clears the cache, AATags is reset directly to the new
query's tags rather than intersecting with the discarded entry.
[RISCV][MC] Don't hardcode enum values in asm-matcher-no-mutation.s checks [NFCI] (#244555)
Use FileCheck patterns instead of literal enum values. This makes the
test easier to maintain if the enums change.
[CMake] Add CFI support to LLVM_USE_SANITIZER
For libc++ CFI CI, we need a way to build the runtimes with Control Flow Integrity enabled via `LLVM_USE_SANITIZER`. Add a `CFI` option on non-Apple Unix platforms that requires `LLVM_ENABLE_LTO` and enables cross-DSO CFI in diagnostic mode, and document it in `llvm/docs/CMake.md`.
Link: https://github.com/llvm/llvm-project/issues/245696
Assisted-by: Gemini
[RISCV] Lower `VECTOR_SHUFFLE_VAR` to `vrgather` (#240222)
Lower `VECTOR_SHUFFLE_VAR` of RVV vectors to `vrgather.vv`. Out-of-range
indices only affect poison lanes, so no clamping is needed.
`vrgather.vv` can only address 256 elements, so longer vectors use
`vrgatherei16.vv` instead.
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[aarch64][win] Preserve Rust panic payload across Windows catchret expansion (#247844)
This issue was originally discovered via
[rust-lang/rust#165346](https://github.com/rust-lang/rust/issues/165346):
A safe Rust program on Windows ARM64 catches a panic and prints its
final line, but exits with 0xC0000409 at opt-level=1 due to an invalid
heap free.
The root cause for the issue is that CATCHRET expansion places the
continuation address in X0 before the epilogue, if the catch
continuation's payload store is first instruction in its block, then
insertion-point check places the continuation address setup before the
store, overwriting the payload pointer returned in X0.
The fix is to move the x0 use for CATCHRET into ISelLowering so that
subsequent lowering will observe it and so save then restore the value.
Assisted-by: GPT-6.2 Sol
[lldb] Make StringPool::GetGlobal private (NFCI) (#249086)
Make GetSystemPool the canonical way to reach the global string pool.
This makes GetGlobal private, with ConstString as its only user, and
drops the default StringPoolRef constructor.
Debugger::GetStringPool now returns the debugger's pool in ASan builds
and the system pool otherwise.
Assisted-by: Claude
[libc++] Fix CFI test failures and add new tests for past CFI issues
Running the libc++ test suite with cross-DSO CFI found four test failures, so resolve them before CFI CI is added. In `allocate_shared.lwg2070.pass.cpp`, change `std::ptrdiff_t` to `std::size_t` so Clang recognizes it as `allocate` and exempts it from CFI checks. In the other three tests, disable `cfi-unrelated-cast` with the `-fno-sanitize=cfi-unrelated-cast` compiler flag to avoid changing these old tests.
In addition, add tests for `vector::reserve` and `std::find_if` to make sure we catch past CFI issues (https://github.com/llvm/llvm-project/pull/248258,https://github.com/llvm/llvm-project/issues/219306) in the future.
Link: https://github.com/llvm/llvm-project/issues/245696
Assisted-by: Gemini
[CodeGen] Port StackMapLiveness to the new pass manager (#247671)
Share the stack-map liveness calculation between the legacy and new pass
managers. Add a MIR test that runs -passes=stackmap-liveness and checks
the live-out register mask on a PATCHPOINT.
Tested the CodeGen suite with X86, AArch64, and AMDGPU enabled. 16,328
tests passed, with no unexpected failures.
---------
Co-authored-by: Aiden Grossman <aidengrossman at google.com>
[mlir][openacc] Enforce signless integer on gang/vector/worker/num_gangs/num_worker/vector_length (#249045)
OpenACC backend only supports signless integer due to various casting to
index types happening during compute_region lowering. This was not
enforce in the dialect itself and a front-end could have generated
signed integer for this operands. This was the case of CIR.
https://github.com/llvm/llvm-project/pull/249041 Update CIR lowering to
use signless integer and the dialect can now enforce this choice in the
verifier.
[X86] Enable SlotIndexes compaction by default
Compacting SlotIndexes before greedy allocation drops the entries of
erased instructions, so live range sizes and instruction distances
reflect the code being allocated rather than how much was erased
before it. AMDGPU has done this since #235806; do the same for X86.
Codegen changes only through allocation: no new crashes, verifier
errors or allocation failures in the lit suites, including
EXPENSIVE_CHECKS, and a stage-2 build of LLVM, clang and lld with
-verify-machineinstrs passes its own tests. On llvm-test-suite at -O3,
spills and reloads drop 0.4% and .text 0.04%, with compile time
unchanged.
Most test updates are regenerated checks. misched-matmul now inserts
20 spills instead of 24. live-debug-vars-stale-slotindexes.mir gets
one more use of %27 so that accumulate_fit still reaches the stale
index path it was written for. reloc-opt.ll gets an NF add that keeps
its source live, because compaction compresses the existing one to the
[3 lines not shown]
[flang][cuda] Do not error on implicit MANAGED and SAVE (#249083)
#244010 introduced a new semantic check but it also trigger on implicit
managed attribute added by the compiler. Update the check to only flag
explicit `MANAGED` and `SAVE` variables.
[X86] Check only demanded VPMADD52 elements for poison (#248944)
X86ISD::VPMADD52L/H fall back to the default
isGuaranteedNotToBeUndefOrPoisonForTargetNode, which checks every
element of every operand. So the vmovq after the multiply-add stays
when an element that isn't demanded may be poison, e.g. when a
multiplicand is a scalar load inserted into zero.
The multiply-add is elementwise and can't create undef or poison
(#247806), so add it next to PCMPGT and the shifts, which check only
the demanded elements of the operands.
Assisted-by: Claude Code (Claude Opus 5.5)
[X86] Merge STRICT_ conversions into upper-zero cases (NFC) (#248943)
In computeKnownBitsForTargetNode and
isGuaranteedNotToBeUndefOrPoisonForTargetNode, the STRICT_ conversions
had their own copy of the upper-elements check, which differs only in
the source operand index. Merge them into the non-strict case and pick
the operand with isTargetStrictFPOpcode, as combineCVTP2I_CVTTP2I does.
Assisted-by: Claude Code (Claude Opus 5.5)
[X86] Mark upper elements of CVTTP2SIS and VTRUNCSS as zero (#248942)
computeKnownBitsForTargetNode and
isGuaranteedNotToBeUndefOrPoisonForTargetNode list the truncation and
conversion opcodes that zero the upper elements of their result, but
miss X86ISD::CVTTP2SIS/CVTTP2UIS (vcvttpd2dqs and vcvttpd2udqs without
a mask; the masked forms are listed) and X86ISD::VTRUNCSS/VMTRUNCSS
(vpmovssdb). So a shuffle that zeroes these elements again is kept as
a vmovq, or a vpxor and vpblendd.
Add them to both lists.
Assisted-by: Claude Code (Claude Opus 5.5)