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

Brian Gaeke gaeke at cs.uiuc.edu
Tue Nov 4 16:41:00 PST 2003


Changes in directory reopt/lib/LightWtProfiling:

UnpackTraceFunction.cpp updated: 1.11 -> 1.12

---
Log message:

Update another comment in insertCopyMachineInstrs().
Implement getSavedStateIndexOfFunction().


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

Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.11 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.12
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.11	Tue Nov  4 16:11:41 2003
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp	Tue Nov  4 16:39:52 2003
@@ -13,6 +13,7 @@
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/Module.h"
 #include "reopt/ScratchMemory.h"
 #include "reopt/MappingInfo.h"
 #include "Support/Debug.h"
@@ -32,7 +33,7 @@
   } else if (Source.AllocState == AllocInfo::Allocated && Target.AllocState == AllocInfo::Spilled) {
     //Insert store instruction from register Source to stack loc. Target
   } else if (Source.AllocState == AllocInfo::Spilled && Target.AllocState == AllocInfo::Spilled) {
-    //Get a temporary register Temp somehow
+    //Get a temporary register Temp somehow (maybe use the path reg, %g1?)
     //Insert load instruction from stack loc. Source into register Temp
     //Insert store instruction from register Temp to stack loc. Target
   }
@@ -126,7 +127,27 @@
 
 extern PhyRegAlloc::SavedStateMapTy ExportedFnAllocState;
 
+/// Returns the index in _llvm_regAllocState.functions[] where F's register
+/// allocation data may be found.
+///
+/// FIXME: This is basically the same as Anand's FunctionKey[] in
+/// getLLVMinfo.cpp; merge the two!
+///
 unsigned getSavedStateIndexOfFunction (Function *F) {
+  unsigned Key = 0;
+  Module *M = F->getParent ();
+  for (Module::iterator I = M->begin (), E = M->end (); I != E; ++I) {
+    Function *FI = I;
+    if (FI->isExternal ()) continue;
+    if (FI == F) 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 Function "
+            << F->getName() << "() in its parent Module, in "
+            << "getSavedStateIndexOfFunction()\n";
+  abort ();
 }
 
 unsigned getSavedStateIndexOfInstruction (Function *F, Value *V) {





More information about the llvm-commits mailing list