[SLP]Check emitted split vector in gather reuse
Cached last inst of split node predates its operand vectors, so a
gather could reuse a split vector emitted after it.
Fixes #241491
Pull-request: https://github.com/llvm/llvm-project/pull/241578
Attributor: Check for a fixpoint state with a single virtual call
Checking whether an abstract attribute is at a fixpoint took two virtual
calls, getState and isAtFixpoint. Add isStateAtFixpoint, which
StateWrapper implements with a direct call, and use it in the fixpoint
iteration.
attributor-light instruction counts (callgrind): -0.62% median over 68
llvm-test-suite TUs, the full attributor -0.70%.
Co-authored-by: Johannes Doerfert <jdoerfert.llvm at gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[ThinLTO] Attach GUID to pre-existing declarations of imported declarations (#241395)
When a function is imported as a declaration, FunctionImporter creates
the declaration by hand and records the original GUID of the function as
!guid metadata, so that it can be located by GUID even if it was a
promoted local whose name no longer hashes to its GUID (e.g. by MemProf
ICP for cloning). However, if a declaration with that name already
existed in the destination module, the import was skipped entirely.
That declaration may have been created by the IRMover as a side effect
of linking an imported definition that references the function, e.g. a
vtable or a method table whose initializer references it. In that case
the declaration does not carry the original GUID, and MemProf's ThinLTO
backend cannot match the thin link's synthesized callsite record for an
indirect tail call to the promoted local target. The backend then does
not create the expected clone of the caller, while the callers of the
caller were already redirected to the clone by the thin link, resulting
in an undefined .memprof.N symbol at link time.
[3 lines not shown]
[clang][MS ABI] Use image-relative throw info on 32-bit Arm (#240571)
MSVC's runtime reads the throw information (ThrowInfo, CatchableTypeArray and
CatchableType) as offsets from the image base on every target but 32-bit x86,
and _CxxThrowException looks up the image base from the ThrowInfo. clang wrote
these tables with absolute pointers on 32-bit Arm, so a throw crashed in the
runtime there. Make them image-relative on Arm, as on 64-bit targets.
The RTTI stays absolute, as on MSVC.
Assisted-by: Claude Opus 5.5 (Anthropic)
[SLP]Fix crash on MinBW cast of callbr/invoke result vector
A demoted no-op cast node may reuse a callbr/invoke result as its
vector, and the cast for external insertelement users was then
inserted after a terminator. Insert it at the def's insertion point
(normal dest for invoke) or in the scalars' block for callbr. Reuse
a cached cast only where it dominates the user.
Fixes #241488
Pull-request: https://github.com/llvm/llvm-project/pull/241563
[VPlan] Don't narrow recipes without underlying instr to single scalars. (#241546)
narrowToSingleScalarRecipes creates the single-scalar replacement from
the underlying instruction of the recipe. Recipes created by VPlan
transforms may not have one. Skip such recipes, like
legalizeAndOptimizeInductions already does.
Fixes https://github.com/llvm/llvm-project/issues/241474
[VPlan] Compute cost of FNeg, Freeze and BitCast natively. (NFC) (#241489)
Compute the cost of replicated FNeg and Freeze recipes using
getCostForRecipeWithOpcode, like for the other unary and binary
operations, and the cost of replicated BitCast recipes like for the
other casts, instead of falling back to the legacy cost model.
Replicated recipes with these opcodes currently either have their costs
pre-computed by the legacy cost model or are single scalars with
matching costs, so no test changes.
[bazel][lldb] Run lldb Shell tests that build with clang (#240988)
Follow up to #238182. Let the Shell tests build inferiors with %clang,
%clang_host and %build, and run the ones that don't also need %lldb:
BuildScript, Expr/TestIRMemoryMap.test, two Breakpoint tests and 49 more
SymbolFile tests.
//clang finds its builtin headers relative to its resolved path in
bazel-out, but bazel stages them in clang/staging, so anything that
includes a header like stddef.h fails. lit_tools/clang is now a script
that runs //clang with -resource-dir pointing there. build.py also looks
for clang++ and clang-cl in the tools directory and otherwise falls back
to the host gcc, so add scripts with those names as well; exec -a keeps
the name, which selects clang's driver mode. Inferiors use the host's
libc and C++ standard library, as they do in CMake builds.
lit_data gains llvm-dwarfdump, which one of the SymbolFile tests uses.
The comments on the tests that are still excluded now only mention
%lldb.
[lldb-dap][ext] Use public npm registry in package-lock.json (#241559)
57f05c5ee419 (#240863) resolved yargs from an internal registry mirror,
which breaks `npm install` in the llvm/vscode-lldb CI.
[mlir][GPUToSPIRV] Preserve signed integer MMA accumulation (#241347)
gpu.subgroup_mma_compute encodes integer A/B signedness in their
component types, but uses a signless i32 accumulator with signed
semantics. Checking only isSigned() therefore omitted CSigned and
ResultSigned when lowering integer MMA operations.
OpCooperativeMatrixMulAddKHR interprets integer components as unsigned
unless the corresponding SignedComponentsKHR operand flag is present.
Treat signed and signless integer components as signed when selecting
these flags, while leaving explicitly unsigned and floating-point
components unflagged.
Update the signed i8 test to require CSigned and ResultSigned, and add
coverage for unsigned i8 inputs with a signed accumulator. Tighten the
floating-point check so unexpected signedness flags cannot match.
Assisted-by: Codex
[libc] Fix GCC allocation diagnostics and sized delete[] (#241533)
AllocChecker's operator new overloads inline malloc and aligned_alloc
while C++ forbids marking replaceable operator delete inline, causing
GCC 11+ to emit false-positive -Wmismatched-new-delete warnings at
delete sites. Hermetic tests compiled with GCC also trigger
-Wsized-deallocation and exception-specification errors in
HermeticTestUtils.cpp.
Pass -Wno-mismatched-new-delete on GCC 11+ in libc and test compile
options so AllocChecker preserves full malloc alias provenance without
inline-assembly barriers, while Clang continues checking new/delete
pairing. Mark placement operator new and all operator delete overloads
noexcept across CPP/new.h and HermeticTestUtils.cpp while adding the
missing aligned operator new and sized/aligned operator delete[]
definitions. Also align alloc_checker's direct includes with its CMake
and Bazel target dependencies.
[2 lines not shown]
DAG: Remove special case ldexp libcall recognition (#241467)
InstCombine now turns the eligible cases into the intrinsic.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[LLDB] Guard Process::m_instrumentation_runtimes with a mutex
This patch is the sixth part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
`Process::m_instrumentation_runtimes` can be accessed from multiple
threads. For example, a plugin can be enabled/disabled in a process
from the command thread (or from another debugger when using the
`global` domain) while `Process::ModulesDidLoad()` iterates over the
plugins on another thread, or while an SB API client calls
`Process::GetInstrumentationRuntime()`. These accesses were
unsynchronized.
Now every access to `m_instrumentation_runtimes` is guarded by the new
`m_instrumentation_runtimes_mutex`:
* `Process::Finalize()` and `Process::DidExec()` clear the map while
holding the mutex.
[13 lines not shown]
[LLDB] Keep InstrumentationRuntime plugins alive during breakpoint callbacks
This patch is the fifth part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
InstrumentationRuntime plugins passed a raw `this` pointer as the baton
for their breakpoint callbacks. Now that disabling a plugin in a process
destroys the plugin instance, a plugin could be destroyed (e.g. by
`plugin disable` running on the command thread) while one of its
breakpoint callbacks was running on another thread (e.g. the thread
handling the stop event), causing a use-after-free.
Try to partially fix this by keeping a plugin alive while the baton is being
used. Now the plugins use a baton created by
`InstrumentationRuntime::CreateBreakpointBaton()` which only holds a weak
reference to the plugin. In a callback,
`InstrumentationRuntime::GetRuntimeFromBaton()` gets a strong reference to the
plugin which keeps the plugin alive until the callback finishes. If the plugin
[13 lines not shown]
[LLDB] Support enabling/disabling InstrumentationRuntime plugins in a debug session
This patch is the fourth part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
This is a rework of an older now abandoned patch:
https://github.com/llvm/llvm-project/pull/193334
Previously enabling/disabling an instrumentation runtime plugin via the
`plugin enable/disable instrumentation-runtime.<name>` command was only
supported using the `global` domain. This only toggled the plugin's
enablement state in the PluginManager. This would affect the enablement
in newly launched processes but not in any existing processes. In
practice what this meant is that:
1. If the plugin was activated when the inferior process was launched it
could not be disabled even if requested. This meant it was impossible
to prevent LLDB from stopping at the breakpoint set by an
[106 lines not shown]
[LLDB] Guard Process::m_instrumentation_runtimes with a mutex
This patch is the sixth part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
`Process::m_instrumentation_runtimes` can be accessed from multiple
threads. For example, a plugin can be enabled/disabled in a process
from the command thread (or from another debugger when using the
`global` domain) while `Process::ModulesDidLoad()` iterates over the
plugins on another thread, or while an SB API client calls
`Process::GetInstrumentationRuntime()`. These accesses were
unsynchronized.
Now every access to `m_instrumentation_runtimes` is guarded by the new
`m_instrumentation_runtimes_mutex`:
* `Process::Finalize()` and `Process::DidExec()` clear the map while
holding the mutex.
[13 lines not shown]
[LLDB] Keep InstrumentationRuntime plugins alive during breakpoint callbacks
This patch is the fifth part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
InstrumentationRuntime plugins passed a raw `this` pointer as the baton
for their breakpoint callbacks. Now that disabling a plugin in a process
destroys the plugin instance, a plugin could be destroyed (e.g. by
`plugin disable` running on the command thread) while one of its
breakpoint callbacks was running on another thread (e.g. the thread
handling the stop event), causing a use-after-free.
Try to partially fix this by keeping a plugin alive while the baton is being
used. Now the plugins use a baton created by
`InstrumentationRuntime::CreateBreakpointBaton()` which only holds a weak
reference to the plugin. In a callback,
`InstrumentationRuntime::GetRuntimeFromBaton()` gets a strong reference to the
plugin which keeps the plugin alive until the callback finishes. If the plugin
[13 lines not shown]
[LLDB] Support enabling/disabling InstrumentationRuntime plugins in a debug session
This patch is the fourth part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
This is a rework of an older now abandoned patch:
https://github.com/llvm/llvm-project/pull/193334
Previously enabling/disabling an instrumentation runtime plugin via the
`plugin enable/disable instrumentation-runtime.<name>` command was only
supported using the `global` domain. This only toggled the plugin's
enablement state in the PluginManager. This would affect the enablement
in newly launched processes but not in any existing processes. In
practice what this meant is that:
1. If the plugin was activated when the inferior process was launched it
could not be disabled even if requested. This meant it was impossible
to prevent LLDB from stopping at the breakpoint set by an
[106 lines not shown]
[NFC][LLDB] Add Debugger::Debuggers() locking iterable (#238463)
This patch is the third part in a patch series that will allow
enabling/disabling InstrumentationRuntime plugins in a running debug
session.
This patch adds a `Debugger::Debuggers()` static method that returns a
`LockingAdaptedIterable` over the global debugger list. This follows the
existing pattern used by other LLDB collections (e.g.
`TargetList::Targets()`).
Assisted-by: Claude Code
[Hexagon] Add HLX driver checks, intrinsic header and Sema diagnostics (#241435)
- Driver: report an error for -mhlx and -mno-hlx on CPUs older than v85,
which do not have HLX (they enabled the HLX feature and defined the
__HLX__ macros), and pass -mhlx to the assembler when HLX is enabled and
the integrated assembler is not used.
- Headers: add hlx_hexagon_protos.h with the Q6_* macros for the V85 HLX
builtins, include it from hexagon_protos.h when HLX is enabled, and
define the HLX_Vector and HLX_VectorPair types in hexagon_types.h.
- Sema: HLX vectors can only be local variables, and there are no
instructions for element access or vector pair loads and stores. When
HLX is enabled, reject global, static and variable sized objects of HLX
types, struct, union and class members of HLX types, subscripts of HLX
vectors, and dereferences of HLX_VectorPair pointers.
Co-authored-by: Adarsha Regmi <aregmi at qti.qualcomm.com>
Co-authored-by: Alexey Karyakin <akaryaki at qti.qualcomm.com>
Co-authored-by: Ankit Aggarwal <aankit at qti.qualcomm.com>
Co-authored-by: Ikhlas Ajbar <iajbar at qti.qualcomm.com>
[10 lines not shown]
[CodeGen] Stop claiming setPreservesAll() in BasicBlockPathCloning (#241026)
BasicBlockPathCloning clones basic blocks and redirects CFG edges, which
invalidates Machine-CFG analyses (such as MachineDominatorTree,
MachineLoopInfo, and MachineBlockFrequencyInfo). Drop
AU.setPreservesAll() and explicitly preserve only MachineBlockHashInfo
(which intentionally records pre-cloning block hashes for downstream
matching and BB-hash emission, though support for
MachineBasicBlockMatchingAndInference with cloning is not ready yet),
relying on MachineFunctionPass::getAnalysisUsage() for MachineModuleInfo
and IR analyses.
[SLP]Clear analysis cache when the replaced scalars are erased
The horizontal reduction and the packed aggregate paths rewrite the IR
outside of the tree vectorization, but the cached pointer distances were
dropped only after the tree vectorization. A reduction folding a GEP
index left a stale failed distance for one pointer order while the other
order succeeded, and the external store users reordering dereferenced it.
Fixes #241484
Pull-request: https://github.com/llvm/llvm-project/pull/241547
[ThinLTO] Add CFI function lists to the textual summary format (#240966)
Print and parse the names of the functions with CFI jump table entries
recorded in a combined summary index (cfiFunctionDefs and
cfiFunctionDecls), along with the GUIDs that ThinLTO uses for them, as
summary entries:
^N = cfiFunctionDefs: ((guid: G, name: "f"), ...)
^N = cfiFunctionDecls: ((guid: G, name: "g"), ...)
These follow the typeidCompatibleVTable entries and precede the flags
and blockcount entries, so the assembler and disassembler round trip a
combined index written by the thin link, and tests can describe a
distributed ThinLTO index for a module built with CFI (which
LowerTypeTests and other backend passes consult) without running a thin
link.
Assisted-by: Gemini
[ThinLTO] Support importing of indirect call target declarations (#241431)
Add support for importing declarations of all indirect call targets with
a hotness at least as high as that specified in the (default hot)
-import-declaration-for-indirect-calls-min-hotness, when the definition
is not being imported. This will facilitate more ICP when enabling
-icp-allow-decls.
Assisted-by: Gemini