[PATCH] [LoopAccesses] Make raw_string_ostream local in VectorizationReport

Adam Nemet anemet at apple.com
Mon Feb 16 14:19:22 PST 2015


Hi hfinkel, aschwaighofer, nadav,

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.

http://reviews.llvm.org/D7678

Files:
  include/llvm/Analysis/LoopAccessAnalysis.h

Index: include/llvm/Analysis/LoopAccessAnalysis.h
===================================================================
--- include/llvm/Analysis/LoopAccessAnalysis.h
+++ include/llvm/Analysis/LoopAccessAnalysis.h
@@ -36,23 +36,22 @@
 /// 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.

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7678.20047.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150216/92551faa/attachment.bin>


More information about the llvm-commits mailing list