Skip to content

merge main into amd-staging#3300

Merged
ronlieb merged 93 commits into
amd-stagingfrom
amd/merge/upstream_merge_20260709135525
Jul 10, 2026
Merged

merge main into amd-staging#3300
ronlieb merged 93 commits into
amd-stagingfrom
amd/merge/upstream_merge_20260709135525

Conversation

@ronlieb

@ronlieb ronlieb commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

lknknm and others added 30 commits July 9, 2026 13:27
[[nodiscard]] should be applied to functions where discarding the return
value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.html
- https://wg21.link/range.lazy.split

Towards llvm#172124

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
…06744)

The compressed offload bundle (CCOB) header integer fields (Version,
Method, FileSize, UncompressedFileSize, Hash) were serialized and read
in
host-native byte order. The on-disk format is little-endian, so on
big-endian hosts these fields were byte-swapped: writing produced a
malformed header, and reading misparsed the size, making
`llvm-objdump --offloading` crash/misbehave on s390x. This is also why
the
earlier bundle-size fix had to be reverted.

Make the header little-endian on every host:

- Read side: declare the `RawCompressedBundleHeader` fields as
`support::ulittle16_t` / `ulittle32_t` / `ulittle64_t`, so the bytes are
  always interpreted as little-endian regardless of host.
- Write side: emit the header with
`support::endian::Writer(OS, endianness::little)` instead of host-native
  `OS.write(&field, sizeof field)`.

Also revert the temporary big-endian test skip added in llvm#205999
(host-byteorder-little-endian guard on fatbin-coff-compress.test): with
the
header now little-endian, the test runs correctly on big-endian hosts.

---------

Co-authored-by: Michael Selehov <michael.selehov@amd.com>
Co-authored-by: Nikita Popov <npopov@redhat.com> (LE approach)
…ed from temporaries (llvm#208131)

## Summary
- Implements LWG4472, i.e., adds a deleted `atomic_ref(T&&)` overload to
the primary template and three partial specializations of `atomic_ref`.


## Test
- Added `static_assert`s in `ctor.pass.cpp` asserting
`atomic_ref<T>`/`atomic_ref<const T>` reject construction from
`T&&`/`const T&&`.

Resolve llvm#189840
The enabling change is e561875 ([ArrayRef] Make iterator_range
constructor const-agnostic, llvm#205183).
)

This patch introduces various changes to the handling of
`declare_target` global variables in Flang:
- Non-`declare_target` globals are unconditionally made "internal" when
compiling for an OpenMP offload target. This prevents potential symbol
redefinition issues related to globals that don't actually exist on the
device.
- Local SAVE variables handling for OpenMP offloading programs is fixed
to prevent their associated "internal" linkage from producing broken
device code for `declare_target enter(...)`.
- When globals are indirectly accessed from the target device (e.g.
`declare_target link(...)`), the associated and unused full-storage
global is marked with "internal" linkage to facilitate later removal.
- `declare_target device_type(host) enter(...)` variables are set to
external linkage when compiling for a target device, causing linker
errors if accessed. This mirrors Clang's behavior.

Fixes llvm#195188, fixes llvm#195468.

Assisted-by: Claude Opus 4.8.
For reductions that come from parallel constructs, explicitly set the
GPU parallel dimensions attribute to blockXDim on the acc.reduction_init
and acc.reduction_combine* ops since they will always be gang private
…#208189)

The MLIR pass that removes operations exclusively intended for the host
from OpenMP target offload modules is currently defined as part of
Flang. However, this is a feature that would benefit from being reusable
by other frontends, as removing such operations is a requirement for all
OpenMP target device modules prior to LLVM IR translation.

By moving the `omp-host-op-filtering` pass out of Flang, it had to be
updated to work on a lower-level LLVM dialect-based representation,
rather than FIR. This simplified some of the existing edge cases, such
as `fir.declare` ops and `fir.boxchar` type handling. In addition, new
function arguments are introduced as placeholders and return values from
host-only functions are removed, producing a cleaner result and
simplifying the pass as compared to previously.

As a result of a later execution of this pass, dynamic dispatch of host
functions via dispatch table using `fir.dispatch`, `fir.type_info` and
`fir.dt_entry` ops would break due to the removal of `fir.dt_entry`
operations pointing to deleted host functions, while `fir.dispatch` ops
pointing to the same functions would remain. The
`omp-function-filtering` pass is updated to prevent `fir.dt_entry` from
being deleted and let them point to an undefined symbol. This lets FIR
lowering to LLVM work well enough to get to the host op filtering stage,
where any resulting operations for this host dynamic dispatch are
cleaned up.
…vm#205600)

The x86 backend had optimization patterns that matched:
  `(or (and GR32:$dst, -256), (i32 (zextloadi8 addr:$src)))`
and lowered it to:
  `(INSERT_SUBREG (i32 (COPY $dst)), (MOV8rm  i8mem:$src), sub_8bit)`

INSERT_SUBREG for sub_8bit emits a movb instruction which preserves the
upper 56 bits. Now, if the GR32 dst came from a node that does not zero
the upper 32 bits (like IMPLICIT_DEF or EXTRACT_SUBREG), those upper 32
bits would be leaked into the resulting register without being zeroed.

This fixes it by ensuring the input operand satisfies def32 which
requires the upper 32 bits of the register to be set.
Set up the infrastructure for regression tests that build and run a
helper tool, in preparation for testing the logging backends.

- Add test/tools/ for test-support binaries, with a first tool,
orc-rt-smoke-check, wired into ORC_RT_TEST_DEPS and onto lit's PATH.
- Add test/regression/smoke-check.test, which runs the tool and matches
its output with FileCheck, exercising the tool-build and lit plumbing
end to end.
Add flags for DirectX in `llc`:
* `--dx-embed-debug` to embed debug info into ILDB part of DXContainer
* `--dx-pdb-path` to specify filename/path for PDB file output

This patch does not add flags for clang Driver, they will be implemented
later.
Move unit tests from orc-rt/unittests into orc-rt/test/unit, completing
the consolidation of the runtime's tests under orc-rt/test (alongside
test/regression and test/tools).
…llvm#208420)

