forked from OSchip/llvm-project
[CaptureTracking] Add statistics (NFC)
Add basic statistics on the number of pointers that have been determined to maybe capture / not capture.
This commit is contained in:
parent
f63ab188c6
commit
57b3bc8c60
|
@ -18,6 +18,7 @@
|
||||||
#include "llvm/Analysis/CaptureTracking.h"
|
#include "llvm/Analysis/CaptureTracking.h"
|
||||||
#include "llvm/ADT/SmallSet.h"
|
#include "llvm/ADT/SmallSet.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Analysis/AliasAnalysis.h"
|
#include "llvm/Analysis/AliasAnalysis.h"
|
||||||
#include "llvm/Analysis/CFG.h"
|
#include "llvm/Analysis/CFG.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
|
@ -29,6 +30,13 @@
|
||||||
|
|
||||||
using namespace llvm;
|
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
|
/// The default value for MaxUsesToExplore argument. It's relatively small to
|
||||||
/// keep the cost of analysis reasonable for clients like BasicAliasAnalysis,
|
/// keep the cost of analysis reasonable for clients like BasicAliasAnalysis,
|
||||||
/// where the results can't be cached.
|
/// where the results can't be cached.
|
||||||
|
@ -194,6 +202,10 @@ bool llvm::PointerMayBeCaptured(const Value *V,
|
||||||
|
|
||||||
SimpleCaptureTracker SCT(ReturnCaptures);
|
SimpleCaptureTracker SCT(ReturnCaptures);
|
||||||
PointerMayBeCaptured(V, &SCT, MaxUsesToExplore);
|
PointerMayBeCaptured(V, &SCT, MaxUsesToExplore);
|
||||||
|
if (SCT.Captured)
|
||||||
|
++NumCaptured;
|
||||||
|
else
|
||||||
|
++NumNotCaptured;
|
||||||
return SCT.Captured;
|
return SCT.Captured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,6 +234,10 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
|
||||||
|
|
||||||
CapturesBefore CB(ReturnCaptures, I, DT, IncludeI);
|
CapturesBefore CB(ReturnCaptures, I, DT, IncludeI);
|
||||||
PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
|
PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
|
||||||
|
if (CB.Captured)
|
||||||
|
++NumCapturedBefore;
|
||||||
|
else
|
||||||
|
++NumNotCapturedBefore;
|
||||||
return CB.Captured;
|
return CB.Captured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue