[LV] When reporting about a specific instruction without debug location use loop's
This can occur for example if some optimization drops the debug location.
llvm-svn: 282048
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 6cf36a8..978e7a5 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -99,7 +99,10 @@
DebugLoc DL = TheLoop->getStartLoc();
const Value *V = TheLoop->getHeader();
if (const Instruction *I = Message.getInstr()) {
- DL = I->getDebugLoc();
+ // If there is no debug location attached to the instruction, revert back to
+ // using the loop's.
+ if (I->getDebugLoc())
+ DL = I->getDebugLoc();
V = I->getParent();
}
ORE.emitOptimizationRemarkAnalysis(PassName, DL, V, Message.str());