[llvm-commits] CVS: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp CloneTrace.cpp CodeExtractor.cpp InlineFunction.cpp SimplifyCFG.cpp

Reid Spencer reid at x10sys.com
Wed Sep 15 10:06:53 PDT 2004



Changes in directory llvm/lib/Transforms/Utils:

BreakCriticalEdges.cpp updated: 1.23 -> 1.24
CloneTrace.cpp updated: 1.8 -> 1.9
CodeExtractor.cpp updated: 1.31 -> 1.32
InlineFunction.cpp updated: 1.26 -> 1.27
SimplifyCFG.cpp updated: 1.51 -> 1.52
---
Log message:

Convert code to compile with vc7.1.

Patch contributed by Paolo Invernizzi. Thanks Paolo!


---
Diffs of the changes:  (+41 -31)

Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.23 llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.24
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.23	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp	Wed Sep 15 12:06:42 2004
@@ -118,8 +118,8 @@
   // If there are any PHI nodes in DestBB, we need to update them so that they
   // merge incoming values from NewBB instead of from TIBB.
   //
-  for (BasicBlock::iterator I = DestBB->begin();
-       PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+  for (BasicBlock::iterator I = DestBB->begin(); isa<PHINode>(I); ++I) {
+    PHINode *PN = cast<PHINode>(I);
     // We no longer enter through TIBB, now we come in through NewBB.  Revector
     // exactly one entry in the PHI node that used to come from TIBB to come
     // from NewBB.


Index: llvm/lib/Transforms/Utils/CloneTrace.cpp
diff -u llvm/lib/Transforms/Utils/CloneTrace.cpp:1.8 llvm/lib/Transforms/Utils/CloneTrace.cpp:1.9
--- llvm/lib/Transforms/Utils/CloneTrace.cpp:1.8	Thu Jul 29 12:21:57 2004
+++ llvm/lib/Transforms/Utils/CloneTrace.cpp	Wed Sep 15 12:06:42 2004
@@ -50,16 +50,17 @@
     //only do this if we are NOT the first block
     if(T != origTrace.begin()) {
       for (BasicBlock::iterator I = clonedBlock->begin();
-	   PHINode *PN = dyn_cast<PHINode>(I); ++I) {
-	//get incoming value for the previous BB
-	Value *V = PN->getIncomingValueForBlock(*(T-1));
-	assert(V && "No incoming value from a BasicBlock in our trace!");
-	
-	//remap our phi node to point to incoming value
-	ValueMap[*&I] = V;
-	
-	//remove phi node
-	clonedBlock->getInstList().erase(PN);
+           isa<PHINode>(I); ++I) {
+        PHINode *PN = cast<PHINode>(I);
+        //get incoming value for the previous BB
+        Value *V = PN->getIncomingValueForBlock(*(T-1));
+        assert(V && "No incoming value from a BasicBlock in our trace!");
+        
+        //remap our phi node to point to incoming value
+        ValueMap[*&I] = V;
+        
+        //remove phi node
+        clonedBlock->getInstList().erase(PN);
       }
     }
   }


Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.31 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.32
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.31	Wed Sep  1 17:55:36 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp	Wed Sep 15 12:06:42 2004
@@ -166,8 +166,8 @@
 
     // Okay, everthing within the region is now branching to the right block, we
     // just have to update the PHI nodes now, inserting PHI nodes into NewBB.
-    for (AfterPHIs = OldPred->begin();
-         PHINode *PN = dyn_cast<PHINode>(AfterPHIs); ++AfterPHIs) {
+    for (AfterPHIs = OldPred->begin(); isa<PHINode>(AfterPHIs); ++AfterPHIs) {
+      PHINode *PN = cast<PHINode>(AfterPHIs);
       // Create a new PHI node in the new region, which has an incoming value
       // from OldPred of PN.
       PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".ce",
@@ -644,20 +644,21 @@
 
   // Loop over all of the PHI nodes in the header block, and change any
   // references to the old incoming edge to be the new incoming edge.
-  for (BasicBlock::iterator I = header->begin();
-       PHINode *PN = dyn_cast<PHINode>(I); ++I)
+  for (BasicBlock::iterator I = header->begin(); isa<PHINode>(I); ++I) {
+    PHINode *PN = cast<PHINode>(I);
     for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
       if (!BlocksToExtract.count(PN->getIncomingBlock(i)))
         PN->setIncomingBlock(i, newFuncRoot);
-
+  }
+  
   // Look at all successors of the codeReplacer block.  If any of these blocks
   // had PHI nodes in them, we need to update the "from" block to be the code
   // replacer, not the original block in the extracted region.
   std::vector<BasicBlock*> Succs(succ_begin(codeReplacer),
                                  succ_end(codeReplacer));
   for (unsigned i = 0, e = Succs.size(); i != e; ++i)
-    for (BasicBlock::iterator I = Succs[i]->begin();
-         PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+    for (BasicBlock::iterator I = Succs[i]->begin(); isa<PHINode>(I); ++I) {
+      PHINode *PN = cast<PHINode>(I);
       std::set<BasicBlock*> ProcessedPreds;
       for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
         if (BlocksToExtract.count(PN->getIncomingBlock(i)))


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.26 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.27
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.26	Tue Jul 20 00:45:24 2004
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp	Wed Sep 15 12:06:42 2004
@@ -111,10 +111,11 @@
     // If there are PHI nodes in the exceptional destination block, we need to
     // keep track of which values came into them from this invoke, then remove
     // the entry for this block.
-    for (BasicBlock::iterator I = InvokeDest->begin();
-         PHINode *PN = dyn_cast<PHINode>(I); ++I)
+    for (BasicBlock::iterator I = InvokeDest->begin(); isa<PHINode>(I); ++I) {
+      PHINode *PN = cast<PHINode>(I);
       // Save the value to use for this edge...
       InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(OrigBB));
+    }
 
     for (Function::iterator BB = FirstNewBlock, E = Caller->end();
          BB != E; ++BB) {
@@ -149,8 +150,10 @@
             // there is now a new entry in them.
             unsigned i = 0;
             for (BasicBlock::iterator I = InvokeDest->begin();
-                 PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i)
+                 isa<PHINode>(I); ++I, ++i) {
+              PHINode *PN = cast<PHINode>(I);
               PN->addIncoming(InvokeDestPHIValues[i], BB);
+            }
             
             // This basic block is now complete, start scanning the next one.
             break;
@@ -174,8 +177,10 @@
         // there is now a new entry in them.
         unsigned i = 0;
         for (BasicBlock::iterator I = InvokeDest->begin();
-             PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i)
+             isa<PHINode>(I); ++I, ++i) {
+          PHINode *PN = cast<PHINode>(I);
           PN->addIncoming(InvokeDestPHIValues[i], BB);
+        }
       }
     }
 


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.51 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.52
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.51	Fri Sep  3 13:19:51 2004
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Wed Sep 15 12:06:42 2004
@@ -52,8 +52,8 @@
     if (std::find(BBPreds.begin(), BBPreds.end(), *PI) != BBPreds.end()) {
       // Loop over all of the PHI nodes checking to see if there are
       // incompatible values coming in.
-      for (BasicBlock::iterator I = Succ->begin();
-           PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+      for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) {
+        PHINode *PN = cast<PHINode>(I);
         // Loop up the entries in the PHI node for BB and for *PI if the values
         // coming in are non-equal, we cannot merge these two blocks (instead we
         // should insert a conditional move or something, then merge the
@@ -68,8 +68,8 @@
     }
 
   // Loop over all of the PHI nodes in the successor BB.
-  for (BasicBlock::iterator I = Succ->begin();
-       PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+  for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) {
+    PHINode *PN = cast<PHINode>(I);
     Value *OldVal = PN->removeIncomingValue(BB, false);
     assert(OldVal && "No entry in PHI for Pred BB!");
 
@@ -341,10 +341,12 @@
   for (succ_iterator I = succ_begin(SI2BB), E = succ_end(SI2BB); I != E; ++I)
     if (SI1Succs.count(*I))
       for (BasicBlock::iterator BBI = (*I)->begin();
-           PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI)
+           isa<PHINode>(BBI); ++BBI) {
+        PHINode *PN = cast<PHINode>(BBI);
         if (PN->getIncomingValueForBlock(SI1BB) !=
             PN->getIncomingValueForBlock(SI2BB))
           return false;
+      }
         
   return true;
 }
@@ -359,8 +361,8 @@
          succ_end(ExistPred) && "ExistPred is not a predecessor of Succ!");
   if (!isa<PHINode>(Succ->begin())) return; // Quick exit if nothing to do
 
-  for (BasicBlock::iterator I = Succ->begin();
-       PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+  for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) {
+    PHINode *PN = cast<PHINode>(I);
     Value *V = PN->getIncomingValueForBlock(ExistPred);
     PN->addIncoming(V, NewPred);
   }
@@ -994,7 +996,8 @@
           // PHI nodes in EdgeBB, they need entries to be added corresponding to
           // the number of edges added.
           for (BasicBlock::iterator BBI = EdgeBB->begin();
-               PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI) {
+               isa<PHINode>(BBI); ++BBI) {
+            PHINode *PN = cast<PHINode>(BBI);
             Value *InVal = PN->getIncomingValueForBlock(*PI);
             for (unsigned i = 0, e = Values.size()-1; i != e; ++i)
               PN->addIncoming(InVal, *PI);






More information about the llvm-commits mailing list