[LoopAccesses] Add missing const to APIs in VectorizationReport
authorAdam Nemet <anemet@apple.com>
Wed, 18 Feb 2015 03:44:20 +0000 (03:44 +0000)
committerAdam Nemet <anemet@apple.com>
Wed, 18 Feb 2015 03:44:20 +0000 (03:44 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229631 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 937718b5408a61d9141bfd93fdc800b3f30245e3..a3dcb79ec3495b69b56c8528232ffbd11c608daa 100644 (file)
@@ -38,10 +38,10 @@ class SCEV;
 /// the user why vectorization did not occur.
 class VectorizationReport {
   std::string Message;
 /// the user why vectorization did not occur.
 class VectorizationReport {
   std::string Message;
-  Instruction *Instr;
+  const Instruction *Instr;
 
 public:
 
 public:
-  VectorizationReport(Instruction *I = nullptr)
+  VectorizationReport(const Instruction *I = nullptr)
       : Message("loop not vectorized: "), Instr(I) {}
 
   template <typename A> VectorizationReport &operator<<(const A &Value) {
       : Message("loop not vectorized: "), Instr(I) {}
 
   template <typename A> VectorizationReport &operator<<(const A &Value) {
@@ -50,15 +50,16 @@ public:
     return *this;
   }
 
     return *this;
   }
 
-  Instruction *getInstr() { return Instr; }
+  const Instruction *getInstr() const { return Instr; }
 
   std::string &str() { return Message; }
 
   std::string &str() { return Message; }
+  const std::string &str() const { return Message; }
   operator Twine() { return Message; }
 
   /// \brief Emit an analysis note for \p PassName with the debug location from
   /// the instruction in \p Message if available.  Otherwise use the location of
   /// \p TheLoop.
   operator Twine() { return Message; }
 
   /// \brief Emit an analysis note for \p PassName 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,
                            const char *PassName);
                            const Function *TheFunction,
                            const Loop *TheLoop,
                            const char *PassName);
index ba2f9b8e427366c05cc048f237a94699928997a3..68f9ee1cb4e227b7d7f11666679ec31c764dcfa3 100644 (file)
@@ -25,12 +25,12 @@ using namespace llvm;
 
 #define DEBUG_TYPE "loop-accesses"
 
 
 #define DEBUG_TYPE "loop-accesses"
 
-void VectorizationReport::emitAnalysis(VectorizationReport &Message,
+void VectorizationReport::emitAnalysis(const VectorizationReport &Message,
                                        const Function *TheFunction,
                                        const Loop *TheLoop,
                                        const char *PassName) {
   DebugLoc DL = TheLoop->getStartLoc();
                                        const Function *TheFunction,
                                        const Loop *TheLoop,
                                        const char *PassName) {
   DebugLoc DL = TheLoop->getStartLoc();
-  if (Instruction *I = Message.getInstr())
+  if (const Instruction *I = Message.getInstr())
     DL = I->getDebugLoc();
   emitOptimizationRemarkAnalysis(TheFunction->getContext(), PassName,
                                  *TheFunction, DL, Message.str());
     DL = I->getDebugLoc();
   emitOptimizationRemarkAnalysis(TheFunction->getContext(), PassName,
                                  *TheFunction, DL, Message.str());
index efbc746ef62f45d4077940d33650ce6c26eccdce..a6dbeed6bc860f6f38820fd8628515c490ebffd7 100644 (file)
@@ -836,7 +836,7 @@ private:
 
   /// Report an analysis message to assist the user in diagnosing loops that are
   /// not vectorized.
 
   /// 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, LV_NAME);
   }
 
     VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop, LV_NAME);
   }
 
@@ -973,7 +973,7 @@ private:
 
   /// Report an analysis message to assist the user in diagnosing loops that are
   /// not vectorized.
 
   /// 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, LV_NAME);
   }
 
     VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop, LV_NAME);
   }