[ObjectYAML][MachO] Support named filetype values (#244575)
yaml2obj accepted the Mach-O `filetype` field only as a number, for
example `filetype: 0x00000002`. Support named values like `filetype:
MH_EXECUTE`, the same way as the `cmd` field of Mach-O load commands and
the `Type` field of ELF (`Type: ET_EXEC`). obj2yaml now prints the
names. Numbers still work, so existing tests don't change.
[mlir][inliner] Ask the terminator dialect before the single-block fast path (#237936)
Fix a crash in the inliner when a func.func ends with llvm.unreachable
or ub.unreachable.
Before taking the single-block fast path, the inliner asked the dialect
of the callable's parent operation (func), but the terminator is then
handled by the inliner interface of its own dialect, which could not
handle the fast path:
- LLVMInlinerInterface::handleTerminator casts the terminator to
llvm.return, so llvm.unreachable failed the cast assertion (#237592).
- UBInlinerInterface does not implement handleTerminator, so
ub.unreachable hit the default llvm_unreachable (#237590).
The inliner now asks the terminator's dialect whether the fast path is
allowed. The LLVM dialect already disables it for llvm.unreachable,
which fixes #237592. The UB dialect now always disables it
(ub.unreachable is its only terminator) and implements the multi-block
[5 lines not shown]
[AMDGPU] Allow instruction prefetch opcodes to use label as operands (#237968)
This patch allows the instruction prefetch opcodes to be able to specify
a label target and have the target offset computed by the assembler,
thus replacing the manual tracking and computing of the offsets.
[mlir][SPIR-V] Add untyped pointer type from SPV_KHR_untyped_pointers (#242410)
First step of SPV_KHR_untyped_pointers support
Untyped variables, access chains and lowering to LLVM will follow later
[clangd] Drop attributes from definitions generated by DefineOutline (#242635)
When DefineOutline moves a function body out of line, it no longer
copies the attributes to the generated definition. They stay on the
declaration, where the definition inherits them from.
Example: Applied to
```
struct A { [[nodiscard]] int foo() { return 0; } };
```
Before:
```
struct A { [[nodiscard]] int foo(); };
[[nodiscard]] int A::foo() { return 0; }
```
Now:
```
struct A { [[nodiscard]] int foo(); };
int A::foo() { return 0; }
[22 lines not shown]
[mlir][tosa] Fix Rescale mixed constant lowering (#241992)
## Summary
Fix `tosa.rescale` lowering when exactly one of the multiplier or shift
operands is constant. Extract each constant operand’s values
independently so the lowering doesn’t create an empty tensor for the
constant input.
Add regression tests for both mixed constant/dynamic cases, covering
scalar and per-channel operands. Add an assertion to catch a constant
operand being passed to the lowering helper without values.
Fixes #238236
AI Usage Disclaimer: Copilot tool was used to generate tests in
`mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir`. I've reviewed
to the best of my ability.
[Mips] Fix DSP bitcasts between v2i16 and v4i8
v2i16 and v4i8 are both legal DSP vector types in the DSPR register
class, but MipsDSPInstrInfo.td only had bitconvert patterns between each
of them and i32/f32, so a bitcast between the two vector types failed to
select.
The bitcast is a no-op: both types are loaded and stored as a 32-bit GPR
word with element 0 at the lowest address on either endianness. Add the
two missing patterns, plus a test covering both directions on both byte
orders.
Fixes #245155
[SPARC] Use a DTP-relative offset for the DWARF location of TLS variables (#244842)
The SPARC target did not override getDebugThreadLocalSymbol, so the
DW_OP_const4u/DW_OP_const8u operand in the location of a thread-local
variable was emitted as a plain address (R_SPARC_32/R_SPARC_UA64)
instead of the variable's offset within the module's TLS block. gdb
then could not read thread-local variables in programs built with clang.
Emit %r_tls_dtpoff32/%r_tls_dtpoff64, as GCC does, which become
R_SPARC_TLS_DTPOFF32/R_SPARC_TLS_DTPOFF64. Accept these specifiers in
.word/.xword in the assembler, mark the referenced symbol STT_TLS like
GNU as, and teach the RelocationResolver about the relocations so
llvm-dwarfdump does not warn about them.
Fixes #244635
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Sparc][MC] Report unknown register names as invalid register names (#245150)
When the name after '%' is neither a register nor a relocation
specifier, the parser always reported "invalid relocation specifier",
even for things like "%r100" or "%f33" that were clearly meant to be
registers.
Make matchSparcAsmModifiers return ParseStatus and only treat the name
as a relocation specifier when it is followed by '('. Otherwise report
"invalid register name" in the caller, right after trying to match a
register name.
Also report an error for the TLS relocation specifiers that are only
valid as the trailing relocation operand, instead of failing without
one.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[LoopInterchange] Hoist Safe instruction to inner loop's PreHeader (#236078)
Currently for one of motivating examples in bwaves benchmark, where
address calculation is emitted near to store in reduction loops exit
block.
To enable reduction2memory in thiscase, we need to hoist the address
calculation to inner loop pre header so it becomes available to perform
the load.
This gives 5-6% performance gain for bwaves.
[SLP]Keep fast-two-sum operands in one column on reorder
Look-ahead paired b of s = a + b; e = s - b with a of the other lane,
so each product was vectorized twice plus shuffles (libc sincos on
AArch64: 4 vector fmuls instead of 2). Operands, used with the lane
root by the same binary users, stay in one column.
Assisted-by: Cursor
Pull-request: https://github.com/llvm/llvm-project/pull/243142
Reviewers: RKSimon, bababuck
Reviewed-by: bababuck
[AArch64][GlobalISel] Fall back to SelectionDAG for GEPs with scalable element types (#234057)
This code Fixes #233165
The IRTranslator file couldn't translate the getelementptr function for
gaining access to the elements of an array due to the function
converting the scalable stride(TypeSize) to an uint64_t which causes an
error.
As a solution for this problem, I changed the
AArch64TargetLowering::fallBackToDAGISel file in order to check for the
getelementptr's source element type and in the case of the scalable
stride data type, falls back to the SelectionDAG which can deal with the
scalable stride element.
A test is added under llvm/test/CodeGen/AArch64/GlobalISel/.
The issue was found with an LLM-based testing tool, and I used Claude to
help reduce it and locate the cause.
[SLP] NFC: make candidate state ownership explicit
Separate the state for the currently owned SLP graph from the graph state
used by dependency analysis, costing and emission. Keep these in private
CandidateState and SharedGraphState members of BoUpSLP.
Centralize candidate reset after scheduler invalidation, clear shared
observers before destroying graph entries, and verify ownership under
EXPENSIVE_CHECKS. Preserve existing reset boundaries and vectorization
behavior.
Assisted-by: codex
[LoongArch] Use INSERT_SUBREG for PseudoXVINSGR2VR into an undefined vector. NFC
When inserting an element into the low half of an undefined LASX vector,
the insert is done on the low 128 bits and the result was widened with
SUBREG_TO_REG. That means that the instruction defining the low 128 bits
also defined the upper 128 bits, which is not the case. Insert the result
into the undefined source vector with INSERT_SUBREG instead, which keeps
its upper 128 bits undefined.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[lld][MachO] Pool relocation storage per input section
Compilers split input sections into many subsections, and each subsection currently grows its own relocation vector. In a Chromium link, that means 3.41 million small allocations for 51.3 million relocations. Allocation dominates parallel relocation parsing: glibc grows worker arenas with `mprotect`, and the workers contend on the process's `mmap_lock`.
## Design
I allocate one relocation array per input Section and let its subsections borrow slices of it. Chromium then needs 82,210 arrays. The arrays come from a thread-local bump allocator, which this PR adds to `lld/Common`: the existing thread-local allocators are typed and construct and destroy their elements, which a buffer filled by placement does not want.
Compilers emit relocations by descending address, so each subsection's relocations arrive one after another. `ld -r` output may not be sorted: the parser checks the order as it goes, and on the first out-of-order relocation it sorts the section's relocations and parses them again, holding back diagnostics until it can no longer start over. A slice that later passes append to moves to a buffer of its own.
The parser fills each array from the back, so relocations end up in ascending address order, both across subsections and within each one. A SUBTRACTOR still precedes its paired UNSIGNED. Upstream stores each subsection's relocations in descending order, and the thunk pass walks them in reverse to visit branches by ascending address. With ascending storage, the relocation scan and the thunk pass both read a section's relocations front to back, and the thunk pass becomes a forward loop.
Passes that act on relocations in storage order now do so in ascending address order within a subsection. GOT, stub and binding entries are therefore created in source order, as are undefined-symbol diagnostics and `-why_live` output. The affected tests are updated; only the order of entries changes.
## Measurements
Both tables compare this PR, merged into `main` at 950baabb7fdf, against that commit. They give means and cbdr 95% confidence intervals over 30 interleaved paired rounds at the default thread count.
Linux (AMD Ryzen 7 7700):
[37 lines not shown]
[TTI][SLP] Pass the scalars of the lanes to getArithmeticInstrCost
SLP prices a vector instruction with one scalar lane as the context. A
target that reads a property of the context, like the users of an fmul
that fuses into an fma, gives the whole vector the property of that lane.
Add the scalars of the lanes to getArithmeticInstrCost, like
getAltInstrCost does, and pass them from SLP. AMDGPU uses them for the
fmul fusion and the fdiv afn costs: the vector gets the cheaper cost only
if all lanes qualify.
Assisted-by: Claude Opus