Test the register pressure cases at -O0, too
A comment said that -O0 picks memory for "rm", which a direct output can't
use. At -O0 only an "rm" input still picks memory, and an output takes a
register for the fast register allocator to fold, which nothing tested end to
end. Add an -O0 RUN line, and fix the same claim in asm-constraints-rm.ll.
Assisted-by: Claude Opus 5.5
Include what the folding uses, and fix two comments
Include STLExtras.h, <algorithm>, and <limits> for the helpers that the
folding code uses. tiedUseMustCopy() had been put between lowerTiedUse() and
its comment, and the reason given for not folding a subregister operand was
wrong: it's that a subregister def would lose the register's other lanes.
Assisted-by: Claude Opus 5.5
Fix the rm_and_m comment
It said that the stack slot's memoperand isn't added to an asm that accesses
other memory without memoperands, but the asm gets one for any memory along
with the slot's.
Assisted-by: Claude Opus 5.5
Assert that an operand is folded, and fix the tied-use comments
The loop that finds the first operand to fold relies on there being one,
which nothing checked. The comments also said that every operand of the
register is folded, but a use tied to another register's def keeps its
register.
Assisted-by: Claude Opus 5.5
Fix the comments in greedy-inline-asm-fold.mir
The C source of tied_rm_before_tied_r had the MIR clobber list pasted over
CLOBBERS, ALL_GPRS wasn't defined, and the header said that one value is
spilled, where the checks show several. Nothing said that the qm tests' MIR
is written by hand, which their C can't produce: instruction selection never
makes a "Qm" operand foldable, and gives an i8 "Q" operand GR8_ABCD_L.
Assisted-by: Claude Opus 5.5
[X86] Keep the implicit zero extension when folding a zero operand (#236135)
`foldImmediateImpl` turns a 32-bit ADD/SUB/OR/XOR with a zero operand
into a COPY. On x86-64 the 32-bit instruction also zeroes the upper 32
bits, and a `SUBREG_TO_REG` user may rely on that. After coalescing, the
COPY leaves the upper bits of the source in place. In #213979 a jump
table index is then computed from those bits.
This patch uses MOV32rr instead of COPY when the result is a 32-bit
register on a 64-bit target.
Fixes #213979
Assisted-by: Claude Opus 5.5
---------
Co-authored-by: Phoebe Wang <phoebe.wang at intel.com>
[orc-rt] Move ForwardArgsAsRequested into its own header. NFC. (#245474)
Moves the arg-tuple type and ForwardArgsAsRequested utility out of
WFHandlerTraitsImpl in WrapperFunction.h and into a new
ArgForwardingTraits class template in ArgForwardingTraits.h.
WFHandlerTraitsImpl now inherits from ArgForwardingTraits.
This will allow the utility to be re-used by AllocActionFunction in an
upcoming patch.
snp(4): drain snp_outpoll before destroying the open data
kib' note: comparing to the original submission, seldrain() is called
before cv_destroy().
PR: 301062
MFC after: 1 week
[Clang][AST] Do not lower the alignment of `_Atomic(T)` below that of `T` (#239264)
Fixes #111295
`getTypeInfoImpl` rounds the size of `_Atomic(T)` up to a power of two
and then sets the alignment equal to that size. When `T` is more aligned
than it is wide, e.g. `typedef __attribute__((aligned(8))) int`, this
lowers the alignment, `_Atomic(T)` ends up less aligned than `T`, and
`AtomicInfo` asserts on every access.
The alignment is now only raised to the size, never lowered. Whenever it
is not raised, the value type's alignment requirement is kept as well,
so record layout places such a member like a plain `T`, including under
`#pragma pack` in the Microsoft layout. This matches GCC behavior.
AI was involved!
Report address and indirect labels, and address outputs
A label with an address constraint ("!p") or an indirect one ("!*i"), and an
output with an address constraint ("=p"), asserted in SelectionDAG, and the
output asserted in GlobalISel, too. A label is a branch target, with no value
to take the address of or to point to, and only an input has an address to
pass to the asm. Report errors for them, as for a memory constraint on a
label.
Assisted-by: Claude Opus 5.5
[InstCombine] Infer exact division from a known-zero remainder (#221509)
Fixes https://github.com/llvm/llvm-project/issues/108449
Related https://github.com/llvm/llvm-project/pull/126438
As others have stated before, there is no direct way to have C or C++
emit `udiv exact` or `sdiv exact`.
My goal with this PR is to allow LLVM to infer `udiv exact` or `sdiv
exact` for user defined functions for performing exact division:
```c++
unsigned udiv_3_exact(unsigned x) {
if (x % 3 != 0) {
__builtin_unreachable();
}
return x / 3;
}
unsigned udiv_exact(unsigned x, unsigned y) {
[29 lines not shown]
[orc-rt] Allow reference params in alloc action handlers (#245470)
AllocActionFunction::handle used CallableArgInfo's args_tuple_type as
the type to deserialize handler arguments into. For handlers with
reference parameters this is a tuple of references, which can't be
default-constructed, so a handler like
Error f(const std::string &S);
failed to compile.
This patch adds an AAHandlerTraits helper (analogous to WFHandlerTraits
in WrapperFunction.h) that decays the handler's parameter types, and
uses it in AllocActionFunction::handle. Handlers may now take arguments
by value, const reference, or rvalue reference.
[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
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>
[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
[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
[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
[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