[lldb] Gate debugserver tests on advertised qSupported features (#214768)
Tests that need a recent `debugserver` skipped themselves with
`@skipIfOutOfTreeDebugserver`, which asks whether the stub was built in
the tree
rather than whether it supports the feature under test. A system
`debugserver`
that already ships the feature was skipped anyway, and a stale in-tree
build was
not. Every year, we remove some `@skipIfOutOfTreeDebugserver` because
the new feature shipped in system `debugserver`.
Ask the stub instead. Tests get the supported features of stub, and
only run the test if stub advertises the very feature.
`TestConsecutiveWatchpoints` keeps the decorator, because it covers a
`debugserver`
bug fix that no capability describes and it also runs against
`lldb-server`.
[27 lines not shown]
[libomp] Fix hang when a fatal error is raised before library registration (#215988)
Uncovered by debug-build testing, not triggered for non-debug builds due
to absence of KMP_DEBUG_ASSERT.
Claude assisted with this patch.
CodeGen: Remove TargetOptions::FloatABIType
This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.
RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.
Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
CodeGen: Synthesize "float-abi" module flag from -float-abi
Avoid annoying test updates when the corresponding TargetOptions
field is removed. Make the -float-abi llc/opt option a lit test
convenience that records the floating-point ABI in the IR,
mirroring how -mcpu/-mattr are recorded as function attributes.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[DAGCombine][AArch64][X86] Adjust profitability check on and(anyext, c) -> zext(and) transform (#214749)
This existing fold was using a profitability check that did not work for
vector operations. It can be profitable to fold (and (anyext V), c) ->
(zext (and V, c)) if it allows the And to work on a narrower type and
possibly for the zext to be folded into other operations.
The combine is profitable or equal if the zext is the same cost as a
anyext. The old isTruncFree was removed as the value being truncated is
a constant. A basic version of isNarrowingProfitable is added for
AArch64 to allow vector types to fold providing that the result type is
legal and a isAnyExtFree method is added for the anyext cost.
RISCV: Fix optimizeCondBranch crash on an undef register (#216633)
Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[X86][CostModel] Free a clean narrow zext used as a GEP index (#216256)
`getCastInstrCost` already treats a narrow (i8/i16) zext of a load as
free (the extension folds into the load). This extends the same
movzx-free reasoning to any narrow zext whose single use is a **GEP
index** with a provably-clean source — a load, a `zeroext` argument, or
known-zero high bits. On x86-64 `[base + index*scale + disp]` reads the
index at full width, so a clean narrow index needs no `movzx`. A dirty
source (e.g. an `i16 add` used only as an index) still needs one and is
unchanged. The cost is consumed by SimplifyCFG's two-entry-PHI fold
budget (`TCK_SizeAndLatency`); overcharging a clean index by one kept
small select diamonds branched on x86.
Test: `llvm/test/Analysis/CostModel/X86/zext-gep-index.ll` — fails on
trunk
(clean known-bits index reports 1), passes with the patch.
---------
Co-authored-by: Cursor <cursoragent at cursor.com>
[RISCV] Move -mtune=native expansion into riscv::getRISCVTuneCPU. NFC (#215891)
Previously it was applied at one of the call sites. Applying it inside
makes it more clear how it is supposed to interact with
-mexperimental-mtune-syntax
[ORC] Extend SymbolLookupSet unit test coverage (#216617)
Covers the rest of the public API: construction, add/append, remove,
remove_if, forEachWithRemoval, getSymbolNames, sortByName, sortByAddress
and containsDuplicates.
[TableGen] Add checks for CheckRegOperand/CheckImmOperand (#215230)
`CheckRegOperand`, `CheckImmOperand`, and their related predicates
currently call `getReg()` and `getImm()` without first verifying that
the operand is a register or an immediate. Users must explicitly use
`CheckIsRegOperand` and `CheckIsImmOperand` to avoid errors for other
operand kinds, as exposed by #213815.
This PR adds default `isReg()` and `isImm()` checks to those predicates
before accessing the corresponding values, and also removes redundant
`CheckIsRegOperand` and `CheckIsImmOperand` checks from existing users
in the X86, ARM, and RISCV backends.
RISCV: Fix optimizeCondBranch crash on an undef register
Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[MLIR][CAPI][Python] Add support for querying memory effect instances (#213459)
The current memory-effect bindings are write-only. Python interface
implementations can append effects to a temporary
`MemoryEffectInstancesList`, but callers cannot inspect an effect
instance or ask an operation for its effects.
This patch adds the missing query support to the C API and exposes it in
Python. Effect instances can be inspected and copied, and the Python
APIs use regular `MemoryEffectInstance` objects and Python-native
`list`s. The Transform helpers follow the same model.
`MemoryEffectInstancesList` is **removed** from both the C and Python
APIs. Python implementations and helpers now return effects instead of
mutating a supplied list, while the C API passes effects through
callbacks (`MlirMemoryEffectInstancesCallback`).
When an API produces a batch of effects, it invokes
`MlirMemoryEffectInstancesCallback` with a count and an array. The
[15 lines not shown]
[dyndbg][Clang] Avoid memcpy on nullptr from #216307 (#216625)
As reported in
https://github.com/llvm/llvm-project/pull/216307#issuecomment-5311023374,
the new tests fail on UBSan buildbots (e.g.,
https://lab.llvm.org/buildbot/#/builders/25/builds/19323) because the
directory may be empty (only the file is initialized [*]). The StringRef
from getDirectory() would be default-initialized, and hashing it results
in memcpy'ing from a null pointer.
This patch attempts to fix-forward by not hashing the output of
getDirectory() if it is empty.
[*] e.g., `!3 = !DIFile(filename:
"/usr/local/google/home/thurston/llvm-projectA/clang/test/DebugInfo/DynamicDebugging/<stdin>",
directory: "")`
CodeGen: Fix MachineSink trivial coalescing crash on an undef register
Fix unchecked getVRegDef use. Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[ADT] Clean up FoldingSet.* (NFC) (#216619)
This patch cleans up minor issues in FoldingSet.*.
- FoldingSetBase::NodeID never existed in the history of FoldingSet.
The comment should refer to FoldingSetNodeID instead.
- GetBucketPtr lost the first line of its doc comment on February 4,
2008 in commit e2887863563f, leaving only "testing.".
- ImmutableSetTest.cpp was relying on FoldingSet.h to include
ArrayRef.h.
Other changes should be self-explanatory.
Assisted-by: Antigravity
[CIR] Correct union lowering behavior re-padding (#216349)
Most of the code that CIR lowers to LLVM counts on the fact that our
alignnments are correct/calculated in LLVM to get our layout correctly.
This works for the most part, and unions have the storage type of the
'highest' alignment type.
However, when creating a constant, we have to convert the type of the
union to have a 'storage' type that matches the data being inserted (not
the union's storage type!). The result was that if we had a storage type
where the alignment was smaller than the actual storage type, LLVM would
mis-calculate the padding.
This patch adds the padding explicitly when we make that conversion to
get the alignment set up correctly.
Note: there is one mild IR-equivilency-regression to this patch. There
isn't really a great way to tell the difference between a
union-tail-padding needing zero-init vs undef-init in this case. This
[2 lines not shown]
[CIR] Fix the 'constant'-ness of vtable-variables (#216434)
The createOrReplaceCXXRuntimeVariable sets the variable to be 'constant'
in classic codegen, this sets that right. However, 1 use of it (in
buildVTablePointer) doesn't match classic-codegen (it instead calls
getOrInsertGlobal directly), so this patch adds a bit of a fixup there
to minimize the impact of this change.
[mlir] Fix RemoveDeadRegionBranchOpSuccessorInputs producing invalid scf.for
RemoveDeadRegionBranchOpSuccessorInputs builds its tied-value sets from
RegionBranchOpInterface::getSuccessorOperandInputMapping, which is derived from
getSuccessorRegions. For an scf.for with a statically-known trip count of 1,
getSuccessorRegions drops the region->region back edge (the loop provably never
iterates back). That back edge is what forwards a yield operand to the region
iter_args, so without it an iter_arg and its corresponding op result are no
longer tied through a shared operand. The pattern then removes a dead iter_arg
without its (structurally required) result, producing an scf.for with
mismatched loop-carried counts:
'scf.for' op mismatch in number of loop-carried values and defined values
The greedy driver repairs this on a later iteration (InlineRegionBranchOp folds
the single-trip loop), so it is only observed with
MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS, which verifies the IR after every
pattern application. It shows up across Linalg tiling / pack-unpack /
convolution lowering and scf loop canonicalization; see issue #163599.
[15 lines not shown]
RuntimeLibcalls: Provide fp128 long double libcalls on X86
16a8d8d038a3 removed the l-suffixed long double math functions
from the default set and re-added them per-target gated on
isLongDoubleF128, but X86 was not given the re-add. On targets
whose long double is fp128 (e.g. x86_64 Android/OHOS) this dropped
the fp128 l-suffixed libcalls.
Fixes the regression reported on #214944.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[mlir] Fix RemoveDeadRegionBranchOpSuccessorInputs producing invalid scf.for
RemoveDeadRegionBranchOpSuccessorInputs builds its tied-value sets from
RegionBranchOpInterface::getSuccessorOperandInputMapping, which is derived from
getSuccessorRegions. For an scf.for with a statically-known trip count of 1,
getSuccessorRegions drops the region->region back edge (the loop provably never
iterates back). That back edge is what forwards a yield operand to the region
iter_args, so without it an iter_arg and its corresponding op result are no
longer tied through a shared operand. The pattern then removes a dead iter_arg
without its (structurally required) result, producing an scf.for with
mismatched loop-carried counts:
'scf.for' op mismatch in number of loop-carried values and defined values
The greedy driver repairs this on a later iteration, so it is only observed
with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS (which verifies the IR after
every pattern application). It shows up across Linalg tiling / pack-unpack /
convolution lowering and scf loop canonicalization; see issue #163599.
[6 lines not shown]
PowerPC: Fix FMA reassociation crash on an undef multiply operand (#216602)
Make sure getVRegDef succeeded.
Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>