[PATCH] [LoopAccesses] Add missing const to APIs in VectorizationReport

Adam Nemet anemet at apple.com
Mon Feb 16 14:20:26 PST 2015


Hi hfinkel, aschwaighofer, nadav,

When I split out LoopAccessReport from this, I need to create some temps
so constness becomes necessary.

This is part of the patchset that converts LoopAccessAnalysis into an
actual analysis pass.

http://reviews.llvm.org/D7689

Files:
  include/llvm/Analysis/LoopAccessAnalysis.h
  lib/Analysis/LoopAccessAnalysis.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp

Index: include/llvm/Analysis/LoopAccessAnalysis.h
===================================================================
--- include/llvm/Analysis/LoopAccessAnalysis.h
+++ include/llvm/Analysis/LoopAccessAnalysis.h
@@ -38,26 +38,27 @@
 /// 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 <typename A> VectorizationReport &operator<<(const A &Value) {
     raw_string_ostream Out(Message);
     Out << Value;
     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);
   }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7689.20058.patch
Type: text/x-patch
Size: 3033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150216/6849a105/attachment.bin>


More information about the llvm-commits mailing list