[libc++][NFC] Remove vector::__base_destruct_at_end (#217631)
We can just inline `__base_destruct_at_end` into `__destruct_at_end`.
The only other place where `__base_destruct_at_end` was used is
`clear()`, but that has basically the same code as `__destruct_at_end`,
so we can use `__destruct_at_end` instead.
[X86] LowerAVXCONCAT_VECTORS - fix some clang-format messiness. NFC. (#218504)
Bad indentation and missing braces
Pulled out of #218381 to simplify functional diff
[mlir][Tensor] Preserve correct rank expansions in InsertSlice canonicalizer (#217361)
Inferring the source type of an `insert_slice` with constant-folded
arguments "canonically", i.e. by dropping off unit dimensions from the
front of the constant-folded destination shape, is not guaranteed to
match the actual rank transformation of the original `insert_slice` op.
I've encountered this as a loop peeling bug, where materializing
constant slice sizes for the peeled iteration would create the following
sequence:
```
// Before fold
%12 = arith.constant 2 : index
%13 = arith.constant 2 : index // Materialized peel iteration sizes
...
%inserted_slice_13 = tensor.insert_slice %conv into %extracted_slice_9[0, 0, 0, 0] [1, %12, 1, %13] [1, 1, 1, 1] : tensor<1x?x?xf32> into tensor<1x?x1x?xf32>
%inserted_slice_14 = tensor.insert_slice %inserted_slice_13 into %arg13[0, 0, 0, 0] [1, %12, 1, %13] [1, 1, 1, 1] : tensor<1x?x1x?xf32> into tensor<1x?x1x?xf32>
// After a series of incorrect folds
%cast = tensor.cast %conv : tensor<1x2x2xf32> to tensor<1x?x2xf32>
[19 lines not shown]
[mlir][scf] Fuse parallel loops with equal constant bounds (#218450)
Two `scf.parallel` loops that run over the same range were not being
fused if
their bounds came from different `arith.constant` ops.
Both loops here go from 0 to 16 by 1, so they should fuse, but they do
not:
```mlir
%c0 = arith.constant 0 : index
%c16 = arith.constant 16 : index
%c1 = arith.constant 1 : index
scf.parallel (%i) = (%c0) to (%c16) step (%c1) { ... }
%c0_0 = arith.constant 0 : index
%c16_1 = arith.constant 16 : index
%c1_2 = arith.constant 1 : index
scf.parallel (%i) = (%c0_0) to (%c16_1) step (%c1_2) { ... }
[33 lines not shown]
[MLIR] fix: ValueBoundsConstraintSet invalidates queue (#218612)
populateConstraints(AffineMap, ValueDimList) updates positionToValueDim,
changing the meaning of all elements in the worklist. In order to
preserve the correct mapping, I've changed the element type to ValueDim.
The new lit tests show the example where the issue happened.
Assisted-by: Cursor / Grok 4.6
[AArch64][SDAG][NFC] Use CNTP intrinsic for compressstore lowering (#218353)
Currently, when lowering compressstore the process is to Zero Extend,
VECREDUCE_ADD and then Zero Extend the result for types that are not
i64. This for i8/i16 types does not work as AArch64 cannot zero extend
these types to i64. Instead, use the CNTP intrinsic to combine the
values before storing them.
[ConstraintElim] Avoid overflow when negating offsets (#218580)
This patch fixes a miscompilation in ConstraintElimination caused by
negating an INT64_MIN offset while constructing a constraint.
Use MulOverflow when negating the decomposed offset and skip constraint
construction if the negation overflows.
Fixes: #218569.
[CodeGen] Speed up instruction insertion with debug info (NFCI) (#218373)
Debug instructions don't have slot indexes, so no need to look them up
when searching for the nearest indexed instruction.
This avoids unnecessary lookups (that would all fail) in functions with
a lot of debug info.
[ORC] Harmonize the SimpleRemoteEPC hangup protocol (#218586)
A Hangup message now always carries a serialized Error saying why the
session is ending -- success for an orderly disconnect, otherwise the
reason -- encoded and decoded through shared helpers so the two ends of
the protocol cannot drift apart. SimpleRemoteEPC::disconnect sends one,
and SimpleRemoteEPCServer decodes the payload it previously discarded.
Both ends now also report an error when the transport disconnects
without either side having announced a hangup. Previously the executor
exited successfully whether the controller hung up or vanished, so a
crashed controller was indistinguishable from a clean run. The cause of
such a disconnection isn't knowable, so the error states what was
observed rather than attributing it.
This aligns SimpleRemoteEPC/SimpleRemoteEPCServer with upcoming ORC
runtime patches that will introduce a SimpleRemoteEPCServer-compatible
ControllerAccess implementation.
[X86] Fix NaN handling in minimumnum/maximumnum zero fixup (#217420)
Fix the X86 lowering of `minimumnum`/`maximumnum` when the first operand
is NaN and signed-zero handling is required.
`PSEUDO_FMIN`/`PSEUDO_FMAX` already select the numeric second operand
when the first operand is NaN. However, the subsequent signed-zero fixup can
modify that numeric result using the sign bit of the first operand.
For example, `minimumnum(-qNaN, +1.0)` can therefore turn the correctly
selected `+1.0` into `-1.0`.
Restore the second operand when the first operand is NaN after the
signed-zero fixup. The additional check is restricted to numeric min/max
operations where NaNs cannot be ignored and the first operand is not
already known to be non-NaN.
The existing handling for a NaN second operand remains unchanged.
[11 lines not shown]
[VPlan] Add tests for consecutive memory ops not widened in VPlan (NFC). (#218501)
Add VPlan printing tests for unit-stride consecutive accesses whose
address VPlan's SCEV construction cannot handle yet, so widening is left
to the legacy cost model.
[InstCombine] Add comment on multi-use for indexed compare fold (NFC) (#218434)
From the experiment in https://github.com/llvm/llvm-project/pull/151524,
restricting the fold to one-use does not appear to be beneficial in
practice. Leave a comment mentioning this.
[Clang] Mark indirect arguments as nofreeobj instead of nofree (#218404)
For indirect arguments, we know that the underlying object cannot be
freed during the execution of the function, through any pointer, not
just that specific pointer. As such, we can use the stronger nofreeobj
attribute. Unlike nofree, it is useful without noalias.
[Loads] Migrate isSafeToLoadUnconditionally() to SimplifyQuery (#218424)
isDereferenceablePointer() was changed to use SimplifyQuery some time
ago, do the same for isSafeToLoadUnconditionally().
[mlir] Build llvm.mlir.constant attributes from the result type
Many conversion patterns created `llvm.mlir.constant` with a value attribute
whose type does not match the result type. The most common case was pairing an
`index`-typed attribute with the converted index type:
llvm.mlir.constant(1 : index) : i64
but there were also plain width and signedness mismatches, e.g. NVGPU's
`makeI64Const` built `i64` constants from `i32` attributes, and the NVVM
`fdiv` expansion used `ui32` attributes on `i32` values.
Translation to LLVM IR ignores the attribute type and uses the result type, so
the emitted IR was correct, but the attribute type is meaningless in this state
and anything that reads it back sees the wrong type. Derive the attribute from
the result type in every case; where the result is the converted index type the
existing `createIndexAttrConstant` helper does this already, so use it. In
`ArithToLLVM`, retype the value attribute when the type converter maps `index`
to a different integer type, and fail the match rather than reinterpret a
[5 lines not shown]
[flang][CodeGen] Use a signless attribute for the addendum flag masks
The descriptor addendum flag masks were built as `ui8` attributes but attached
to `i8` constants:
llvm.mlir.constant(254 : ui8) : i8
The LLVM dialect only models signless integers, so the attribute type and the
result type disagree. Use the signless `i8` type for the attribute as well; the
bit patterns are unchanged, only their printed form is (`254 : ui8` becomes
`-2 : i8`).
Co-Authored-By: Claude Opus 5 (1M context) <noreply at anthropic.com>
[clang][HIP] Do not treat address of managed variable as a constant expression (#217047)
According to CUDA programming guide, the address of a __managed__
variable is not a constant expression, so it should not be accepted
where a constant expression is expected, i.e. NTTP, constexpr variable
initializers etc. Right now because addresses of managed variables are
assumed to be constexpr, crashes in clang's codegen happen during
replacement of uses of managed variables with loads from transformed
managed variables. It is not expected that a use of a managed variable
can be `llvm::ConstantExpr` which clang creates due to assumption that
address of a managed variable is a constant expression.
Fixes https://github.com/llvm/llvm-project/issues/198079
Assisted-by: claude in documentation writing
[PluginLoader] Drop legacy -load option from llc (#217860)
Loading of legacy Codegen pass plugins is the last remaining use-case
for the `-load` option in llc. We can drop it, if we switch the
respective test to `-load-pass-plugin`. We use the option only to load
the plugin shared-lib.
[X86] Remove TuningFastVariableCrossLaneShuffle from X86_64V4Tuning (#212178)
## 1. Background
This flag pushes the compiler toward a shuffle variant that pulls its
permutation pattern from memory, even when that pattern is a
compile-time constant that could just be baked straight into the
instruction. Skipping the load shows gains whenever the pattern is fixed
like that.
We propose dropping it from the `x86-64-v4` tuning list as both SPEC and
the microbenchmark below show a real improvement in runtime in both
Intel and AMD machines.
## 2. SPEC impact
We ran SPEC CPU2017 `base` tuning, `refrate`. No regressions observed in
any of the other benchmarks in the suite, and **noticable gains were
observed in 557.xz_r**
[137 lines not shown]
[MC] eatToEndOfStatement: eat trailing EOL with Lex() (#218590)
eatToEndOfStatement() advances the lexer with Lexer.Lex(), which neither
filters comment tokens nor pops the include stack at Eof. It therefore
leaves the token after the newline unfiltered, and leads to a spurious
error:
```
.extern foo
/* comment */
nop
error: unexpected token at start of statement
```
Fix with Lex(). Loosely take and clean up tests from #218456
RuntimeLibcalls: Stop providing __powitf2 on MSVCRT (#216987)
MSVCRT does not provide the powi helpers, so gate the fp128 __powitf2 on
isNotOSMSVCRT alongside the f32/f64 __powisf2/__powidf2, instead of
adding it unconditionally. The unconditional add was a hack to satisfy a test
that expected a wrongly-typed powi call on windows-msvc.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[libc++][ranges][enumerate_view] Fix sentinel converting constructor test (#217365)
Completes the `[range.enumerate.sentinel]` converting constructor test
by addressing the review comment
https://github.com/llvm/llvm-project/pull/73617#discussion_r1416643142
from the original implementation.
---------
Co-authored-by: Hristo Hristov <zingam at outlook.com>