From f986a7f39c34d6161d3596300c581a244d4e578a Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Sun, 1 Feb 2015 16:55:58 +0000 Subject: [PATCH] [LoopVectorize] Factor out duplicated code into Report::emitAnalysis The logic in emitAnalysis is duplicated across multiple functions. This splits it into a function. Another use will be added by the patchset. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227748 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Vectorize/LoopVectorize.cpp | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index 68d057d43f8..1d671930c2e 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -239,6 +239,11 @@ public: std::string &str() { return Out.str(); } operator Twine() { return Out.str(); } + + /// \brief Emit an analysis note with the debug location from the instruction + /// in \p Message if available. Otherwise use the location of \p TheLoop. + static void emitAnalysis(Report &Message, const Function *TheFunction, + const Loop *TheLoop); }; /// InnerLoopVectorizer vectorizes loops which contain only one basic @@ -551,6 +556,15 @@ static void propagateMetadata(Instruction *To, const Instruction *From) { } } +void Report::emitAnalysis(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) @@ -889,11 +903,7 @@ private: /// 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()); + Report::emitAnalysis(Message, TheFunction, TheLoop); } /// The loop that we evaluate. @@ -1029,11 +1039,7 @@ private: /// 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()); + Report::emitAnalysis(Message, TheFunction, TheLoop); } /// Values used only by @llvm.assume calls. -- 2.40.0