[NFC,StackSafety] Add test flag
authorVitaly Buka <vitalybuka@google.com>
Thu, 28 May 2020 22:36:17 +0000 (15:36 -0700)
committerVitaly Buka <vitalybuka@google.com>
Thu, 28 May 2020 22:38:12 +0000 (15:38 -0700)
llvm/lib/Analysis/StackSafetyAnalysis.cpp

index 1c59d5f..f415fac 100644 (file)
@@ -31,6 +31,9 @@ using namespace llvm;
 static cl::opt<int> StackSafetyMaxIterations("stack-safety-max-iterations",
                                              cl::init(20), cl::Hidden);
 
+static cl::opt<int> StackSafetyPrint("stack-safety-print", cl::init(0),
+                                     cl::Hidden);
+
 namespace {
 
 /// Rewrite an SCEV expression for a memory access address to an expression that
@@ -681,6 +684,8 @@ const StackSafetyGlobalInfo::InfoTy &StackSafetyGlobalInfo::getInfo() const {
       }
     }
     Info.reset(new InfoTy{createGlobalStackSafetyInfo(std::move(Functions))});
+    if (StackSafetyPrint)
+      print(errs());
   }
   return *Info;
 }
@@ -689,7 +694,10 @@ StackSafetyGlobalInfo::StackSafetyGlobalInfo() = default;
 
 StackSafetyGlobalInfo::StackSafetyGlobalInfo(
     Module *M, std::function<const StackSafetyInfo &(Function &F)> GetSSI)
-    : M(M), GetSSI(GetSSI) {}
+    : M(M), GetSSI(GetSSI) {
+  if (StackSafetyPrint > 1)
+    getInfo();
+}
 
 StackSafetyGlobalInfo::StackSafetyGlobalInfo(StackSafetyGlobalInfo &&) =
     default;