[PM/AA] Remove two no-op overridden functions that just delegated to the
[oota-llvm.git] / include / llvm / Analysis / PHITransAddr.h
index ed5ddcae2800f1f748776d2982fbdb30f48bf54d..cbdbb88f740711d4ad240425d8a7a7b9a6b5b5f5 100644 (file)
 #ifndef LLVM_ANALYSIS_PHITRANSADDR_H
 #define LLVM_ANALYSIS_PHITRANSADDR_H
 
-#include "llvm/Instruction.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/Instruction.h"
 
 namespace llvm {
+  class AssumptionCache;
   class DominatorTree;
-  class TargetData;
-  
+  class DataLayout;
+  class TargetLibraryInfo;
+
 /// PHITransAddr - An address value which tracks and handles phi translation.
 /// As we walk "up" the CFG through predecessors, we need to ensure that the
 /// address we're tracking is kept up to date.  For example, if we're analyzing
@@ -34,19 +36,28 @@ namespace llvm {
 class PHITransAddr {
   /// Addr - The actual address we're analyzing.
   Value *Addr;
-  
-  /// TD - The target data we are playing with if known, otherwise null.
-  const TargetData *TD;
-  
+
+  /// The DataLayout we are playing with.
+  const DataLayout &DL;
+
+  /// TLI - The target library info if known, otherwise null.
+  const TargetLibraryInfo *TLI;
+
+  /// A cache of @llvm.assume calls used by SimplifyInstruction.
+  AssumptionCache *AC;
+
   /// InstInputs - The inputs for our symbolic address.
   SmallVector<Instruction*, 4> InstInputs;
 public:
-  PHITransAddr(Value *addr, const TargetData *td) : Addr(addr), TD(td) {
+  PHITransAddr(Value *addr, const DataLayout &DL, AssumptionCache *AC)
+      : Addr(addr), DL(DL), TLI(nullptr), 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);
   }
   
+  Value *getAddr() const { return Addr; }
+  
   /// NeedsPHITranslationFromBlock - Return true if moving from the specified
   /// BasicBlock to its predecessors requires PHI translation.
   bool NeedsPHITranslationFromBlock(BasicBlock *BB) const {
@@ -64,10 +75,12 @@ public:
   bool IsPotentiallyPHITranslatable() const;
   
   /// PHITranslateValue - PHI translate the current address up the CFG from
-  /// CurBB to Pred, updating our state the reflect any needed changes.  This
-  /// returns true on failure.
-  bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB);
-  
+  /// CurBB to Pred, updating our state to reflect any needed changes.  If
+  /// 'MustDominate' is true, the translated value must dominate
+  /// PredBB.  This returns true on failure and sets Addr to null.
+  bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB,
+                         const DominatorTree *DT, bool MustDominate);
+
   /// PHITranslateWithInsertion - PHI translate this value into the specified
   /// predecessor block, inserting a computation of the value if it is
   /// unavailable.
@@ -78,15 +91,16 @@ public:
   Value *PHITranslateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB,
                                    const DominatorTree &DT,
                                    SmallVectorImpl<Instruction*> &NewInsts);
-private:
-  Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB);
   
+  void dump() const;
   
-  /// GetAvailablePHITranslatedSubExpr - Return the value computed by
-  /// PHITranslateSubExpr if it dominates PredBB, otherwise return null.
-  Value *GetAvailablePHITranslatedSubExpr(Value *V,
-                                          BasicBlock *CurBB, BasicBlock *PredBB,
-                                          const DominatorTree &DT);
+  /// Verify - Check internal consistency of this data structure.  If the
+  /// structure is valid, it returns true.  If invalid, it prints errors and
+  /// returns false.
+  bool Verify() const;
+private:
+  Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB,
+                             const DominatorTree *DT);
   
   /// InsertPHITranslatedSubExpr - Insert a computation of the PHI translated
   /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
@@ -96,6 +110,15 @@ private:
   Value *InsertPHITranslatedSubExpr(Value *InVal, BasicBlock *CurBB,
                                     BasicBlock *PredBB, const DominatorTree &DT,
                                     SmallVectorImpl<Instruction*> &NewInsts);
+  
+  /// AddAsInput - If the specified value is an instruction, add it as an input.
+  Value *AddAsInput(Value *V) {
+    // If V is an instruction, it is now an input.
+    if (Instruction *VI = dyn_cast<Instruction>(V))
+      InstInputs.push_back(VI);
+    return V;
+  }
+  
 };
 
 } // end namespace llvm