[llvm] r229620 - [LoopAccesses] Make raw_string_ostream local in VectorizationReport

Adam Nemet anemet at apple.com
Tue Feb 17 19:42:15 PST 2015


Author: anemet
Date: Tue Feb 17 21:42:15 2015
New Revision: 229620

URL: http://llvm.org/viewvc/llvm-project?rev=229620&view=rev
Log:
[LoopAccesses] Make raw_string_ostream local in VectorizationReport

Since VectorizationReport will be part of the result of the analysis it
will be stored in a container.  However, one of its members is a
raw_string_ostream which cannot be copy-constructed.

This makes the raw_string_ostream local to the << operator.

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

Modified:
    llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h

Modified: llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h?rev=229620&r1=229619&r2=229620&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h Tue Feb 17 21:42:15 2015
@@ -36,23 +36,22 @@ class SCEV;
 /// the user why vectorization did not occur.
 class VectorizationReport {
   std::string Message;
-  raw_string_ostream Out;
   Instruction *Instr;
 
 public:
-  VectorizationReport(Instruction *I = nullptr) : Out(Message), Instr(I) {
-    Out << "loop not vectorized: ";
-  }
+  VectorizationReport(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; }
 
-  std::string &str() { return Out.str(); }
-  operator Twine() { return Out.str(); }
+  std::string &str() { 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.





More information about the llvm-commits mailing list