add ability for clients of SSAUpdater to find out about the
authorChris Lattner <sabre@nondot.org>
Sat, 10 Oct 2009 23:15:24 +0000 (23:15 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 10 Oct 2009 23:15:24 +0000 (23:15 +0000)
PHI nodes inserted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83744 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/Utils/SSAUpdater.h
lib/Transforms/Utils/SSAUpdater.cpp

index 8af50e35d1b40229a1ffb36e2527d414de663a95..c697d048f1f911c91bd558cb529818e40608aa86 100644 (file)
@@ -18,6 +18,9 @@ namespace llvm {
   class Value;
   class BasicBlock;
   class Use;
+  class PHINode;
+  template<typename T>
+  class SmallVectorImpl;
   
 /// SSAUpdater - This class updates SSA form for a set of values defined in
 /// multiple blocks.  This is used when code duplication or another unstructured
@@ -40,8 +43,14 @@ class SSAUpdater {
   /// should be empty.
   //std::vector<std::pair<BasicBlock*, TrackingVH<Value> > > IncomingPredInfo;
   void *IPI;
+  
+  /// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that
+  /// it creates to the vector.
+  SmallVectorImpl<PHINode*> *InsertedPHIs;
 public:
-  SSAUpdater();
+  /// SSAUpdater constructor.  If InsertedPHIs is specified, it will be filled
+  /// in with all PHI Nodes created by rewriting.
+  SSAUpdater(SmallVectorImpl<PHINode*> *InsertedPHIs = 0);
   ~SSAUpdater();
   
   /// Initialize - Reset this object to get ready for a new set of SSA
index 294d9aa61e0b4c94b294667be5df8cdf2b91f5d0..2fb742bb4459c206773f9ee55fa20f62d908606c 100644 (file)
@@ -33,7 +33,8 @@ static IncomingPredInfoTy &getIncomingPredInfo(void *IPI) {
 }
 
 
-SSAUpdater::SSAUpdater() : AV(0), PrototypeValue(0), IPI(0) {}
+SSAUpdater::SSAUpdater(SmallVectorImpl<PHINode*> *NewPHI)
+  : AV(0), PrototypeValue(0), IPI(0), InsertedPHIs(NewPHI) {}
 
 SSAUpdater::~SSAUpdater() {
   delete &getAvailableVals(AV);
@@ -158,6 +159,10 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
     InsertedPHI->eraseFromParent();
     return ConstVal;
   }
+
+  // If the client wants to know about all new instructions, tell it.
+  if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI);
+  
   DEBUG(errs() << "  Inserted PHI: " << *InsertedPHI << "\n");
   return InsertedPHI;
 }
@@ -313,6 +318,9 @@ Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) {
     InsertedVal = ConstVal;
   } else {
     DEBUG(errs() << "  Inserted PHI: " << *InsertedPHI << "\n");
+    
+    // If the client wants to know about all new instructions, tell it.
+    if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI);
   }
   
   return InsertedVal;