[PATCH] D60602: [InferAddressSpaces] Add AS parameter to the pass factory

Kévin Petit via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 02:41:20 PDT 2019


kpet created this revision.
kpet added a reviewer: arsenm.
Herald added subscribers: llvm-commits, kristof.beyls, javed.absar, wdng.
Herald added a project: LLVM.

This enables the pass to be used in the absence of
TargetTransformInfo. When the argument isn't passed,
the factory defaults to UninitializedAddressSpace and
the flat address space is obtained from the
TargetTransformInfo as before this change. Existing
users won't have to change.

Signed-off-by: Kevin Petit <kevin.petit at arm.com>


Repository:
  rL LLVM

https://reviews.llvm.org/D60602

Files:
  include/llvm/Transforms/Scalar.h
  lib/Transforms/Scalar/InferAddressSpaces.cpp


Index: lib/Transforms/Scalar/InferAddressSpaces.cpp
===================================================================
--- lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -148,7 +148,9 @@
 public:
   static char ID;
 
-  InferAddressSpaces() : FunctionPass(ID) {}
+  InferAddressSpaces() :
+    FunctionPass(ID), FlatAddrSpace(UninitializedAddressSpace) {}
+  InferAddressSpaces(unsigned AS) : FunctionPass(ID), FlatAddrSpace(AS) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.setPreservesCFG();
@@ -624,9 +626,13 @@
 
   const TargetTransformInfo &TTI =
       getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
-  FlatAddrSpace = TTI.getFlatAddressSpace();
-  if (FlatAddrSpace == UninitializedAddressSpace)
-    return false;
+
+  if (FlatAddrSpace == UninitializedAddressSpace) {
+
+    FlatAddrSpace = TTI.getFlatAddressSpace();
+    if (FlatAddrSpace == UninitializedAddressSpace)
+      return false;
+  }
 
   // Collects all flat address expressions in postorder.
   std::vector<WeakTrackingVH> Postorder = collectFlatAddressExpressions(F);
@@ -1018,6 +1024,6 @@
   return true;
 }
 
-FunctionPass *llvm::createInferAddressSpacesPass() {
-  return new InferAddressSpaces();
+FunctionPass *llvm::createInferAddressSpacesPass(unsigned AS) {
+  return new InferAddressSpaces(AS);
 }
Index: include/llvm/Transforms/Scalar.h
===================================================================
--- include/llvm/Transforms/Scalar.h
+++ include/llvm/Transforms/Scalar.h
@@ -381,7 +381,7 @@
 // in the source address space if using the destination address space is slower
 // on the target.
 //
-FunctionPass *createInferAddressSpacesPass();
+FunctionPass *createInferAddressSpacesPass(unsigned AS = ~0u);
 extern char &InferAddressSpacesID;
 
 //===----------------------------------------------------------------------===//


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60602.194822.patch
Type: text/x-patch
Size: 1909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190412/084366c8/attachment.bin>


More information about the llvm-commits mailing list