[CodeGen] Remove write-only private member variables (NFC) (#245007)
This patch removes private member variables in CodeGen that are
initialized or assigned to but never read, along with their
initializers and assignments.
Assisted-by: Antigravity
[CODEOWNERS] Group MLIR rules and add section markers (NFC) (#244354)
This is part of improving CODEOWNERS hygiene for MLIR. For context, see:
https://discourse.llvm.org/t/rfc-mlir-align-codeowners-with-active-reviewing/
This PR adds markers around the MLIR section and moves the rules
introduced in #234652 so that MLIR and non-MLIR rules are no longer
interleaved.
[llvm-mca][ARM] Fix Cortex-A9 dispatch hazards and NEON memory resources (#230454)
Fix the Cortex-A9 llvm-mca crash by checking execution-resource
availability for instructions that must issue immediately.
Restore NEON structure load/store resource pressure by using the
existing `ItinRW` mappings instead of resource-free `SchedRW` entries.
Add regression tests for the dispatch hazard, original crash reproducer,
and NEON load/store resource pressure.
Fixes #225087.
[DirectX] Declare command line options in TableGen (#234865)
Move the options into MCTargetDesc/DirectXMCOptions.td, since the object
writer reads them too. The asm backend hands them from MCTargetOptions
to the object writer; the passes read them from the module's
LLVMContext.
-disable-dxil-remove-unused-resources is renamed to
-dx-remove-unused-resources, with the old spelling kept as an alias.
Aided by Opus 5.5
[ARM] Trap after a noreturn call that ends a function or funclet on Windows (#242026)
On Windows the unwinder finds the function or funclet of a frame from
its return address. When a noreturn call is the last instruction of a
function or funclet, the return address is the start of the next one. With
C++ EH (#240693), MSVC's runtime then catches a rethrow from the
end of a catch funclet again and again until the stack overflows. I hit
this running Kodi's exception tests on a Surface RT.
MSVC puts a `__debugbreak` after these calls. This adds a pass that puts
a trap there. AArch64 does this in its AsmPrinter (#232358), but on ARM
blocks can't grow after ARMConstantIslands, so the pass runs before it.
Assisted-by: Claude Opus 5.5 (Anthropic)
[ARM] Count the funclet entry alignment in ARMConstantIslands (#242153)
WinException aligns each funclet entry to the function's preferred
alignment, which is 4 once ARMConstantIslands has placed a
constant pool or found a Thumb-2 jump table. ARMConstantIslands
didn't count that padding, so in a function with many funclets a
constant pool load could end up out of range, and the assembler
stopped with "out of range pc-relative fixup value". I hit this building
Kodi for Windows on Arm: a vldr ended up 1032 bytes from its
pool, behind 38 bytes of funclet padding.
This gives funclet entries that alignment once it is final, and updates
the block offsets.
Assisted-by: Claude Opus 5.5 (Anthropic)
[LLD][COFF] Make the call graph profile sort deterministic (#240563)
sortSections copied the call graph priorities into ctx.config.order,
which is keyed by symbol name. When two sections had leaders
with the same name, for example static functions with the same
name in different files, both got the priority of whichever came
last in a map keyed by pointers. So the layout could change
between two links of the same inputs. Sort by each section's
own priority instead.
Assisted-by: Claude Opus 5.5 (Anthropic)
[LLD][COFF] Don't thunk an in-range branch within one section (#240564)
createThunks gives a branch a range extension thunk when it is out of
range with a safety margin, and the margin grows when a pass fails. A
branch to a target in its own section chunk got one too, although its
distance can't change: thunks are only placed between chunks. The
thunk clobbers r12 on ARM (x16 on ARM64) in the middle of a function.
MSVC's __rt_sdiv keeps a value in r12 across such a branch, so its
remainders came back with the wrong sign. Check these branches
without the margin.
Assisted-by: Claude Opus 5.5 (Anthropic)
[CodeGenPrepare] Use shouldTreatInstructionLikeSelect(), as SelectOptimize does
Replace the check for a logical and/or that feeds a branch, and its
exceptions, with TTI::shouldTreatInstructionLikeSelect(), which
SelectOptimize uses to pick its candidates. A logical and/or or a select
of two constants no longer becomes a branch, by its branch weights or to
sink an expensive operand. Check every select of a group on the same
condition, so that the result does not depend on their order. A select
that the target does not support is still expanded.
On i686, the large integer division expansion puts unlikely weights on a
logical or (#175862). CodeGenPrepare no longer turns it into a branch.
Assisted-by: Claude Code (Claude Opus 5.5)
[CodeGenPrepare] Add tests for selects of two constants and select groups (NFC)
Add selects of two constants with branch weights, and selects on the same
condition next to a logical or with branch weights, in both orders.
Assisted-by: Claude Code (Claude Opus 5.5)
[lldb] Let language plugins add options to the expression command (#244453)
This patch adds a new mechanism so Language plugins can reguster their
own options with the expression and dwim-print commands and add them to
EvaluateExpressionOptions. It moves --c++-ignore-context-qualifiers from
the expression command into the C++ plugin.
Assisted-by: Claude
[AArch64] Remove write-only and unused members (NFC) (#245006)
AArch64PipelinerLoopInfo::TRI: Added on June 12, 2024 in commit
0c5319e546321d7a766999e49e0ccf801ff2b3dc without any readers. This
patch also removes its initializer.
AArch64StackTaggingPreRAImpl::TRI: Added on August 30, 2019 in commit
04647f5e222b21b9ff178abf77fbdcb4577a7979 without any readers. This
patch also removes its assignment.
MachineSMEABI::emitSetupFullZASave: This declaration was added on
September 9, 2025 in commit 96d556784ed3ec7a8a6c377b44afb5dfa49229e6
without a definition or any callers.
Assisted-by: Antigravity
[X86] Check global size before section kind in isLargeGlobalValue (NFC) (#237015)
Checking a global's section kind can walk its entire initializer,
whereas
checking its size is cheap.
Part of #236952.
Assisted-by: Gemini
[LAA] Find no dependence between invariant accesses a constant distance apart
Two loop-invariant accesses whose addresses differ by a constant overlap
in every iteration or in none, even if the addresses wrap. LAA showed
they were disjoint only when one ended exactly where the other began,
or when it could prove the addresses do not wrap. Otherwise it reported
an unknown dependence and gave up on the loop, so a loop that updates
three or more fields of a struct through a pointer was not vectorized:
struct trio { int a, b, c; };
void acc3(struct trio *p, const int *x, int n) {
for (int i = 0; i < n; i++) {
p->a += x[i];
p->b ^= x[i];
p->c |= x[i];
}
}
This now vectorizes on x86-64 (VF 4, interleaved by 2). 200000 calls on
[5 lines not shown]
[VPlan] Don't drop poison-generating flags while building VPlans (#245029)
VPSCEVExpander::tryToReuseIRValue dropped poison-generating flags from
reused IR values right away, modifying the IR even if the plan is
discarded. Prefer values that don't need flags dropped, and otherwise
create an in-IR VPExpandSCEVRecipe, leaving it to SCEVExpander instead.
Such recipes may now only be in the epilogue plan, so don't assert they
were expanded for the main plan.
[llubi] Add support for memcpy/memmove/memset (#245021)
This patch adds support for memcpy/memmove/memset libcalls. Unlike LLVM
intrinsics, passing null pointers or invalid pointers is UB, even if the
length is zero. Calling memcpy w/ equal src and dest pointers is also
UB.
Aided by DeepSeek-V4.1-Flash-1017.
[libc++][random] Implement LWG 3809 and LWG 4014 (#239844)
Summary:
- Implement LWG 3809 by correcting the seed initialization of
`std::subtract_with_carry_engine` for narrow result types.
- Implement LWG 4014 by reducing seed values modulo `2147483563` before
conversion to `uint_least32_t`, preserving the intended behavior for
wider result types.
- Add regression tests covering both defect reports.
Testing:
-
`libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp`
[AMDGPU] Keep soft waitcnts unchanged until SIInsertWaitcnts converges
On the first visit to a loop header only the preheader state is known.
A soft waitcnt there (e.g. from a release fence) can have some of its
counters simplified away while another counter keeps the instruction
alive: the fence's own vmcnt(0), a preceding wait.asyncmark, or an
explicit s_waitcnt. The soft waitcnt was then rewritten with the
simplified value and promoted to a hard waitcnt, or merged into a
preceding hard one. When the back edge later brought a pending LDS
store, the original lgkmcnt(0) request was gone, and the s_barrier after
the release fence no longer waited for it.
Treat soft waitcnts as requests that depend on the incoming state: never
merge, promote or rewrite them while the analysis iterates. They are
kept unchanged in DeferredErasures, a hard waitcnt (existing or new)
carries what is needed on each visit, and the soft waitcnts are erased
once the analysis converges. This extends #220357, which did the same
only for soft waitcnts that were simplified away entirely.
[11 lines not shown]
Reland "[clang][CIR] Add tests for SVE RINT{N,P} intrinsics" (#244954)
This relands #241220 and #241236, which were reverted in #244680.
Since AArch64 call conv lowering, which is now the default since
#244014, doesn't have support for SVE, this does the migration with
`-fno-clangir-call-conv-lowering`, which allows these tests to avoid
call conv lowering.