lib/callgraph-profiler-inst/ProfilingInstrumentationPass.cpp
/* fills the fnmap for function name lookup at runtime */
fills the fnmap for function name lookup at runtime
fills the fnmap for function name lookup at runtime
static void
createFunctionTable(Module& m, uint64_t numFunctions, std::vector<Function*> functions) {
	auto& context = m.getContext();
	auto *int64Ty = Type::getInt64Ty(context);
	auto *stringTy = Type::getInt8PtrTy(context);
	Type *fieldTys[] = {stringTy, int64Ty};
	auto* structTy   = StructType::get(context, fieldTys, false);
	auto* tableTy    = ArrayType::get(structTy, numFunctions);
	std::vector<Constant*> values;
	std::transform(
		functions.begin(),
		functions.end(),
		std::back_inserter(values),
		[&m, structTy, int64Ty](Function* f) {
			Constant* structFields[] = {
				createConstantString(m, f->getName()), 
				ConstantInt::get(int64Ty, 0, false) 
			};
			return ConstantStruct::get(structTy, structFields);
		}
	);
	auto *funTable = ConstantArray::get(tableTy, values);
	new GlobalVariable(m, tableTy, false, GlobalValue::ExternalLinkage,
		funTable, "CaLlPrOfIlEr_fnmap");
}
static void createFunctionTable ( Module & m , uint64_t numFunctions , std :: vector < Function * > functions ) { auto & context = m . getContext ( ) ; auto * int64Ty = Type :: getInt64Ty ( context ) ; auto * stringTy = Type :: getInt8PtrTy ( context ) ; Type * fieldTys [ ] = { stringTy , int64Ty } ; auto * structTy = StructType :: get ( context , fieldTys , false ) ; auto * tableTy = ArrayType :: get ( structTy , numFunctions ) ; std :: vector < Constant * > values ; std :: transform ( functions . begin ( ) , functions . end ( ) , std :: back_inserter ( values ) , [ & m , structTy , int64Ty ] ( Function * f ) { Constant * structFields [ ] = { createConstantString ( m , f -> getName ( ) ) , ConstantInt :: get ( int64Ty , 0 , false ) } ; return ConstantStruct :: get ( structTy , structFields ) ; } ) ; auto * funTable = ConstantArray :: get ( tableTy , values ) ; new GlobalVariable ( m , tableTy , false , GlobalValue :: ExternalLinkage , funTable , " " ) ; }
fills the fnmap for function name lookup at runtime
fills the fnmap for function name lookup at runtime
// function name // fnptr