Skip to content

Commit 168149a

Browse files
committed
Only enable "fancy" stuff fof amdgcnspirv for now.
1 parent ab1fb66 commit 168149a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ enum AddressSpace {
108108
};
109109

110110
unsigned SPIRVTargetMachine::getAssumedAddrSpace(const Value *V) const {
111+
// TODO: we only enable this for AMDGCN flavoured SPIR-V, where we know it to
112+
// be correct; this might be relaxed in the future.
113+
if (getTargetTriple().getVendor() != Triple::VendorType::AMD)
114+
return UINT32_MAX;
115+
111116
const auto *LD = dyn_cast<LoadInst>(V);
112117
if (!LD)
113118
return UINT32_MAX;
@@ -127,6 +132,13 @@ unsigned SPIRVTargetMachine::getAssumedAddrSpace(const Value *V) const {
127132

128133
std::pair<const Value *, unsigned>
129134
SPIRVTargetMachine::getPredicatedAddrSpace(const Value *V) const {
135+
// TODO: this is only enabled for AMDGCN flavoured SPIR-V at the moment, where
136+
// we can rely on the intrinsics being available; we should re-implement it on
137+
// top of SPIR-V specific intrinsics if/when they are added or
138+
// OpGenericCastToPtrExplicit / OpGenericPtrMemSemantics directly.
139+
if (getTargetTriple().getVendor() != Triple::VendorType::AMD)
140+
return std::pair(nullptr, UINT32_MAX);
141+
130142
using namespace PatternMatch;
131143

132144
if (auto *II = dyn_cast<IntrinsicInst>(V)) {

llvm/test/Transforms/InferAddressSpaces/SPIRV/assumed-addrspace.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
; RUN: opt -S -mtriple=spirv32-- -passes=infer-address-spaces -o - %s | FileCheck %s
2-
; RUN: opt -S -mtriple=spirv64-- -passes=infer-address-spaces -o - %s | FileCheck %s
1+
; RUN: opt -S -mtriple=spirv64-amd-amdhsa -passes=infer-address-spaces -o - %s | FileCheck %s
32

43
@c0 = addrspace(2) global ptr undef
54

0 commit comments

Comments
 (0)