[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
www/bozohttpd: Use blocklist
Starting from FreeBSD version 1500000, prefer the new blocklist
nomenclature.
Once older versions are no longer supported, we should use blocklist
exclusively.
PR: 294080
[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.
asmc: prefer MMIO backend over PIO when both are present
T2, T1, and some pre-T1 Macs advertise a legacy PIO
range in the SMC ACPI _CRS alongside a live MMIO window, but the
silicon behind the PIO range is bogus.
Try MMIO first, validate via LDKN >= 2, fall back to PIO if that
fails or no MMIO resource is present. Drop "(T2)" from the backend
message since MMIO isn't T2-exclusive.
MFC: 1 week
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D58839
[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]
testcases/libnvmm: Print more info and report total failures
* Print a few more details in the output logs.
* Run all tests to completeion and report the total number of failures
at the end.
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]