[analyzer] Drop the unused FoldingSetNode base of EquivalenceClass (#244866)
EquivalenceClass derived from FoldingSetNode but was never put in a
FoldingSet; its Profile method is all ImmutableMap/Set need. Drop the
base. This shrinks it from 16 to 8 bytes on 64-bit targets, and the
ClassMap, ClassMembers, ConstraintRange and DisequalityMap nodes from 80
to 72 bytes and the ClassSet nodes from 72 to 64 bytes.
Assisted-by: Claude Opus 5.5
Co-authored-by: Gabor Horvath <gaborh at apple.com>
[lldb][NativePDB] Don't turn function-local enums into scoped enums (#244640)
CodeView can't tell a scoped enum from an unscoped enum.
`EnumRecord::isScoped()` was the wrong check: it does not say whether
the enum is an `enum class`. Instead, it says if the type is declared
inside the body of a function.
This patch always creates unscoped enums and adds a new test which fails
without the change.
rdar://192360576
[clang][AST] Dump saved APValue of all `VarDecl`s (#239672)
Only evaluate the value of constexpr variables during `dump()`, but
always print the saved `APValue` if there is one.
This is more honest since we don't withhold the values we calculated for
non-constexpr variables.
[lldb][Windows] Restore blocking mode of sockets polled by MainLoopWindows (#243851)
`MainLoopWindows` polls sockets with `WSAEventSelect`, which makes them
non-blocking, and `DidPoll` never restores blocking mode.
This patch restores blocking mode in `DidPoll`, after clearing the event
selection.
Under load, at desk, `SocketTest.CreatePair` fails 49 of 6000 runs
without this patch and passes 8000 of 8000 with it. The new
`MainLoopTest.PolledSocketStaysBlocking` fails every run without it.
rdar://191149178
[OpenMP] Don't emit explicit flushes for atomic constructs
Clang and the OpenMPIRBuilder followed every atomic construct that has a
memory ordering other than relaxed with a call to __kmpc_flush, which is
a full memory barrier. However the LLVM LangRef specifies that an atomic
operation itself can provide the ordering "rather than an explicit fence",
so this isn't actually necessary.
It seems the calls are emitted based on a reading of the spec describing
*implied* flushes to mean that flushes should be literally emitted;
an alternative reading (here) is that the flushes are implied by the
atomic operation itself. See e.g. OpenMP 6.0 "17.8.5 atomic Construct"
or equivalent passages in 5.0 through 5.2. The flushes in question
are the "with a list" type for seq_cst, i.e. relating only to the
memory locations used in the atomic. For acquire/release atomics,
synchronization happens through the atomic's variable.
The __kmpc_flush call was also only emitted after the atomic operation,
so in some cases we're *already* relying on the ordering provided by
[29 lines not shown]
[SPIR-V] Rebuild multi-register aggregate arms from a typed placeholder (#236369)
`insertCompositeAggregateArms` rebuilds a multi-register aggregate arm
(e.g. the result of `llvm.sincos`) of an aggregate select or PHI with
`insertvalue`, starting from `poison`. It runs after
`preprocessUndefsAndPoisons`, so that poison stayed bare and
`visitInsertValueInst` turned it into `UndefValue::get(i32)`, which is
uniqued: a second such chain in the function, or any `i32 undef`, then
got the first chain's SPIR-V type, giving an invalid
`OpCompositeInsert`. The chain now starts from the placeholder
`preprocessUndefsAndPoisons` would have created.
Assisted-by: Claude Opus 5.5
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[SPIRV] Fold constant byte offsets past an array element into the index (#243461)
Logical SPIR-V asserts in `walkLogicalAccessChainConstant` when a GEP
adds a constant byte offset to a pointer into a byte-addressed array and
the offset reaches past the element. For example, InstCombine turns
`color.data[o + 2]` on `float4 data[8]` into `getelementptr [16 x i8],
%base, i32 %o` followed by `getelementptr i8, %p, i32 32`. The access
chain walk deduces `<4 x float>` for `%p` and cannot apply a 32-byte
offset to it.
This splits offsets like this into a count of array elements, which it
adds to the array index, and the leftover bytes, which stay a byte
offset inside the new element. In the example, `color.data[o]` plus 32
bytes becomes `color.data[o + 2]`. Longer GEP chains and variable
offsets still fail.
Addresses the constant-byte-offset crash in #206815.
RuntimeLibcalls: Add attributes to fenv libcalls (#244446)
Treat the fp environment as inaccessible memory.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[IR] Fix name clashes in Module move assignment (#245152)
The global variable, function, alias, and ifunc lists share one symbol
table, but move assignment cleared and spliced them one list at a time.
An incoming value named like a destination value in a list not cleared
yet was renamed, such as an incoming global variable @foo becoming
@foo.1 next to a destination function @foo. Clear all four lists before
splicing any.
Assisted-by: Claude Code (Claude Opus 5.5)
[SPARC] Use the f128 compare helpers for matching strict compares (#244836)
With strict FP, every soft-quad f128 compare called _Q_cmp/_Qp_cmp or
_Q_cmpe/_Qp_cmpe and decoded the result. The predicate helpers have
fixed exception behaviour: _Q_flt, _Q_fle, _Q_fgt and _Q_fge (and the
_Qp_ forms) are signaling like fcmpe, and _Q_feq and _Q_fne are quiet
like fcmp. Use them when that matches the compare, as GCC does. This
covers the plain C comparison operators. The other compares still use
_Q[p]_cmp/_Q[p]_cmpe.
Fixes #244636
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc] Use the gettid syscall wrapper in tests (#244825)
This PR move gettid calls in libc tests behind the centralized syscall
wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.
[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
[CodeGenPrepare] Add tests for selects with branch weights (NFC)
Precommit tests for #244382 (issue #236043) and for a follow-up that
uses TTI::shouldTreatInstructionLikeSelect() in optimizeSelectInst():
- logical and/or selects, most of them with branch weights and feeding a
conditional branch in the same block;
- selects of two constants with branch weights, alone and next to other
selects on the same condition;
- a select of two constant vectors on ARM, which does not support it.
The CodeGenPrepare tests are for x86-64 and ARM. The llc tests are for
x86-64, AArch64 (neoverse-v2, where a predictable select is expensive)
and PowerPC.
Assisted-by: Claude Code (Claude Opus 5.5)