[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/lib/Phase1/PrimInfo.cpp
Joel Stanley
jstanley at cs.uiuc.edu
Tue May 13 13:37:01 PDT 2003
Changes in directory llvm/lib/Reoptimizer/Inst/lib/Phase1:
PrimInfo.cpp updated: 1.13 -> 1.14
---
Log message:
Start- and end- sites are being properly invoked.
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/Inst/lib/Phase1/PrimInfo.cpp
diff -u llvm/lib/Reoptimizer/Inst/lib/Phase1/PrimInfo.cpp:1.13 llvm/lib/Reoptimizer/Inst/lib/Phase1/PrimInfo.cpp:1.14
--- llvm/lib/Reoptimizer/Inst/lib/Phase1/PrimInfo.cpp:1.13 Tue May 13 12:29:50 2003
+++ llvm/lib/Reoptimizer/Inst/lib/Phase1/PrimInfo.cpp Tue May 13 13:36:34 2003
@@ -81,7 +81,10 @@
// unsigned paramSize;
//
// // Pointer to memory for instFunc's return value
- // void* paramMem;
+ // // This is initalized to null for start-interval sites, and filled in at runtime
+ // // by a pointer to heap-allocated memory of the appropriate size. For all other
+ // // site types, this is initialized to the metric variable address.
+ // void* retVal;
//
// // Pointer to instrumentation function
// void* instFunc;
@@ -100,37 +103,57 @@
fields.push_back(PointerType::get(Type::UShortTy)); // unsigned short* loadVar;
fields.push_back(Type::UIntTy); // unsigned gbtStartIdx;
fields.push_back(Type::UIntTy); // unsigned paramSize;
- fields.push_back(PointerType::get(Type::VoidTy)); // void* paramMem;
+ fields.push_back(PointerType::get(Type::VoidTy)); // void* retVal;
fields.push_back(PointerType::get(Type::VoidTy)); // void* instFunc;
sm_structType = StructType::get(fields);
module->addTypeName("PrimInfo", sm_structType);
}
+
+// For start sites
static ConstantStruct* makeConstStruct(StructType* st,
unsigned gbtType,
GlobalVariable* loadVar,
unsigned paramSize,
- Function* instFunc,
- unsigned startLinkIdx = 0)
+ Function* instFunc)
{
- std::vector<Constant*> initFlds;
- initFlds.push_back(ConstantUInt::get(Type::UIntTy, gbtType));
- initFlds.push_back(ConstantPointerRef::get(loadVar));
- initFlds.push_back(ConstantUInt::get(Type::UIntTy, startLinkIdx));
- initFlds.push_back(ConstantUInt::get(Type::UIntTy, paramSize));
- initFlds.push_back(Constant::getNullValue(PointerType::get(Type::VoidTy)));
- initFlds.push_back(ConstantExpr::getCast(ConstantPointerRef::get(instFunc),
+ std::vector<Constant*> inits;
+ inits.push_back(ConstantUInt::get(Type::UIntTy, gbtType));
+ inits.push_back(ConstantPointerRef::get(loadVar));
+ inits.push_back(ConstantUInt::get(Type::UIntTy, (unsigned) 0));
+ inits.push_back(ConstantUInt::get(Type::UIntTy, paramSize));
+ inits.push_back(Constant::getNullValue(PointerType::get(Type::VoidTy)));
+ inits.push_back(ConstantExpr::getCast(ConstantPointerRef::get(instFunc),
PointerType::get(Type::VoidTy)));
- return ConstantStruct::get(st, initFlds);
+ return ConstantStruct::get(st, inits);
+}
+
+// For non-start sites
+static ConstantStruct* makeConstStruct(StructType* st,
+ unsigned gbtType,
+ GlobalVariable* loadVar,
+ unsigned startLinkIdx,
+ unsigned paramSize,
+ GlobalVariable* metricVar,
+ Function* instFunc)
+{
+ std::vector<Constant*> inits;
+ inits.push_back(ConstantUInt::get(Type::UIntTy, gbtType));
+ inits.push_back(ConstantPointerRef::get(loadVar));
+ inits.push_back(ConstantUInt::get(Type::UIntTy, startLinkIdx));
+ inits.push_back(ConstantUInt::get(Type::UIntTy, paramSize));
+ inits.push_back(ConstantExpr::getCast(ConstantPointerRef::get(metricVar),
+ PointerType::get(Type::VoidTy)));
+ inits.push_back(ConstantExpr::getCast(ConstantPointerRef::get(instFunc),
+ PointerType::get(Type::VoidTy)));
+ return ConstantStruct::get(st, inits);
}
void PrimInfo::buildStructInstances(std::vector<Constant*>& gbtElems,
std::map<PrimInfo*, unsigned>& gbtIdxMap,
const TargetData* targetData)
{
- std::vector<Constant*> initFlds;
-
StructType* st = getStructType();
switch(m_type) {
@@ -149,7 +172,7 @@
assert(m_endFunc->asize() == 2 && "Unexpected # args for end func");
psize = targetData->getTypeSize(m_endFunc->afront().getType());
gbtElems.push_back(makeConstStruct(st, GBT_INTERVAL_END, m_globVolEnd,
- psize, m_endFunc, i->second));
+ i->second, psize, m_metricVar, m_endFunc));
break;
}
More information about the llvm-commits
mailing list