[GVN] Scan possible loads in transparent blocks before collecting predecessors
The closest load in a transparent block may already be an available
value for the current clobber. Therefore, try scanning the block
before collecting its predecessors.
Assisted-by: Claude # Test
[BPF] Support linking modules with CO-RE relocations (#249081)
Linking BPF bitcode files (e.g., llvm-link a.bc b.bc) and optimizing
the result breaks CO-RE relocations in two ways:
- The IR linker merges same-named relocation globals, e.g.,
@"llvm.t:0:4$0:1" or @"llvm.btf_type_id.0$6", and keeps only the
destination's !llvm.preserve.access.index metadata. If a.c and b.c
define different 'struct t', the relocation for 'p->d' in b.c then
refers to 'struct t::b' of a.c.
- __builtin_bpf_passthrough() calls, which keep optimizations from
merging the relocation loads of different branches, are numbered
from 0 in every compilation. After linking, calls of different
modules may be inlined into the same function with the same number,
SimplifyCFG merges them, and llc fails with "relocation global in
PHI node".
Add a module id to the names of the relocation globals, e.g.,
[9 lines not shown]
[CodeGen] Prefer MFAM/MF naming scheme (#249342)
This is canonical for LLVM and only a couple places use alternative
naming, mostly from recent PRs where I didn't catch this during review.
[ORC] Add controller-side handler for lookupInJITDylib (#242974)
orc-rt's sps::lookupInJITDylib lets code in the executor (the process
running JIT'd code) ask the controller (the process running ORC) to look
up symbols in one of its JITDylibs. This commit adds the controller side
of that call.
createLookupInJITDylibHandler builds the handler from a client-supplied
function that maps the executor's key (e.g. the address of an image
header) to a JITDylib. Clients register it with
bindCallControllerHandler, using the SPS spec in
HandleLookupInJITDylibSPS.h.
Results are returned in request order. A missing required symbol fails
the whole lookup without materializing anything. A missing weakly
referenced symbol is reported as nullopt, so a null address always means
a symbol defined at address zero.
[X86] Fix EFLAGS copy lowering across INLINEASM_BR indirect edges
An INLINEASM_BR isn't a terminator, so it can branch to an indirect
target from the middle of its block, before the instructions after it
run. The EFLAGS that live into an indirect target are the ones at the
asm, not the ones at the end of the block, but X86FlagsCopyLowering
assumed the latter in two places.
When the pass lowers an EFLAGS copy, it rewrites the copy's uses in its
block and then in every successor that EFLAGS live into. For a copy
after an INLINEASM_BR, that includes the asm's indirect targets, which
the copy never reaches, so the pass removed their live-in and rewrote
their flag reads to use SETCCs computed after the asm, which only the
fallthrough path runs. The pass could also hoist the test position for
a copy in an indirect target into its predecessor, before the
terminator that follows the asm, where the indirect path never goes.
Don't follow a copy from its block into the indirect targets of an
INLINEASM_BR before it, and don't hoist the test position out of an
[11 lines not shown]
[X86] Handle more INLINEASM_BR shapes in X86FlagsCopyLowering
A copy before an INLINEASM_BR that leaves EFLAGS alone reaches the asm's
indirect targets, but the pass stopped at a later redefinition of EFLAGS
in the block and never rewrote the reads there. It could also hoist the
test position to the end of a block with an asm, which the indirect path
skips, and splitting a block between two conditional branches moved the
asm's indirect edges to the new block.
Follow the copy into the indirect targets of an asm that it reaches,
don't hoist the test into a block with an INLINEASM_BR, and keep the
asm's indirect edges in the first half of a split block. A block that
both the copy and an indirect path from an asm before it reach needs a
PHI, which the pass can't insert, so report it as it already does for a
use that the copy doesn't dominate.
Assisted-by: Claude Opus 5.5
Refer to the recorded callbr outputs through SmallVectorImpl
The code that records them doesn't depend on the inline size.
Assisted-by: Claude Opus 5.5
Test more outputs that the indirect targets convert
Add the RISC-V shape of #143795, where an i32 output is sign-extended on
each path, a float in a specific physical register on x86, a double in a
pair of registers on i686, and a flag output on AArch64, whose NZCV is now
live into the indirect target. Also check that a callbr with direct and
indirect register outputs now only reports the error.
Assisted-by: Claude Opus 5.5
Move the asm error handling to its own PR
This PR now fixes only valid asm whose outputs crash the indirect targets.
Lowering a callbr whose asm has an error, which crashes after reporting
it, moves to its own PR stacked on this one.
Assisted-by: Claude Opus 5.5
Move a callbr output's operand info and registers into its record
Nothing reads them after the output is recorded, so they don't need to be
copied.
Assisted-by: Claude Opus 5.5
Regenerate callbr tests for label-must-be-emitted
Main now prints label-must-be-emitted on INLINEASM_BR indirect targets
(#234850).
Assisted-by: Claude Opus 5.5
[SelectionDAG] Read callbr outputs from the INLINEASM_BR's registers
An indirect target of a callbr found the registers holding the asm's
outputs by walking back from the callbr's exported value through COPYs to
the INLINEASM_BR, and asserted that the chain held nothing else ("start of
copy chain MUST be COPY"). An output whose type differs from its register's,
such as a float in a general-purpose register, is converted, e.g. with
MOVDI2SSrr on x86, so the assertion fired. And the target didn't convert the
output to its result type, as visitInlineAsm() does.
After an error in the asm, nothing defines the exported value, so the walk
crashed, and the callbr block kept edges to the indirect targets with no
INLINEASM_BR to branch there, which later passes reject.
Record the registers that the INLINEASM_BR defines its outputs in when
lowering the callbr, and read the outputs from them in the indirect target,
converting each to its result type as visitInlineAsm() does. After an error,
give the indirect targets undefined outputs and no edges from the callbr.
Fixes #98379, #112914, #143795, #170100, #172657, and #173609.
Regenerate callbr tests for inline asm operand counts
Main now prints the operand count of an inline asm operand with more than
one register, such as "regdef:GR32_NOREX2 ops:2" (#235184).
Assisted-by: Claude Opus 5.5
Remove the stale FollowCopyChain comment and unrelated comment changes
The comment that explained FollowCopyChain's walk was left above
visitCallBrLandingPad() when the walk was removed. Also put the BTI comment
in visitCallBr() back as it was, and fix a double space.
Assisted-by: Claude Opus 5.5