[llvm] r300544 - [SampleProfile] Don't assert when printing the DebugLoc of a branch. NFC.
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 18 04:27:59 PDT 2017
Author: adibiagio
Date: Tue Apr 18 06:27:58 2017
New Revision: 300544
URL: http://llvm.org/viewvc/llvm-project?rev=300544&view=rev
Log:
[SampleProfile] Don't assert when printing the DebugLoc of a branch. NFC.
Modified:
llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=300544&r1=300543&r2=300544&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Tue Apr 18 06:27:58 2017
@@ -1191,8 +1191,11 @@ void SampleProfileLoader::propagateWeigh
if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI))
continue;
+ DebugLoc BranchLoc = TI->getDebugLoc();
DEBUG(dbgs() << "\nGetting weights for branch at line "
- << TI->getDebugLoc().getLine() << ".\n");
+ << ((BranchLoc) ? Twine(BranchLoc.getLine())
+ : Twine("<UNKNOWN LOCATION>"))
+ << ".\n");
SmallVector<uint32_t, 4> Weights;
uint32_t MaxWeight = 0;
DebugLoc MaxDestLoc;
@@ -1229,7 +1232,6 @@ void SampleProfileLoader::propagateWeigh
DEBUG(dbgs() << "SUCCESS. Found non-zero weights.\n");
TI->setMetadata(llvm::LLVMContext::MD_prof,
MDB.createBranchWeights(Weights));
- DebugLoc BranchLoc = TI->getDebugLoc();
emitOptimizationRemark(
Ctx, DEBUG_TYPE, F, MaxDestLoc,
Twine("most popular destination for conditional branches at ") +
More information about the llvm-commits
mailing list