Revert exported target check added in
00b2f81
to fix reported mingw cross compile regression. This is the quick fix
which restores the cmake warnings when building libc for amdgpu.
… to reduce diff in llvm#189971 (llvm#208419)

Add AVX1ORAVX2 check prefix to distinguish from AVX512 codegen
Move towards using the triple for representing incompatible
ISA changes. Use the subarch field to represent the various
incompatible cases. Previously we pretended a single triple arch
was universally compatible, and only distinguished by function
level subtargets. Move towards using distinct triples to enable
more sophisticated toolchain handling in the future, like proper
runtime library linking.

Introduce a new subarch per unique ISA, but also introduce
"major subarches" which are compatible by a set of covered
minor ISA versions. These map to the existing generic targets.
There are a few placeholder subarch entries, which currently
have missing backing generic arches for codegen.

This should be the preferred triple arch name going forward,
but is treated as an alias of amdgcn. This does not yet change
clang to emit the new triples.

Part of llvm#154925
This PR implements the System V X86-64 ABI for the LLVM ABI Library
prototyped in llvm#140112, and
wires it into clang's Codegen.

`X86_64TargetInfo` is a direct parallel to
`clang::CodeGen::X86_64ABIInfo`, but operates entirely on the
`llvm::abi` type system.
The AMD64 ABI classification spec, argument/return lowering , and the
supporting helpers are all reproduced against `llvm::abi::Type` and
FunctionInfo, keeping the ABI logic frontend-independent.

