Skip to content

Conversation

@shiltian
Copy link
Contributor

This has been moved to DataLayout.

@shiltian shiltian marked this pull request as ready for review September 16, 2024 03:09
Copy link
Contributor Author

shiltian commented Sep 16, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @shiltian and the rest of your teammates on Graphite Graphite

@llvmbot
Copy link
Member

llvmbot commented Sep 16, 2024

@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-amdgpu
@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-backend-nvptx

Author: Shilei Tian (shiltian)

Changes

This has been moved to DataLayout.


Full diff: https://github.com/llvm/llvm-project/pull/108787.diff

7 Files Affected:

  • (modified) llvm/include/llvm/Analysis/TargetTransformInfo.h (-21)
  • (modified) llvm/include/llvm/Analysis/TargetTransformInfoImpl.h (-2)
  • (modified) llvm/include/llvm/CodeGen/BasicTTIImpl.h (-5)
  • (modified) llvm/lib/Analysis/TargetTransformInfo.cpp (-4)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h (-8)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h (-4)
  • (modified) llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp (+1-1)
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index b2124c6106198e..e5986225b6fc32 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -451,24 +451,6 @@ class TargetTransformInfo {
   /// Return false if a \p AS0 address cannot possibly alias a \p AS1 address.
   bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const;
 
-  /// Returns the address space ID for a target's 'flat' address space. Note
-  /// this is not necessarily the same as addrspace(0), which LLVM sometimes
-  /// refers to as the generic address space. The flat address space is a
-  /// generic address space that can be used access multiple segments of memory
-  /// with different address spaces. Access of a memory location through a
-  /// pointer with this address space is expected to be legal but slower
-  /// compared to the same memory location accessed through a pointer with a
-  /// different address space.
-  //
-  /// This is for targets with different pointer representations which can
-  /// be converted with the addrspacecast instruction. If a pointer is converted
-  /// to this address space, optimizations should attempt to replace the access
-  /// with the source address space.
-  ///
-  /// \returns ~0u if the target does not have such a flat address space to
-  /// optimize away.
-  unsigned getFlatAddressSpace() const;
-
   /// Return any intrinsic address operand indexes which may be rewritten if
   /// they use a flat address space pointer.
   ///
@@ -1836,7 +1818,6 @@ class TargetTransformInfo::Concept {
   virtual bool isAlwaysUniform(const Value *V) = 0;
   virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const = 0;
   virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const = 0;
-  virtual unsigned getFlatAddressSpace() = 0;
   virtual bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                           Intrinsic::ID IID) const = 0;
   virtual bool isNoopAddrSpaceCast(unsigned FromAS, unsigned ToAS) const = 0;
@@ -2263,8 +2244,6 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
     return Impl.addrspacesMayAlias(AS0, AS1);
   }
 
-  unsigned getFlatAddressSpace() override { return Impl.getFlatAddressSpace(); }
-
   bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                   Intrinsic::ID IID) const override {
     return Impl.collectFlatAddressOperands(OpIndexes, IID);
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 90eef93a2a54d5..192a1c15347dc7 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -115,8 +115,6 @@ class TargetTransformInfoImplBase {
     return true;
   }
 
-  unsigned getFlatAddressSpace() const { return -1; }
-
   bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                   Intrinsic::ID IID) const {
     return false;
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 50dc7d5c54c54a..05b0e5844ac5d5 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -292,11 +292,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
     return true;
   }
 
