[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>
trust: fix server certificate purpose detection (#10785)
The current check requires digitalSignature together with either
keyEncipherment or keyAgreement. This rejects valid ECDSA server
certificates that only use digitalSignature.
RFC 5280 section 4.2.1.12 lists these key usage bits as alternatives
consistent with serverAuth. Accept any compatible bit, or an absent key
usage extension, and apply the same logic in Store.php and certs.inc.
[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>
[BOLT][RISCV] Add target symbolizer for relocations (#217944)
Depends on #217550, which adds RISC-V disassembler symbolization hooks
for `UImm20` and `SImm12Lo` operands.
BOLT currently reconstructs RISC-V relocation-backed operands in
`BinaryFunction::disassemble()` after the instruction has been decoded.
This places RISC-V-specific relocation handling in target-independent
code and makes it difficult to correctly associate `%pcrel_lo`
relocations with their corresponding `%pcrel_hi` instructions after code
movement.
This change adds a target-specific `RISCVMCSymbolizer` and installs it
through `RISCVMCPlusBuilder`. Relocation-backed `MCExpr` operands are
now created directly while instructions are being decoded.
[LoongArch] Add memory barrier optimization pass
Add a machine-level pass to remove redundant DBARs and merge them
with atomic memory operations. The pass uses machine dominator and
post-dominator trees to ensure the transformation is safe across
basic blocks.
[AMDGPU] Combine redundant ballot intrinsic calls (#218357)
Suppose there is a loop where there is a call to @llvm.amdgcn.ballot,
which maps to an instruction involving the exec mask as an operand. This
instruction duplicates if the loop is unrolled. With a higher number of
unrolled iterations, the code bloats with such redundant instructions
with $exec as there is no middle-end/backend pass which could combine
such instructions in a uniform CFG.
This patch introduces a transform in AMDGPUUniformIntrinsicCombine to
combine redundant calls to @llvm.amdgcn.ballot, to mitigate this issue.
The approach is to walk over the dominator tree and collect all calls to
@llvm.amdgcn.ballot. Map the result type and condition to the calls, to
avoid combining calls of different kinds. Calls A and B can be combined
into A iff:
- A and B are identical
- A dominates B
- all paths from A to B are uniform and exec-invariant.
Co-authored by Claude Opus 5
[MLIR] Configure CompositeFixedPointPass's convergence-failure behavior (#218394)
Add an option to `CompositeFixedPointPass` controlling what happens if
the pass fails to converge within max-iterations: emit a warning
(default), emit an error and fail the pass, or do nothing.
[lldb] Compare generic DWARF relational operands as signed values (#218335)
DWARF v5 requires relational comparisons whose operands have the generic
type
to be performed as signed operations. LLDB currently dispatches
`DW_OP_lt`,
`DW_OP_le`, `DW_OP_gt`, and `DW_OP_ge` directly to `Scalar` comparisons,
whose
C-like integer promotion makes an equal-width unsigned operand win. As a
result, the generic comparison of an all-one address-sized value with
zero can
be evaluated as `UINT64_MAX < 0` instead of `-1 < 0`.
Reuse the evaluator's existing approximation for potentially generic
integer
operands and mark temporary operand copies signed before evaluating the
four
ordering operations. This keeps the change local to DWARF expression
semantics, without changing general `Scalar` comparisons or `DW_OP_eq`
[18 lines not shown]
RuntimeLibcalls: Dispatch to library functions from SystemRuntimeLibrary
When a SystemRuntimeLibrary names LibcallLibrary defs, setTargetRuntimeLibcallSets
now dispatches each under an isLibraryAvailable guard, so an impl can be homed
into a library without dropping it from the target. Non-library members keep the
inline path. No target names a library yet, so output is unchanged.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
RuntimeLibcalls: Introduce LibcallLibrary schema
Currently the set of system libraries calls is flat and
disorganized. Begin organizing this per-provider library.
The goal is to organize groups of functions by named sets,
corresponding to the underlying library which will be linked.
A LibcallLibrary is a named runtime library whose impls are made
available as a unit; its members use the same dag vocabulary as
LibcallImpls. The emitter emits one setAvailableLibFuncs_<name>
per distinct library name, merging same-named libraries under their
per-variant availability predicates. isLibraryAvailable()
is added as a stub for a future dispatch driver. No target
defines a LibcallLibrary, so generated output is mostly unchanged
(there are some incidental enum reorderings).
Reorganizing all of the library functions require a good bit more
infrastructure to be practical, but this is a minimally functional
piece to start the review.
[2 lines not shown]