[X86][FastISel] Cache import-call-optimization (NFC) (#248155)
`X86FastISel::fastLowerCall()` currently calls
`Module::getModuleFlag("import-call-optimization")` on every 64-bit
call, linearly scanning the `llvm.module.flags` metadata list each time.
Since `X86FastISel` is instantiated per function and module flags do not
change during instruction selection, lazily cache the lookup in a
`std::optional<bool>` on the first 64-bit call (0 lookups for leaf
functions, 1 lookup for call-heavy functions).
Tested locally with `llc -O0 -time-passes` on LLVM bitcode from
`rustc-perf` crates (`ripgrep`, `syn` at `-O0 -g1`): reduces `X86
DAG->DAG Instruction Selection` time by ~2.8% with bit-identical object
output.
Assisted-by: Gemini 4 Neon via Antigravity
[lldb-dap] Move running the server to lldbDAP library. (#248937)
Move running the server out of `lldb-dap.cpp`, so it can be unit tested.
The server now registers only one deadline, and only shutdown if there
are no more clients. instead of creating a new callback for each client
that disconnects.
[libc++] Implement `projected_value_t` from P2248R8 (#248662)
This PR adds `std::projected_value_t` (C++26), the alias template
introduced by [P2248R8](https://wg21.link/P2248R8) "Enabling
list-initialization for algorithms". `std` module exportation is
correspondingly added.
Feature-test macro `__cpp_lib_algorithm_default_value_type` is not added
because algorithms are not yet modified.
The addition is covered by a compile-only test because we only need to
care about the transformed types.
After landing `std::projected_value_t`, modification to each algorithm
in P2248R8 and P3217R0 (for `ranges::find_last`) can be implemented
separately in following-up PRs.
Part of #105421.
Assisted-by: Claude
[OCaml] Use ext_dll suffix for stub libraries (#234939)
ocamlmklib names shared stub libraries with OCaml's `ext_dll` config
value, not `CMAKE_SHARED_LIBRARY_SUFFIX.` On macOS these differ (`.so`
vs `.dylib`), so with `BUILD_SHARED_LIBS=ON` the build looks for
nonexistent `dll<name>.dylib` files and fails with:
Error copying file ".../bindings/ocaml/llvm/dllllvm.dylib" to
".../lib/ocaml/llvm/": No such file or directory
FindOCaml.cmake now reads ext_dll from `ocamlfind ocamlc -config` into
`OCAML_EXT_DLL,` and `AddOCaml.cmake` uses it for the stub library
outputs and install rules.
This is the same issue reported on Cygwin, #92736, which this should
also address (but I have not yet tested it). #123478 also touches on
this by hardcoding .so. Reading `ext_dll` uses the actual suffix
ocamlmklib produces rather than hardcoding it.
[7 lines not shown]
[LangRef] Specify that `allocsize` gives the exact size (#249103)
The LangRef describes `allocsize` as a lower bound: the function returns
"at least" the given number of bytes. The implementation disagrees and
optimizes under the assumption that it is exact. Alternative to #245519
and see there for more details.
I've had Claude survey downstream projects. Findings:
Of major frontends only julia assumed the langref semantics (we're happy
to change this). Additional frontends that make this assumption that
Claude found are llgo, nlvm and kairo, but these are relatively small
projects (and as mentioned in the issue, these are the semantics today,
so clearly they didn't notice). Still if this merges, I'm happy to file
courtesy issues there. Other frontends (e.g. Rust, Mojo) appear to
assume exact as best as I can tell.
Clang uses `allocsize` in two places: For `operator new` and for the
`alloc_size` attribute. For `operator new` on objects, I think the exact
[16 lines not shown]
[flang][cuda] Wait for kernel completion when requested by NVCOMPILER_ACC_SYNCHRONOUS (#248668)
`NVCOMPILER_ACC_SYNCHRONOUS` is a bit field. For CUDA Fortran, bit 2
requests a wait at the end of each CUF kernel and bit 4 requests a wait
at the end of each kernel subroutine launch. The CUDA Fortran runtime
did not look at the variable, so a launch always returned before the
kernel completed.
**Change:**
* `CUFLaunchKernel` takes a new trailing argument `isCUFKernel`.
`CUFGPUToLLVMConversion` passes 1 when the kernel was generated for a
CUF kernel directive and 0 when it is a kernel subroutine. A CUF kernel
is recognized by `_cufk_` in the kernel name, the same test
`CUFLaunchAttachAttr` uses; the constant moves to `CUFCommon.h`.
* After a successful launch, the runtime calls `cudaStreamSynchronize`
on the stream of the launch when the bit for that kind of kernel is set.
`CUFLaunchClusterKernel` and `CUFLaunchCooperativeKernel` only launch
kernel subroutines, so they test bit 4 and keep their signature.
[37 lines not shown]
[VPlan] Generate ExtractLastLane directly (NFC) (#249291)
ExtractLastLane and ExtractPenultimateElement went through
VPTransformState's per-lane value map to extract lane VF - Offset of
their operand. Emit the extractelement directly instead.
The lane map also implicitly handled scalar operands by returning their
lane-0 value. Those extracts are now all folded in VPlan before
execution, so generate can assume a vector operand, which also resolves
the TODO to remove ExtractLastLane for scalar VFs.
[VPlan] Only treat recipes as ephemeral if all defined values are. (#249290)
Only treat a recipe as ephemeral if all its defined values are only used
by ephemeral recipes. This fixes register usage computation and the
check whether a plan generates vectors for interleave groups with a
member only used by an assume.
[CodeGen] Remove unused members in MIRAddFSDiscriminatorsLegacy (NFC) (#249270)
This patch removes getMachineFunction and MF from
MIRAddFSDiscriminatorsLegacy. getMachineFunction has no callers, and
MF has no writers.
Assisted-by: Antigravity
[X86] Compute `CTLZ` using fp math for `v4i32` on SSE2 targets (#190930)
This PR implements optimization for the `ISD::CTLZ` and
`ISD::CTLZ_ZERO_POISON` for X86 SSE2 target.
This PR builds upon #167034
Closes #161746
Co-authored-by: NishiB137 <cs23btech11041 at iith.ac.in>
Co-authored-by: VindhyaP312 <cs23btech11044 at iith.ac.in>
Co-authored-by: Simon Pilgrim <llvm-dev at redking.me.uk>
[SampleProfile] Recover hot contexts rejected by indirect-call promotion (#243628)
A sample profile can record samples for an indirect-call target under
its caller, as if the compiler had inlined the target. If the compiler
leaves the target out of line, those samples belong in the target's
standalone profile. Leaving them under the caller makes the standalone
function appear colder than it is.
This patch recovers those samples in both sample-profile inliners:
- Priority inliner: A target can be hot in absolute terms but account
for too few calls at a site to qualify for promotion. Previously, the
loader stopped at the first target that failed the percentage check. It
now records that target and continues through the remaining hot targets.
It stops when the targets are no longer hot. Several rejected targets at
the same call can therefore recover their samples.
- Iterative inliner (line-based AutoFDO): When the compiler promotes and
inlines one target, an indirect fallback remains for the other targets.
A later scan can mistake the already-inlined target for one that still
needs recovery. Tracking only one target per call can also miss other
[19 lines not shown]
[Passes] Declare -enable-profcheck-in-pipeline and -use-ctx-profile in TableGen (#249267)
Move them into IROptions and AnalysisOptions with exported getters.
CtxProfAnalysis reads -use-ctx-profile in run() instead of its
constructor.
Renames, with the old spellings kept as aliases:
```
-enable-profcheck-in-pipeline -> -profcheck-in-pipeline
```
Co-authored-by: Alexis Engelke <mail at aengelke.net>
[RISCV] Replace some uses of SplatFPOp with a ComplexPattern. NFC (#249166)
SplatFPOp is a PatFrag that checks 2 different opcodes. Every time it is
used we create 2 isel patterns. Since all those patterns handle multiple
element types and LMULs, this quickly adds up.
Replace it with a ComplexPattern like we do for integer. This reduces
the isel table size by 9.3%.
Assisted-by: Claude
[AArch64]Duplicate the repeated lower half of 128-bit build vectors
A 128-bit build vector whose upper half repeats the lower half, e.g.
(a, b, a, b), was lowered with one lane insert per element. Build the
lower half once and concatenate it with itself. Undef upper lanes match
anything; an all-undef upper half is left to the insert sequence, where
it needs no copy.
Assisted-by: Cursor
Pull-request: https://github.com/llvm/llvm-project/pull/247230
Reviewers: davemgreen, huntergr-arm, john-brawn-arm, paulwalker-arm, sdesmalen-arm
Reviewed-by: sdesmalen-arm
[mlir][OpenACC] Fix assertion macro expansion (#248975)
ACC_COMPUTE_CONSTRUCT_AND_LOOP_OPS expands to a comma-separated type
list. On systems where assert forwards its expression to another macro,
the commas are parsed as separate macro arguments.
Wrap the isa expression in an extra parenthesized group so it is passed
as one macro argument.