[LoopAccesses] Add missing const to APIs in VectorizationReport
authorAdam Nemet <anemet@apple.com>
Thu, 19 Feb 2015 19:15:13 +0000 (19:15 +0000)
committerAdam Nemet <anemet@apple.com>
Thu, 19 Feb 2015 19:15:13 +0000 (19:15 +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@229896 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 936783e53b02c91bb7ab929cfad4039a03d230c6..91b572b6ae6d235f1e10c7ac50adfa6b1b2616ef 100644 (file)
@@ -38,10 +38,10 @@ class SCEV;
 /// 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) {
@@ -50,15 +50,16 @@ public:
     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 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);
index 40b70ef30d47eb3e5082d9e4e0492dabca923a2c..8588e611bc8f2f68f0c63ec323522ac3d78a396d 100644 (file)
@@ -50,12 +50,12 @@ bool VectorizerParams::isInterleaveForced() {
   return ::VectorizationInterleave.getNumOccurrences() > 0;
 }
 
-void VectorizationReport::emitAnalysis(VectorizationReport &Message,
+void VectorizationReport::emitAnalysis(const VectorizationReport &Message,
                                        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());
index 9ced65f13e17e492b30cfa371869493ce4944aa7..e39375fa9296a05a3c4a35370ada72d095b37eb2 100644 (file)
@@ -815,7 +815,7 @@ private:
 
   /// 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);
   }
 
@@ -952,7 +952,7 @@ private:
 
   /// 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);
   }