[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Sat May 22 21:03:01 PDT 2004
Changes in directory reopt/lib/LightWtProfiling:
UnpackTraceFunction.cpp updated: 1.65 -> 1.66
---
Log message:
Save live-in values that originate in MatrixFn's register on TraceFn's stack.
(Still need to reload them into TraceFn's registers from there.)
Remove some dead references from rewriteProlog().
---
Diffs of the changes: (+25 -9)
Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.65 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.66
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.65 Sat May 22 19:09:59 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Sat May 22 21:02:13 2004
@@ -270,11 +270,30 @@
E.push_back (BuildMI (V9::ADDi, 3).addMReg (sp).addSImm (-Size).addMReg (sp,
MachineOperand::Def));
+ std::set<unsigned> regsToSave (regsUsed);
+ // Save live-in values in registers onto the stack
+ LiveVariableSet &Si = TF->LiveInSet;
+ std::map<Value *, std::pair<AllocInfo, AllocInfo> > AllocStates;
+ for (LiveVariableSet::iterator SI = Si.begin (), SE = Si.end (); SI != SE;
+ ++SI) {
+ Value *V = *SI;
+ std::pair<Value *, std::pair<AllocInfo, AllocInfo> > as =
+ std::make_pair (V, getValueAllocState (TF, V));
+ AllocStates.insert (as);
+ AllocInfo &Source = as.second.first, &Target = as.second.second;
+ if (Source != Target)
+ if (Source.AllocState == AllocInfo::Allocated) {
+ DEBUG (std::cerr << "Need to save incoming live value in reg "
+ << Source.Placement << " onto the stack\n");
+ regsToSave.insert (Source.Placement);
+ }
+ }
+
// 3. Save used registers onto the stack.
std::vector<MachineInstr *> mvec;
int RegType;
- for (std::set<unsigned>::iterator i = regsUsed.begin (), e = regsUsed.end ();
- i != e; ++i) {
+ for (std::set<unsigned>::iterator i = regsToSave.begin (),
+ e = regsToSave.end (); i != e; ++i) {
mvec.clear ();
unsigned R = *i;
unsigned RegType = TRI.getRegType (R);
@@ -300,25 +319,22 @@
}
}
+
// 4. Insert copies from each live-in variable's reg. in the matrix fn.
// to its reg. in the trace.
- Function *TraceF = TF->TraceFn, *MatrixF = TF->MatrixFn;
- LiveVariableSet &Si = TF->LiveInSet;
+ Function *MatrixF = TF->MatrixFn;
std::vector<CopyInfo> EntryCopies;
for (LiveVariableSet::iterator SI = Si.begin (), SE = Si.end (); SI != SE;
++SI) {
Value *V = *SI;
- DEBUG(std::cerr
- << "rewriteProlog: Getting alloc state for live-in value ";
- WriteAsOperand (std::cerr, V, true, true, MatrixF->getParent ());
- std::cerr << "\n");
- std::pair<AllocInfo, AllocInfo> ai = getValueAllocState (TF, V);
+ std::pair<AllocInfo, AllocInfo> &ai = AllocStates[V];
AllocInfo &Source = ai.first, &Target = ai.second;
DEBUG(std::cerr << "rewriteProlog: Source in MatrixFn = " << Source << "\n"
<< "rewriteProlog: Target in TraceFn = " << Target << "\n");
if (Source != Target)
EntryCopies.push_back (CopyInfo (Source, Target, &E, V->getType ()));
}
+
for (std::vector<CopyInfo>::iterator i = EntryCopies.begin (),
e = EntryCopies.end (); i != e; ++i) {
DEBUG(std::cerr << "rewriteProlog: Inserting copy " << *i << "\n");
More information about the llvm-commits
mailing list