[llvm] r272875 - Attempt to define friend function more portably.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 00:00:22 PDT 2016


Author: silvas
Date: Thu Jun 16 02:00:19 2016
New Revision: 272875

URL: http://llvm.org/viewvc/llvm-project?rev=272875&view=rev
Log:
Attempt to define friend function more portably.

Patch written by Reid. I verified it locally with clang.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=272875&r1=272874&r2=272875&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Thu Jun 16 02:00:19 2016
@@ -601,7 +601,6 @@ private:
   /// A list of blocks that we are going to CSE.
   SetVector<BasicBlock *> CSEBlocks;
 
-public: // Workaround for MSVC friend semantics.
   /// Contains all scheduling relevant data for an instruction.
   /// A ScheduleData either represents a single instruction or a member of an
   /// instruction bundle (= a group of instructions which is combined into a
@@ -731,11 +730,13 @@ public: // Workaround for MSVC friend se
     /// dry-run).
     bool IsScheduled;
   };
-private:
 
 #ifndef NDEBUG
-  friend raw_ostream &operator<<(raw_ostream &os,
-                                 const BoUpSLP::ScheduleData &SD);
+  friend inline raw_ostream &operator<<(raw_ostream &os,
+                                        const BoUpSLP::ScheduleData &SD) {
+    SD.dump(os);
+    return os;
+  }
 #endif
 
   /// Contains all scheduling data for a basic block.
@@ -945,21 +946,9 @@ private:
   MapVector<Value *, uint64_t> MinBWs;
 };
 
-#ifndef NDEBUG
-raw_ostream &operator<<(raw_ostream &os, const BoUpSLP::ScheduleData &SD);
-#endif
-
 } // end namespace llvm
 } // end namespace slpvectorizer
 
-#ifndef NDEBUG
-raw_ostream &llvm::slpvectorizer::operator<<(raw_ostream &os,
-                                             const BoUpSLP::ScheduleData &SD) {
-  SD.dump(os);
-  return os;
-}
-#endif
-
 void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
                         ArrayRef<Value *> UserIgnoreLst) {
   deleteTree();




More information about the llvm-commits mailing list