Previous commit message:
> Original commit message:
>
>>When users explicitly specify a PTX version via -mattr=+ptxNN that's
insufficient for their target SM, we now emit a fatal error. Previously,
we silently upgraded the PTX version to the minimum required for the
target SM.
>>
>>When no SM or PTX version is specified, we now use PTX 3.2 (the
minimum for the default SM 3.0) instead of PTX 6.0.
>
>The following commits should fix the failures that arose when I
previously tried to land this commit:
>
>9fc5fd0ad6
should address the llvm-nvptx*-nvidia-* build failures:
https://github.com/llvm/llvm-project/pull/174834#issuecomment-3742242651
>
>600514a637
should address the MLIR failures
---
The previous commit was reverted with
d23cb79ba497281de050ef609cb91b91058bf323 because the
[mlir-nvidia](https://lab.llvm.org/buildbot/#/builders/138/builds/24797)
and
[mlir-nvidia-gcc7](https://lab.llvm.org/buildbot/#/builders/116/builds/23929)
Buildbots were failing.
Those tests failed because MLIR's default SM was 5.0, which caused NVPTX
to target PTX ISA v4.0, which did not support the intrinsics used in the
failing tests.
243f011577193c99358ccc4142b296d4fa80ea11 should address this by bumping
MLIR's default SM to 7.5. Now, using MLIR's new default SM, NVPTX
targets the PTX ISA v6.3, which supports the intrinsics used in the
failing tests.
As noted on #174761 - we need to ensure custom lowering to logic/add/sub
ops might actually occur before assuming the node will have been on the
vector unit
Handle the include similar to ProgramTest, to fix the build failures in
darwin
```
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/unittests/CAS/OnDiskCASLoggerTest.cpp:38:15: error: use of undeclared identifier '_NSGetEnviron'
return *_NSGetEnviron();
^
1 error generated.
```
`global_load_lds` and `buffer_load to lds` do only increment `vmcnt` and
not touch `lgkmcnt`. This causes invalid `waitcnts` for some Triton
kernels, similar to the added lit tests.
Note that the change for buffer ops is not necesssary, i.e. the lit test
passes even before this PR, because it seems like `SIInsertWaitcnts`
does not use `LGKM_CNT` for buffer ops. But this change might prevent a
bug in the future.
#170525
Previously, lookup tables were defined in a header so that they can be
constexpr, but this lead to each translation unit having it's own copy,
bloating the library size. Looking at current usages of wctype
functions, they are always used at runtime, so there's no benefit of
having them constexpr, so I'm moving them to a cpp file, so that there's
only a single copy in the library.
Set up the test similar to ProgramTest to avoid missing necessary env.
eg: In our downstream build, the process would rely on a shared libs,
the test would fail to find the dependent lib if we don't pass the env
down to multiprocess test.
Add support for lowering vector.transfer_read to
gpu.subgroup_mma_load_matrix with transpose permutation_map
with non-minor dimensions e.g. (d0, d1, d2) -> (d2, d0)
Add `FormatInfoEntry` template to support per-analysis-type
serialization within a `SerializationFormat`.
This allows to implement different formats for the different analyses in
a decoupled way.
For testing, this patch also implements the MockSerializationFormat
demonstrating the FormatInfo sub-registry pattern.
Assisted-by: claude
Depends on #179516
rdar://169192127
Add a registry infrastructure for SerializationFormat implementations,
enabling registration and instantiation of different serialization
formats.
For example:
```c++
static SerializationFormatRegistry::Add<MyFormat>
RegisterFormat("MyFormat", "Description");
```
Formats can then be instantiated by name using `makeFormat()`.
The patch also updates the SerializationFormat base class to accept
FileSystem for virtualising reading inputs eg. by using file overlays in
the future.
Assisted-by: claude
rdar://169192127
Extending the work from https://github.com/llvm/llvm-project/pull/162678
which skips `llvm.compiler.used`, we also need to skip processing of
`llvm.used`.
The OpenMP frontend puts an `addrspace(2)` variable in `llvm_used`, but
the `llvm.used` array type uses the generic AS `addrspace(4)` so there's
a `addrspacecast` from `2` to `4` inside the initalizer for `llvm.used`
which is illegal and errors in the backend.
There is
[discussion](https://github.com/llvm/llvm-project/pull/162678#issuecomment-3396735124)
in the above linked PR that the handing should be the same for
`llvm.used` and `llvm.compiler.used`, but `llvm.used` was not added to
minimize the scope of the PR.
This is required to use the OpenMP Device RTL with SPIR-V.
Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
Handle this case by extending the integer to a wider type. This can
probably be handled more optimally, but this is conservatively correct.
Proof: https://alive2.llvm.org/ce/z/0RwDO1
Improving stability of the TestDAP_launch_commands test.
When collecting output for verifying 'stopCommands' we were not waiting
for the output to finish, which could cause issues if the test is
running very fast.
On GFX9, BUFFER_WBL2 is used to write back dirty cache lines and
requires an s_waitcnt vmcnt(0) afterwards to ensure completion.
This patch fixes by incrementing vmcnt for buffer_wbl2 instruction
---------
Co-authored-by: Jay Foad <jay.foad@gmail.com>
Currently we only fold an op into vmerge if we know the smaller of the
two vls, because we can't increase the vl.
However if the op's passthru is undef, then we can just use vmerge's vl
because the lanes past op's vl were undef anyway. We need to make sure
that the op doesn't access memory though. Other instructions where the
result depends on the VL should already be handled by the
RISCVII::elementsDependOnVL check below.
This is probably always profitable because even though we increase vl,
we remove a vmerge which needs to process vl elements anyway.
This removes some regressions in #179622.
If the source of an fpto*i doesn't fit in the destination type, the
result is poison. For i1 destinations, this means the result needs to be
0 or 1/-1, so we can just compare the result to 0 directly instead of
truncating.
The VP lowering for fpto*i already does this.
625038d5d5f406385f44983ac2a442b20ad7b241 added NewPM CGSCC coverage to
all of the inliner tests. Now that the NewPM is the default for the
middle end, both check lines cover the same thing (with -passes="inline"
expanding to -passes="cgscc(inline)"). Given that, remove them to get
rid of the redundancy and make the tests run slightly faster (not
measured).
Update HIPSPV toolchain to support `--offload-new-driver`. Additionally,
tailor llvm-spirv invocation for
[chipStar](github.com/CHIP-SPV/chipStar) via `spirv64-*-chipstar`
offload triple.
AFAICT, all the relevant test failures in the previous PR (#178664) came
from tests involving `-Xoffload-compiler ‘-###’` in their RUN
directives. I have reworked those tests in this PR.
This PR updates the OffloadBinary format from version 1 to version 2,
enabling support for multiple offloading entries in a single binary.
This allows combining multiple device images into a single binary with
common global metadata while maintaining backwards compatibility with
version 1 binaries.
# Key Changes
## Binary Format Enhancements
**Version 2 Format Changes:**
- Changed from single-entry to multi-entry design
- Updated `Header` structure:
- Renamed `EntryOffset` → `EntriesOffset` (offset to entries array)
- Renamed `EntrySize` → `EntriesCount` (number of entries)
- Added `StringEntry::ValueSize` field to support explicit string value
sizes (enables non-null-terminated strings)
- Introduced `OffloadEntryFlags` enum with `OIF_Metadata` flag for
metadata-only entries (entries without binary images)
**API Changes:**
- `OffloadBinary::create()` now returns
`Expected<SmallVector<std::unique_ptr<OffloadBinary>>>` instead of
single binary
- Added optional `Index` parameter to extract specific entry:
`create(Buffer, std::optional<uint64_t> Index)`
- `OffloadBinary::write()` now accepts `ArrayRef<OffloadingImage>`
instead of single image
- Added `OffloadBinary::extractHeader()` for header extraction
**Memory Management:**
- Implemented `SharedMemoryBuffer` class to enable memory sharing across
multiple `OffloadBinary` instances from the same file
- Multiple entries from a single serialized binary share the underlying
buffer
## Testing
**Unit Tests (`unittests/Object/OffloadingTest.cpp`):**
- `checkMultiEntryBinaryExtraction`: Tests extracting all entries from a
multi-entry binary
- `checkIndexBasedExtraction`: Tests extracting specific entries by
index, including out-of-bounds validation
- `checkEdgeCases`: Tests edge cases including:
- Empty string metadata
- Empty image data
- Large string values (4KB)
**Other Tests:**
- Updated `test/ObjectYAML/Offload/multiple_members.yaml` to include
metadata-only entry
---------
Co-authored-by: Joseph Huber <huberjn@outlook.com>
LoadCombine pattern handling was added as a workaround for the cases,
where the SLP vectorizer could not vectorize the code effectively. With
the copyables support, it can handle it directly.
Also, patch adds support for scalar loads[ + bswap] pattern for byte
sized loads (+ reverse bytes for bswap)
Reviewers: RKSimon, hiraditya
Pull Request: https://github.com/llvm/llvm-project/pull/174205
We have not finished fixing all the ExpandIRInsts tests for the
profcheck configuration (PRs are in flight), so disable for now until
those land so it is easier to catch more regressions.
Before this patch, reading union template parameter object will trigger
diagnostics saying it's not initialized. This patch fixes this issue.
Reading union template parameter with no active fields, class type
fields, or bit-fields is handled as a drive-by.
AI usage: The implementation was generated by AI and modified by me
afterwards.
Assisted-by: GPT-5.2
---------
Co-authored-by: Timm Baeder <tbaeder@redhat.com>
GISel CallLowering currently does a Type -> EVT -> Type roundtrip early
on when populating ArgInfo in splitToValueType(). This is a bit odd as
this structure operates at the IR Type level. Keep the original type
there and only convert to EVT when performing assignments.
I don't think anything here requires the integer bit width to be
strictly larger. It's fine if it's the same (in which case some zexts
just go away).
Add tests on half + i32 that can be verified by alive2. Note that half
is handled via float, so the minimum supported type is i32 rather than
i16.
Proof (uitofp): https://alive2.llvm.org/ce/z/CsMfkU
Proof (sitofp): https://alive2.llvm.org/ce/z/jzuxyt
The last FreeBSD version supporting mips64 is FreeBSD 13 which will be
EOLed on April 30th. LLVM 23.1.0 release is expected to be August 25th
according to the LLVM calendar. The usage of mips64 is less noticeable
so it's hard to know if it is properly working, and even if it works, it
is hard to test new features on FreeBSD mips64.
Thus, remove support for mips64 on FreeBSD.
---------
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
As I was trying to understand the class `NodeBuilder` and its
subclasses, I wasted a few hours on studying dead or needlessly
complicated code. I'm creating this patch to ensure that others in the
future won't need to bother with this cruft.
This commit eliminates three deficiencies:
- (Small change:) In a constructor of `StmtNodeBuilder` I switched to
using the `takeNodes()` overload which accepts an `ExplodedNodeSet`
(instead of manually iterating).
- The `Finalized` attribute of NodeBuilder was completely irrelevant (it
was always initialized to `true`).
- The "main" feature of `NodeBuilderWithSinks` was that it gathered the
generated sink nodes into a set, but this was never actually used. As
the only other feature (storing a `ProgramPoint` in a data member) was
very trivial, I replaced this class with a plain `NodeBuilder` in the
only location that used it.
FreeBSD has moved from svn to git. Use https://cgit.freebsd.org/src
instead as it is the source of truth. i386 and mips64 were no longer
supported as of FreeBSD 15 and 14, respectively, so link stable branch
instead of main branch. See [FreeBSD platforms
page](https://www.freebsd.org/platforms/).
---------
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
When an assembly file is passed to the Flang driver, it currently fails
with a confusing internal error mentioning the unsupported `-cc1as`
tool.
This update detects assembly inputs early in the driver and emits a
clear, user-facing diagnostic explaining that Flang does not support
assembly files as input. The logic is implemented in a small helper
function and is intentionally temporary, so it can be removed once Flang
gains support for assembling inputs.
Fixes: #173528
EvaluateRequests handler now uses the target's context if no valid
frameId is provided, enabling evaluation of
global variables without requiring a valid stack frame.
In repl mode it now uses the last `successful` variable or command
expression, if the provided user's expression is empty.
Try to evaluate the expression if the evaluation context is `Unknown`
Improve lifetime safety analysis by tracking moved objects and providing
more precise warnings for potentially false positive cases.
- Added support for detecting moves in function calls with rvalue
reference parameters
- Added a new `MovedOriginFact` to track when objects are moved
- Modified the lifetime checker to detect when a loan's storage has been
moved
- Added new diagnostic messages that indicate when a warning might be a
false positive due to moved storage
- Added notes in diagnostics to show where objects were potentially
moved
This patch restructures Find(First|Last)IV handling. Instead of
differentiating between FindLast, FindFirstIV and FindLastIV up front,
this patch simplifies the logic in IVDescriptor to just identify the
FindLast pattern up-front.
It then adds a new VPlan transformation to optimize FindLast reductions
to FindIV reductions if there is a suitable sentinel value.
Find(Last|First)IV recurrence kinds to a single FindIV kind.
This is simpler and more accurate, given selecting the first/last
induction of the final IV reduction is directly controlled by the
corresponding recurrence kind of the ComputeReductionResult.
The new structure also allows further optimizations, like vectorizing
FindLastIV with another boolean reduction that tracks if the condition
in the loop was ever true, if there is no suitable sentinel value.
PR: https://github.com/llvm/llvm-project/pull/177870
This patch adds a new TargetLowering pass to the CIR pipeline. The new
pass is run immediately before CXXABILowering. This new pass does not
perform any heavy transformations yet -- for now it only converts sync
scopes attached to load and store operations according to the target
info, which was done in the LLVM lowering pass.
Related to #175968 .