[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp SparcInstManip.cpp
Joel Stanley
jstanley at cs.uiuc.edu
Wed May 14 07:44:01 PDT 2003
Changes in directory llvm/lib/Reoptimizer/Inst/lib:
Phases.cpp updated: 1.30 -> 1.31
SparcInstManip.cpp updated: 1.10 -> 1.11
---
Log message:
Removed hard-coded name of function; now instruments all functions. Checkpoint
before implementing heap-allocated code regions.
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp
diff -u llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.30 llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.31
--- llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.30 Tue May 13 14:43:02 2003
+++ llvm/lib/Reoptimizer/Inst/lib/Phases.cpp Wed May 14 07:43:04 2003
@@ -66,6 +66,10 @@
#include "PhaseInfo.h"
#include "SparcInstManip.h"
+// tmp
+#include "llvm/Reoptimizer/InstrUtils.h"
+// tmp
+
using std::vector;
using std::cerr;
using std::endl;
@@ -182,18 +186,18 @@
DEBUG_MSG(1, "There are " << funcs.size() << " functions to process." << endl);
m_pIM->makePhase3SpillRegion(funcs.size());
-
+
for(vector<std::pair<std::string, AddressRange> >::iterator i = funcs.begin(),
e = funcs.end(); i != e; ++i) {
if(m_excludeSet.find(i->first) == m_excludeSet.end()) {
// Function is not in exclude set, so go ahead and transform it
- //cerr << i->first << " is to be transformed" << endl;
- if(i->first == "fibs") {
- DEBUG_MSG(1, "Transforming function " << i->first << "...\n");
- transformFunction(i->second);
- }
+ DEBUG_MSG(1, "Transforming function " << i->first
+ << "[" << HEX(i->second.first)
+ << ", " << HEX(i->second.second) << "]...\n");
+
+ transformFunction(i->second);
}
}
@@ -242,11 +246,20 @@
// Obtain address of first replacable instruction in function and obtain a new slot
// from the TraceCache memory manager (i.e., a new slot in the dummy function). Hold
// onto the replaced instruction for later restoration.
-
+
VirtualMem* vm = m_pTC->getVM();
uint64_t repInstAddr = m_pIM->getStartAddr(range.first);
unsigned origInst = vm->readInstrFrmVm(repInstAddr);
-
+
+#if 0
+#if VERBOSE > 3
+ DEBUG_MSG(4, "printing function before writing branch-to-slot\n");
+ DEBUG_MSG(4, "range goes from " << HEX(range.first) << " to " << HEX(range.second) << endl);
+ m_pIM->printRange(range.first, range.second);
+ DEBUG_MSG(4, "done printing function...\n");
+#endif
+#endif
+
assert(!m_pIM->isBranch(origInst) &&
"Unhandled case: branch instruction first in function body");
@@ -254,17 +267,27 @@
// Replace instruction at repInstAddr with a branch to start of a new slot.
uint64_t slotBase = replaceInstWithBrToSlot(repInstAddr, slotSize, m_pTC, m_pIM);
+ //::doFlush(range.first, range.second);
+
+#if 0
+#if VERBOSE > 3
+ DEBUG_MSG(4, "printing function after writing branch-to-slot\n");
+ DEBUG_MSG(4, "range goes from " << HEX(range.first) << " to " << HEX(range.second) << endl);
+ m_pIM->printRange(range.first, range.second);
+ DEBUG_MSG(4, "done printing function...\n");
+#endif
+#endif
// Build the Phase3Info structure and generate the phase 3 slot.
Phase3Info* p3info = new Phase3Info(range, origInst, repInstAddr,
slotBase, slotSize, m_pTC, m_pIM);
-
+
vector<unsigned> snippet;
m_pIM->buildSlot(p3info, snippet);
-
- DEBUG_MSG(3, "phase3 slot instructions:\n");
-#if VERBOSE > 2
+
+ DEBUG_MSG(5, "phase3 slot instructions:\n");
+#if VERBOSE > 4
dumpSnippet(snippet, m_pIM);
#endif
@@ -295,6 +318,8 @@
// as well).
m_pTC->getVM()->writeInstToVM(p3info->getReplaceAddr(), p3info->getOrigInst());
+// ::doFlush(m_pPhase3Info->getReplaceAddr(),
+// m_pPhase3Info->getReplaceAddr() + m_pIM->getInstWidth());
}
Phase3::~Phase3()
@@ -359,6 +384,7 @@
// ...and process them
processCandidates(candidates);
+
DEBUG_MSG(1, "============================== End Phase 3 ==============================\n");
}
@@ -458,17 +484,6 @@
#endif
copySnippetToSlot(snippet, slotBase, m_pTC->getVM(), m_pIM);
-
-#if 0
- void* instFuncVP = (void*) fakeInstFunc; // From the GBT eventually
- void (*instFunc)(void*) = (void (*)(void*)) instFuncVP;
-
- void* mem = malloc(sizeof(double));
- instFunc(mem);
- printf("%f\n", *((double*) mem));
- free(mem);
-
-#endif
}
else {
DEBUG_MSG(1, "does not match\n");
Index: llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp
diff -u llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp:1.10 llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp:1.11
--- llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp:1.10 Tue May 13 14:43:02 2003
+++ llvm/lib/Reoptimizer/Inst/lib/SparcInstManip.cpp Wed May 14 07:43:04 2003
@@ -305,11 +305,15 @@
// For SparcV9, skip the save instruction, if present.
unsigned inst = m_pTC->getVM()->readInstrFrmVm(addr);
- assert(RD_FLD(inst, INSTR_OP) == OP_2 &&
- RD_FLD(inst, INSTR_OP3) == OP3_SAVE &&
- "Unhandled case: non-save instruction in function header");
+ if(RD_FLD(inst, INSTR_OP) == OP_2 &&
+ RD_FLD(inst, INSTR_OP3) == OP3_SAVE) {
+ return addr + getInstWidth();
+ }
+ else {
+ DEBUG_MSG(2, "WARNING: Non-save instruction at function entry\n");
+ return addr;
+ }
- return addr + getInstWidth();
}
void SparcInstManip::printRange(unsigned* start,
More information about the llvm-commits
mailing list