diff options
author | Diego Novillo <dnovillo@google.com> | 2015-10-27 17:37:00 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2015-10-27 17:37:00 +0000 |
commit | c04270d2e44c4eab0cd2b1ae64601804d654db9c (patch) | |
tree | aa44a8c143371d7692f0fbfa93ddaf802bb87e20 /llvm/lib/Transforms/IPO/SampleProfile.cpp | |
parent | 012f1acca7b63e408bab14cc21ad73c54e2dca08 (diff) | |
download | llvm-c04270d2e44c4eab0cd2b1ae64601804d654db9c.zip llvm-c04270d2e44c4eab0cd2b1ae64601804d654db9c.tar.gz llvm-c04270d2e44c4eab0cd2b1ae64601804d654db9c.tar.bz2 |
Fix SamplePGO segfault when debug info is missing.
When emitting a remark for a conditional branch annotation, the remark
uses the line location information of the conditional branch in the
message. In some cases, that information is unavailable and the
optimization would segfaul. I'm still not sure whether this is a bug or
WAI, but the optimizer should not die because of this.
llvm-svn: 251420
Diffstat (limited to 'llvm/lib/Transforms/IPO/SampleProfile.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/SampleProfile.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 6ab73450..d8f8eb8 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -780,8 +780,10 @@ void SampleProfileLoader::propagateWeights(Function &F) { emitOptimizationRemark( Ctx, DEBUG_TYPE, F, MaxDestLoc, Twine("most popular destination for conditional branches at ") + - BranchLoc->getFilename() + ":" + Twine(BranchLoc.getLine()) + - ":" + Twine(BranchLoc.getCol())); + ((BranchLoc) ? Twine(BranchLoc->getFilename() + ":" + + Twine(BranchLoc.getLine()) + ":" + + Twine(BranchLoc.getCol())) + : Twine("<UNKNOWN LOCATION>"))); } else { DEBUG(dbgs() << "SKIPPED. All branch weights are zero.\n"); } |