[PATCH] [LoopVectorize] Factor out a global emitLoopAnalysis
Adam Nemet
anemet at apple.com
Sat Jan 31 15:58:08 PST 2015
Addresses Hal's comment from http://reviews.llvm.org/D7285: change this to Report::emitAnalysis rather
than a global function so that it's more hidden when this all becomes public.
http://reviews.llvm.org/D7280
Files:
lib/Transforms/Vectorize/LoopVectorize.cpp
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -239,6 +239,11 @@
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 @@
}
}
+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<Value *> &To, const Instruction *From) {
for (Value *V : To)
@@ -889,11 +903,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());
+ Report::emitAnalysis(Message, TheFunction, TheLoop);
}
/// The loop that we evaluate.
@@ -1029,11 +1039,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());
+ Report::emitAnalysis(Message, TheFunction, TheLoop);
}
/// Values used only by @llvm.assume calls.
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7280.19101.patch
Type: text/x-patch
Size: 2361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150131/2aa0604c/attachment.bin>
More information about the llvm-commits
mailing list