[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Mon May 17 16:50:02 PDT 2004


Changes in directory reopt/lib/TraceToFunction:

TraceToFunction.cpp updated: 1.39 -> 1.40

---
Log message:

Fold branches that go to FLI blocks, and PHI sources that come from FLI blocks.
Untabify.


---
Diffs of the changes:  (+25 -12)

Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.39 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.40
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.39	Mon May 17 16:38:18 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp	Mon May 17 16:49:37 2004
@@ -482,17 +482,22 @@
     // to guess which one it is. Assume it's any phi value source in
     // the entry BB which is not in the trace.
     for (BasicBlock::iterator BI = srcB->begin ();
-	 PHINode *PN = dyn_cast<PHINode> (BI); ++BI)
-      for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i)
-	if (!T.contains (PN->getIncomingBlock (i))) {
-	  // FIXME: Assert that O2CMap[PN]'s value i is live in.
-	  Value *V = O2CMap[PN];
-	  assert (V && "Can't find clone of Phi node from trace entry BB");
-	  PHINode *PNinF = dyn_cast<PHINode> (V);
-	  assert (PNinF
-		  && "Clone of Phi node from entry BB is not a Phi node");
-	  PNinF->setIncomingBlock (i, EntryFixup);
-	}
+         PHINode *PN = dyn_cast<PHINode> (BI); ++BI)
+      for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i) {
+        // Fold Phi sources which come from FLI blocks
+        BasicBlock *phiSource = PN->getIncomingBlock (i);
+        if (BasicBlock *realSource = getFLIEdgeSource (phiSource))
+          phiSource = realSource;
+        if (!T.contains (phiSource)) {
+          // FIXME: Assert that O2CMap[PN]'s value i is live in.
+          Value *V = O2CMap[PN];
+          assert (V && "Can't find clone of Phi node from trace entry BB");
+          PHINode *PNinF = dyn_cast<PHINode> (V);
+          assert (PNinF
+                  && "Clone of Phi node from entry BB is not a Phi node");
+          PNinF->setIncomingBlock (i, EntryFixup);
+        }
+     }
   }
 
   // If srcB contains a trace-exiting branch B, fix up B's clone in
@@ -507,11 +512,13 @@
     BranchInst *BIinF = cast<BranchInst> (V);
     for (unsigned i = 0; i < BI->getNumSuccessors (); ++i) {
       BasicBlock *successor = BI->getSuccessor (i);
+      // Fold branches which go to FLI blocks
       if (BasicBlock *backEdgeTarget =
           getFLIEdgeTarget (successor)) {
         std::cerr << "Branch instr " << *BI << " looks like an instrumented "
-                  << "backedge from " << srcB->getName() << " to "
+                  << "back-edge from " << srcB->getName() << " to "
                   << backEdgeTarget->getName () << "\n";
+        successor = backEdgeTarget;
       }
       if (!T.contains (successor)) {
 	// This is a trace-exiting destination of branch BI. Create a new
@@ -573,6 +580,12 @@
     Instruction &I = *BI;
     for (unsigned i = 0; i < I.getNumOperands (); ++i) {
       Value *V = I.getOperand (i);
+      // Fold Phi sources which come from FLI blocks
+      if (isa<PHINode> (&I))
+        if (BasicBlock *phiSource = dyn_cast<BasicBlock> (V))
+          if (BasicBlock *realSource = getFLIEdgeSource (phiSource))
+            V = realSource;
+
       // If the instruction I has an operand which is in the live-in
       // set of the trace, then we must replace that operand with
       // the corresponding argument of F. We can find out which





More information about the llvm-commits mailing list