[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]