diff options
author | Rong Xu <xur@google.com> | 2019-02-05 22:34:45 +0000 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2019-02-05 22:34:45 +0000 |
commit | ce10d5ead422f1d2da8476f79e8f2f87db893b34 (patch) | |
tree | dc4add6f8a5ec0126a26ead7dc9869df20b822a1 /llvm/lib/ProfileData/InstrProf.cpp | |
parent | 63f9def72eb149ed12a6d03d243f89c64cba6f49 (diff) | |
download | bcm5719-llvm-ce10d5ead422f1d2da8476f79e8f2f87db893b34.tar.gz bcm5719-llvm-ce10d5ead422f1d2da8476f79e8f2f87db893b34.zip |
[PGO] Use a function for creating variable for profile file name. NFC.
Factored out the code for creating variable for profile file name to
a function.
llvm-svn: 353230
Diffstat (limited to 'llvm/lib/ProfileData/InstrProf.cpp')
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index d4efde0fb27..8a2ff7769f1 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -1011,4 +1011,21 @@ void getMemOPSizeRangeFromOption(StringRef MemOPSizeRange, int64_t &RangeStart, assert(RangeLast >= RangeStart); } +// Create the variable for the profile file name. +void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput) { + if (InstrProfileOutput.empty()) + return; + Constant *ProfileNameConst = + ConstantDataArray::getString(M.getContext(), InstrProfileOutput, true); + GlobalVariable *ProfileNameVar = new GlobalVariable( + M, ProfileNameConst->getType(), true, GlobalValue::WeakAnyLinkage, + ProfileNameConst, INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR)); + Triple TT(M.getTargetTriple()); + if (TT.supportsCOMDAT()) { + ProfileNameVar->setLinkage(GlobalValue::ExternalLinkage); + ProfileNameVar->setComdat(M.getOrInsertComdat( + StringRef(INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR)))); + } +} + } // end namespace llvm |