[orc-rt] Add SymbolLookupSet for interned symbol names (#242969)
SymbolLookupSet holds symbol names as StringPool::Ptrs, so building a
set doesn't copy the name strings. It has the same interface as
RemoteSymbolLookupSet, which holds plain std::strings.
sps::lookupInJITDylib now takes a SymbolLookupSet. To support this:
- StringPool::Ptr and WeakPtr can be serialized to SPSString, which
writes the string's value. Only serialization is supported:
deserializing into an interned string would need a StringPool, and SPS
deserialization has no way to obtain one.
- SymbolLookupSet can be serialized (but not deserialized) as an
SPSSymbolLookupSet. The wire format doesn't change, so controllers are
unaffected.
- SPSRemoteSymbolLookupSet.h is renamed to SPSSymbolLookupSet.h, after
the tag it defines. It now holds the traits for both kinds of set.
[libc][GPU] Enable scalbn/ldexp, rand, remainder for SPIR-V (#242212)
This PR is a follow up of
https://github.com/llvm/llvm-project/pull/236324 to fix more build
issues for SPIR-V compiler-rt builtin tests. "Undefined symbols" from
libc and libm still lead to a bunch of build failures such as rand,
srand, scalbn/f, remainder/f. Before the fix, building results:
Total Discovered Tests: 275
Unsupported: 125 (45.45%)
Passed : 128 (46.55%)
Failed : 22 (8.00%)
After the fix:
Total Discovered Tests: 275
Unsupported: 125 (45.45%)
Passed : 136 (49.45%)
Failed : 14 (5.09%)
8 more tests can build pass now.
[8 lines not shown]
[llvm-exegesis] Parse library options into a context (#242680)
Parse the command line into a cl::LibraryOptionsContext instead of the
global option values. LLVMState::create takes the context and points
the target machine's MCOptions.LibraryOptions at it. The assembler's
LLVMContext and the disassembler's MCAsmInfo read from it as well.
LLM-aided
AtomicExpand: Cast the xchg from an expanded atomic store to integer
expandAtomicStoreToXChg created the atomicrmw xchg and expanded it
directly, skipping the cast to integer that shouldCastAtomicRMWIInIR
requests for other xchg instructions. A vector store expanded this way
reached the LL/SC expansion with a vector type, which asserted on ARM.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[mlir][AMDGPU] Add preferAgpr hint to MFMA operations
The AMDGPU backend accepts the `!amdgpu.mfma !{!"agpr"}` instruction
metadata on calls to the `llvm.amdgcn.mfma.*` intrinsics (including
`llvm.amdgcn.mfma.scale.*`). The metadata is a hint that asks the backend
to allocate the accumulator input (C) and the result (D) of the MFMA to
AGPRs. The backend can ignore the hint, and dropping it does not change
program behavior.
Add an optional `preferAgpr` unit attribute to the ROCDL MFMA intrinsic
operations, including the scaled MFMA operations, and to `amdgpu.mfma` and
`amdgpu.scaled_mfma`. When the attribute is present, the translation to
LLVM IR attaches `!amdgpu.mfma !{!"agpr"}` to the intrinsic call, and the
AMDGPUToROCDL conversion copies the attribute to the ROCDL operation. When
the attribute is absent, the printed operations and the translated LLVM IR
are the same as before.
The SMFMAC operations do not get the attribute because the backend ignores
the hint on `llvm.amdgcn.smfmac.*`.
[5 lines not shown]
[AMDGPU] Keep metadata when shrinking scaled MFMA fp4/fp6 operands
InstCombine narrows the A/B operands of llvm.amdgcn.mfma.scale.*.f8f6f4
for fp4/fp6 formats by creating a new call, but did not copy the old
call's metadata. Copy it, as the other rewrites in this file do, so
hints such as !amdgpu.mfma survive.
[AMDGPU][SelectionDAG] Select the MFMA AGPR form from !amdgpu.mfma metadata
Problem
- Frontends (Triton) pin MFMA accumulators to AGPRs with "=a" inline asm.
- The asm forces VGPR->AGPR copies around every MFMA (v_accvgpr_mov
+ s_nop inside loops), and selection has no way to ask for the AGPR
form per instruction: it is chosen per function.
Idea: a droppable hint on the MFMA call, read when the form is selected.
IR call @llvm.amdgcn.mfma.*(...), !amdgpu.mfma !{!"agpr"}
| SelectionDAGBuilder: TLI.getTargetIntrinsicHint(I)
DAG INTRINSIC_WO_CHAIN --SDEI side table: TargetHint
| CanUseAGPR_MAI predicate
MIR V_MFMA_..._e64 (AGPR form): C/D are AReg, no copies
How
1. TargetLowering::getTargetIntrinsicHint returns metadata from an
intrinsic call; SelectionDAGBuilder stores it on the node in the
[34 lines not shown]
AMDGPU: Fold inline immediates in peephole-opt (#242952)
Currently the AMDGPU implementation of foldImmediate handles a small
set of special cases that require rewriting the instruction opcode
(COPY -> mov, and fma-like to fmac-like). Most general immediate folding
is handled in SIFoldOperands. Teach PeepholeOpt to fold all inline
immediates into target instructions which should always be an
improvement.
This is to help alleviate some phase ordering problems in future changes.
I've also never liked how SIFoldOperands is written and it could use a
rewrite, and this will alleviate some of its responsibilties. It will
always be necessary since some operand folds require additional context
that foldImmediate won't have (namely, we have to make contextually
aware tradeoffs for which operands are worth folding to respect constant bus
restrictions, considering other users of the values).
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
AMDGPU: Clear stale kills when merging v_mov_b16 pairs
SIPostRA16BitMovFolding can insert the merged 32-bit instruction after
an instruction that kills the first mov's source, which then reads a
register the verifier considers dead:
$vgpr7_lo16 = V_MOV_B16_t16_e32 $vgpr5_lo16
$vgpr16 = V_PERM_B32_e64 killed $vgpr5, $vgpr6, ...
$vgpr7_hi16 = V_MOV_B16_t16_e32 killed $vgpr6_lo16
=>
$vgpr16 = V_PERM_B32_e64 killed $vgpr5, $vgpr6, ...
$vgpr7 = V_PERM_B32_e64 $vgpr6, $vgpr5, ...
Clear kill flags of the first mov's source between the first mov and
the insertion point.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
IR: Check for overlap before copying in AttributeSet::removeAttributes
removeAttributes copied the whole set into an AttrBuilder to check if
the mask overlaps it, which it usually doesn't. Check the attributes
of directly with the mask and only build the AttrBuilder if something
needs to be removed.
callgrind instructions, opt -O3: kimwitu++ k.bc -0.16%, SPASS cnf.bc
-0.08%. CTMark instructions:u: ThinLTO -0.02% (kimwitu++ -0.06%)
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[orc-rt] Rename SymbolLookupSet to RemoteSymbolLookupSet. NFC. (#242950)
The std::string-based set is only used for lookup requests that arrive
from the controller. Renaming it frees SymbolLookupSet for a set of
interned (StringPool::Ptr) names, and matches the existing names on the
LLVM side, where llvm::orc::SymbolLookupSet holds interned names and
llvm::orc::RemoteSymbolLookupSet holds plain strings.
The SPS tag SPSSymbolLookupSet is unchanged: it names the wire format,
which LLVM uses for both kinds of set.
AutoUpgrade: Skip return values and arguments without attributes
UpgradeFunctionAttributes built the mask of type incompatible
attributes and tried to remove them from all arg and return positions,
even if there were no attributes.
callgrind instructions, opt -O3: kimwitu++ k.bc -0.05%, SPASS cnf.bc
-0.02%. CTMark instructions:u: ThinLTO -0.02%
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AMDGPU: Fold inline immediates in peephole-opt
Currently the AMDGPU implementation of foldImmediate handles a small
set of special cases that require rewriting the instruction opcode
(COPY -> mov, and fma-like to fmac-like). Most general immediate folding
is handled in SIFoldOperands. Teach PeepholeOpt to fold all inline
immediates into target instructions which should always be an improvement.
This is to help alleviate some phase ordering problems in future changes.
I've also never liked how SIFoldOperands is written and it could use a
rewrite, and this will alleviate some of its responsibilties. It will
always be necessary since some operand folds require additional context
that foldImmediate won't have (namely, we have to make contextually aware
tradeoffs for which operands are worth folding to respect constant bus
restrictions, considering other users of the values).
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[X86][ACEV1][NFC] Emit the ACE instruction definitions from multiclasses
Most ACE operations need three definitions: the instruction itself, a pseudo
for the user-facing intrinsic that takes an immediate tile ID, and a pseudo
for the internal intrinsic that takes a shape and a tile register so the
register allocator can assign TMMs. All three were written out by hand for
every operation, so the four integer outer products differed only in
mnemonic and prefix, and the twelve row-read pseudos only in the intrinsic.
Emit them from five multiclasses, one per operation shape, deriving the
intrinsic names from the mnemonic as X86InstrAMX.td already does.
[clang-tidy][docs] Rewrite modernize check docs to Markdown [1/4] (#232207)
Tracking issue: #201242
See the [migration guide] for more information.
[migration guide]:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
This is the first part of rewriting check documentations in modernize module from reST to MyST Markdown.
AI Usage: This was prepared with rnk's fork of rst2myst and GPT6-assisted (Codex) cleanup.
I manually verified that the documentation renders as expected.
Preview site:
https://broken.life/llvm-staging/modernize-markdown-port/index.html
Co-authored-by: EugeneZelenko <eugene.zelenko at gmail.com>
[orc-rt] Move SymbolLookupResult into its own header. NFC. (#242948)
Splits SymbolLookupResult out of SymbolLookupSet.h, along with its SPS
serialization (now SPSSymbolLookupResult.h) and its unit tests. This
prepares for adding an interned-string counterpart to SymbolLookupSet:
both kinds of set will share the result type.
[clang-tidy][docs] Rename modernize check docs to Markdown [1/4] (#232206)
Tracking issue: #201242
See the [migration guide] for more information.
[migration guide]:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
This is the first part of the mechanical rename of the check
documentations in modernize module.
The rewrite is provided by the next PR in this stack.