Skip to content

Commit 180bf13

Browse files
committed
[TargetTransformInfo] Remove getFlatAddressSpace
This has been moved to `DataLayout`.
1 parent c2be824 commit 180bf13

File tree

11 files changed

+7
-50
lines changed

11 files changed

+7
-50
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -454,24 +454,6 @@ class TargetTransformInfo {
454454
/// Return false if a \p AS0 address cannot possibly alias a \p AS1 address.
455455
bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const;
456456

457-
/// Returns the address space ID for a target's 'flat' address space. Note
458-
/// this is not necessarily the same as addrspace(0), which LLVM sometimes
459-
/// refers to as the generic address space. The flat address space is a
460-
/// generic address space that can be used access multiple segments of memory
461-
/// with different address spaces. Access of a memory location through a
462-
/// pointer with this address space is expected to be legal but slower
463-
/// compared to the same memory location accessed through a pointer with a
464-
/// different address space.
465-
//
466-
/// This is for targets with different pointer representations which can
467-
/// be converted with the addrspacecast instruction. If a pointer is converted
468-
/// to this address space, optimizations should attempt to replace the access
469-
/// with the source address space.
470-
///
471-
/// \returns ~0u if the target does not have such a flat address space to
472-
/// optimize away.
473-
unsigned getFlatAddressSpace() const;
474-
475457
/// Return any intrinsic address operand indexes which may be rewritten if
476458
/// they use a flat address space pointer.
477459
///
@@ -1870,7 +1852,6 @@ class TargetTransformInfo::Concept {
18701852
virtual bool isAlwaysUniform(const Value *V) = 0;
18711853
virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const = 0;
18721854
virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const = 0;
1873-
virtual unsigned getFlatAddressSpace() = 0;
18741855
virtual bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
18751856
Intrinsic::ID IID) const = 0;
18761857
virtual bool isNoopAddrSpaceCast(unsigned FromAS, unsigned ToAS) const = 0;
@@ -2312,8 +2293,6 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
23122293
return Impl.addrspacesMayAlias(AS0, AS1);
23132294
}
23142295

2315-
unsigned getFlatAddressSpace() override { return Impl.getFlatAddressSpace(); }
2316-
23172296
bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
23182297
Intrinsic::ID IID) const override {
23192298
return Impl.collectFlatAddressOperands(OpIndexes, IID);

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ class TargetTransformInfoImplBase {
120120
return true;
121121
}
122122

123-
unsigned getFlatAddressSpace() const { return -1; }
124-
125123
bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
126124
Intrinsic::ID IID) const {
127125
return false;

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
292292
return true;
293293
}
294294

295-
unsigned getFlatAddressSpace() {
296-
// Return an invalid address space.
297-
return -1;
298-
}
299-
300295
bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
301296
Intrinsic::ID IID) const {
302297
return false;

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,6 @@ bool llvm::TargetTransformInfo::addrspacesMayAlias(unsigned FromAS,
313313
return TTIImpl->addrspacesMayAlias(FromAS, ToAS);
314314
}
315315

316-
unsigned TargetTransformInfo::getFlatAddressSpace() const {
317-
return TTIImpl->getFlatAddressSpace();
318-
}
319-
320316
bool TargetTransformInfo::collectFlatAddressOperands(
321317
SmallVectorImpl<int> &OpIndexes, Intrinsic::ID IID) const {
322318
return TTIImpl->collectFlatAddressOperands(OpIndexes, IID);

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,6 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
199199
return AMDGPU::addrspacesMayAlias(AS0, AS1);
200200
}
201201

202-
unsigned getFlatAddressSpace() const {
203-
// Don't bother running InferAddressSpaces pass on graphics shaders which
204-
// don't use flat addressing.
205-
if (IsGraphics)
206-
return -1;
207-
return AMDGPUAS::FLAT_ADDRESS;
208-
}
209-
210202
bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
211203
Intrinsic::ID IID) const;
212204

llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ class NVPTXTTIImpl : public BasicTTIImplBase<NVPTXTTIImpl> {
4545

4646
bool isSourceOfDivergence(const Value *V);
4747

48-
unsigned getFlatAddressSpace() const {
49-
return AddressSpace::ADDRESS_SPACE_GENERIC;
50-
}
51-
5248
bool canHaveNonUndefGlobalInitializerInAddressSpace(unsigned AS) const {
5349
return AS != AddressSpace::ADDRESS_SPACE_SHARED &&
5450
AS != AddressSpace::ADDRESS_SPACE_LOCAL && AS != ADDRESS_SPACE_PARAM;

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,10 @@ bool InferAddressSpacesImpl::run(Function &CurFn) {
870870
FlatAddrSpace = 0;
871871

872872
if (FlatAddrSpace == UninitializedAddressSpace) {
873-
FlatAddrSpace = TTI->getFlatAddressSpace();
874-
if (FlatAddrSpace == UninitializedAddressSpace)
873+
if (!DL->getFlatAddressSpace().has_value())
875874
return false;
875+
FlatAddrSpace = DL->getFlatAddressSpace().value();
876+
assert(FlatAddrSpace != UninitializedAddressSpace);
876877
}
877878

878879
// Collects all flat address expressions in postorder.

llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -o - -passes=infer-address-spaces %s | FileCheck -check-prefixes=COMMON,AMDGCN %s
22
; RUN: opt -S -o - -passes=infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck -check-prefixes=COMMON,NOTTI %s
33

4-
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7:8"
4+
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7:8-T0"
55

66
; COMMON-LABEL: @noop_ptrint_pair(
77
; AMDGCN-NEXT: store i32 0, ptr addrspace(1) %{{.*}}

llvm/test/Transforms/InferAddressSpaces/AMDGPU/old-pass-regressions-inseltpoison.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -data-layout=A5 -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces %s | FileCheck %s
1+
; RUN: opt -data-layout=A5-T0 -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces %s | FileCheck %s
22

33
; Regression tests from old HSAIL addrspacecast optimization pass
44

llvm/test/Transforms/InferAddressSpaces/AMDGPU/old-pass-regressions.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -data-layout=A5 -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces %s | FileCheck %s
1+
; RUN: opt -data-layout=A5-T0 -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces %s | FileCheck %s
22

33
; Regression tests from old HSAIL addrspacecast optimization pass
44

0 commit comments

Comments
 (0)