[llvm] b1600d8 - [NFC] Guard the cost report block of debug outputs with NDEBUG and

Dinar Temirbulatov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 07:35:24 PDT 2020


Author: Dinar Temirbulatov
Date: 2020-08-11T16:34:47+02:00
New Revision: b1600d8b8971e7d5967ed29476ee3ae71ade6a81

URL: https://github.com/llvm/llvm-project/commit/b1600d8b8971e7d5967ed29476ee3ae71ade6a81
DIFF: https://github.com/llvm/llvm-project/commit/b1600d8b8971e7d5967ed29476ee3ae71ade6a81.diff

LOG: [NFC] Guard the cost report block of debug outputs with NDEBUG and
switch to SmallString, this is part of D57779.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 3502ae90d695..6a5e8e25951c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/iterator.h"
@@ -3911,17 +3912,18 @@ int BoUpSLP::getTreeCost() {
   int SpillCost = getSpillCost();
   Cost += SpillCost + ExtractCost;
 
-  std::string Str;
+#ifndef NDEBUG
+  SmallString<256> Str;
   {
-    raw_string_ostream OS(Str);
+    raw_svector_ostream OS(Str);
     OS << "SLP: Spill Cost = " << SpillCost << ".\n"
        << "SLP: Extract Cost = " << ExtractCost << ".\n"
        << "SLP: Total Cost = " << Cost << ".\n";
   }
   LLVM_DEBUG(dbgs() << Str);
-
   if (ViewSLPTree)
     ViewGraph(this, "SLP" + F->getName(), false, Str);
+#endif
 
   return Cost;
 }


        


More information about the llvm-commits mailing list