From: Duncan P. N. Exon Smith Date: Fri, 20 Mar 2015 00:56:55 +0000 (+0000) Subject: SampleProfile: Check for missing debug locations X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=67934e4b411a29383059d3ecab09dc184601c75e;p=oota-llvm.git SampleProfile: Check for missing debug locations Don't use `DebugLoc` accessors if we're pointing at null, which will be a problem after a WIP patch to make the `DIDescriptor` accessors more strict. Caught by Frontend/profile-sample-use-loc-tracking.c (in clang). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232792 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/SampleProfile.cpp b/lib/Transforms/Scalar/SampleProfile.cpp index c7232a97764..3e7cf04001f 100644 --- a/lib/Transforms/Scalar/SampleProfile.cpp +++ b/lib/Transforms/Scalar/SampleProfile.cpp @@ -217,6 +217,9 @@ void SampleProfileLoader::printBlockWeight(raw_ostream &OS, BasicBlock *BB) { /// \returns The profiled weight of I. unsigned SampleProfileLoader::getInstWeight(Instruction &Inst) { DebugLoc DLoc = Inst.getDebugLoc(); + if (DLoc.isUnknown()) + return 0; + unsigned Lineno = DLoc.getLine(); if (Lineno < HeaderLineno) return 0;