9355 Commits

Author SHA1 Message Date
Chaitanya
e6c20e11e7
[AMDGPU] Move AMDGPUAsanInstrumentation outside of utils (#100323)
#98863 merged AMDGPUAsanInstrumentation module which missed
TransformUtils to be linked to AMDGPUUtils.
This PR moves AMDGPUAsanInstrumentation files outside utils folder and
adds them to AMDGPUCodegen lib.
2024-07-24 18:06:10 +05:30
Jessica Del
6a1b119035
[AMDGPU] Add intrinsics for atomic struct buffer loads (#100140)
Mark these intrinsics as atomic loads within LLVM to prevent hoisting
out of loops in cases where
the load is considered invariant.

Similar to https://github.com/llvm/llvm-project/pull/97707, but for
struct buffer loads.
2024-07-24 11:05:28 +02:00
Chaitanya
ddb75ca606
[AMDGPU] Utilities to asan instrument memory instructions. (#98863)
This change adds the utilities required to asan instrument memory
instructions. In "amdgpu-sw-lower-lds" pass #87265, during lowering from
LDS to global memory, new instructions in global memory would be created 
which need to be asan instrumented.
2024-07-24 12:19:57 +05:30
Jun Wang
b316cebae1
[AMDGPU][MC] Improve error message for missing dim operand (#96588)
For GFX10+, the MIMG instrucitons generally require a dim operand.
However, when dim is missing, the assembler produces the error message
"operands are not valid for this GPU or mode" (See issue
https://github.com/llvm/llvm-project/issues/47585). This patch fixes the
issue by producing a more direct error message.

---------

Co-authored-by: Jun Wang <jun.wang7@amd.com>
2024-07-23 10:14:55 -07:00
Sumanth Gundapaneni
fc832d5349
[AMDGPU] Implement llvm.lround intrinsic lowering. (#98970)
This patch enables the target-independent lowering of llvm.lround via
GlobalISel. For SelectionDAG, the instrinsic is custom lowered for
AMDGPU. In order to support vector floating point input for llvm.lround,
this patch extends the target independent APIs and provide support for
scalarizing. pr98950 is needed to let verifier allow vector floating
point types
2024-07-23 20:34:34 +04:00
Matt Arsenault
81e2a57b41
AMDGPU: Fix assembler asserting on expressions in vop3 instructions (#100103)
Fixes #100075

---------

Co-authored-by: Jay Foad <jay.foad@amd.com>
2024-07-23 18:58:30 +04:00
Christudasan Devadasan
229e118559
[AMDGPU] Codegen support for constrained multi-dword sloads (#96163)
For targets that support xnack replay feature (gfx8+), the
multi-dword scalar loads shouldn't clobber any register that
holds the src address. The constrained version of the scalar
loads have the early clobber flag attached to the dst operand
to restrict RA from re-allocating any of the src regs for its
dst operand.
2024-07-23 13:59:15 +05:30
Christudasan Devadasan
a1d7da05d0
[AMDGPU][SILoadStoreOptimizer] Merge constrained sloads (#96162)
Consider the constrained multi-dword loads while merging
individual loads to a single multi-dword load.
2024-07-23 13:50:42 +05:30
Christudasan Devadasan
eeb7feb5e6
[AMDGPU] Define constrained multi-dword scalar load instructions. (#96161) 2024-07-23 13:36:22 +05:30
Carl Ritson
939a6624ac
[AMDGPU] Implement workaround for GFX11.5 export priority (#99273)
On GFX11.5 shaders having completed exports need to execute/wait at a
lower priority than shaders still executing exports.
Add code to maintain normal priority of 2 for shaders that export and
drop to priority 0 after exports.
2024-07-23 17:03:21 +09:00
Fangrui Song
c473e75ade MCAssmembler: Move ELFHeaderEFlags to ELFObjectWriter
Now that MCELFStreamer can access ELFObjectWriter (commit
70c52b62c5669993e341664a63bfbe5245e32884), we can move ELFHeaderEFlags
there.
2024-07-22 18:20:18 -07:00
Jeffrey Byrnes
03936534b5 [AMDGPU] Protect against null entries in ValMap
Change-Id: Icbda7c3fecf38679d06006986e5e17cb1f1b8749
2024-07-22 16:50:54 -07:00
Fangrui Song
70c52b62c5 [MC] Export llvm::ELFObjectWriter
Similar to commit 28fcafb50274be2520117eacb0a886adafefe59d (2011) for
MachObjectWriter and commit 9539a7796094ff5fb59d9c685140ea2e214b945c for
WinCOFFObjectWriter.

MCELFStreamer can now access ELFObjectWriter directly without adding
ELF-specific markGnuAbi (https://reviews.llvm.org/D97976) and
setOverrideABIVersion to MCObjectWriter.

A few member variables have to be made public since we cannot use a
friend declaration for ELFWriter.
2024-07-22 16:18:25 -07:00
Jessica Del
ec7f8e1113
[AMDGPU] Add intrinsic for raw atomic buffer loads (#97707)
Upstream the intrinsics `llvm.amdgcn.raw.atomic.buffer.load`
and `llvm.amdgcn.raw.atomic.ptr.buffer.load`.

These additional intrinsics mark atomic buffer loads
as atomic to LLVM by removing the `IntrReadMem`
attribute. Otherwise, it could hoist these
intrinsics out of loops in cases where LLVM marks
them as invariant. That can cause issues such as
infinite loops.

Continuation of https://reviews.llvm.org/D138786
with the additional use in the fat buffer lowering,
more test cases and the additional ptr versions 
of these intrinsics.

---------

Co-authored-by: rtayl <>
Co-authored-by: Jay Foad <jay.foad@amd.com>
Co-authored-by: Mariusz Sikora <mariusz.sikora@amd.com>
2024-07-22 18:04:49 +02:00
Joseph Huber
f39bd0a24e
[AMDGPU] Do not print kernel-resource-usage information on non-kernels (#99720)
Summary:
This pass is used to get helpful information about the kernel resources
without needing to insepct the binary. However, it currently prints on
every function. These values will always be zero, so it's just spam on
the terminal, at best an indication that a function wasn't internalized
/ optimized out. This patch makes it only print for kernels to make it
more useful in practice.
2024-07-22 07:07:51 -05:00
Christudasan Devadasan
15b41d207e
[CodeGen] change prototype of regalloc filter function (#93525)
[CodeGen] Change the prototype of regalloc filter function

Change the prototype of the filter function so that we can
filter not just by RegClass. We need to implement more
complicated filter based upon some other info associated
with each register.

Patch provided by: Gang Chen (gangc@amd.com)
2024-07-22 16:49:39 +05:30
Matt Arsenault
7b28cc0c59
AMDGPU: Query MachineModuleInfo from PM instead of MachineFunction (#99679) 2024-07-22 08:55:39 +04:00
Fangrui Song
6717dc5c47 *AsmBackend.cpp: Include StringSwitch.h
They currently get the header from MCLinkerOptimizationHint.h, which
will be removed from MCAssembler.h.
2024-07-21 11:17:19 -07:00
Fangrui Song
7f017f0ab4 [MC] Drop unnecessary MCSymbol::setExternal calls for ELF
Similar to e4c360a897fe062914519d331e8f1e28b2b1fbfd (2020).
2024-07-21 10:49:25 -07:00
Fangrui Song
8f14e39e59 [MC] Remove unnecessary isVerboseAsm from Target::AsmTargetStreamerCtorTy
The parameter is confusing as it duplicates MCStreamer::isVeboseAsm
(initialized from MCTargetOptions::AsmVerbose). After
233cca169237b91d16092c82bd55ee6a283afe98, no in-tree target uses the
parameter.
2024-07-21 10:19:17 -07:00
Carl Ritson
62aa596ba1
[AMDGPU] Add no return image_sample intrinsics and instructions (#97542)
An appropriately configured image resource descriptor can trigger
image_sample instructions to store outputs directly to a linked memory
location instead of returning to VGPRs.

This is opaque to the backend as instruction encoding is unchanged;
however, a mechanism is require to allow frontends to communicate that
these instructions do not require destination VGPRs and store to memory.
Flagging these as stores means they will not be optimized away.
2024-07-20 17:26:58 +09:00
Jeffrey Byrnes
6e68b75e66 [AMDGPU] Reland: Do not use original PHIs in coercion chains
Change-Id: I579b5c69a85997f168ed35354b326524b6f84ef7
2024-07-19 09:02:28 -07:00
Changpeng Fang
25f4bd8872
AMDGPU: Clear kill flags after FoldZeroHighBits (#99582)
After folding, all uses of the result register are going to be replaced
by the operand register. The kill flags on the uses of the result and
operand registers are no longer valid after the replacement, and need to
be cleared.
The only exception is, however, if the kill flag is set for the operand
register, we are sure the last use of the result register is the new
last use of the operand register, and thus we are safe to keep the kill
flags.
2024-07-19 00:46:37 -07:00
Changpeng Fang
e2c3cd7f3d
AMDGPU: Loop over the types for global_load_tr16 pats (NFC) (#99551) 2024-07-18 12:16:55 -07:00
Changpeng Fang
280d90d0fd
AMDGPU: Add back half and bfloat support for global_load_tr16 pats (#99540)
half and bfloat are common types for 16-bit elements. The support of
them was original there and dropped due to some reasons. This work adds
the support of the float types back.
2024-07-18 11:23:35 -07:00
Changpeng Fang
06ab30b574
[AMDGPU] Constant folding of llvm.amdgcn.trig.preop (#98562)
If the parameters(the input and segment select) coming in to
amdgcn.trig.preop intrinsic are compile time constants, we pre-compute
the output of amdgcn.trig.preop on the CPU and replaces the uses with
the computed constant.

This work extends the patch https://reviews.llvm.org/D120150 to make it
a complete coverage.

For the segment select, only src1[4:0] are used. A segment select is
invalid if we are selecting the 53-bit segment beyond the [1200:0] range
of the 2/PI table. 0 is returned when a segment select is not valid.
2024-07-18 09:40:37 -07:00
Jay Foad
27ec379f63
[AMDGPU] Do not select llvm.amdgcn.inverse.ballot with wrong wave size (#99470)
This produces a "cannot select" error, instead of failing later with an
illegal vgpr to sgpr copy.
2024-07-18 13:53:22 +01:00
Jay Foad
0ce3ea1bff
[AMDGPU] Simplify selection of llvm.amdgcn.inverse.ballot. NFCI. (#99345) 2024-07-18 07:45:13 +01:00
Jay Foad
63fae3ed65
[AMDGPU] clang-tidy: no else after return etc. NFC. (#99298) 2024-07-17 21:11:00 +01:00
Joseph Huber
351a4b27da [AMDGPU] Simplify alias stripping to use utility function 2024-07-17 10:11:53 -05:00
Carl Ritson
8d28a4102b
[AMDGPU] Remove SIWholeQuadMode pass early exit (#98450)
Merge the code bypass elements from the early exit into the main pass
execution flow.
2024-07-17 19:38:23 +09:00
Jay Foad
c7309dadbf
[AMDGPU] Use range-based for loops. NFC. (#99047) 2024-07-17 10:18:03 +01:00
Amara Emerson
f270a4dd66
[AArch64] Don't tail call memset if it would convert to a bzero. (#98969)
Well, not quite that simple. We can tc memset since it returns the first
argument but bzero doesn't do that and therefore we can end up
miscompiling.

This patch also refactors the logic out of isInTailCallPosition() into the callers.
As a result memcpy and memmove are also modified to do the same thing
for consistency.

rdar://131419786
2024-07-17 01:31:52 -07:00
Jay Foad
5e338f1f4a [AMDGPU] clang-tidy: use emplace_back instead of push_back. NFC. 2024-07-17 08:27:35 +01:00
Jay Foad
f10a78b7e4 [AMDGPU] clang-tidy: use std::make_unique. NFC. 2024-07-17 07:58:09 +01:00
Carl Ritson
befd44bcdc
[AMDGPU] Update hasUnwantedEffectsWhenEXECEmpty (#97982)
Add barriers and s_wait_event to hasUnwantedEffectsWhenEXECEmpty.
Add a comment documenting the current expected use of the function.
2024-07-17 11:30:44 +09:00
Jay Foad
74b87b02d2 [AMDGPU] Fix and add namespace closing comments. NFC. 2024-07-16 16:56:31 +01:00
Jay Foad
aeafdc21d2 [AMDGPU] Use using instead of typedef. NFC. 2024-07-16 16:44:12 +01:00
Jay Foad
0b43d573f5 [AMDGPU] clang-tidy: replace macro with enum. NFC. 2024-07-16 16:37:34 +01:00
Jay Foad
80d261493e [AMDGPU] clang-tidy: use override consistently. NFC. 2024-07-16 15:55:39 +01:00
Jay Foad
fdb669b0dc [AMDGPU] clang-format: pass Triple by value and std::move it. NFC. 2024-07-16 15:52:58 +01:00
Jay Foad
78dea4c1ea [AMDGPU] Use bool literals for bools. NFC. 2024-07-16 15:44:49 +01:00
Jay Foad
63a1242ae3 [AMDGPU] clang-tidy: define trivial constructors with = default. NFC. 2024-07-16 15:41:54 +01:00
Jay Foad
ff81bbede4 [AMDGPU] Concatenate nested namespaces. NFC. 2024-07-16 15:36:49 +01:00
Jay Foad
6bba44e8dc [AMDGPU] Use member initializers. NFC. 2024-07-16 15:29:10 +01:00
Jay Foad
38a1dec30b [AMDGPU] Use std::min with initializer list. NFC. 2024-07-16 15:25:08 +01:00
Jay Foad
c1fa62ba74 [AMDGPU] Sort #includes. NFC. 2024-07-16 15:22:10 +01:00
Jay Foad
b115edc86c [AMDGPU] Use std::is_same_v. NFC. 2024-07-16 15:14:07 +01:00
Jay Foad
d059497965 [AMDGPU] clang-tidy: use lambda instead of std::bind. NFC. 2024-07-16 15:08:48 +01:00
Joseph Huber
6dc8c2dada
[AMDGPU] Fix resource analysis crash on alias-to-alias function (#99034)
Summary:
Previously this code only looked through a single level of aliases to
find the underlying function. This patch changes it to continue until it
finds the end. Aliases that form a cycle are illegal IR, so we shouldn't
need to worry about infinite loops.

Fixes https://github.com/llvm/llvm-project/issues/96812
2024-07-16 08:34:18 -05:00