Create undef reference to profile hook symbol

Create undef reference to profile hook symbol when
PGO instrumentation is turned on. This allows 
LLVM to omit emission of hook variable use method
for every single module instrumented.

llvm-svn: 251385
This commit is contained in:
Xinliang David Li 2015-10-27 05:15:35 +00:00
parent b61e14e596
commit 170cd100ed
2 changed files with 15 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@ -3811,6 +3812,18 @@ SanitizerMask Linux::getSupportedSanitizers() const {
return Res;
}
void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {
if (!needsProfileRT(Args)) return;
// Add linker option -u__llvm_runtime_variable to cause runtime
// initialization module to be linked in.
if (!Args.hasArg(options::OPT_coverage))
CmdArgs.push_back(Args.MakeArgString(
Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
ToolChain::addProfileRTLibs(Args, CmdArgs);
}
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple,

View File

@ -744,6 +744,8 @@ public:
llvm::opt::ArgStringList &CC1Args) const override;
bool isPIEDefault() const override;
SanitizerMask getSupportedSanitizers() const override;
void addProfileRTLibs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
std::string Linker;
std::vector<std::string> ExtraOpts;