[llvm] 291dabe - [StackSafety,NFC] Add statistic counters

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 16:25:40 PDT 2020


Author: Vitaly Buka
Date: 2020-06-03T16:12:08-07:00
New Revision: 291dabefde01eae7473da224b49f6359766e0663

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

LOG: [StackSafety,NFC] Add statistic counters

Added: 
    

Modified: 
    llvm/lib/Analysis/StackSafetyAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index d4689f5fefa3..e0c864fd85e1 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -11,6 +11,7 @@
 #include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
 #include "llvm/IR/ConstantRange.h"
 #include "llvm/IR/DerivedTypes.h"
@@ -30,6 +31,9 @@ using namespace llvm;
 
 #define DEBUG_TYPE "stack-safety"
 
+STATISTIC(NumAllocaStackSafe, "Number of safe allocas");
+STATISTIC(NumAllocaTotal, "Number of total allocas");
+
 static cl::opt<int> StackSafetyMaxIterations("stack-safety-max-iterations",
                                              cl::init(20), cl::Hidden);
 
@@ -660,9 +664,12 @@ const StackSafetyGlobalInfo::InfoTy &StackSafetyGlobalInfo::getInfo() const {
         new InfoTy{createGlobalStackSafetyInfo(std::move(Functions)), {}});
     for (auto &FnKV : Info->Info) {
       for (auto &KV : FnKV.second.Allocas) {
+        ++NumAllocaTotal;
         const AllocaInst *AI = KV.first;
-        if (getStaticAllocaSizeRange(*AI).contains(KV.second.Range))
+        if (getStaticAllocaSizeRange(*AI).contains(KV.second.Range)) {
           Info->SafeAllocas.insert(AI);
+          ++NumAllocaStackSafe;
+        }
       }
     }
     if (StackSafetyPrint)


        


More information about the llvm-commits mailing list