[llvm] 57b3bc8 - [CaptureTracking] Add statistics (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 7 03:57:52 PST 2020
Author: Nikita Popov
Date: 2020-11-07T12:57:00+01:00
New Revision: 57b3bc8c603e25380ba56a5b95b2887010e9c1c0
URL: https://github.com/llvm/llvm-project/commit/57b3bc8c603e25380ba56a5b95b2887010e9c1c0
DIFF: https://github.com/llvm/llvm-project/commit/57b3bc8c603e25380ba56a5b95b2887010e9c1c0.diff
LOG: [CaptureTracking] Add statistics (NFC)
Add basic statistics on the number of pointers that have been
determined to maybe capture / not capture.
Added:
Modified:
llvm/lib/Analysis/CaptureTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp
index 6ff7cbc048f2..b2fc6e603f9e 100644
--- a/llvm/lib/Analysis/CaptureTracking.cpp
+++ b/llvm/lib/Analysis/CaptureTracking.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/ValueTracking.h"
@@ -29,6 +30,13 @@
using namespace llvm;
+#define DEBUG_TYPE "capture-tracking"
+
+STATISTIC(NumCaptured, "Number of pointers maybe captured");
+STATISTIC(NumNotCaptured, "Number of pointers not captured");
+STATISTIC(NumCapturedBefore, "Number of pointers maybe captured before");
+STATISTIC(NumNotCapturedBefore, "Number of pointers not captured before");
+
/// The default value for MaxUsesToExplore argument. It's relatively small to
/// keep the cost of analysis reasonable for clients like BasicAliasAnalysis,
/// where the results can't be cached.
@@ -194,6 +202,10 @@ bool llvm::PointerMayBeCaptured(const Value *V,
SimpleCaptureTracker SCT(ReturnCaptures);
PointerMayBeCaptured(V, &SCT, MaxUsesToExplore);
+ if (SCT.Captured)
+ ++NumCaptured;
+ else
+ ++NumNotCaptured;
return SCT.Captured;
}
@@ -222,6 +234,10 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
CapturesBefore CB(ReturnCaptures, I, DT, IncludeI);
PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
+ if (CB.Captured)
+ ++NumCapturedBefore;
+ else
+ ++NumNotCapturedBefore;
return CB.Captured;
}
More information about the llvm-commits
mailing list