[llvm-commits] CVS: reopt/lib/LightWtProfiling/SecondTrigger.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Thu Oct 30 14:14:01 PST 2003
Changes in directory reopt/lib/LightWtProfiling:
SecondTrigger.cpp updated: 1.21 -> 1.22
---
Log message:
Found one more place where resetCounters() should be used.
Eliminate one use of SAVE_G1_REG(). Yay!
---
Diffs of the changes: (+20 -15)
Index: reopt/lib/LightWtProfiling/SecondTrigger.cpp
diff -u reopt/lib/LightWtProfiling/SecondTrigger.cpp:1.21 reopt/lib/LightWtProfiling/SecondTrigger.cpp:1.22
--- reopt/lib/LightWtProfiling/SecondTrigger.cpp:1.21 Thu Oct 30 13:56:13 2003
+++ reopt/lib/LightWtProfiling/SecondTrigger.cpp Thu Oct 30 14:13:18 2003
@@ -24,9 +24,16 @@
#include <cassert>
#include <libcpc.h>
+// Keeps a pointer to a map from branch histories to the number of
+// times we reached countPath for that particular branch history:
static std::map<uint64_t, std::map<uint64_t, int> *> pathCounter;
+// Counts the number of times we reached countPath():
static std::map<uint64_t, int> totalCount;
+// Counts the number of times we reached llvm_time_end():
static std::map<uint64_t, int> exitCounter;
+// In backOffCounters, the first element of the pair counts the number
+// of times a given trace is selected, and the second element of the
+// pair counts the number of times a given trace is *not* selected:
static std::map<uint64_t, std::pair<long, long> > backOffCounters;
extern "C" void llvm_first_trigger(int *cnt);
@@ -46,6 +53,13 @@
#endif
}
+static void resetCounters (uint64_t pcAddr, uint64_t reverseAddr) {
+ delete pathCounter[pcAddr];
+ pathCounter.erase(pcAddr);
+ totalCount[pcAddr] = 0;
+ exitCounter[reverseAddr] = 0;
+}
+
extern "C" void llvm_time_end(){
uint64_t i_reg_save[6];
uint32_t f_reg_save[32];
@@ -86,16 +100,13 @@
tr->getEndAddress(tr->getOriginalAddress(tr->getAddrLessThan(brAddr)))
<< "\n");
- exitCounter[reverseAddr] = 0;
- delete pathCounter[reverseAddr];
- pathCounter.erase(reverseAddr);
- totalCount[reverseAddr] = 0;
+ resetCounters (reverseAddr, reverseAddr);
tr->patchTrace(tr->getAddrLessThan(brAddr));
if(!backOffCounters[reverseAddr].second)
backOffCounters[reverseAddr].second = 1;
-
backOffCounters[reverseAddr].second *= 2;
+
assert(firstTriggerAddr.find(reverseAddr) != firstTriggerAddr.end());
insert_address_at(llvm_interval_counter +
@@ -165,15 +176,7 @@
return instr;
}
-static void resetCounters (uint64_t pcAddr, uint64_t reverseAddr) {
- delete pathCounter[pcAddr];
- pathCounter.erase(pcAddr);
- totalCount[pcAddr] = 0;
- exitCounter[reverseAddr] = 0;
-}
-
void countPath () {
- uint64_t branchHist;
uint64_t i_reg_save[6];
uint32_t f_reg_save[32];
uint64_t fd_reg_save[16];
@@ -184,7 +187,6 @@
// Save registers on the stack in variables declared above.
SAVE_I_REGS(i_reg_save);
- SAVE_G1_REG(branchHist);
SAVE_G1_REG(g1_reg);
SAVE_F_REGS_1(f_reg_save);
// SAVE_F_REGS_2(f_reg_save);
@@ -192,7 +194,7 @@
SAVE_FSR_REG(fsr_reg);
SAVE_FPRS_REG(fprs_reg);
SAVE_CCR_REG(ccr_reg);
-
+
// Get return address -- that is, the PC where this call to countPath
// was made (on SPARC, this is in %i7).
uint64_t pcAddr = (uint64_t) __builtin_return_address(0);
@@ -213,6 +215,9 @@
totalCount[pcAddr]++;
else
totalCount[pcAddr] = 1;
+
+ // Get the branch history saved by the second-level instrumentation in %g1.
+ uint64_t branchHist = g1_reg;
if(pathCounter.find(pcAddr) != pathCounter.end()){
std::map<uint64_t, int> *oldMap = pathCounter[pcAddr];
More information about the llvm-commits
mailing list