[StackSafety,NFC] Add statistic counters

This commit is contained in:
Vitaly Buka 2020-06-03 16:12:08 -07:00
parent 5477cf06d6
commit 291dabefde
1 changed files with 8 additions and 1 deletions

View File

@ -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)