mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[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
This commit is contained in:
parent
cb0186abee
commit
a75864e8e1
@ -1040,6 +1040,9 @@ struct Header {
|
|||||||
void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart,
|
void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart,
|
||||||
int64_t &RangeLast);
|
int64_t &RangeLast);
|
||||||
|
|
||||||
|
// Create the variable for the profile file name.
|
||||||
|
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput);
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
||||||
#endif // LLVM_PROFILEDATA_INSTRPROF_H
|
#endif // LLVM_PROFILEDATA_INSTRPROF_H
|
||||||
|
@ -1011,4 +1011,21 @@ void getMemOPSizeRangeFromOption(StringRef MemOPSizeRange, int64_t &RangeStart,
|
|||||||
assert(RangeLast >= 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
|
} // end namespace llvm
|
||||||
|
@ -967,22 +967,8 @@ void InstrProfiling::emitUses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InstrProfiling::emitInitialization() {
|
void InstrProfiling::emitInitialization() {
|
||||||
StringRef InstrProfileOutput = Options.InstrProfileOutput;
|
// Create variable for profile name.
|
||||||
|
createProfileFileNameVar(*M, Options.InstrProfileOutput);
|
||||||
if (!InstrProfileOutput.empty()) {
|
|
||||||
// Create variable for profile name.
|
|
||||||
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));
|
|
||||||
if (TT.supportsCOMDAT()) {
|
|
||||||
ProfileNameVar->setLinkage(GlobalValue::ExternalLinkage);
|
|
||||||
ProfileNameVar->setComdat(M->getOrInsertComdat(
|
|
||||||
StringRef(INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function *RegisterF = M->getFunction(getInstrProfRegFuncsName());
|
Function *RegisterF = M->getFunction(getInstrProfRegFuncsName());
|
||||||
if (!RegisterF)
|
if (!RegisterF)
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user