[flang][Driver] Make the offload arch detection tool option visible to flang (#247265)
--offload-arch-tool= chooses the tool that detects the architecture of
the GPUs of the system, for --offload-arch=native and when no
architecture is given. It was only visible to the clang driver. Make it
visible to flang, so that the flang driver can be pointed at a tool, and
tested without a GPU.
Assisted-by: Claude Sonnet 5.5
---------
Co-authored-by: Tarun Prabhu <tarun at lanl.gov>
[GVN][MemDep] Handle PartialAlias for lifetime.start more precisely (#247924)
A lifetime.start gets PartialAlias for inbounds accesses to a statically
sized allocation. For such accesses, we can precisely return a Def
instead of treating them as MayAlias, which leads to a clobber.
After taking a look at MDA, we found that we can also fix this over
there, as it uses getAfter, which returns a Clobber for inbounds
accesses to statically sized allocations.
[SPIR-V] Support SPV_INTEL_rounded_divide_sqrt extension (compute only) (#238403)
Implement `SPV_INTEL_rounded_divide_sqrt` extension support, that allows
div and sqrt to have `FPRoundingMode` decoration. Currently it's
supported for compute only, no shader support will be added unless
there's explicit requirement for it in the future.
Note that currently, constrained arithmetic instructions other than div
and sqrt can also be decorated with `FPRoundingMode`. This is illegal
and will be rejected by spirv-val, but it's out of scope for this PR. It
will be fixed by a future PR instead.
[AMDGPU] Insert s_nop 0 for cross-wave VALU co-execution on gfx942/gfx950 (#242519)
On subtargets with FeatureCrossWaveVALUCoexecution, a SIMD can co-issue
VALUs of two waves, depending on both VALUs. While an older wave issues
a sequence of VALUs, a younger wave's VALU that cannot be co-issued with
them stalls, and so do the VALUs that follow it. Inserting s_nop 0 in
the older wave lets the younger wave issue that VALU.
SIPreEmitPeephole now inserts s_nop 0 where this lets the younger wave
co-issue a sequence of VALUs. It does so only in small loops that
consist mostly of such VALUs, outside MFMA shadows, and when the
occupancy is not known to be 1.
-mattr=-cross-wave-valu-coexecution disables the transformation.
Fixes LCOMPILER-3001.
Assisted-by: Claude Opus 5.5
[Clang] Complete the element type when list-initializing an array of unknown bound (#221488)
List-initializing a temporary array of unknown bound from an empty
initializer list creates a zero-length array whose elements are never
initialized, so nothing ever completes the element type. If that type is
a class template specialization that has not been instantiated yet (or a
forward-declared class), the destructor lookup for the temporary in
`MaybeBindToTemporary` runs on a record without a definition and trips
the `CanDeclareSpecialMemberFunction` assertion in
`LookupSpecialMember`.
```cpp
template <typename> struct Q {};
const Q<int> (&r)[] = {};
```
`TryListInitialization` already requires a record destination type to be
complete. This extends that check to the base element type of an
incomplete array destination (so `T (&)[][N]` is covered too), which
[17 lines not shown]
Attributor: Skip seeding loads, stores and allocas if nothing can be seeded
None of the abstract attributes seeded for them are allowed with
attributor-light, which still visited every load, store and alloca. NFC.
CTMark instructions:u with -attributor-enable=light changes by O3 -0.05%,
ThinLTO -0.11%. The attributor-light pass itself is 0.5-4.9% faster
(callgrind), and 1.4-17.7% faster with the other pending Attributor
compile-time changes applied.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Attributor: Don't seed simplification without simplification AAs
When seeding, the Attributor asks for the simplified value of every
argument, return, call site and stored value, only to create the AAs that
simplify them. If none of those AAs are allowed, as in the light pass,
this computed simplified values that were thrown away, which includes
walking the returned values of every function.
CTMark instructions:u with -attributor-enable=light:
O3: -0.13%
ThinLTO: -0.12%
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Attributor][NFC] Return early for attributes that are not allowed (#245769)
Looking up or creating an abstract attribute of a kind that is not
allowed still hashed the position and probed the attribute map, only to
find nothing. attributor-light allows few kinds but queries others
often, e.g. `AAPotentialValues` for every simplification query. Check
whether the kind is allowed before probing the map.
`opt` instructions on CTMark bitcode: attributor-light -1.9% to -2.3%,
attributor-light-cgscc -1.4% to -2.0%, full attributor up to +0.25%;
`amdgpu-attributor` on HIP device code -0.3%.
Co-authored-by: Matt Arsenault <Matthew.Arsenault at amd.com>
Assisted-by: Claude Opus 5.5
[mlir][ArmSME] Do not use the store loop for writes with out-of-bounds rows (#245286)
`LegalizeMultiTileTransferWriteAsStoreLoop` lowers a multi-tile
`transfer_write` to a loop that writes one row at a time and marks every
row write as in-bounds. If the rows may be out of bounds, this writes
past the end of the memref.
With `-arm-sme-vector-legalization -cse -canonicalize`, this write:
```mlir
vector.transfer_write %vec, %dest[%y, %x] {in_bounds = [false, true]} : vector<[8]x[8]xf32>, memref<?x?xf32>
```
became a loop over the rows with no bounds check:
```mlir
%0 = arith.addi %arg7, %arg5 : index
vector.transfer_write %1, %arg0[%0, %arg6] {in_bounds = [true]} : vector<[4]xf32>, memref<?x?xf32>
```
[13 lines not shown]
[FlowSensitive][Expected] Model constructors, assignments and `emplace` in `UncheckedExpectedAccessModel` [PR 3/N] (#246771)
This is the third part of a split of #233219
(`bugprone-unchecked-expected-access`). It adds modeling of the calls
that set
whether an expected holds a value:
- **`emplace`**: every overload leaves the expected holding a value.
- **Constructors**:
- `expected(unexpect_t, ...)`, `expected(const unexpected<G> &)` and
`expected(unexpected<G> &&)`
construct an expected that holds an error.
- The converting constructors from `expected<U, G>` copy whether the
source holds a value.
- All other constructors (default, from a value, `in_place_t`) construct
an expected that holds a value.
- Copy and move constructors are left to the Dataflow framework, which
copies the "has_value" property of the source.
- **Assignments**:
- `operator=(const unexpected<G> &)` and `operator=(unexpected<G> &&)`
[37 lines not shown]
[mlir][ArmSME] Swap the in_bounds flags of transposed stores via ZA (#245272)
The row and column flags end up swapped when
`LowerIllegalTransposeStoreViaZA` writes each tile with a transposed
permutation map but copies `in_bounds` from the original write without
swapping it.
With `-arm-sme-vector-legalization -cse -canonicalize`, this write,
whose columns may be out of bounds:
```mlir
%tr = vector.transpose %vec, [1, 0] : vector<2x[4]xf32> to vector<[4]x2xf32>
vector.transfer_write %tr, %dest[%i, %j] {in_bounds = [true, false]} : vector<[4]x2xf32>, memref<?x?xf32>
```
became a tile write that marks the columns in-bounds:
```mlir
#map = affine_map<(d0, d1) -> (d1, d0)>
[14 lines not shown]
Reapply "AMDGPU: Fold inline immediates in peephole-opt (#242952)" (#248494)
This reverts commit 463d84c55eb1e2ac5c8f10e9e0bd23c5d3f3de9e.
Fix the problems reported on #242952. Do not fold into tied operands,
check isOperandLegal, and use isImmEquivalentToReg to check the
immediate reads the same value as the register.
Assisted-by: Claude
CloneFunction: Check invokes for memprof metadata when pruning (#248341)
The pruning cloner reports whether the cloned code contains !memprof
or !callsite metadata, but only looked at non-terminator calls. The
inliner uses this to decide whether to strip the metadata from the
copied calls if the original call site has no !callsite metadata.
As a result, the metadata was not stripped from an inlined invoke
unless the callee also had a call with the metadata.
Assisted-by: Claude
[Clang] Look through cleanups when computing expansion statement sizes (#245109)
This fixes https://github.com/llvm/llvm-project/issues/245102. After
diagnosing a malformed std::initializer_list in a range-based for loop,
Clang can wrap the next expansion variable's initializer in an
ExprWithCleanups. Casting that initializer directly to
CXXExpansionSelectExpr then triggers an assertion. So look through
implicit wrappers to find the underlying initializer list both when
checking for unexpanded packs and when counting elements.
Assisted-by: OpenAI Codex
---------
Co-authored-by: Shengxin Pei <TPPPP72 at outlook.com>
AMDGPU: Fix immediate folds into bf16 and packed f32 operands (#248493)
On subtargets which read bf16 inline constants from the high half of
the fp32 constant, isOperandLegal accepted a bf16 floating-point inline
constant without op_sel in VOP3 sources and 16-bit mix instruction
sources. A mix instruction source is read as f32 unless op_sel_hi is
set.
SIFoldOperands worked around this for src0 only, and had separate
special cases for packed bf16 and packed f32 operands. Replace these
with one model in SIInstrInfo of the bits an immediate reads as and the
halves op_sel selects. A folded immediate must read the same value as
the register it replaces, choosing op_sel to preserve it.
There's an unfortunate amount of special casing based on instruction
type instead of operand kind. This starts fixing the isPacked special
cases, but there's a lot more to clean up.
Assisted-by: Claude
[lldb] Return nullopt from ScriptedBreakpointInterface::GetShortHelp (#248504)
Fixes #247670
At least one compiler does not allow a nullptr->std::string->optional
path. Even if they all did, this method's uses imply that empty optional
should be the return value if you have nothing to return.
[mlir][gpu] Don't crash verifying a launch_func nested in an unregistered op (#245372)
LaunchFuncOp::verifySymbolUses asks SymbolTable::getNearestSymbolTable
for the table the launch should be resolved in, then calls
isa<GPUModuleOp> on the result. That helper returns null when it meets
an unregistered single-region op on the way up, because such an op might
itself be a symbol table. The isa then dereferences the null pointer and
mlir-opt --allow-unregistered-dialect segfaults.
With no known symbol table there is nothing to resolve the kernel
against, so return success in that case. This matches what the function
already does for launches that are nested deeper than a function
directly inside the container module (those are skipped as well), and
what ModuleToBinary does when it cannot find a table.
This is a regression from 67e47fb5317c (#173277): the old
verifyOperationAttribute walk resolved against the module being
verified, which is never null, and skipped any launch whose grandparent
was not that module. Recomputing the table from the launch is what made
[3 lines not shown]
[clang][CodeGen] Fix postopt bitcode linking for LLVM IR input (#246138)
Currently the `-mlink-builtin-bitcode-postopt` option completely
disables linking of the builtin bitcode modules for LLVM IR input
instead of moving it after the optimizations. This might lead to the
loss of the symbols defined in these modules.
This patch resolves the issue by enabling the postopt linking for LLVM
IR input.