-  unsigned getFlatAddressSpace() {
-    // Return an invalid address space.
-    return -1;
-  }
-
   bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                   Intrinsic::ID IID) const {
     return false;
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 2c26493bd3f1ca..5eb6be7a362cb5 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -305,10 +305,6 @@ bool llvm::TargetTransformInfo::addrspacesMayAlias(unsigned FromAS,
   return TTIImpl->addrspacesMayAlias(FromAS, ToAS);
 }
 
-unsigned TargetTransformInfo::getFlatAddressSpace() const {
-  return TTIImpl->getFlatAddressSpace();
-}
-
 bool TargetTransformInfo::collectFlatAddressOperands(
     SmallVectorImpl<int> &OpIndexes, Intrinsic::ID IID) const {
   return TTIImpl->collectFlatAddressOperands(OpIndexes, IID);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
index 01df2e6caaba1d..6f32e439231273 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
@@ -200,14 +200,6 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
     return AMDGPU::addrspacesMayAlias(AS0, AS1);
   }
 
-  unsigned getFlatAddressSpace() const {
-    // Don't bother running InferAddressSpaces pass on graphics shaders which
-    // don't use flat addressing.
-    if (IsGraphics)
-      return -1;
-    return AMDGPUAS::FLAT_ADDRESS;
-  }
-
   bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                   Intrinsic::ID IID) const;
 
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h b/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
index 4160f5f6bfae76..fd03b565ccf917 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
@@ -45,10 +45,6 @@ class NVPTXTTIImpl : public BasicTTIImplBase<NVPTXTTIImpl> {
 
   bool isSourceOfDivergence(const Value *V);
 
-  unsigned getFlatAddressSpace() const {
-    return AddressSpace::ADDRESS_SPACE_GENERIC;
-  }
-
   bool canHaveNonUndefGlobalInitializerInAddressSpace(unsigned AS) const {
     return AS != AddressSpace::ADDRESS_SPACE_SHARED &&
            AS != AddressSpace::ADDRESS_SPACE_LOCAL && AS != ADDRESS_SPACE_PARAM;
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 566cdc51f6e74a..6a40d661035a9b 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -854,7 +854,7 @@ bool InferAddressSpacesImpl::run(Function &CurFn) {
     FlatAddrSpace = 0;
 
   if (FlatAddrSpace == UninitializedAddressSpace) {
-    FlatAddrSpace = TTI->getFlatAddressSpace();
+    FlatAddrSpace = DL->getFlatAddressSpace();
     if (FlatAddrSpace == UninitializedAddressSpace)
       return false;
   }

@arsenm
Copy link
Contributor

arsenm commented Sep 16, 2024

Needs RFC

@shiltian
Copy link
Contributor Author

@shiltian shiltian force-pushed the users/shiltian/data-layout-flat-address-space branch 4 times, most recently from feadf29 to a4187bb Compare September 18, 2024 02:22
@shiltian shiltian force-pushed the users/shiltian/remove-get-flat-as-from-tti branch from 8db0d52 to f2331fc Compare September 18, 2024 02:22
@shiltian shiltian force-pushed the users/shiltian/data-layout-flat-address-space branch from a4187bb to 7b6a66d Compare September 18, 2024 14:27
@shiltian shiltian force-pushed the users/shiltian/remove-get-flat-as-from-tti branch from f2331fc to ad6ff10 Compare September 18, 2024 14:28
@shiltian shiltian force-pushed the users/shiltian/data-layout-flat-address-space branch 2 times, most recently from 4d86d8d to 3052d9a Compare September 18, 2024 17:09
@shiltian shiltian force-pushed the users/shiltian/remove-get-flat-as-from-tti branch from ad6ff10 to 3541dca Compare September 18, 2024 17:09
@shiltian shiltian force-pushed the users/shiltian/data-layout-flat-address-space branch from 3052d9a to cad9ac7 Compare September 18, 2024 18:48
@shiltian shiltian force-pushed the users/shiltian/remove-get-flat-as-from-tti branch from 3541dca to e6fb6d5 Compare September 18, 2024 18:49
This has been moved to `DataLayout`.
@shiltian shiltian force-pushed the users/shiltian/data-layout-flat-address-space branch from cad9ac7 to c2be824 Compare October 14, 2024 19:30
@shiltian shiltian force-pushed the users/shiltian/remove-get-flat-as-from-tti branch from e6fb6d5 to 180bf13 Compare October 14, 2024 19:30
@shiltian
Copy link
Contributor Author

The dependent PR has been closed.

@shiltian shiltian closed this Oct 27, 2024
@shiltian shiltian deleted the users/shiltian/remove-get-flat-as-from-tti branch October 27, 2024 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AMDGPU backend:NVPTX llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants