[RISCV] Ignore debug uses in RISCVVLOptimizer (#244237)
Fixes #242732.
With `-g`, `DBG_VALUE` users prevented `RISCVVLOptimizer` from reducing
the VL of vector instructions causing `-g` and `-g0` codegen to diverge.
There were two places where debug uses got in the way
- `checkUsers` walked `use_operands()` including when peeking through
`COPY`, `INSERT_SUBREG` and `PHI` so hitting a `DBG_VALUE` made it give
up since debug instructions dont have an SEW operand.
- `tryReduceVL` walked `use_instructions()` when checking whether same
block uses are dominated by the new VL before moving `MI` after the VL
definition so a `DBG_VALUE` sitting between `MI` and the VL def blocked
the move.
This switches those walks to `use_nodbg_operands()` and
`use_nodbg_instructions()` and adds MIR tests in
[4 lines not shown]
[X86][MachO] Allow undefined symbols in subtraction (#244243)
MachO on X86 currently rejects undefined symbols that appear in a
subtraction expression. I don't believe this is necessary -- an
undefined symbol here should not be substantially different from a
symbol in a different section, we just don't need to add an addend, and
should emit the usual X86_64_RELOC_SUBTRACTOR plus
X86_64_RELOC_UNSIGNED relocations.
MachO on AArch64 already handles undefined symbols this way.
AI assistance used for the test case.
[CIR] Fix address space of __ret_operand_tmp created by FlattenCFG (#244210)
On AMDGPU (and other address space aware targets) allocas must reside in
specific address space.
[coro][NFC] Use bb numbers instead of map (#244370)
Remove the custom block index map and use basic block numbers instead.
This saves a map lookup and removes some code.
[VPlan] Narrow truncates of an induction plus a loop-invariant offset (#226035)
narrowInductionTruncates replaces trunc(iv) by an induction in the
truncated type, but bails out when the truncate operand is the induction
plus an offset, such as the induction increment.
Handle a loop-invariant offset C by folding it into the start value of
the narrowed induction, computed once in the vector preheader, which
covers both trunc(iv + C) and trunc(iv - C). The offset does not have to
be the induction step, as start + C + i * step stays affine for any
loop-invariant C, and trunc(x + C) agrees with trunc(x) + trunc(C)
modulo the truncated width. When the epilogue is vectorized, the resume
value of the narrowed induction is adjusted by the same offset.
On targets where wide i64 vector arithmetic is expensive, this can
decide whether the loop is vectorized at all.
[OpenMP] Build libomp on 32-bit PowerPC Linux (#227539)
kmp_affinity.h has no `sched_{set,get}affinity` syscall numbers for
32-bit PowerPC and stops at its #error. They are the same as on ppc64
(222 and 223), so share that case.
32-bit PowerPC has no 64-bit atomic instructions, so linking libomp.so
also fails on undefined `__atomic_*_8` references. Link libatomic, as
for MIPS, but only if it exists: other 32-bit PowerPC targets such as
OpenBSD (52a02b6d1e0c) may not have it. AIX already links libcompiler_rt
for these.
Assisted-by: Claude Code
[AMDGPU] Describe MFMAs with a variant in MAIInstInfoTable (NFC)
- Add an MFMAVariant enum. Each MFMA pseudo gets its variant from
MAIInstInfoTable, a TableGen GenericTable.
- Look up an MFMA's co-execution info by its variant, as gfx1250 does
for WMMA, instead of matching every opcode.
- Replace the is_dgemm and is_gfx940_xdl fields with the variant.
- Describe each MFMA row by the first stage at which SALU, memory, VALU
and the next MFMA may issue, plus the window length.
- Real MFMA opcodes get no variant, since nothing needs one.
- Strictly speaking this is not NFC, but no code path asks for the
co-execution info of a real opcode.
Assisted-by: Claude Opus 5.5
[TTI][SLP] Pass the scalars of the lanes to getArithmeticInstrCost
SLP prices a vector instruction with one scalar lane as the context. A
target that reads a property of the context, like the users of an fmul
that fuses into an fma, gives the whole vector the property of that lane.
Add the scalars of the lanes to getArithmeticInstrCost, like
getAltInstrCost does, and pass them from SLP. AMDGPU uses them for the
fmul fusion and the fdiv afn costs: the vector gets the cheaper cost only
if all lanes qualify.
Assisted-by: Claude Opus
Revert "[RISCV] Make clang's -mcpu=help and -mtune=help accurate for RISC-V. (#243697)" (#244534)
This reverts commit 6a92538ef2a7103e62e66e490f5d2aafa354b767, which
broke check-flang because -mtune=help was changed to alias a new option
handled only in Clang's frontend, whereas Flang's frontend still checks
only the original option:
FAIL: Flang :: Driver/print-supported-cpus.f90
The failure log is at
https://github.com/llvm/llvm-project/actions/runs/44690702871/job/136135570988
Assisted-by: Antigravity
[libc++] Avoid copying locales throughout the library (#242392)
The normal `getloc()` returns a `locale` by value, which forces a copy
constructor and destructor call (for reference counting) in a lot of
places where we really just need to access the locale. This introduces a
private `__getloc()` to access the locale by reference, saving these
calls.
[libc++] Optimize std::streambuf::pubimbue (#243505)
Using `std::swap` on locales is more efficient than the naive swapping
algorithm, so we should use it.
[libc++] Fix std::invoke with address spaces (#243879)
#213403 improved the compile time of `std::invoke`. Part of that was
avoiding `std::declval`. However, this new version causes references
with `[[clang::address_space]]`s to error. We can just revert to
`std::declval` and keep the rest of the patch.
Fixes #243495
[mlir][gpu] Remove ApplyUnrollVectorsSubgroupMmaOp (#243894)
As discussed in #233408, vector unrolling ops will be replaced with a
single op. To unblock that refactoring, this PR removes
`transform.apply_patterns.gpu.unroll_vectors_subgroup_mma`.
This GPU Transform dialect op includes extensive vector unrolling
configuration that currently lacks test coverage. It also selects
unrolling sizes and traversal order based on hardware assumptions that
may not suit all intended uses.
If the removed functionality is needed, we can reintroduce it through a
higher-level Transform dialect op, similar in spirit to Linalg's
`transform.structured.vectorize_children_and_apply_patterns`.
[BOLT] Parse library options into a context and pass it to MC (#244336)
After #242689, options of LLVM libraries declared in
TableGen (e.g. X86MCOptions: -x86-align-branch-boundary,
-x86-align-branch, -x86-pad-max-prefix-size, ...) are only recognized by
cl::parseCommandLineOptions taking a LibraryOptionsContext, and the MC
layer reads them through MCTargetOptions::LibraryOptions.
llvm-bolt still used the legacy cl::ParseCommandLineOptions, so these
options became "Unknown command line argument" and the Intel JCC erratum
mitigation (-x86-align-branch*) could no longer be requested.
Parse command lines into
opts::LibraryOptionsCtx and point the MCTargetOptions used for
BinaryContext MCAsmInfo at it.
[RISCV] Probe residuals, small frames, call frames and realignment (#237170)
With inline stack probing ("probe-stack"="inline-asm", which
-fstack-clash-protection sets), the RISC-V prologue could leave more
than a probe interval of stack unprobed, so a sequence of frames could step
over a guard page:
- An allocation of at most the probe size, such as a whole frame under
4 KiB, was never probed, and neither was the residual left after the
probes of a larger one. A caller with a 10000-byte frame made its calls
3888 bytes below its last probe, and a callee with a 4064-byte local
array then stored first at the bottom of that array: 7952 bytes between
two stack accesses.
- Call frames smaller than the probe size were not probed.
- Realigning SP was probed at most once, and not at all with an RVV area
or a second SP adjustment of at least the probe size, although it moves
SP down by up to MaxAlign - StackAlign bytes: nearly 64 KiB for a 64 KiB
aligned local.
[17 lines not shown]
[SandboxVec][LoadStoreVec] Address review on mixed-type loads
Rename getLanesTypeFor to getSameBitWidthType and document that a wider
scalar spans several lanes. Drop the unused LoadInst cast, explain the
test data layout, and cover a reversed vector/scalar chain plus loads
with multiple uses.
Co-authored-by: Cursor <cursoragent at cursor.com>
[GitHub] Automatically apply the clang-repl label to PRs and Issues (#243473)
The clang-repl label exists, but it is only applied manually. This PR
adds rules to the issue and PR labelers so it is applied automatically.
Issues are labeled when "clang-repl" appears in the title. PRs are
labeled when they change the clang-repl sources, tests or tool.
Assisted by Claude Sonnet 5.5
[NFCI][LowerTypeTests] Reuse one DIBuilder per module for jump tables (#244484)
`createJumpTableDebugInfo` previously constructed and finalized a new
`DIBuilder` for every CFI jump table, copying and re-hashing an existing
`DICompileUnit`'s metadata arrays on each jump table. Reuse one
`DIBuilder`
(along with the `DICompileUnit`, `DIFile`, and `DISubroutineType`) per
`LowerTypeTestsModule` and finalize it once in
`~LowerTypeTestsModule()`,
matching the intended single-builder-per-module usage
(https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.html).
No meaningful compile-time improvement was measured under ThinLTO:
`ThinLTOBitcodeWriter` strips debug info from the split regular-LTO
module, so its `DICompileUnit` metadata arrays are empty and `DIBuilder`
accounts for a negligible fraction of link time (most overhead is DWARF
emission for the jump-table subprograms). This avoids repeated array
copying/re-hashing when a non-empty `DICompileUnit` is present (e.g.,
[2 lines not shown]