Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -552,6 +552,17 @@ } } +/// \brief Emit an analysis note with the debug location from the instruction in +/// \p Message or \p TheLoop's. +static void emitLoopAnalysis(Report &Message, const Function *TheFunction, + const Loop *TheLoop) { + DebugLoc DL = TheLoop->getStartLoc(); + if (Instruction *I = Message.getInstr()) + DL = I->getDebugLoc(); + emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE, + *TheFunction, DL, Message.str()); +} + /// \brief Propagate known metadata from one instruction to a vector of others. static void propagateMetadata(SmallVectorImpl &To, const Instruction *From) { for (Value *V : To) @@ -835,11 +846,7 @@ /// Report an analysis message to assist the user in diagnosing loops that are /// not vectorized. void emitAnalysis(Report &Message) { - DebugLoc DL = TheLoop->getStartLoc(); - if (Instruction *I = Message.getInstr()) - DL = I->getDebugLoc(); - emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE, - *TheFunction, DL, Message.str()); + emitLoopAnalysis(Message, TheFunction, TheLoop); } /// The loop that we evaluate. @@ -975,11 +982,7 @@ /// Report an analysis message to assist the user in diagnosing loops that are /// not vectorized. void emitAnalysis(Report &Message) { - DebugLoc DL = TheLoop->getStartLoc(); - if (Instruction *I = Message.getInstr()) - DL = I->getDebugLoc(); - emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE, - *TheFunction, DL, Message.str()); + emitLoopAnalysis(Message, TheFunction, TheLoop); } /// Values used only by @llvm.assume calls.