SanitizerCoverage: Check for null DebugLocs
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 20 Mar 2015 18:48:45 +0000 (18:48 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 20 Mar 2015 18:48:45 +0000 (18:48 +0000)
After a WIP patch to make `DIDescriptor` accessors more strict, this
started asserting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232832 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/SanitizerCoverage.cpp

index 9c74b5ea5c26031a560d337869a5378bf8c601df..9f534e4f51de6a5d2788661dc14ca56aa6622776 100644 (file)
@@ -329,8 +329,9 @@ void SanitizerCoverageModule::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
   }
 
   bool IsEntryBB = &BB == &F.getEntryBlock();
-  DebugLoc EntryLoc =
-      IsEntryBB ? IP->getDebugLoc().getFnDebugLoc(*C) : IP->getDebugLoc();
+  DebugLoc EntryLoc = IsEntryBB && !IP->getDebugLoc().isUnknown()
+                          ? IP->getDebugLoc().getFnDebugLoc(*C)
+                          : IP->getDebugLoc();
   IRBuilder<> IRB(IP);
   IRB.SetCurrentDebugLocation(EntryLoc);
   SmallVector<Value *, 1> Indices;