"__llvm_pgo_register_functions",
&CGM.getModule());
RegisterF->setUnnamedAddr(true);
- RegisterF->addFnAttr(llvm::Attribute::NoInline);
if (CGM.getCodeGenOpts().DisableRedZone)
RegisterF->addFnAttr(llvm::Attribute::NoRedZone);
RuntimeRegisterTy);
}
-static llvm::Constant *getOrInsertRuntimeWriteAtExit(CodeGenModule &CGM) {
- // TODO: make this depend on a command-line option.
- auto *VoidTy = llvm::Type::getVoidTy(CGM.getLLVMContext());
- auto *WriteAtExitTy = llvm::FunctionType::get(VoidTy, false);
- return CGM.getModule().getOrInsertFunction("__llvm_pgo_register_write_atexit",
- WriteAtExitTy);
-}
-
static bool isMachO(const CodeGenModule &CGM) {
return CGM.getTarget().getTriple().isOSBinFormatMachO();
}
if (CGM.getModule().getFunction("__llvm_pgo_init"))
return nullptr;
- // Get the functions to call at initialization.
+ // Get the function to call at initialization.
llvm::Constant *RegisterF = getRegisterFunc(CGM);
- llvm::Constant *WriteAtExitF = getOrInsertRuntimeWriteAtExit(CGM);
- if (!RegisterF && !WriteAtExitF)
+ if (!RegisterF)
return nullptr;
// Create the initialization function.
// Add the basic block and the necessary calls.
CGBuilderTy Builder(llvm::BasicBlock::Create(CGM.getLLVMContext(), "", F));
- if (RegisterF)
- Builder.CreateCall(RegisterF);
- if (WriteAtExitF)
- Builder.CreateCall(WriteAtExitF);
+ Builder.CreateCall(RegisterF);
Builder.CreateRetVoid();
return F;
Args.hasArg(options::OPT_fprofile_instr_generate) ||
Args.hasArg(options::OPT_fcreate_profile) ||
Args.hasArg(options::OPT_coverage)) {
+ // Pull in runtime for -fprofile-inst-generate. This is required since
+ // there are no calls to the runtime in the code.
+ if (Args.hasArg(options::OPT_fprofile_instr_generate)) {
+ CmdArgs.push_back("-u");
+ CmdArgs.push_back("___llvm_pgo_runtime");
+ }
+
// Select the appropriate runtime library for the target.
if (isTargetIOSBased())
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a");