[PATCH] D19463: Thread TargetLibraryInfo through PHITransAddr.

Nick Lewycky via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 23 23:08:07 PDT 2016


nicholas created this revision.
nicholas added a subscriber: llvm-commits.
nicholas set the repository for this revision to rL LLVM.

PHITransAddr has a TargetLibraryInfo* member which it always sets to nullptr at construction. It has the logic to pass the TLI down to instruction simplify utility functions, but it doesn't take any value from the pass.

The attached pass simply adds the plumbing to the four callees, three of which have TLIs to pass in.

There is no testcase included, all the existing tests continue to pass. This change wasn't motivated by any example code, only by the "huh that's funny" of seeing the PHITransAddr constructor always set TLI to nullptr.

Repository:
  rL LLVM

http://reviews.llvm.org/D19463

Files:
  include/llvm/Analysis/PHITransAddr.h
  include/llvm/Transforms/Utils/MemorySSA.h
  lib/Analysis/MemoryDependenceAnalysis.cpp
  lib/Analysis/PHITransAddr.cpp
  lib/Transforms/Scalar/GVN.cpp

Index: lib/Transforms/Scalar/GVN.cpp
===================================================================
--- lib/Transforms/Scalar/GVN.cpp
+++ lib/Transforms/Scalar/GVN.cpp
@@ -1494,7 +1494,7 @@
     // If all preds have a single successor, then we know it is safe to insert
     // the load on the pred (?!?), so we can insert code to materialize the
     // pointer if it is not available.
-    PHITransAddr Address(LI->getPointerOperand(), DL, AC);
+    PHITransAddr Address(LI->getPointerOperand(), DL, TLI, AC);
     Value *LoadPtr = nullptr;
     LoadPtr = Address.PHITranslateWithInsertion(LoadBB, UnavailablePred,
                                                 *DT, NewInsts);
Index: lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- lib/Analysis/MemoryDependenceAnalysis.cpp
+++ lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -909,7 +909,7 @@
     return;
   }
   const DataLayout &DL = FromBB->getModule()->getDataLayout();
-  PHITransAddr Address(const_cast<Value *>(Loc.Ptr), DL, &AC);
+  PHITransAddr Address(const_cast<Value *>(Loc.Ptr), DL, &TLI, &AC);
 
   // This is the set of blocks we've inspected, and the pointer we consider in
   // each block.  Because of critical edges, we currently bail out if querying
Index: lib/Analysis/PHITransAddr.cpp
===================================================================
--- lib/Analysis/PHITransAddr.cpp
+++ lib/Analysis/PHITransAddr.cpp
@@ -371,7 +371,7 @@
                            SmallVectorImpl<Instruction*> &NewInsts) {
   // See if we have a version of this value already available and dominating
   // PredBB.  If so, there is no need to insert a new instance of it.
-  PHITransAddr Tmp(InVal, DL, AC);
+  PHITransAddr Tmp(InVal, DL, TLI, AC);
   if (!Tmp.PHITranslateValue(CurBB, PredBB, &DT, /*MustDominate=*/true))
     return Tmp.getAddr();
 
Index: include/llvm/Transforms/Utils/MemorySSA.h
===================================================================
--- include/llvm/Transforms/Utils/MemorySSA.h
+++ include/llvm/Transforms/Utils/MemorySSA.h
@@ -918,7 +918,8 @@
     if (WalkingPhi && Location.Ptr) {
       PHITransAddr Translator(
           const_cast<Value *>(Location.Ptr),
-          OriginalAccess->getBlock()->getModule()->getDataLayout(), nullptr);
+          OriginalAccess->getBlock()->getModule()->getDataLayout(), nullptr,
+          nullptr);
       if (!Translator.PHITranslateValue(OriginalAccess->getBlock(),
                                         DefIterator.getPhiArgBlock(), nullptr,
                                         false))
Index: include/llvm/Analysis/PHITransAddr.h
===================================================================
--- include/llvm/Analysis/PHITransAddr.h
+++ include/llvm/Analysis/PHITransAddr.h
@@ -50,8 +50,9 @@
   SmallVector<Instruction*, 4> InstInputs;
 
 public:
-  PHITransAddr(Value *addr, const DataLayout &DL, AssumptionCache *AC)
-      : Addr(addr), DL(DL), TLI(nullptr), AC(AC) {
+  PHITransAddr(Value *addr, const DataLayout &DL, const TargetLibraryInfo *TLI,
+               AssumptionCache *AC)
+      : Addr(addr), DL(DL), TLI(TLI), AC(AC) {
     // If the address is an instruction, the whole thing is considered an input.
     if (Instruction *I = dyn_cast<Instruction>(Addr))
       InstInputs.push_back(I);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19463.54793.patch
Type: text/x-patch
Size: 3335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160424/3ec0e3f3/attachment.bin>


More information about the llvm-commits mailing list