[llvm-commits] CVS: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h SecondTrigger.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Thu Aug 7 22:53:01 PDT 2003
Changes in directory llvm/lib/Reoptimizer/LightWtProfiling/Trigger:
GetTimer.h updated: 1.3 -> 1.4
SecondTrigger.cpp updated: 1.8 -> 1.9
---
Log message:
FOR_DEBUG merged with GET_ALL_INFO.
triggerBB renamed to optimizeTrace. Print out trace in this method if
GET_ALL_INFO is on.
Get rid of no-op XORs with zero of fprs_reg and ccr_reg.
Rewrite doTrigger into two smaller methods: getSuccessorByPath and
constructVBB.
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h:1.3 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h:1.4
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h:1.3 Tue Aug 5 15:00:18 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h Thu Aug 7 22:51:58 2003
@@ -7,9 +7,14 @@
#ifndef GETTIMER_H
#define GETTIMER_H
+// When this is defined, the reoptimizer prints out lots of debugging
+// information. (We can't easily pass arguments such as -debug to the
+// reoptimizer as with other LLVM tools, so we use this for now.)
#define GET_ALL_INFO
+
// #undef GET_COVERAGE
-// #undef FOR_DEBUG
+
+// Tunable parameters (see thesis?)
#define MAX_PATH_HISTORIES 12
#define MAX_ALLOWED_PATHS 6
#define THRESHOLD_PERCENTAGE 90
Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp:1.8 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp:1.9
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp:1.8 Thu Aug 7 13:11:44 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp Thu Aug 7 22:51:58 2003
@@ -66,8 +66,17 @@
/// the trace; the second parameter is presumably one of the starting
/// addresses for the trace.
///
-void triggerBB(vector<BasicBlock *> &vBB, uint64_t a) {
- std::cerr << "We made it to triggerBB\n";
+void optimizeTrace (vector<BasicBlock *> &vBB, uint64_t a) {
+#ifdef GET_ALL_INFO
+ // Dump the trace to the standard error stream.
+ std::cerr << "=== In optimizeTrace; a = " << a << "================\n";
+ std::cerr << "--- Function where the trace starts -----------------\n";
+ std::cerr << vBB[0]->getParent();
+ std::cerr << "--- BasicBlocks in the trace ------------------------\n";
+ for (unsigned i = 0; i < vBB.size(); ++i)
+ std::cerr << *vBB[i];
+ std::cerr << "=====================================================\n";
+#endif // GET_ALL_INFO
}
extern "C" void llvm_time_start(){
@@ -141,9 +150,6 @@
firstTriggerAddr[reverseAddr]);
}
- fprs_reg ^= 0;
- ccr_reg ^= 0;
-
// Restore registers from local variables.
LOAD_CCR_REG(ccr_reg);
LOAD_I_REGS(i_reg_save);
@@ -376,9 +382,6 @@
pathCounter[pcAddr] = newMap;
}
- fprs_reg ^= 0;
- ccr_reg ^= 0;
-
LOAD_CCR_REG(ccr_reg);
LOAD_I_REGS(i_reg_save);
LOAD_G1_REG(g1_reg);
@@ -459,58 +462,57 @@
std::cerr<<"\n";
}
-#if 0
-void doTrigger(unsigned int path, uint64_t start,
- uint64_t firstLevelTraceStartAddr){
- vector<BasicBlock *> vBB;
- BasicBlock *startBB, *bb;
-
- //std::cerr<<"FINAL TRACE ---------------------------------\n";
-
- assert(getReverseBBMap(start, M, startBB) && "No BB found");
+/// Given a BranchInst BRANCH and a PATH that starts at the basic
+/// block ending with BRANCH, return the successor basic block of
+/// BRANCH which is on the trace. As a side effect, modifies PATH
+/// so that it starts at the returned basic block.
+///
+BasicBlock *getSuccessorByPath (BranchInst &branch, unsigned &path)
+{
+ BasicBlock *bb;
- vBB.push_back(startBB);
- //std::cerr<<startBB;
-
- TerminatorInst *TI = startBB->getTerminator();
- BranchInst *BI = dyn_cast<BranchInst>(TI);
- assert(BI && "Must be a branch!");
-
- if(BI->isConditional()){
- if(path & 1)
- bb = BI->getSuccessor(0);
+ if (branch.isConditional ()) {
+ // If the branch is conditional, it corresponds to a bit in PATH.
+ if (path & 1)
+ bb = branch.getSuccessor (0);
else
- bb = BI->getSuccessor(1);
- path = path >> 1;
- }
- else
- bb = BI->getSuccessor(0);
-
- while(bb != startBB){
- vBB.push_back(bb);
- //std::cerr<<bb;
-
- TI = bb->getTerminator();
- BI = dyn_cast<BranchInst>(TI);
- assert(BI && "Must be a branch!");
-
- if(BI->isConditional()){
- if(path & 1)
- bb = BI->getSuccessor(0);
- else
- bb = BI->getSuccessor(1);
+ bb = branch.getSuccessor (1);
+ // Now we're done with this bit of PATH, so shift it off the end.
+ path >>= 1;
+ } else {
+ // Unconditional branches do not correspond to a PATH bit.
+ bb = branch.getSuccessor (0);
+ }
+ return bb;
+}
- path = path >> 1;
- }
- else{
- bb = BI->getSuccessor(0);
+/// Given a path PATH starting in the basic block whose machine
+/// address is START, construct in VBB a vector of LLVM BasicBlocks
+/// that represents the trace.
+///
+void constructVBB (unsigned int path, uint64_t start, vector<BasicBlock *>&vBB){
+ BasicBlock *bb;
+ BasicBlock *startBB;
+ // Get the first basic block by querying the mapping information.
+ assert (getReverseBBMap (start, M, startBB) &&
+ "Couldn't find starting BasicBlock for trace start addr");
+ bb = startBB;
+ do {
+ // Add basic block to trace.
+ vBB.push_back(bb);
+ // Try to find the next basic block. FIXME: Currently we're
+ // limited to looking for a terminating branch and following that
+ // branch according to the path. This dies if there is a basic
+ // block in the trace which ends in a `ret'.
+ TerminatorInst *TI = bb->getTerminator();
+ BranchInst *BI = dyn_cast<BranchInst>(TI);
+ if (!BI) {
+ std::cerr << "Offending instruction: " << *TI << "\n";
+ assert(0 && "Terminator instruction of BB must be a branch");
}
- }
-
- triggerBB(vBB, firstLevelTraceStartAddr);
-}
-#endif
-
+ bb = getSuccessorByPath (*BI, path);
+ } while (bb != vBB[0]);
+}
//Create traces, stich them together, and add them to tracecache
void generateTraces(uint64_t start, uint64_t end,
@@ -527,8 +529,7 @@
return;
}
-
-#ifdef FOR_DEBUG
+#ifdef GET_ALL_INFO
std::cerr<<"Start: "<<(void *)start<<"\t End: "<<(void *)end<<"\n";
std::cerr<<"Paths------\n";
for(std::vector<uint64_t>::iterator VI = paths.begin(), VE = paths.end();
@@ -555,10 +556,12 @@
getPathIntersections(pathIntersections, paths);
//use path 0 to form vBB
- //doTrigger(paths[0], start, firstLevelTraceStartAddr);
+ //vector<BasicBlock *> vBB;
+ //constructVBB (path, start, vBB);
+ //optimizeTrace (vBB, firstLevelTraceStartAddr);
//return;
-#ifdef FOR_DEBUG
+#ifdef GET_ALL_INFO
std::cerr<<"Path Intersections------\n";
for(std::map<int, std::map<int, int> >::iterator MI =
pathIntersections.begin(), ME = pathIntersections.end(); MI != ME;
@@ -630,7 +633,7 @@
seenStartPC = true;
sawUnconditional = false;
-#ifdef FOR_DEBUG
+#ifdef GET_ALL_INFO
std::cerr<<"PC:\t"<<(void *)pc<<"\n";
#endif
@@ -793,7 +796,7 @@
//is it taken?
if(firstPath & (1ULL << pathIndex)){
-#ifdef FOR_DEBUG
+#ifdef GET_ALL_INFO
std::cerr<<" taken \t";
#endif
More information about the llvm-commits
mailing list