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

Brian Gaeke gaeke at cs.uiuc.edu
Wed Jun 23 15:08:24 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

ValueAllocState.cpp updated: 1.3 -> 1.4

---
Log message:

If getSavedStateIndexOfInstruction can't find the instruction,
just return -1, don't abort.
In getValueAllocStateKeys, look for the PhiCp node if it's in any trace
boundary (enter-from or return-to) block, not just the entry block.
Add new static method findTraceBoundaryBlocks to compute the set of trace
boundary blocks for each TraceFunction.


---
Diffs of the changes:  (+22 -10)

Index: reopt/lib/LightWtProfiling/ValueAllocState.cpp
diff -u reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.3 reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.4
--- reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.3	Tue Jun  8 13:53:57 2004
+++ reopt/lib/LightWtProfiling/ValueAllocState.cpp	Wed Jun 23 15:06:35 2004
@@ -56,7 +56,7 @@
 
 /// Returns the index of the given Instruction in the given Function.
 ///
-static unsigned getSavedStateIndexOfInstruction (const Function *F,
+static int getSavedStateIndexOfInstruction (const Function *F,
                                                  const Instruction *I) {
   unsigned Key = 0;
   for (const_inst_iterator II=inst_begin (F), IE=inst_end (F); II!=IE; ++II) {
@@ -64,12 +64,10 @@
       return Key;
     ++Key;
   }
-  // By this time we had better have found it, otherwise we are about to do bad
-  // things.
-  std::cerr << "ERROR: UnpackTraceFunction: Cannot find index of Value "
-            << F->getName() << "() in its parent Function using inst_iterator, "
-            << "in getSavedStateIndexOfInstruction()\n";
-  abort ();
+  DEBUG (std::cerr << "getSavedStateIndexOfInstruction: Warning: Cannot find "
+    << "index of value " << I->getName() << " in its parent function "
+    << F->getName () << "()\n");
+  return -1;
 }
 
 /// Returns the index of the given Argument in the given Function's
@@ -86,7 +84,17 @@
   abort ();
 }
 
-static BasicBlock *TraceEntryBB = 0;
+static std::set<BasicBlock *> TraceBoundaryBlocks;
+static TraceFunction *lastTraceFunction;
+
+static void findTraceBoundaryBlocks (TraceFunction *TF) {
+  TraceBoundaryBlocks.clear ();
+  TraceBoundaryBlocks.insert (TF->T.getEntryBasicBlock ());
+  for (BasicBlockMap::iterator i = TF->ReturnBlockForTraceExit.begin (),
+       e = TF->ReturnBlockForTraceExit.end (); i != e; ++i) {
+    TraceBoundaryBlocks.insert (i->second);
+  }
+}
 
 /// getValueAllocStateKeys - Fill in InstructionKey and OperandKey with the
 /// indices used to look up saved register allocation state for V in F.
@@ -99,7 +107,8 @@
   } else if (Instruction *Inst = dyn_cast<Instruction> (V)) {
     InstructionKey = getSavedStateIndexOfInstruction (F, Inst);
     if (isa<PHINode> (Inst) && preferLiveIn
-        && Inst->getParent() == TraceEntryBB)
+        && TraceBoundaryBlocks.find (Inst->getParent ())
+           != TraceBoundaryBlocks.end ())
       OperandKey = -2; // look for PhiCpRes instead.
   } else {
     DEBUG (std::cerr << "getValueAllocStateKeys: keys not known for "
@@ -179,7 +188,10 @@
 ///
 std::pair<AllocInfo, AllocInfo>
 GetValueAllocState (TraceFunction *TF, Value *V, bool preferLiveIn) {
-  TraceEntryBB = TF->T.getEntryBasicBlock();
+  if (lastTraceFunction != TF) {
+    findTraceBoundaryBlocks (TF);
+    lastTraceFunction = TF;
+  }
   return std::make_pair
    (getValueAllocStateFromModule (TF->MatrixFn, V, preferLiveIn),
     getValueAllocStateFromGlobal (TF->TraceFn,





More information about the llvm-commits mailing list