Remove caching in FunctionImport: a Module can't be reused after being linked from
[oota-llvm.git] / lib / Transforms / Instrumentation / InstrProfiling.cpp
index 334c41f3abc2287e59b3218c04e38cac0c24894a..a144dafdcbdfb98e252a3d2babd12a5cc7eecb9c 100644 (file)
@@ -173,14 +173,15 @@ bool InstrProfiling::runOnModule(Module &M) {
 }
 
 static Constant *getOrInsertValueProfilingCall(Module &M) {
-  auto *VoidTy = Type::getVoidTy(M.getContext());
-  auto *VoidPtrTy = Type::getInt8PtrTy(M.getContext());
-  auto *Int32Ty = Type::getInt32Ty(M.getContext());
-  auto *Int64Ty = Type::getInt64Ty(M.getContext());
-  Type *ArgTypes[] = {Int64Ty, VoidPtrTy, Int32Ty};
+  LLVMContext &Ctx = M.getContext();
+  auto *ReturnTy = Type::getVoidTy(M.getContext());
+  Type *ParamTypes[] = {
+#define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType
+#include "llvm/ProfileData/InstrProfData.inc"
+  };
   auto *ValueProfilingCallTy =
-      FunctionType::get(VoidTy, makeArrayRef(ArgTypes), false);
-  return M.getOrInsertFunction("__llvm_profile_instrument_target",
+      FunctionType::get(ReturnTy, makeArrayRef(ParamTypes), false);
+  return M.getOrInsertFunction(getInstrProfValueProfFuncName(),
                                ValueProfilingCallTy);
 }
 
@@ -343,7 +344,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
                                   getVarName(Inc, getInstrProfDataVarPrefix()));
   Data->setVisibility(NamePtr->getVisibility());
   Data->setSection(getDataSection());
-  Data->setAlignment(8);
+  Data->setAlignment(INSTR_PROF_DATA_ALIGNMENT);
   Data->setComdat(ProfileVarsComdat);
 
   PD.RegionCounters = CounterPtr;