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

Brian Gaeke gaeke at cs.uiuc.edu
Mon May 10 19:21:06 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

TraceToFunction.cpp updated: 1.29 -> 1.30

---
Log message:

Rename our old Trace::dominates function as just dominates().  (We'll
see about getting rid of it for good later.) This allows us to use
llvm/Analysis/Trace.h instead of our own, outdated local copy.

Call the entryfixup block EntryFixup instead of FEntry.

Dump trace on entry if DEBUG set.


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

Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp
diff -u reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.29 reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.30
--- reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.29	Sun Apr  4 20:32:11 2004
+++ reopt/lib/LightWtProfiling/TraceToFunction.cpp	Mon May 10 19:19:59 2004
@@ -64,10 +64,10 @@
   virtual TraceFunction *traceToFunction (Trace &T);
 };
 
-bool Trace::dominates (const BasicBlock *B1, const BasicBlock *B2,
-		       const BasicBlock *start) {
+static bool dominates (Trace &T, const BasicBlock *B1,
+                       const BasicBlock *B2, const BasicBlock *start = 0) {
   if (!start)
-    start = getEntryBasicBlock ();
+    start = T.getEntryBasicBlock ();
   if (start == B1) {
     return true;        // Seen B1 on this path, if we see B2 later it's OK.
   } else if (start == B2) {
@@ -78,8 +78,8 @@
     for (succ_const_iterator i = succ_begin (start), e = succ_end (start);
 	 i != e; ++i) {
       const BasicBlock *succ = *i;
-      if (contains (succ) && (getEntryBasicBlock () != succ)
-	  && (!dominates (B1, B2, succ)))
+      if (T.contains (succ) && (T.getEntryBasicBlock () != succ)
+	  && (!dominates (T, B1, B2, succ)))
 	return false;
     }
     return true; // Dominates on all successors ==> dominates here too
@@ -117,7 +117,7 @@
 	// If UBlock appears BEFORE Block on some path from the first
 	// basic block of the trace to an exit BB of the trace, return
 	// false.
-	if (!T.dominates (Block, UBlock))
+	if (!dominates (T, Block, UBlock))
 	  return false;
       }
     }
@@ -419,10 +419,10 @@
   // the function. So create new entry basic block to serve as source
   // for old entry's initial phi node.
   if (srcB == T.getEntryBasicBlock ()) {
-    BasicBlock *FEntry = new BasicBlock ("entryfixup", F, dstB);
-    FEntry->getInstList ().push_back (new BranchInst (dstB));
+    BasicBlock *EntryFixup = new BasicBlock ("entryfixup", F, dstB);
+    EntryFixup->getInstList ().push_back (new BranchInst (dstB));
     // Replace the references to the trace's predecessor with a
-    // reference to FEntry now. This is kind of a dodge because we
+    // reference to EntryFixup now. This is kind of a dodge because we
     // don't have a pointer to the trace's predecessor, so we have
     // to guess which one it is. Assume it's any phi value source in
     // the entry BB which is not in the trace.
@@ -436,7 +436,7 @@
 	  PHINode *PNinF = dyn_cast<PHINode> (V);
 	  assert (PNinF
 		  && "Clone of Phi node from entry BB is not a Phi node");
-	  PNinF->setIncomingBlock (i, FEntry);
+	  PNinF->setIncomingBlock (i, EntryFixup);
 	}
   }
 
@@ -467,8 +467,8 @@
 	unsigned Slot = 0;
 	for (LiveVariableSet::iterator SI = So.begin (), SE = So.end ();
 	     SI != SE; ++SI) {
-      if (T.dominates (cast<Instruction> ((*SI))->getParent (),
-                        BI->getParent ())) {
+      if (dominates (T, cast<Instruction> ((*SI))->getParent (),
+                     BI->getParent ())) {
 	    std::vector<Value *> Index;
 	    Index.push_back (Constant::getNullValue (Type::LongTy));  //long 0
 	    Index.push_back (ConstantUInt::get (Type::UIntTy, Slot));//uint Slot
@@ -579,6 +579,7 @@
 
   std::string CurrentFnName = T.getFunction ()->getName ();
   DEBUG(std::cerr << "In traceToFunction() for " << CurrentFnName << "\n");
+  DEBUG(T.dump ());
 
   // Get some information about the trace's relationship to its parent
   // function.





More information about the llvm-commits mailing list