[RISCV][GISel] Support scalable vector G_SHL, G_LSHR and G_ASHR (#247078)
Scalable vector `shl`/`lshr`/`ashr` under `-global-isel` previously fell
back to SelectionDAG.
Part of https://github.com/llvm/llvm-project/issues/246831
CC: @topperc
[CoroSplit] Quadratic memory use splitting Swift async functions (#243212)
When splitting a Swift async function, CoroSplit would proceed by making
a clone of the function for each suspension point, but leaving
unreachable code in each continuation clone that wasn't cleaned up until
SimplifyCFG.
This means that it transiently requires memory equal to a full copy of
the original function times the number of async calls in that function.
Instead, run the CoroSplit local cleanup function on each clone
immediately after generating it. This significantly reduces transient
memory usage.
TODO: Note that there's still a quadratic CPU cost inherent in this
approach. To avoid that, we would need to walk the original function and
only clone the blocks relevant for each split.
Resolves rdar://192111984
[CIR][AMDGPU] Avoid strlen loop for constant strings in hostcall printf (#244565)
Also stop treating weak or externally initialized globals as constant
strings in CIR, like LLVM, because the linker or host may change them
[Clang][AArch64] Fix immediate range for FP Multiply-add by indexed … (#246426)
…instruction
This patch fix the lane limit from [0-7] to [0-15] accoring to the
specification for:
svmlallbb_lane[_f32_mf8], svmlallbt_lane[_f32_mf8],
svmlalltb_lane[_f32_mf8] and svmlalltt_lane[_f32_mf8].
[TTI] Remove getPopcntSupport and use the ctpop cost instead (#246272)
getPopcntSupport() was only used by LoopIdiomRecognize and by the
table-based ctpop recognition in AggressiveInstCombine. Use cost
comparisons there instead:
- LoopIdiomRecognize replaces the loop if ctpop costs no more than one
iteration of the loop, since the loop runs at least once.
- AggressiveInstCombine replaces the table lookup if ctpop costs no more
than the GEP and load.
BasicTTIImpl gave an expanded scalar ctpop a flat TCC_Expensive, which
is
less than one iteration of the loop. Cost the expansion done by
TargetLowering::expandCTPOP instead, as is done for clmul.
LoopIdiomRecognize used to always ask about a 32-bit popcount, before
the
idiom was matched. It now uses the type of the loop value.
[15 lines not shown]
[DebugInfo] Skip ODR uniquing on conflicting DICompositeType sizes (#245268)
When two modules define a C++ type with the same ODR identifier but
different DICompositeType sizes, ODR type uniquing in
DICompositeType::buildODRType and getODRType collapses both modules onto
whichever size is materialized first. If a smaller-sized module is
loaded before a larger-sized module (e.g., during ThinLTO importing or
Full LTO linking), DW_OP_LLVM_fragment expressions from the larger
module can exceed the uniqued type's size and abort compilation in the
IR verifier ("fragment is larger than or outside of variable" or
"fragment covers entire variable"), either stripping debug info during
auto-upgrade or aborting compilation when auto-upgrade is disabled.
Reject ODR uniquing (returning nullptr, matching existing mismatched-tag
handling from D111770) when both the existing and incoming
DICompositeType
have conflicting non-zero sizes, so callers fall back to creating a
separate
DICompositeType node for the conflicting module. Null and zero sizes are
[9 lines not shown]
[clang] Remove unused includes (NFC) (#247087)
This patch removes unused #include directives across .cpp files under
clang/lib/. Identified by clang-include-cleaner and verified locally.
Assisted-by: Antigravity
[libc][test] Gate HashTable tests without linking hsearch (#247015)
Commit 6fd1c1b8ef40 (#74371) added `libc.src.search.hsearch` to the
`DEPENDS` list of `bitmask_test`, `table_test`, and `group_test` solely
so those tests are skipped on targets where `hsearch` is not enabled.
Listing the entrypoint in `DEPENDS` also links `hsearch.cpp` and its
global table state into unit tests that never call `hsearch`.
Check `TARGET_LLVMLIBC_ENTRYPOINTS` at the top of
`libc/test/src/__support/HashTable/CMakeLists.txt` instead, drop
`libc.src.search.hsearch` from all three `DEPENDS` lists, and list the
direct `libc.hdr.types.ENTRY` dependency on `table_test`.
Assisted-by: Gemini
[clang][SYCL] Fix crash on `sycl_kernel_entry_point` with incomplete parameter type (#243185)
Clang crashed when a `sycl_kernel_entry_point` function had a parameter
of incomplete type, or a reference to an incomplete type. For a value
parameter, Sema diagnosed the incomplete type but still went on to build
the `SYCLKernelCallStmt`. `KernelParamsChecker` then crashed while
traversing the incomplete record. A reference to an incomplete type is
valid C++, so it wasn't diagnosed at all. But the generated kernel takes
the parameter by value, so incomplete type and crashed.
`KernelParamsChecker::checkParameter` now returns early, marking the
check as failed, for parameters that are already invalid.
It does the same for references to incomplete types, which are diagnosed
with `err_typecheck_decl_incomplete_type`.
`SemaSYCL::BuildSYCLKernelCallStmt` then returns an error instead of
continuing. Reference parameters reuse the existing `variable has
incomplete type` diagnostic.
Fixes https://github.com/llvm/llvm-project/issues/235558
[AMDGPU] Preserve resource requirements through call-graph cycles (#221625)
When a function closes a cycle in the call graph, the cycle's register
counts are flattened to a constant (#142766), which drops callees whose
symbols are not defined yet, and the flags drop the cyclic callee
entirely. A kernel can then get too few VGPRs and no dynamic stack for
a function it reaches through the cycle.
Flatten the function's whole max() or or() expression instead: fold the
constants, skip the function's own symbol and keep the symbols that are
not defined yet. Named barrier counts in a cycle are flattened the same
way instead of using the module maximum.
The private segment size also drops the cyclic callee, so set
has_recursion in that case to request a dynamic stack on code object V5
and later. Since that sets has_recursion for more kernels, restore the
V5 check on the dynamic stack bit (D134714), which #94788 dropped, so V4
object files no longer set that reserved bit.
[CIR] Flatten structs with bitfields in CallConvLowering (#245599)
On AMDGPU, struct over 64 bits is passed as one argument per field
CIR split the struct by its CIR members, but bitfield member is not a
plain value type, so reading it failed with "member type mismatch"
Pass the integer that stores the bitfields instead, and skip zero-width
bitfields, which take no space
This matches the arguments that classic codegen passes
[profcheck] Guard CFI-related profile fixes with the ablation flag (#246999)
The ablation study of `ProfcheckDisableMetadataFixes` did not have CFI
enabled, so it did not exercise the profile fixes in WholeProgramDevirt
and LowerTypeTests. Restore the check that #222393 removed around
computing the branch funnel entry count, and add one to the type test
branch weights from #170752, so that these can be ablated.
[RISCV] Fix RVV callee-saves in realigned frames
The prologue saves RVV callee-saved registers before it realigns SP
and sets up BP, but their slots were addressed from the realigned SP
or BP. The epilogue reloaded them from the wrong address, BP frames
stored them through the caller's s1, and their CFI was wrong.
Address these slots from FP, which does not move, and derive their
CFI from getFrameIndexReference so the two cannot diverge.
Fixes #244792
[RISCV] Add tests for RVV CSRs in realigned frames
Precommit the tests for #244792 so that its fix shows up as a diff.
The checks record the current, wrong output: the prologue saves the
vector callee-saved registers before it realigns the stack, and the
epilogue reloads them from a different address.
[AMDGPU] Add tests for large static LDS offsets (NFC) (#245447)
Add tests for LDS accesses whose constant offsets from a common address
exceed the 16-bit DS offset field, as with more than 64 KiB of
statically allocated LDS on gfx950. The checks record the current
output, where each such access gets its own add. This is used to
simplify #242846
Assisted-by: Claude Code
[CIR] Return the value stored to the return slot directly
Classic codegen returns the value stored to the return slot directly
when that store dominates the return, and then drops the slot
(findDominatingStoreToReturnValue in CGCall.cpp). CIR always lowered the
slot to alloca, store, load and ret, so most scalar-returning functions
differed from classic codegen.
Add a cir-forward-return-slot function pass. In a function with a single
cir.return of a load from the return slot, it returns the stored value
when the store is the slot's only other use and reaches the load through
a chain of single predecessors, or when it immediately precedes the
load. These are classic codegen's rules. The return keeps its own
location, which CIRGen already sets to the return statement's. The pass
runs before LLVM lowering, after FlattenCFG and ABI lowering, so
-emit-cir output does not change. Volatile, atomic, record, array and
complex slots are left alone.
The tests change only in their LLVM checks. In files where the LLVM and
[3 lines not shown]
[ARM] Declare command line options in TableGen (#244990)
Move the ARMCodeGen cl::opts into ARMOptions.td and the ARMAsmParser
ones into MCTargetDesc/ARMMCOptions.td, registered by
LLVMInitializeARMTargetMC(). ARMBaseTargetMachine holds
`const ARMOptions &CLOpts` and ARMSubtarget copies it.
TailPredication::Mode and TPLoop::MemTransfer become the enum classes
TailPredication and TPLoopMemTransfer in ARMSubtarget.h, and
ImplicitItModeTy moves to ARMMCOptions.h. The nameless IT mode option
becomes -arm-restrict-it, with -arm-default-it an alias of
-arm-restrict-it=false. -arm-data-bank-mask and
-arm-assume-itcm-bankconflict become std::optional/BoolOrDefault
members falling back to the CPU defaults.
-disable-arm-parallel-dsp keeps its spelling, as -arm-parallel-dsp is
the pass name opt pins to the legacy pass manager. -tail-predication and
-arm-implicit-it are no longer listed by -help, only by -help-hidden;
-arm-add-build-attributes, which has no help text, is listed by neither.
[33 lines not shown]
[VPlan] Add memory check tests for loop nests (NFC) (#247226)
Print the plan directly after the memory checks are attached instead of
the final plan, and add tests with runtime checks hoisted out of the
outer loop, including stride checks.
[lldb-dap][test][NFC] Relax the corefile frame check (#246482)
Some of the fields are implementation details that may change. and will
always require updating the corefile test.
Drop those from the test.
[MSF] Reserve FPM pairs whenever the block map grows (#233563)
Automatic allocation could skip a Free Page Map (FPM) pair when growth
started exactly at its first block. Initial preallocation and growth
for explicit block-map or stream placement could also leave later FPM
blocks marked free.
Centralize growth in `growFreeBlocks`. Reserve both blocks of every FPM
pair reached, including a pair at the growth boundary, without counting
them toward the requested number of usable blocks.
Add regression tests for initial preallocation, explicit placement, and
adding or extending streams at an FPM boundary. Verify that reserved
blocks are marked used and excluded from stream and directory
allocations.
Assisted-by: GPT 6.1 Sol (via VS Code)
[flang][OpenMP] Evaluate composite DISTRIBUTE clauses outside PARALLEL (#245417)
In composite DISTRIBUTE PARALLEL DO [SIMD], lowering creates
omp.parallel first, nests omp.distribute inside it, and lowers the
DISTRIBUTE clauses inside the parallel region. Take
```
!$omp teams distribute parallel do dist_schedule(static, chunk(n))
```
where chunk has variants for construct={teams} and construct={parallel}.
Flang currently emits
```mlir
omp.teams {
omp.parallel {
%c = fir.call @parallel_chunk(...)
omp.distribute dist_schedule_static dist_schedule_chunk_size(%c) {
```
[22 lines not shown]
[CodeGen] Don't run BasicBlockSections for BB address map alone (#243978)
When only the BB address map was enabled, the BasicBlockSections pass
only renumbered basic blocks so that block IDs could be derived
implicitly from block numbers. The BB address map now emits each block's
ID explicitly (MBB.getBBID()) and walks blocks in layout order, so the
renumbering is no longer needed. Remove it and stop scheduling the
BasicBlockSections pass for the BB address map alone; it now only runs
for basic block sections or function splitting. `handleBBSections` and
`handleBBAddrMap` are thereby removed.
MachineBlockHashInfo is still scheduled at the same position for the BB
address map so the emitted hashes are unchanged.
The only output difference is in the names of local .LBB labels, which
no longer follow layout order; update the affected tests.
[X86] Add X86ISD::PSADBW/VZEXT_LOAD poison handling (#247221)
canCreateUndefOrPoisonForTargetNode - X86ISD::PSADBW can never overflow
or create undef/poison
isGuaranteedNotToBeUndefOrPoisonForTargetNode - add VZEXT_LOAD handling
for constant pool loads
Pulled out of #245048
[CIR] Pass the __cxa_throw destructor in the program address space (#246091)
Function pointers live in the program address space on targets like
spirv64-amd-amdhsa, as in classic codegen
ABI lowering now also keeps that address space when it retypes a
function address
[RISCV][GISel] Support scalable vector G_SDIV, G_UDIV, G_SREM and G_UREM (#247003)
Scalable vector `sdiv`/`udiv`/`srem`/`urem` under `-global-isel`
previously fell back to SelectionDAG.
Part of https://github.com/llvm/llvm-project/issues/246831
[llvm] Avoid more unnecessary Instruction casts for users() (NFC) (#247213)
This removes more unnecessary Instructions casts, now that users()
returns an Instruction iterator. Followup to
https://github.com/llvm/llvm-project/pull/246676.
The cases covered here are mostly ones not using users() but
user_iterator, user_begin() or similar.
Patch generated by Claude.