Attributor: Clear tail markers after heap-to-stack (#231611)
A tail call cannot access the allocas of its caller. AAHeapToStack
replaced heap allocations with allocas but kept the tail markers on the
calls using them, so alias analysis treated those calls as not accessing
the new allocas. This miscompiled tramp3d-v4 with the full Attributor.
Clear the tail markers in functions where allocations were moved to
the stack, as AAPrivatizablePtr already does for privatized arguments.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Clang][RISCV] Add scalar widening zip intrinsics (#238758)
Add the scalar Bitmanip intrinsics `__riscv_wzip8p_64` and
`__riscv_wzip16p_64` using the existing packed zip intrinsics.
[GlobalISel] Do not attach instruction metadata to debug instructions (#232607)
`MachineIRBuilder` retains PC-section and MMRA metadata while lowering
an IR instruction so that the ordinary MachineInstrs produced from it
can inherit the metadata. Debug records are translated before their
attached instruction, so the builder can still contain metadata from the
preceding instruction.
`buildFIDbgValue`, `buildConstDbgValue`, and `buildDbgLabel` used the
general instruction-building path and therefore copied that stale state
to `DBG_VALUE` and `DBG_LABEL` instructions. This can produce spurious
PC-section entries and incorrectly attach MMRA metadata to debug
instructions.
Construct these debug instructions with only their debug locations,
matching the existing direct and indirect `DBG_VALUE` helpers. The
regression test checks constant and frame-index debug values and a debug
label, while also verifying that the ordinary instruction still retains
its PC-section and MMRA metadata.
[5 lines not shown]
[ConstraintElim] Split signed min/max across their operands when checking a compare
The existing constraint systems only record the bounds that hold for both
operands of a min/max (smax(a, b) >= a and >= b, smin(a, b) <= a and <= b). The
other direction is a disjunction, which cannot be recorded as a fact. When a
compare of signed decompositions involves a min/max result, split it into its
operands: the decomposition is monotonic in that result, so it is the max or min
of its values on each side, and the relation holds for all or for either side
respectively.
https://alive2.llvm.org/ce/z/zsGkJ-
[ConstraintElim] A signed sum of operands with opposite signs cannot wrap
If one operand is known non-negative and the other non-positive, the signed
sum is between them, so it cannot overflow.
https://alive2.llvm.org/ce/z/ZF5Yqr
[ConstraintElim] Prove sadd/ssub.with.overflow cannot overflow from the exact sum
Decompose the operands and show that the sum lies in the range of the type. This
handles patterns like A + (B - A), as well as sums involving signed min/max
results, which are split across their respective operands using monotonicity
(for example start + smax(end - start - 1, 0) <= end).
https://alive2.llvm.org/ce/z/ze8LCk
[clang-tidy] Ignore 0 and NULL null pointers in modernize-use-emplace (#237770)
The check rewrites
```
v.push_back(T(42, 0));
```
where the second parameter of the constructor of `T` is a pointer, to
`v.emplace_back(42, 0)`. The forwarding reference of `emplace_back`
deduces `0` as an `int`, which, unlike the literal, does not convert to
a pointer, so the rewritten call does not compile. `NULL`, which is
`__null` or an integer literal, has the same problem, as does a literal
zero passed for a pointer to member.
Ignore such calls, as the check already does for bit-field arguments,
and remove the FIXME about them. `nullptr` is deduced as
`std::nullptr_t`, which converts to any pointer, so calls passing it are
still reported.
Assisted-by: Claude Opus 5.5
[3 lines not shown]
[clang-tidy] Match IgnoreHeaders against slash-normalized paths in misc-include-cleaner (#237924)
On Windows, `misc-include-cleaner` matches `IgnoreHeaders` regexes
against `tryGetRealPathName()`, which returns a backslashed path in MSVC
builds. Patterns containing `/` therefore never match there.
This patch matches each pattern against both the original path and the
path converted with `llvm::sys::path::convert_to_slash` to fix the
issue.
Fixes #237692
reuse known bits result with WithCache
The overloads feel like a bit of a hack, but we need them because ValueTracking
is much more strict about const than ConstraintElimination, and where we'd want
automatic conversion from WithCache<Value*>& to WithCache<const Value*>& we
can't even do it manually. See: https://github.com/llvm/llvm-project/pull/235158#discussion_r4449759101
[LLD][COFF] Retry pathStr directly in LinkerDriver::enqueuePath before findFileIfNew (#230249)
On Windows XLA CI builds, lld-link occasionally fails with hundreds of
undefined symbol errors for symbols defined in an object file that was
passed on the linker command line, without reporting any error opening
that object file.
Before calling LinkerDriver::enqueuePath, callers check findFileIfNew or
findLibIfNew. If the input file already exists on disk, findFileIfNew
records the file's unique ID in visitedFiles so the same file is not
linked twice.
On 64-bit Windows, enqueuePath opens the file asynchronously via
createFutureForFile. When the main thread later calls future->get(), if
that initial open failed (for example, due to a transient file-sharing
error on Windows when many async tasks open files concurrently, or when
an existing file lacks read permissions), enqueuePath enters its
fallback path.
[16 lines not shown]
[AArch64] Use a single inserter in AArch64SLSHardeningPass
We need to keep the Thunks list as state inside the inserter or
otherwise we will try and insert duplicate functions which will insert a
function with an incorrect name (e.g., .1 suffix).
Reviewers: davemgreen, aeubanks, kbeyls
Pull Request: https://github.com/llvm/llvm-project/pull/238481
RuntimeLibcalls: Add signatures for vector stret libcalls
The vector modf, sincos and sincospi stret functions return a pair of
vectors, so describe them with a struct of two vectors.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add signatures for the divrem libcalls
Add struct types to the signature table so libcalls returning multiple
values can be described in TableGen. Use them for the ARM, Windows and
AVR divmod functions, which return the quotient and remainder in
registers, instead of building their types in C++.
The other divrem libcalls use the compiler-rt prototype, which stores
the remainder through a pointer. AVR gets its own __divmodsi4 and
__udivmodsi4, since ARM Darwin uses the compiler-rt functions with
those names.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RISCV] Use a fully covered switch in RISCVABI::getStackAlignment.
This makes it more obvious the alignment has been chosen explicitly
for every ABI.
Not quite NFC because we no longer emit the stack align attribute for
an unknown ABI.
CodeGen: Compute the machine dominance frontier lazily (#239029)
The legacy pass eagerly computed the frontier whenever a pass required
it. X86 LVI load hardening always required it but returned immediately
unless the lvi-load-hardening feature is enabled, so this was computed
and thrown away in the default case. Record the dominator tree when
the wrapper runs and compute the frontier the first time it is
requested.
Instructions retired for llc -O3 -filetype=null over the 10 CTMark
programs as x86_64 full-LTO modules:
total -0.26%
ClamAV -0.47%
7zip -0.41%
consumer-typeset -0.32%
SPASS -0.31%
sqlite3 -0.29%
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Attributor: Require willreturn to skip capture checks for readonly functions (#231616)
AANoCapture assumed that a function which only reads memory, does not
unwind, and does not return a value cannot capture its arguments,
without looking at the uses. However, such a function can still capture
the address by whether it returns, e.g. by recursing forever if a
pointer is null. FunctionAttrs also requires willreturn for this.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[lldb] Extract reusable core register contexts (#237442)
As part of RegisterInfo/RegisterContext refactoring under
Process/Utility, move RegisterContextPOSIX to
Plugins/Register/Core/RegisterContextCore. The renaming is necessary
because RegisterContextPOSIX doesn't use any POSIX APIs, so the term is
misleading (e.g. FreeBSD-Kernel-Core does not have any relationship with
POSIX except that the FreeBSD operating system itself is compatible with
POSIX). Although RegisterContextPOSIX doesn't do coredump-specific
operations, only elf-core and FreeBSD-Kernel-Core depend on it and
that's the only naming I could justify (Names like Unix and Common don't
fit in this case). We can change the name later when non-coredump
process plugin depends on it, but the probability is low considering
that NativeRegisterContext and RegisterContextDarwin/Mach already cover
what we need.
[TargetParser] Map an Intel GPU to its IGCA target (#238917)
Map an Intel GPU to its IGCA target.
Each Intel GPU in `IntelGPUTargetParser.def` lists its IGCA target, e.g.
`igca_30r` for both `xe-mtl-u` and `xe-mtl-h`, but nothing could read it
out.
This PR adds `llvm::IntelGPU::getIGCATarget(GPUKind)`, which returns the
IGCA target that `IntelGPUTargetParser.def` lists for an Intel GPU, e.g.
igca_30r for xe-mtl-u, or an invalid IGCA target for `GK_NONE`.
It is the first step towards compiling device code once per IGCA target:
with `--offload-arch=xe-mtl-u,xe-mtl-h`, the driver will compile once
for `igca_30r` instead of once per device.
[ConstraintElim] Propagate the sign across an icmp samesign
If one operand of `icmp samesign` is known (non-)negative, so is the other. Add
that as a fact in the signed system.
https://alive2.llvm.org/ce/z/xUgGRM