LLVM/project bb38b73 — llvm/lib/Target/PowerPC PPCISelLowering.cpp, llvm/test/CodeGen/PowerPC inline-asm-wide-gpr.ll

[PowerPC] Use 64-bit registers for wide "r" inline asm operands

On PPC64, an integer wider than 64 bits, such as an i128, in an "r" or
"b" operand was given a 32-bit register for each 64 bits of it, so half
of its bits were lost. Give it 64-bit registers instead. AArch64 had the
same problem (#238926).

Assisted-by: Claude Opus 5.5
DeltaFile
+54-0llvm/test/CodeGen/PowerPC/inline-asm-wide-gpr.ll
+8-2llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+62-22 files

LLVM/project e07a419 — llvm/test/CodeGen/PowerPC inline-asm-wide-gpr.ll

Check the register class of wide GPR operands in MIR

The assembly prints a GPR the same way whether it is used as a 32-bit or
a 64-bit register, so the old checks couldn't show the fix working. Stop
after isel and check the register class of each inline asm operand.

Also add i64 cases for "r" and "b", an i32 case, and a 32-bit PowerPC
RUN line.

Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+199-29llvm/test/CodeGen/PowerPC/inline-asm-wide-gpr.ll
+199-291 files

LLVM/project 07e2eae — llvm/lib/Target/AArch64 AArch64AsmPrinter.cpp, llvm/test/CodeGen/AArch64 inline-asm-wide-gpr-error.ll inline-asm-wide-gpr.ll

[AArch64] Add the H modifier for the second register of a 128-bit operand

A 128-bit integer in an "r" operand takes two X registers, but an asm
could name only the first, so it couldn't use the other half. GCC has
the H modifier for this, so support it too.

Assisted-by: Claude Opus 5.5

DeltaFile
+54-1llvm/test/CodeGen/AArch64/inline-asm-wide-gpr.ll
+18-0llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+18-0llvm/test/CodeGen/AArch64/inline-asm-wide-gpr-error.ll
+90-13 files

LLVM/project bfd0a7d — llvm/lib/Target/AArch64 AArch64ISelLowering.cpp, llvm/test/CodeGen/AArch64 build-pair-isel.ll inline-asm-wide-gpr.ll

[AArch64] Use 64-bit registers for wide "r" inline asm operands

An integer wider than 64 bits, such as an i128, in an "r" operand was
given a 32-bit register for each 64 bits of it, so half of its bits were
lost. Give it 64-bit registers instead.

Fixes #238926.

Assisted-by: Claude Opus 5.5
DeltaFile
+41-0llvm/test/CodeGen/AArch64/inline-asm-wide-gpr.ll
+7-1llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+2-5llvm/test/CodeGen/AArch64/build-pair-isel.ll
+50-63 files

LLVM/project 7c20142 — clang/lib/Basic/Targets AArch64.cpp, clang/test/Sema arm64-inline-asm.c

[Clang][AArch64] Don't warn about a 128-bit "r" operand

Clang warned that a 128-bit value in an "r" operand didn't fit its
register and suggested %w. But the value takes two X registers, and %H
names the second, so don't warn about it.

Assisted-by: Claude Opus 5.5

DeltaFile
+5-0clang/test/Sema/arm64-inline-asm.c
+4-0clang/lib/Basic/Targets/AArch64.cpp
+9-02 files

LLVM/project 13fd739 — llvm/lib/Target/AArch64 AArch64ISelLowering.cpp, llvm/test/CodeGen/AArch64 fmlal-loreg.ll inline-asm-wide-gpr.ll

[AArch64] Use 64-bit registers for wide FP and vector "r" operands

An fp128 or a 128-bit vector, such as a <2 x double>, in an "r" operand
was still given 32-bit registers, so half of its bits were lost, as with
an i128 before. Give it 64-bit registers too.

Assisted-by: Claude Opus 5.5

DeltaFile
+61-2llvm/test/CodeGen/AArch64/inline-asm-wide-gpr.ll
+4-5llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+3-4llvm/test/CodeGen/AArch64/fmlal-loreg.ll
+68-113 files

LLVM/project 64678eb — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp, llvm/test/CodeGen/X86 callbr-asm-error.ll

[SelectionDAG] Don't crash after an error in a callbr's asm

When a callbr's asm has an error, such as a constraint it can't satisfy,
visitInlineAsm() reports it and returns before creating the INLINEASM_BR.
But the callbr's block still got edges to the indirect targets, which
BranchFolding rejects since nothing branches there, and a landing pad in
an indirect target looked for the registers that the INLINEASM_BR would
have defined.

Don't add the edges to the indirect targets, and make a landing pad's
value poison, since nothing reaches it.

Fixes #98379 and #172657. Part of #173609, whose asm is still rejected,
since LLVM picks the "k" alternative of "+kr", which needs AVX-512.

Assisted-by: Claude Opus 5.5
DeltaFile
+69-0llvm/test/CodeGen/X86/callbr-asm-error.ll
+11-2llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+80-22 files

LLVM/project e31c2f6 — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp

Keep the comments on the indirect-target marking together
DeltaFile
+2-1llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+2-11 files

LLVM/project 3119a3c — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp, llvm/test/CodeGen/SystemZ callbr-asm-outputs.ll

Don't use VT's register class for an Untyped callbr output

An i128 output in an explicit register pair on SystemZ is Untyped,
which has no register class, so getRegClassFor() asserted when the
indirect target read the pair. Use VT's class only when VT has one.

Assisted-by: Claude Opus 5.5
DeltaFile
+33-0llvm/test/CodeGen/SystemZ/callbr-asm-outputs.ll
+6-4llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+39-42 files

LLVM/project de009fc — llvm/test/CodeGen/X86 callbr-asm-flag-outputs.ll

Apply suggestion from @arsenm

Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
DeltaFile
+2-2llvm/test/CodeGen/X86/callbr-asm-flag-outputs.ll
+2-21 files

LLVM/project 5ee23ed — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp

Add blank lines after control-flow blocks and before comments
DeltaFile
+6-0llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+6-01 files

LLVM/project 43fc6b4 — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp, llvm/test/CodeGen/SystemZ callbr-asm-flag-outputs.ll

[SelectionDAG] Read callbr outputs at the top of indirect targets

A callbr's indirect target reads the asm's outputs again, from the
registers that the INLINEASM_BR defines them in. When those are
physical registers, they have to be live into the indirect target, and
the read has to come before anything in the block clobbers them.
Neither was ensured.

Only the registers that an output was assigned were marked live-in. An
x86 flag output ("=@ccz") is assigned an unused GR32 virtual register,
and its lowering reads EFLAGS instead, so EFLAGS wasn't live-in, and
the verifier reported "Using an undefined physical register" (#60827).
AArch64 and SystemZ assign a flag output the flags register itself, so
they weren't affected. The read was also a CopyFromReg in the DAG,
which the scheduler could put after an instruction that clobbers the
register. At -O2, an indirect target that added the asm's carry flag to
a product ran the imul before the adc that reads the carry.

Read the registers the way an EH pad reads its exception registers.

    [23 lines not shown]
DeltaFile
+347-0llvm/test/CodeGen/X86/callbr-asm-flag-outputs.ll
+121-9llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+62-13llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+33-0llvm/test/CodeGen/SystemZ/callbr-asm-flag-outputs.ll
+17-11llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
+6-5llvm/test/CodeGen/X86/callbr-asm-outputs.ll
+586-382 files not shown
+594-428 files

LLVM/project f4a08e8 — llvm/lib/Target/X86 X86FlagsCopyLowering.cpp

Use contains() to check for a visited block

Assisted-by: Claude Opus 5.5
DeltaFile
+1-1llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
+1-11 files

LLVM/project b3c4e13 — llvm/lib/Target/X86 X86FlagsCopyLowering.cpp, llvm/test/CodeGen/X86 flags-copy-lowering-inlineasm-br.mir

[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]
DeltaFile
+147-0llvm/test/CodeGen/X86/flags-copy-lowering-inlineasm-br.mir
+23-3llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
+170-32 files

LLVM/project b1371c8 — llvm/lib/Target/X86 X86FlagsCopyLowering.cpp

Use braces for the nested loops over the copy's block
DeltaFile
+10-6llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
+10-61 files

LLVM/project 7727d72 — llvm/test/CodeGen/SystemZ callbr-asm-flag-outputs.ll

Remove -verify-machineinstrs flag
DeltaFile
+1-1llvm/test/CodeGen/SystemZ/callbr-asm-flag-outputs.ll
+1-11 files

LLVM/project 831f889 — llvm/test/CodeGen/AArch64 callbr-asm-outputs-indirect-isel.ll, llvm/test/CodeGen/RISCV callbr-asm-outputs.ll

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
DeltaFile
+87-0llvm/test/CodeGen/RISCV/callbr-asm-outputs.ll
+39-0llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+39-0llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
+36-0llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
+13-0llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll
+214-05 files

LLVM/project dffc3e3 — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp

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
DeltaFile
+6-29llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+6-291 files

LLVM/project 4bc5ab1 — llvm/include/llvm/CodeGen FunctionLoweringInfo.h, llvm/lib/CodeGen/SelectionDAG FunctionLoweringInfo.cpp SelectionDAGBuilder.h

Replay each output's read in the indirect targets

The indirect targets re-parsed the constraints, recomputed each output's
registers and types, and paired them with the recorded registers in order,
so they were right only if both computations agreed. Record each output's
operand info and registers when lowering the callbr instead, and read them
in the indirect targets with the same code as visitInlineAsm().

This also marks a flag output's register (NZCV on AArch64, CC on SystemZ)
live into the indirect targets, as a register output's already was. And the
indirect targets no longer create virtual registers they don't use, which
renumbers some in the AArch64 test.

Assisted-by: Claude Opus 5.5
DeltaFile
+65-93llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+14-0llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+0-7llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+3-3llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
+0-1llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+82-1045 files

LLVM/project f0cfe8e — llvm/test/CodeGen/AArch64 callbr-asm-outputs-indirect-isel.ll, llvm/test/CodeGen/X86 callbr-asm-outputs-indirect-isel-m32.ll callbr-asm-outputs-indirect-isel.ll

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
DeltaFile
+3-3llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+1-1llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
+1-1llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
+5-53 files

LLVM/project 2a06b60 — llvm/include/llvm/CodeGen FunctionLoweringInfo.h, llvm/lib/CodeGen/SelectionDAG FunctionLoweringInfo.cpp SelectionDAGBuilder.cpp

[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.
DeltaFile
+122-110llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+76-0llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+37-0llvm/test/CodeGen/X86/callbr-asm-error.ll
+7-0llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+1-0llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+243-1105 files

LLVM/project 5543655 — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp, llvm/test/CodeGen/X86 callbr-asm-error.ll

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
DeltaFile
+0-37llvm/test/CodeGen/X86/callbr-asm-error.ll
+2-17llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+2-542 files

LLVM/project d125aa2 — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp

Add braces for a large single statement.
DeltaFile
+2-1llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+2-11 files

LLVM/project da90703 — llvm/lib/CodeGen/SelectionDAG SelectionDAGBuilder.cpp, llvm/test/CodeGen/X86 callbr-asm-indirect-output.ll

[SelectionDAG] Report an error for a callbr's indirect register output

An indirect output with a register constraint, e.g. "=*r", is stored to its
pointer after the asm. But a callbr's asm can branch to an indirect target
before then, so the store was silently skipped on the indirect paths. Clang
emits such an output for a _Complex lvalue with a register constraint:

  _Complex float c;
  asm goto("" : "=r"(c) : : : l);

Report an error instead. A callbr without indirect targets has no such
path, so it's still allowed.

Assisted-by: Claude Opus 5.5
DeltaFile
+47-0llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll
+8-0llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+55-02 files

LLVM/project 11a7393 — llvm/lib/CodeGen MachineCSE.cpp, llvm/test/CodeGen/X86 machine-cse-inlineasm-br.mir

[MachineCSE] Don't reuse an instruction after an INLINEASM_BR elsewhere

An INLINEASM_BR can branch to its indirect targets before the instructions
after it in its block run, but MachineCSE let those instructions replace
ones in any block that their block dominates, including the indirect
targets. E.g., when both paths out of a callbr sign-extend its output, the
indirect target reused the extension on the path to the default target and
read a register that its own path never wrote.

Reuse an instruction after an INLINEASM_BR only in its own block. MachineSink
already refuses to sink into an indirect target for the same reason.

Assisted-by: Claude Opus 5.5
DeltaFile
+83-0llvm/test/CodeGen/X86/machine-cse-inlineasm-br.mir
+22-0llvm/lib/CodeGen/MachineCSE.cpp
+105-02 files

LLVM/project e194779 — llvm/test/CodeGen/X86 callbr-asm-indirect-output.ll

use -filetype=null

Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
DeltaFile
+1-1llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll
+1-11 files

LLVM/project 4688805 — llvm/lib/CodeGen InlineAsmPrepare.cpp, llvm/test/CodeGen/AArch64 inline-asm-prepare.ll

[InlineAsmPrepare] Fix callbr uses when indirect dest reaches default dest (#235938)

updateSSA() left a use of a callbr's result alone if the callbr's default
dest dominated it. But an indirect dest can reach the default dest too,
e.g. when they're the same block or when the indirect dest branches to it,
so such a use still read the callbr's result on the indirect path.
SelectionDAG copies that result to a virtual register after the
INLINEASM_BR, on the path to the default dest only, so the indirect path
read a register that it never defined.

Leave a use alone only if the edge to the default dest dominates it, and
don't make the result the value at the end of the default dest, so that
SSAUpdater merges it with the landing pad's value there.

Assisted-by: Claude Opus 5.5
DeltaFile
+65-0llvm/test/CodeGen/AArch64/inline-asm-prepare.ll
+4-3llvm/lib/CodeGen/InlineAsmPrepare.cpp
+69-32 files

LLVM/project cdf8c4a — llvm/test/tools/llvm-cfi-verify/X86 ud1-out-of-line.s, llvm/unittests/tools/llvm-cfi-verify FileAnalysis.cpp GraphBuilder.cpp

[test][llvm-cfi-verify] Test x86 ud1l trap recognition for out-of-line CFI checks (#245404)

Add unit and lit tests verifying that llvm-cfi-verify recognizes UBSan
ud1l traps as non-fallthrough CFI traps and classifies indirect calls
guarded by out-of-line checks branching to ud1l as PROTECTED.

Assisted-by: Gemini
DeltaFile
+45-0llvm/test/tools/llvm-cfi-verify/X86/ud1-out-of-line.s
+29-0llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp
+7-1llvm/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp
+81-13 files

LLVM/project 579b1e2 — clang/unittests/Format BracesInserterTest.cpp, flang/test/Analysis/AliasAnalysis modref-call-descriptor-argument.fir modref-call-saved-locals.fir

[spr] update

Created using spr 2.0.0-beta.2
DeltaFile
+403-0flang/test/Analysis/AliasAnalysis/modref-call-saved-locals.fir
+295-0llvm/test/Transforms/SROA/subbyte-vector-promotion.ll
+253-23llvm/test/Transforms/Attributor/nofpclass-fptrunc-round.ll
+192-0flang/test/Analysis/AliasAnalysis/modref-call-descriptor-argument.fir
+186-0clang/unittests/Format/BracesInserterTest.cpp
+172-0llvm/unittests/SandboxIR/PassManagerTest.cpp
+1,501-23150 files not shown
+4,481-558156 files

LLVM/project 60f219c — clang/unittests/Format BracesInserterTest.cpp, flang/test/Analysis/AliasAnalysis modref-call-descriptor-argument.fir modref-call-saved-locals.fir

[spr] update

Created using spr 2.0.0-beta.2
DeltaFile
+403-0flang/test/Analysis/AliasAnalysis/modref-call-saved-locals.fir
+295-0llvm/test/Transforms/SROA/subbyte-vector-promotion.ll
+253-23llvm/test/Transforms/Attributor/nofpclass-fptrunc-round.ll
+192-0flang/test/Analysis/AliasAnalysis/modref-call-descriptor-argument.fir
+186-0clang/unittests/Format/BracesInserterTest.cpp
+172-0llvm/unittests/SandboxIR/PassManagerTest.cpp
+1,501-23150 files not shown
+4,481-558156 files