summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/DiagnosticInfo.cpp10
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp5
2 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp
index eab14e69eaa..4753789d9c1 100644
--- a/llvm/lib/IR/DiagnosticInfo.cpp
+++ b/llvm/lib/IR/DiagnosticInfo.cpp
@@ -123,10 +123,12 @@ void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const {
}
void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {
- if (getFileName() && getLineNum() > 0)
- DP << getFileName() << ":" << getLineNum() << ": ";
- else if (getFileName())
- DP << getFileName() << ": ";
+ if (!FileName.empty()) {
+ DP << getFileName();
+ if (LineNum > 0)
+ DP << ":" << getLineNum();
+ DP << ": ";
+ }
DP << getMsg();
}
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 7c01a8672fe..5979f022bc6 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1009,9 +1009,8 @@ bool SampleProfileLoader::emitAnnotations(Function &F) {
unsigned Total = CoverageTracker.countBodySamples(Samples);
unsigned Coverage = CoverageTracker.computeCoverage(Used, Total);
if (Coverage < SampleProfileCoverage) {
- StringRef Filename = getDISubprogram(&F)->getFilename();
F.getContext().diagnose(DiagnosticInfoSampleProfile(
- Filename.str().c_str(), getFunctionLoc(F),
+ getDISubprogram(&F)->getFilename(), getFunctionLoc(F),
Twine(Used) + " of " + Twine(Total) + " available profile records (" +
Twine(Coverage) + "%) were applied",
DS_Warning));
@@ -1033,7 +1032,7 @@ bool SampleProfileLoader::doInitialization(Module &M) {
auto ReaderOrErr = SampleProfileReader::create(Filename, Ctx);
if (std::error_code EC = ReaderOrErr.getError()) {
std::string Msg = "Could not open profile: " + EC.message();
- Ctx.diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));
+ Ctx.diagnose(DiagnosticInfoSampleProfile(Filename, Msg));
return false;
}
Reader = std::move(ReaderOrErr.get());
OpenPOWER on IntegriCloud