[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp
Joel Stanley
jstanley at cs.uiuc.edu
Fri May 30 11:36:00 PDT 2003
Changes in directory llvm/lib/Reoptimizer/Inst/lib:
Phases.cpp updated: 1.35.2.2 -> 1.35.2.3
---
Log message:
Added handling for the case where new instrumentation is dynamically registered
with an interval while within the interval boundaries.
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp
diff -u llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.35.2.2 llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.35.2.3
--- llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.35.2.2 Fri May 30 10:57:09 2003
+++ llvm/lib/Reoptimizer/Inst/lib/Phases.cpp Fri May 30 11:34:48 2003
@@ -150,11 +150,11 @@
uint64_t m_tag; // Entry to look for in the GBT
};
-// InstFunctionInfo is the class used to represent information (e.g., address of
-// return value, pointer-to-instrumentation function) about particular
-// registered instrumentation functions. In the case of end-interval functions,
-// the link 'm_pStart' is filled in to refer to the InstFunctionInfo instance
-// that contains information about the corresponding start-interval function.
+// InstFunctionInfo is the class used to represent information (e.g., address of return
+// value, pointer-to-instrumentation function) about particular registered instrumentation
+// functions. In the case of end-interval functions, the link 'm_pStart' is filled in to
+// refer to the InstFunctionInfo instance that contains information about the
+// corresponding start-interval function.
class InstFunctionInfo
{
@@ -162,11 +162,18 @@
InstFunctionInfo(void* pRetVal,
void* pInstFunc,
InstFunctionInfo* pStart = 0):
- m_pRetVal(pRetVal), m_pInstFunc(pInstFunc), m_pStart(pStart)
+ m_pRetVal(pRetVal),
+ m_pInstFunc(pInstFunc),
+ m_pStart(pStart),
+ m_invoked(false)
{
}
- InstFunctionInfo(): m_pRetVal(0), m_pInstFunc(0), m_pStart(0)
+ InstFunctionInfo():
+ m_pRetVal(0),
+ m_pInstFunc(0),
+ m_pStart(0),
+ m_invoked(false)
{
}
@@ -176,6 +183,7 @@
void* m_pRetVal;
void* m_pInstFunc;
InstFunctionInfo* m_pStart; // Info about start-interval function
+ bool m_invoked; // Has this function been invoked yet?
};
// InstSiteInfo instances contain information about the state of particular
@@ -762,16 +770,32 @@
void InstFunctionInfo::invoke()
{
+ // In the case of start-interval functions, the boolean m_invoked is set to true upon
+ // completion of the invocation. This same boolean (i.e, the one associated with the
+ // start-interval InstFunctionInfo instance) is cleared by the corresponding
+ // end-interval function invocation. This is to ensure that no end-interval
+ // instrumentation function is ever invoked unless its corresponding start-interval
+ // instrumentation function has been invoked (which implies that the start-interval
+ // site has been handled properly and all of the registration mechanisms).
+
DEBUG_MSG(3, "(InstFunctionInfo::invoke) retVal address is: " << HEX(m_pRetVal) << endl);
if(m_pStart) {
DEBUG_MSG(3, "End-interval inst func detected\n");
void (*instFunc)(void*, void*) = (void (*)(void*, void*)) m_pInstFunc;
- instFunc(m_pRetVal, m_pStart->m_pRetVal);
+
+ if(m_pStart->m_invoked) {
+ DEBUG_MSG(4, "Corresponding start function has been invoked, so invoking this inst func\n");
+ instFunc(m_pRetVal, m_pStart->m_pRetVal);
+ m_pStart->m_invoked = false;
+ }
+ else
+ DEBUG_MSG(4, "Corresponding start func has not been invoked, so not invoking\n");
}
else {
DEBUG_MSG(3, "Start-interval or non-end inst func detected\n");
void (*instFunc)(void*) = (void (*)(void*)) m_pInstFunc;
instFunc(m_pRetVal);
+ m_invoked = true;
}
DEBUG_MSG(3, "(InstFunctionInfo::invoke) instrumentation function returned\n");
More information about the llvm-commits
mailing list