lib/callgraph-profiler-inst/ProfilingInstrumentationPass.cpp
/* fills the csmap for access to callsite info at runtime */
fills the csmap for access to callsite info at runtime
fills the csmap for access to callsite info at runtime
static void
createCallTable(Module& m, uint64_t numCalls, std::vector<CallSite> calls) {
	auto& context = m.getContext();
	auto *int64Ty = Type::getInt64Ty(context);
	auto *stringTy = Type::getInt8PtrTy(context);
	Type *fieldTys[] = {stringTy, int64Ty, stringTy};
	auto* structTy   = StructType::get(context, fieldTys, false);
	auto* tableTy    = ArrayType::get(structTy, numCalls);
	std::vector<Constant*> values;
	std::transform(
		calls.begin(),
		calls.end(),
		std::back_inserter(values),
		[&m, structTy, int64Ty](CallSite cs) {
			DILocation *Loc = cs.getInstruction()->getDebugLoc();
			Constant* structFields[] = {
				createConstantString(m, Loc->getFilename()), 
				ConstantInt::get(int64Ty, Loc->getLine(), false), 
				createConstantString(m, cs.getParent()->getParent()->getName()), 
			};
			return ConstantStruct::get(structTy, structFields);
		}
	);
	auto* callTable = ConstantArray::get(tableTy, values);
	new GlobalVariable(m, tableTy, false, GlobalValue::ExternalLinkage,
		callTable, "CaLlPrOfIlEr_csmap");
}
static void createCallTable ( Module & m , uint64_t numCalls , std :: vector < CallSite > calls ) { auto & context = m . getContext ( ) ; auto * int64Ty = Type :: getInt64Ty ( context ) ; auto * stringTy = Type :: getInt8PtrTy ( context ) ; Type * fieldTys [ ] = { stringTy , int64Ty , stringTy } ; auto * structTy = StructType :: get ( context , fieldTys , false ) ; auto * tableTy = ArrayType :: get ( structTy , numCalls ) ; std :: vector < Constant * > values ; std :: transform ( calls . begin ( ) , calls . end ( ) , std :: back_inserter ( values ) , [ & m , structTy , int64Ty ] ( CallSite cs ) { DILocation * Loc = cs . getInstruction ( ) -> getDebugLoc ( ) ; Constant * structFields [ ] = { createConstantString ( m , Loc -> getFilename ( ) ) , ConstantInt :: get ( int64Ty , Loc -> getLine ( ) , false ) , createConstantString ( m , cs . getParent ( ) -> getParent ( ) -> getName ( ) ) , } ; return ConstantStruct :: get ( structTy , structFields ) ; } ) ; auto * callTable = ConstantArray :: get ( tableTy , values ) ; new GlobalVariable ( m , tableTy , false , GlobalValue :: ExternalLinkage , callTable , " " ) ; }
fills the csmap for access to callsite info at runtime
fills the csmap for access to callsite info at runtime
// srcfile // line_num // caller