summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/InstrProf.cpp
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2019-02-05 22:34:45 +0000
committerRong Xu <xur@google.com>2019-02-05 22:34:45 +0000
commitce10d5ead422f1d2da8476f79e8f2f87db893b34 (patch)
treedc4add6f8a5ec0126a26ead7dc9869df20b822a1 /llvm/lib/ProfileData/InstrProf.cpp
parent63f9def72eb149ed12a6d03d243f89c64cba6f49 (diff)
downloadbcm5719-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.cpp17
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
OpenPOWER on IntegriCloud