[VPlan] Single-scalar VPInstructions only use first lane of operands. (#248702)
Single-scalar VPInstructions only use the first lane of their operands,
independent of their users. Report this in usesFirstLaneOnly and do not
propagate first-lane use through them, removing the cast special case in
replicateByVF and the cases for always-single-scalar opcodes. Assert
that vector-to-scalar opcodes are not marked single-scalar.
Blends only used by single-scalar casts are now costed as scalar
selects.
[mlir][acc] Introduce acc-partition-kernel-loops pass (#248659)
Add a pass that maps the parallel loops of an acc.compute_region onto
the GPU dimensions they were assigned. Each scf.parallel loop carries an
acc.par_dims attribute that lists the dimensions it runs over. The pass
splits the loop so that each loop carries a single dimension, which is
the form the GPU lowering expects. For every non-sequential dimension,
the loop gets an outer loop over the launch width of that dimension. The
original loop becomes sequential and walks the iterations of one lane,
so that neighboring lanes work on neighboring iterations.
```
acc.compute_region launch(%w = %pw_x) {
scf.parallel (%i) = (%lb) to (%ub) step (%s) {
...
} {acc.par_dims = #acc<par_dims[thread_x]>}
}
```
[23 lines not shown]
[lldb] Incl SC UUID in headerbytes cache for old debugservers (#248667)
I added a new caching for lldb for binaries read out of memory, saving
the binary header bytes, in
https://github.com/llvm/llvm-project/pull/231344
It creates a filename for the headerbytes cache based on the filename,
file UUID, and if the binary is inside the Darwin shared cache region,
the shared cache UUID. If the debugserver doesn't report the shared
cache VM range, it would suppress headerbytes caching.
One CI bot was using an older debugserver that did not provide the
shared cache VM region, and the test would fail because the expected
headerbytes file was not found.
This changes the behavior for an old debugserver that fails to report
the shared cache VM region bounds -- now, we will include the shared
cache UUID for the filename of every binary read out of memory on that
system, when caching the headerbytes. This means that a filename which
[13 lines not shown]
[RISCV][MC] Diagnose symbol differences in instructions under relaxation (#247981)
With linker relaxation enabled, the distance between two labels that
span a relaxable instruction is only known at link time. `addReloc()`
handles such a symbol difference by emitting an ADD/SUB relocation pair,
but those exist only for data fixups. For an instruction operand, e.g.
`li t0, (9f - 0f)`, it hit `llvm_unreachable("unsupported fixup size")`,
and release builds emitted bogus relocations.
Report an error at the operand instead, as GNU as does. Without
relaxation the difference is still folded to a constant.
A PC-relative target of the form `sym - .`, where `.` is the instruction
itself, is a reference to `sym` and is resolved or relocated as such.
The forms that reach this path past the parser are `li`, `qc.e.li`, and
branches/`jal` with a label-difference target; all are covered by the
new test.
[5 lines not shown]
[SCEV] Compute non-strict exit counts without widening if RHS < MAX (#237107)
For `IV <= RHS` exits, if RHS is loop invariant and less than MAX on
entry to the loop,
RHS + 1 does not wrap.
Compute the exit count as `IV < RHS + 1` in the original type before
widening, where howManyLessThans
can use loop guards to rule out IV overflow.
Updates the RHS argument of helper to allow contextual information
nsw/nuw etc.
howManyLessThans ( .. , const SCEV* RHS )
->
howManyLessThans ( .. , SCEVUse RHS )
Alive2: https://alive2.llvm.org/ce/z/77u3KL unsigned and signed source.
IR diff: https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1900
scalar-evolution.NumExitCountsComputed does increase for few cases.
[4 lines not shown]
Reapply "[RISCV] Remove unnecessary 'and' from masked cmpxchg loop." (#248699)
This reapplies #246502, with updates to the GISel ZALRSC checks.
As noted during review of #240749. loophead has already created a
register that holds 'dest & mask' and newval was already masked.
Assisted-by: Claude
EntryExitInstrumenter: Report unknown instrumentation functions as errors
Use emitError instead of report_fatal_error when an
instrument-function-entry or instrument-function-exit attribute names a
function the pass does not know how to call.
Assisted-by: Claude
EntryExitInstrumenter: Don't pass the return address to __cyg_profile_func_enter_bare
__cyg_profile_func_enter_bare does not take any arguments. It was
passed the return address on AArch64, LoongArch and RISC-V because it
shared the mcount path, which started passing it for _mcount in
eafbab6facb0.
Assisted-by: Claude
[lldb] Add a new UInt32 hex to DataFileCache symtab filenames (#247855)
Create a string of all Language plugins in the current lldb for
creating/loading a DataFileCache symtab file. If a user is running two
different lldb's on the same computer, one with additional Language
plugins so they may have additional demangling schemes, and the user has
symtab file creation enabled, the DataFileCache will have symtab files
for each of the different lldb's in use.
This prevents an lldb with fewer demanglers from writing its symtab to
disk, and then an lldb with additional demanglers using the symtab
as-is, and not having a chance to demangle additional names that it is
able to handle.
I outlined the two approaches that I could take in this Discourse,
https://discourse.llvm.org/t/datafilecache-symtab-issue-with-lldbs-that-have-different-language-plugins-demanglers/93018
and in the end I decided that the new 32-bit hex field in the filename
was the simplest and best choice.
assisted-by: claude
rdar://193942473
[RISCV][MC] Fix crash relaxing compressed branches to symbol + offset (#247917)
The assembler accepts `symbol + offset` as the target of `c.j`, `c.jal`,
`c.beqz` and `c.bnez`. When such an instruction has to be relaxed,
`relaxInstruction()` expanded it with `RISCVRVC::uncompress()`, but the
decompression patterns only accept a constant or a bare symbol. The
expansion failed, which hit the "Can't uncompress instruction"
assertion, or "Unsupported instruction" when assertions were disabled.
Build the uncompressed BEQ/BNE/JAL directly instead, as is already done
for JAL and C_LI.
Fixes #247828
This change was written with the help of an AI tool (Claude Code); I
reviewed and tested it.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc++] Fix CFI unrelated-cast failures in allocator and shared_ptr
While working on the CFI CI (https://github.com/llvm/llvm-project/issues/245696), running the tests with CFI found two new `cfi-unrelated-cast` failures in libc++. They were caused by casting newly allocated memory to a typed pointer before an object is constructed in it. We add `_LIBCPP_NO_SANITIZE("cfi-unrelated-cast")` to `__operator_new_wrapper` in `allocator.h` since it cannot avoid the cast. The other case, `__allocate_shared_unbounded_array`, was casting uninitialized storage to `_ControlBlock*` before `_ControlBlock` was constructed, so we change it to use placement new on `void*` directly like `__allocate_shared_impl` does.
Assisted-by: Gemini
SelectionDAG: Fix marking used physreg defs dead on cloned nodes
94a90a694f87 marked an expensive-to-copy physreg def dead on a
scheduler-cloned node if no successor edge was associated with the
register. An edge is only associated with the register if the user
reads it through a glued CopyToReg. If the physreg result is also used
as an ordinary value operand, InstrEmitter emits a copy from the
physreg to a virtual register after each clone of the node.
This left a read of the register after its def was marked dead:
S_CMP_EQ_U32 %16, %17, implicit-def dead $scc
%18:sreg_32 = COPY $scc
Don't mark the def dead if InstrEmitter emitted a copy from the
physreg.
Assisted-by: Claude
[clang][MS ABI] Fix non-virtual part of vtordispex this adjustment (#248414)
A vtordispex thunk locates the virtual base that contains the final
overrider
through the vbtable of the most derived class and then adds a static
offset.
`CalculateVtordispAdjustment` computed that offset relative to the
overrider's
own class (`Overrider.Offset`) instead of relative to that virtual base
(`Overrider.VirtualBase`). The two only agree when the class sits at
offset
zero inside the virtual base. Otherwise, e.g. when a base with a vfptr
is laid
out before it, the overrider is called with a `this` that is too low by
exactly that offset. In the project where I ran into this, the callee
then
read its pimpl pointer from the wrong place and crashed.
The fix computes the static part relative to `Overrider.VirtualBase`,
[33 lines not shown]
Attributor: Only store AAKindSet IDs of kinds without a mask bit (#248611)
AAKindSet::contains only searches the ID list for kinds that have no
bit in the mask, but the list held the IDs of every kind in the
set. Store only the ones without a bit, so AMDGPUAttributor searches 8
IDs instead of 18.
amdgpu-attributor pass, callgrind: -0.08% on a full-LTO rocPRIM module.
Assisted-by: Claude
Reland "[SPIR-V] Default to NewPM" (#239489) (#248672)
This reapplies #239489, reverted in #245119 because NewPM runs the
machine verifier and exposed latent SPIR-V bugs. These are fixed by
#245209 and #245610
The first reland #246273 was reverted in #246562 because of failures in
expensive checks builds. These are fixed by #247244, #247249 and #247357
Attributor: Use the function information already looked up when seeding (#248645)
identifyDefaultAbstractAttributes looked up the function information at
the start, and again for its opcode map. Use the one it already has.
Assisted-by: Claude
[Offload] Use DataTransfer as the LIBOMPTARGET_DEBUG name of data transfer INFO
Rename the LIBOMPTARGET_DEBUG category of OMP_INFOTYPE_DATA_TRANSFER
messages from "DataCopy" back to "DataTransfer", as before this change.
LIBOMPTARGET_DEBUG=DataTransfer now selects both the INFO data transfer
messages and the ODBG(ODT_DataTransfer) debug messages. The debug
messages are still compiled out without OMPTARGET_DEBUG, so release
builds print only the INFO messages.
Add checks for both build modes to info_category.c.
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
[flang] Treat omp.loop_nest bodies as loops in StackArrays (#248026)
The body of an `omp.loop_nest` runs once per iteration, but it is
neither a control flow graph loop nor a `LoopLikeOpInterface`, so
`isInStackGrowingLoop` did not treat it as a loop. A stack allocation
sized in the body, like a character temporary in a `parallel do`, got no
stack save/restore. The stack grew with every iteration until it
overflowed.
Treat `omp.loop_nest` and `omp.canonical_loop` bodies as loop bodies.
Fixes #245263.
[Clang][CUDA][HIP] Fix Itanium mangler assertion on kernels in template arguments (#248543)
The Itanium mangler made a `GlobalDecl` from a `NamedDecl` when it
mangled a declaration that is referenced from a template argument or an
expression. That c'tor hits an assertion for a CUDA or HIP kernel ("Use
other ctor with GPU kernels!"), because the `GlobalDecl` of a kernel
must tell whether it refers to the kernel or to its host stub.
For example, clang with assertions crashed on this host code:
```
__global__ void kern();
template <auto F> int prepare() { return 0; }
int use() { return prepare<kern>(); }
```
There are three places that needs to be fixed:
`mangleValueInTemplateArg` (the example above), the `DeclRefExpr` case
of `mangleExpression` (a kernel named in an expression in a function
[9 lines not shown]
[X86] LowerBUILD_VECTOR - for [src, 0, .., 0] vectors ensure we freeze the i8/i16 source before zero extending (#248666)
Protect against cases where the original source element is undef/poison, causing propagation etc.
Fixes #244615
[libc++] Introduce relocation primitives and use them in std::any
We can use relocation primitives in std::any to optimize trivially
relocatable objects. This turns moves, move assignments and swaps of
std::any holding trivially relocatable types like std::string into a
memcpy instead of a move construction followed by a destruction.
Relocation algorithms usable in containers will follow.
[libc++] Fix vector::insert_range with a sized input range when not reallocating (#229763)
`vector::insert_range` inserts the new elements in the wrong place when
all of these hold:
- the range is sized but only an input range (e.g. `views::counted` over
a single-pass iterator),
- the vector has enough spare capacity, so it does not reallocate, and
- fewer elements follow the insertion point than are being inserted.
The new elements are left at the end of the vector instead of at the
insertion point. This patch fixes that.
Co-authored-by: Louis Dionne <ldionne.2 at gmail.com>
Co-authored-by: A. Jiang <de34 at live.cn>
(cherry picked from commit 8fc265422f1502a198457fe34e7474da5e8f03fc)
[libc][math] Fix acoshf raising FE_INVALID on quiet NaN. (#248633)
Check x <= 1.0f using integer bits instead of an FP comparison before
NaN handling. On RISC-V, <= lowers to signaling fle.s, raising
FE_INVALID on quiet NaN (+qNaN and -qNaN).
Add the reproducing steps to the smoke test.
```
cmake -B build -S runtimes -G Ninja \
-DLLVM_ENABLE_RUNTIMES=libc \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER_TARGET=riscv64-linux-gnu \
-DCMAKE_CXX_COMPILER_TARGET=riscv64-linux-gnu \
-DCMAKE_BUILD_TYPE=Release \
-DLIBC_TARGET_TRIPLE=riscv64-linux-gnu \
-DCMAKE_CROSSCOMPILING_EMULATOR=qemu-riscv64
[2 lines not shown]
[lldb][OpenBSD] Add blank lines to NativeProcessOpenBSD for readability (NFC) (#248681)
Separate the steps within the functions with blank lines, as was
asked for in the review of the fork and memory region support.
Revert "[libc++] Add __new_at_least" (#248673)
Reverts llvm/llvm-project#215813
There is a long list of issues on #215813, some are bugs in other
components. We need time to resolve them.