[CIR] Lower constant vectors with undef, poison and zero elements
The `cir::ConstVectorAttr` verifier only checks the element types, so
`#cir.undef`, `#cir.poison` and `#cir.zero` are valid elements, and
`VecShuffleOp::fold` created an undef element for a -1 index. The
lowering to the LLVM dialect handled int, float and bool elements and
hit an `llvm_unreachable` on anything else, so a
`__builtin_shufflevector` of two constant vectors with a -1 index
crashed `-fclangir -emit-llvm`.
A zero element is now a zero in the dense constant. An undef or poison
element also takes a zero there and is then replaced by an
`llvm.insertelement` of `llvm.mlir.undef` or `llvm.mlir.poison`.
`llvm.mlir.constant` cannot hold such an element itself: a dense
elements attribute holds only literals, and the translation to LLVM IR
accepts a per-element `LLVM::UndefAttr` or `LLVM::ZeroAttr` only in
struct and array constants and no `LLVM::PoisonAttr` at all. The
IRBuilder folds the insertions when the module is translated, in
function bodies and in global initializers, so the LLVM IR holds one
[10 lines not shown]
[DAGCombiner] Fix splat(bitcast(build_vector)) crash for expanded integers (#245005)
When combining `splat(bitcast(build_vector))` into `build_vector`,
`getTypeToTransformTo` may return an expanded type for `SVT`. Using this
type as the `build_vector` operand type crashes, as `build_vector`
requires the operand bit width to be no smaller than the result scalar
type.
Fix by using `SVT` as the operand type.
Fixes: https://github.com/llvm/llvm-project/issues/244519
Assisted-by: Claude Opus 5.5 <noreply at anthropic.com>
[VPlan] Fix use-before-def in transformToPartialReduction (#247583)
transformToPartialReduction was inserting the partial reduction at the
widen recipe, but in the test case added the widen recipe (%add) is
defined before Link.Blend's mask (%c) and hit a use-before-def
assertion. simplifyCFG can sometimes produce CFGs that trigger this.
This fixes it by creating the partial reduction before the blend
instead.
[clang][NFC] Remove ASTContext::Types (#246322)
ASTContext kept a vector of every Type it created, 8 bytes per type plus
growth slack: 1.5M types and a 16 MB buffer on SemaExpr.cpp. It was only
used by -print-stats, the typo-correction scan for classes that can name
a nested-name-specifier, UncheckedStatusOrAccessModel::findStatusType,
and one unit test.
-print-stats now uses per-type-class counters. Both other users only
look at types whose canonical type is a record, and each such type is
created after its canonical RecordType or InjectedClassNameType, so they
now walk a vector of only those (in the same creation order), which
gives the same results. The unit test finds its function types through
the declarations instead.
On some LLVM TUs (GVN, LiveVariables, RegionStore, SemaExpr) this
shrinks the vector from 8/8/16/16 MB to 0.25/0.5/0.5/1 MB of capacity.
The -print-stats output, typo-correction diagnostics, and analyzer
statistics and diagnostics are unchanged.
[3 lines not shown]
[CIR] Fix crashes in the complex constant folders
The folders of `cir.complex.real`, `cir.complex.imag` and
`cir.complex.create` asserted on constants that the `cir.const` verifier
accepts.
`cir.complex.real` and `cir.complex.imag` cast a constant operand to
`#cir.const_complex`. A complex constant can also be `#cir.zero`,
`#cir.undef` or `#cir.poison`. CIRGen emits `#cir.zero` for a
value-initialized complex, so clang crashed on `__real__ CI()`. A part
of `#cir.zero` now folds to the zero of the element type. A part of
`#cir.undef` or `#cir.poison` folds to undef or poison, as the cast
folder does for its operand.
`cir.complex.create` built a `#cir.const_complex` from any two constant
parts. The attribute holds int or float literals only, so its verifier
failed on a part that is undef, poison or a global view. The folder now
leaves such a create alone.
[5 lines not shown]
[C23][Clang] Claim conformance to WG14 Issue 1025 (#247291)
The crux of this issue is that standard library types cannot be
variably-modified types nor can they be qualified types. Note, it's
still okay to have 'const int *' as a standard library type because the
qualification is not top-level. 'int * const' is an example of a
problematic type.
This only tests the standard library headers which Clang vends in
freestanding mode because the runtime standard library is responsible
for testing this requirement more generally for the library itself.
[RISCV] [SelectionDAG] Improve negative absolute difference expansion (#233222)
Form ABD nodes before expanding negated ABS expressions and avoid
expanding scalar ABD through ABS when ABS is not legal or custom.This
builds on #239859 and covers the remaining RV64 cases. Preserve
efficient Zbb sequences and avoid the PPC regression and unnecessary
narrowing around negation.
Fix Active Directory integration tests
- Re-enable with the full configuration in set_ds_config(). An update
that enables directory services must include service_type, so
{'enable': True} failed validation.
- Raise the idmap test timeout to 600s. A test that changes and then
restores idmap settings rebuilds the user and group cache twice, about
100s each on the test domain, and the first test also pays for the
module's join.
- Expect the TrueNAS issuer in the 2FA provisioning URI.
- Delete the privilege that the join grants to domain admins before
checking that the account cannot create an API key. The test account
is a domain admin, so the check passed only when the grant failed.
[mlir][tblgen] Add `cppNamespace` to passes
The code generated by `-gen-pass-decls` has no notion of a namespace
and is placed wherever the generated file is included, which in
practice is always inside a namespace. The generator can therefore not
emit anything that has to live at global scope, such as includes or
forward declarations.
Add a `cppNamespace` field to `PassBase`, similar to the one of
dialects. Passes that set it place their generated code in that
namespace themselves, and the generated file must then be included at
global scope. The group registration is placed in the innermost
namespace enclosing the namespaces of all passes of the group, if any.
Passes without a namespace behave as before.
This makes namespace handling of passes also consistent with the rest
the of MLIR.
Co-authored-by: Claude <noreply at anthropic.com>
[CIR][OpenMP] Emit single region cleanups before the terminator (#247650)
A local in a `single` body broke CIR verification at -O2 because its
cleanups were popped after `omp.terminator`
Discussed as a part of https://github.com/llvm/llvm-project/pull/247263
[X86] Emit the import call optimization table in a deterministic order
X86AsmPrinter kept the import call sites per section in a DenseMap keyed
by MCSection pointers and emitted the .retplne table by iterating it, so
the order of the sections in the table depended on pointer values and
changed between runs. Use a MapVector, like AArch64AsmPrinter does.
Compile time and memory are unchanged on a module with 10000 such
sections.
The table checks in win-import-call-optimization.ll had no colons, so
FileCheck ignored them, and their call kinds were out of date. Fix both.
Assisted-by: Claude Code (Claude Opus 5.5)
[CIR][AMDGPU] Add support for __builtin_amdgcn_alignbit (#242166)
Lower the builtin to cir.fshr (and then llvm.fshr), matching classic
CodeGen. Fixes part of #241525.
[Attributor] Do not copy large value sets in `AAPotentialValues`
`AAPotentialValuesImpl::recurseForValue` copies all values of another position
into the state. For example, if a callee returns one of its arguments, the call
result takes the values of the call site operand. In a chain of calls where each
call gets the result of the previous call, each call result then has one more
value than the previous one. A call result also sees the new values of the
previous call only in the next fixpoint iteration, so a chain of N calls needs N
iterations, and a long chain hits the iteration limit.
In this PR, we just limit the number of values to copy to 7, and use the value
of the position itself otherwise. 7 is a magic number here, but it is sufficient
for most cases (telling from the fact that no existing test is affected by this
change).
This PR was assisted by AI but I reviewed all the changes.
[Attributor] Use call site values when the callee returns an argument (#246890)
`AAPotentialValuesCallSiteReturned` takes the interprocedural values of
a call from the interprocedural return values of the callee. If the
callee returns one of its arguments, these values contain the arguments
of all call sites, so each call result also gets the values passed at
all other call sites. This is not necessary. If the callee has many call
sites and the call results are passed to other calls, the value sets
also become very large.
If the callee returns only its arguments and constants, we just need to
translate these values to the call site for the interprocedural scope.
This PR was assisted by AI but I reviewed all the changes.
fixup! [AArch64] Support direct RCPC3 FP atomic loads and stores
Continue to cast fp stores to integer stores where the value to store is
a compile time positive zero constant. This results in a better codegen
because of existence of a dedicated zero register in GPR bank which is
not available in FPR bank.
[AMDGPU] Fix gfx950/gfx942 TRANS co-execute slot
On gfx950/gfx942, fix TRANS co-exec slot to be same as VALU.
Excluded from this commit:
TRANS on gfx950 (in unit of hardware cycle):
Reciprocal throughput (per SIMD):
f32/f16: 8
f64: 16
Def-to-use latency:
f32/f16: 12 to a non-TRANS reader, 8 to a TRANS reader
f64: 20 to a non-TRANS reader, 16 to a TRANS reader
Blocks this wave's issue for:
f32/f16: 8
f64: 16
On gfx942, f32/f16 have the same numbers as f64 above.
Currently, GCNHazardRecognizer inserts the correct s_nop between a TRANS
[4 lines not shown]
[AMDGPU] Precommit TRANS co-exec tests (NFC)
Add a gfx950 coexec scheduler case where a v_exp_f32 and a v_add_f32
compete for the window of an XDL2x (v_mfma_f32_16x16x32_bf16) MFMA.
No MFMA row allows TRANS so far, so the v_exp_f32 issues after the
MFMA window.
Assisted-by: Claude Opus 5.5
[CIR] Handle integers wider than 64 bits in the vector constant folders
`cir::IntAttr::getUInt()` and `getSInt()` assert when the value needs
more than 64 bits. The folders of `cir.vec.cmp`, `cir.vec.ternary` and
`cir.vec.shuffle.dynamic` read constant elements through them, so they
asserted on a vector of `__int128` with such an element. C++ reaches
all three at -O0. The verifier of `cir.vec.shuffle` read its indices the
same way and asserted while parsing an index wider than 64 bits.
They now work on the `APInt` values:
- `cir.vec.cmp` compares the elements at their full width.
- `cir.vec.ternary` tests whether the condition element is zero.
- `cir.vec.shuffle.dynamic` masks the index before narrowing it.
- The `cir.vec.shuffle` verifier recognizes the -1 index by all of its
bits being set and range-checks the other indices without narrowing
them.
Folds of integers up to 64 bits are unchanged.
[2 lines not shown]
linuxulator/powerpc: fix the argument order of clone()
PowerPC passes tls before child_tidptr. New threads got a pointer to their
TID as thread pointer.
While here make linux_set_upcall() return 0 to the child instead of
copying r1 to r0.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62272