[llvm] d0e7714 - [AMDGPU] Error on non-global pointer with s_prefetch_data (#107624)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 11:14:31 PDT 2024
Author: Stanislav Mekhanoshin
Date: 2024-09-13T11:14:28-07:00
New Revision: d0e7714de73b8b657dca1706e676027d42bbb775
URL: https://github.com/llvm/llvm-project/commit/d0e7714de73b8b657dca1706e676027d42bbb775
DIFF: https://github.com/llvm/llvm-project/commit/d0e7714de73b8b657dca1706e676027d42bbb775.diff
LOG: [AMDGPU] Error on non-global pointer with s_prefetch_data (#107624)
Added:
llvm/test/Verifier/AMDGPU/intrinsic-prefetch.ll
Modified:
llvm/include/llvm/Support/AMDGPUAddrSpace.h
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.prefetch.data.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/AMDGPUAddrSpace.h b/llvm/include/llvm/Support/AMDGPUAddrSpace.h
index c9d9bdd2f2fa31..4a278d0acc23b8 100644
--- a/llvm/include/llvm/Support/AMDGPUAddrSpace.h
+++ b/llvm/include/llvm/Support/AMDGPUAddrSpace.h
@@ -81,6 +81,20 @@ enum : unsigned {
UNKNOWN_ADDRESS_SPACE = ~0u,
};
} // end namespace AMDGPUAS
+
+namespace AMDGPU {
+inline bool isFlatGlobalAddrSpace(unsigned AS) {
+ return AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS ||
+ AS == AMDGPUAS::CONSTANT_ADDRESS || AS > AMDGPUAS::MAX_AMDGPU_ADDRESS;
+}
+
+inline bool isExtendedGlobalAddrSpace(unsigned AS) {
+ return AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::CONSTANT_ADDRESS ||
+ AS == AMDGPUAS::CONSTANT_ADDRESS_32BIT ||
+ AS > AMDGPUAS::MAX_AMDGPU_ADDRESS;
+}
+} // end namespace AMDGPU
+
} // end namespace llvm
#endif // LLVM_SUPPORT_AMDGPUADDRSPACE_H
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index d8f3bab45b2a65..06a67346fbf959 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -114,6 +114,7 @@
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
+#include "llvm/Support/AMDGPUAddrSpace.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
@@ -6281,6 +6282,13 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
"Value for inactive lanes must be a VGPR function argument", &Call);
break;
}
+ case Intrinsic::amdgcn_s_prefetch_data: {
+ Check(
+ AMDGPU::isFlatGlobalAddrSpace(
+ Call.getArgOperand(0)->getType()->getPointerAddressSpace()),
+ "llvm.amdgcn.s.prefetch.data only supports global or constant memory");
+ break;
+ }
case Intrinsic::nvvm_setmaxnreg_inc_sync_aligned_u32:
case Intrinsic::nvvm_setmaxnreg_dec_sync_aligned_u32: {
Value *V = Call.getArgOperand(0);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 399aa9c633564c..07f9bbeb42029b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -461,20 +461,6 @@ enum TargetIndex {
TI_SCRATCH_RSRC_DWORD3
};
-// FIXME: Missing constant_32bit
-inline bool isFlatGlobalAddrSpace(unsigned AS) {
- return AS == AMDGPUAS::GLOBAL_ADDRESS ||
- AS == AMDGPUAS::FLAT_ADDRESS ||
- AS == AMDGPUAS::CONSTANT_ADDRESS ||
- AS > AMDGPUAS::MAX_AMDGPU_ADDRESS;
-}
-
-inline bool isExtendedGlobalAddrSpace(unsigned AS) {
- return AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::CONSTANT_ADDRESS ||
- AS == AMDGPUAS::CONSTANT_ADDRESS_32BIT ||
- AS > AMDGPUAS::MAX_AMDGPU_ADDRESS;
-}
-
static inline bool addrspacesMayAlias(unsigned AS1, unsigned AS2) {
static_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 9, "Addr space out of range");
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.prefetch.data.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.prefetch.data.ll
index 54c39d78adb583..b677f7863c14dc 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.prefetch.data.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.prefetch.data.ll
@@ -110,15 +110,6 @@ entry:
ret void
}
-define amdgpu_ps void @prefetch_data_sgpr_base_imm_len_local(ptr addrspace(3) inreg %ptr) {
-; GCN-LABEL: prefetch_data_sgpr_base_imm_len_local:
-; GCN: ; %bb.0: ; %entry
-; GCN-NEXT: s_endpgm
-entry:
- tail call void @llvm.amdgcn.s.prefetch.data.p3(ptr addrspace(3) %ptr, i32 31)
- ret void
-}
-
define amdgpu_ps void @prefetch_data_vgpr_base_imm_len(ptr addrspace(4) %ptr) {
; GCN-LABEL: prefetch_data_vgpr_base_imm_len:
; GCN: ; %bb.0: ; %entry
diff --git a/llvm/test/Verifier/AMDGPU/intrinsic-prefetch.ll b/llvm/test/Verifier/AMDGPU/intrinsic-prefetch.ll
new file mode 100644
index 00000000000000..1a7e949c31e2a1
--- /dev/null
+++ b/llvm/test/Verifier/AMDGPU/intrinsic-prefetch.ll
@@ -0,0 +1,8 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+define amdgpu_ps void @prefetch_data_sgpr_base_imm_len_local(ptr addrspace(3) inreg %ptr) {
+entry:
+ ; CHECK: llvm.amdgcn.s.prefetch.data only supports global or constant memory
+ tail call void @llvm.amdgcn.s.prefetch.data.p3(ptr addrspace(3) %ptr, i32 31)
+ ret void
+}
More information about the llvm-commits
mailing list