This, similar to the [BPF ABI implementaiton
](https://github.com/llvm/llvm-project/pull/194031/changes)is gated
under the `-fexperimental-abi-lowering` flag.
…addubsw.ll (llvm#208430)

Allows better SSE2 test coverage for PMADDWD combines
…" (llvm#208426)

It caused various breakages; see comments on the PR.

This reverts commit 031b773.
…can (llvm#206745)

When multiple offload bundles are concatenated, the unbundler
(clang-offload-bundler) and llvm-objdump --offloading located the end of
a compressed bundle, and the start of the next one, by scanning for the
next "CCOB" magic string starting right after the current header.

A zstd/zlib-compressed payload can legally contain those four bytes, so
the scan could stop in the middle of the compressed data and truncate
the bundle, corrupting the embedded code object. In practice this
produced a "decomposition" failure for hipBLASLt bf16 GEMMs on gfx942.

Use the authoritative total-size field recorded in the compressed bundle
header (format V2/V3) to compute the exact bundle boundary, and only
scan for the next magic past that point. Legacy bundles without a
recorded size (V1) keep the previous magic-scan fallback.

A skippable-frame fixture that embeds "CCOB" inside the compressed
payload is added to exercise the boundary logic from both
clang-offload-bundler and llvm-objdump --offloading.
llvm#206504)

`shouldKeepJumpConditionsTogether` decides whether to fold two integer
branch conditions into a CMP/CCMP chain by pricing the RHS
dependency-chain latency. That ignores register pressure: when both
conditions compare loaded values, merging pins all the loaded operands
live at once to feed the chain instead of consuming them at each split
compare-and-branch. On a load-store target that extends their live
ranges across the region the branch dominates.

Decline to merge when both sides are integer compares of loaded values,
mirroring the machine CCMP pass (which won't speculate loads).

Reference:
llvm#201486 (comment)
llvm#202688 incorrectly marked
`TestPlatformProcessConnect.py` as PASS on Windows with `lldb-server`.
They do not work and are failing just like with the in process plugin.

Re-mark both of them as XFAIL.

rdar://181797532
The goal for us is to be able to demangle Microsoft mangled function
names toward something that reads more like AST function names and
Itanium demangled names. All defaults remain the same and no existing
code or tool user should be impacted by the change.

* Make the OF_NoTagSpecifier flag accessible from `microsoftDemangle`
* Add a flag to skip the "void" keyword when there is no parameter
* Add a flag to skip the type descriptions
* Respect MSDF_NoCallingConvention with function pointers
* Add unit tests.

Assisted-by: Claude
--
CPP-7550
This patch adds support for the NVIDIA Rigel core.

This does not add any special tuning decisions, and those may come
later.
Added AShr opcode in analysis and minbitwidth analysis

Reviewers: RKSimon, hiraditya, bababuck

Reviewed By: RKSimon

Pull Request: llvm#207841
The closing #endif comment was using _LIBCPP_ABI_SIZE_BASED_VECTOR,
which was the name of the macro in previous iterations of the size-based
vector patch. We ended up landing on _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED
instead.
…06754)

When we have an AddRec where the step value is n*vscale this value
doesn't occupy a register if the target has an add instruction where
this value is a legal offset.
…204658)

MSVC preserves null check after dereference, e.g

```
struct Obj { int value, extra; };

int null_check_is_kept(Obj* p) {
    int v = p->value;
    if (p == nullptr)
        return -1;
    return v + p->extra;
}
```
Also MSVC keeps standard library calls (e.g memcpy), where target is
null pointer.
Access the index value at constant time and use for range for the
`ForEach` functions.
alexey-bataev and others added 22 commits July 9, 2026 12:51
…nchmarks (llvm#208412)

The point of the custom predicates is to defeat any detection of special
predicates within the library. There isn't much point in adding
`benchmark::DoNotOptimize` on top of that. It can actually hurt, since
it may hide performance changes due to how much/which information we
provide to the compiler.
fadd(x, c) and fsub(x, c) are interchangeable via fadd(x, -c), so treat
them like the existing Add/Sub/Mul/Shl/AShr/And/Or/Xor interchange in
BinOpSameOpcodeHelper. This lets a mixed fadd/fsub bundle vectorize as
a single op instead of needing an alt-shuffle/split node.

Restrict the interchange to a constant RHS. A constant LHS (e.g.
"0.0 - x") cannot be moved to the other opcode without also swapping
the variable operand, which would misalign it against lanes that keep
their native opcode and produce a node too expensive to vectorize.

Reviewers: hiraditya, bababuck, RKSimon

Pull Request: llvm#208002
This was problematic because these CMake headers were never intended to
be used from a GPU target. We had to hack around this to suppress
threads, but all this is used for is getting the default CUDA path, so
just do this directly.
llvm#208505)

In release builds, the variable is now unused. Sink and inline into
single user to silence warning.
…)) over UNPCKL(SHUFFLE(X), SHUFFLE(Y)) (llvm#208503)

If blends are cheap and at least one input is a noop - perform a
permute+blend
The downstream swift CI is getting PermissionError instead of
FileNotFoundError for a [couple of
tests](https://ci.swift.org/job/pr-apple-llvm-project-llvm-linux/1819/consoleFull#-556494529d6fdb6cb-f376-4f2e-8bce-d31c7304698b).
I have no idea what is wrong with our CI, but we should be handling
those errors the same way anyway.

Also fix documentation typo.
…lvm#196635)

Earlier, special `lifetime_capture_by` spellings `global` and `unknown`
could conflict with actual parameter names, causing [some
code](https://godbolt.org/z/YWhW1dnoe) to fail to compile.

Because of that, we deprecate those parameters (they can probably be
removed in the near future)

llvm#192102

Assisted-by: GPT-5.4 for cleanup
In preparation of moving the implementation from `LegalizeDAG` into
`ExpandIRInsts`.
…llvm#208404)

The constraint system uses 64-bit coefficients and previously aborted
the entire elimination as soon as a single row combination overflowed.

This is unnecessary pessimistic and can lead to lost optimizations if
the system contains constraints with large coefficients which do not
contribute to a particular solution (e.g. signed wrap checks).

Instead, skip only the overflowing row combination and continue.

Compile-time impact is in the noise:

https://llvm-compile-time-tracker.com/compare.php?from=4f41b6be1a89796d6ce89188a4fd4e0cde9d06b7&to=1dedecc1cefea9c94631cdb272717d898ac6696b&stat=instructions:u

PR: llvm#208404
…llvm#205930)

When a target's `getVTableUniqueness()` is `UniqueIfStrongLinkage`, as
on Apple Mach-O, the platform may emit a class's weak vtable as a
separate copy in more than one linkage unit. A symbol that can
legitimately exist at several addresses has no meaningful address, so
such a vtable can be marked `unnamed_addr`.

On Mach-O, a weak vtable that is `unnamed_addr` lowers to a
`.weak_def_can_be_hidden` definition, which the static linker coalesces
and then drops from the dynamic export trie. Keeping these vtables out
of the exported symbol set cuts the work dyld has to do at load time.

llvm#200108 dropped `unnamed_addr` from vtables because the exact
`dynamic_cast` optimization compares an object's vtable pointer against
a known vtable address and depends on that address being unique. Adding
`unnamed_addr` is safe here because that optimization is never performed
for these weak vtables, so nothing relies on them having a unique
address.

rdar://179929460
On z/OS, the user has a choice between two different va_list formats.  
1. (default) uses the __builtin_zos_va_list typedef for va_list, being
added in this change
2. (-D_VARARG_EXT_) uses __builtin_va_list typedef for va_list.

The __builtin_zos_va_list type is `char * [2]`. 

This PR adds this type along with the __builtin_zos_va_start(),
__builtin_zos_va_end() & __builtin_zos_va_copy() functions to go with
it.
Fix the detected UB in the `stack_larger_than_signed_64bit_warning`
test-case. Now just checks that the warning is correctly not emitted.
This reverts commit b69ec10.

Recommit with small fix for potential nullptr dereference.

Original message:
Currently hasEarlyExit misses cases where we have things like dead exit
blocks or simplified the middle block.

Update to check by counting the predecessors.

This fixes a case where we missed properly updating LoopInfo due to
incorrect results.

Fixes llvm#206007.
…lare (llvm#208091)

Inlining can leave a `fir.declare`'s dummy_scope operand (`!fir.dscope`)
defined outside an OpenACC compute region while the declare itself gets
rematerialized inside, since `fir.dummy_scope` wasn't registered as an
OutlineRematerializationOpInterface candidate.

This dangling, unmappable live-in is illegal for parallelization. 

Fix: Added `OutlineIdentityOperandOpInterface`, implemented by
`fir.declare/hlfir.declare`, so `OffloadLiveInValueCanonicalization`
drops their dummy_scope operand (an identity token that must never be
duplicated) instead of cloning it when sinking/rematerializing them into
offload regions.
…FC) (llvm#208306)

The canonical form preferred by instCombine is to use 64-bit values for
the index when it is a constant for ExtractElement.
…m#203941)

Canonicalizes explicit broadcasting into implicit broadcasting by
folding the tile input into the binary element-wise operation.
@ronlieb ronlieb requested review from a team, dpalermo and skganesan008 July 9, 2026 19:56
@ronlieb ronlieb merged commit 7b8408c into amd-staging Jul 10, 2026
108 of 110 checks passed
@ronlieb ronlieb deleted the amd/merge/upstream_merge_20260709135525 branch July 10, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.