From 615f6579bd0d4911e536f0bcac6d9e366d83eb3c Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Tue, 18 Apr 2017 11:27:58 +0000 Subject: [PATCH] [SampleProfile] Don't assert when printing the DebugLoc of a branch. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300544 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/SampleProfile.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index 642d80e6b8a..e755e2bd8f2 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -1191,8 +1191,11 @@ void SampleProfileLoader::propagateWeights(Function &F) { if (!isa(TI) && !isa(TI)) continue; + DebugLoc BranchLoc = TI->getDebugLoc(); DEBUG(dbgs() << "\nGetting weights for branch at line " - << TI->getDebugLoc().getLine() << ".\n"); + << ((BranchLoc) ? Twine(BranchLoc.getLine()) + : Twine("")) + << ".\n"); SmallVector Weights; uint32_t MaxWeight = 0; DebugLoc MaxDestLoc; @@ -1229,7 +1232,6 @@ void SampleProfileLoader::propagateWeights(Function &F) { 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 ") + -- 2.40.0