Index: include/llvm/Analysis/LoopAccessAnalysis.h =================================================================== --- include/llvm/Analysis/LoopAccessAnalysis.h +++ include/llvm/Analysis/LoopAccessAnalysis.h @@ -38,10 +38,10 @@ /// the user why vectorization did not occur. class VectorizationReport { std::string Message; - Instruction *Instr; + const Instruction *Instr; public: - VectorizationReport(Instruction *I = nullptr) + VectorizationReport(const Instruction *I = nullptr) : Message("loop not vectorized: "), Instr(I) {} template VectorizationReport &operator<<(const A &Value) { @@ -50,14 +50,15 @@ return *this; } - Instruction *getInstr() { return Instr; } + const Instruction *getInstr() const { return Instr; } std::string &str() { return Message; } + const std::string &str() const { return Message; } operator Twine() { return Message; } /// \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(VectorizationReport &Message, + static void emitAnalysis(const VectorizationReport &Message, const Function *TheFunction, const Loop *TheLoop); }; Index: lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- lib/Analysis/LoopAccessAnalysis.cpp +++ lib/Analysis/LoopAccessAnalysis.cpp @@ -25,11 +25,11 @@ #define DEBUG_TYPE "loop-accesses" -void VectorizationReport::emitAnalysis(VectorizationReport &Message, +void VectorizationReport::emitAnalysis(const VectorizationReport &Message, const Function *TheFunction, const Loop *TheLoop) { DebugLoc DL = TheLoop->getStartLoc(); - if (Instruction *I = Message.getInstr()) + if (const Instruction *I = Message.getInstr()) DL = I->getDebugLoc(); emitOptimizationRemarkAnalysis(TheFunction->getContext(), "loop-vectorize", *TheFunction, DL, Message.str()); Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -836,7 +836,7 @@ /// Report an analysis message to assist the user in diagnosing loops that are /// not vectorized. - void emitAnalysis(VectorizationReport &Message) { + void emitAnalysis(const VectorizationReport &Message) { VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop); } @@ -970,7 +970,7 @@ /// Report an analysis message to assist the user in diagnosing loops that are /// not vectorized. - void emitAnalysis(VectorizationReport &Message) { + void emitAnalysis(const VectorizationReport &Message) { VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop); }