mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[CaptureTracking] Replace hardcoded constant to option. NFC.
The motivation is to be able to play with the option and change if it is required. Reviewers: fedor.sergeev, apilipenko, rnk, jdoerfert Reviewed By: fedor.sergeev Subscribers: hiraditya, dantrushin, llvm-commits Differential Revision: https://reviews.llvm.org/D78624
This commit is contained in:
parent
1d82c3d44a
commit
5b93390019
@ -21,13 +21,10 @@ namespace llvm {
|
||||
class Instruction;
|
||||
class DominatorTree;
|
||||
|
||||
/// 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.
|
||||
/// TODO: we should probably introduce a caching CaptureTracking analysis and
|
||||
/// use it where possible. The caching version can use much higher limit or
|
||||
/// don't have this cap at all.
|
||||
unsigned constexpr DefaultMaxUsesToExplore = 20;
|
||||
/// getDefaultMaxUsesToExploreForCaptureTracking - Return default value of
|
||||
/// the maximal number of uses to explore before giving up. It is used by
|
||||
/// PointerMayBeCaptured family analysys.
|
||||
unsigned getDefaultMaxUsesToExploreForCaptureTracking();
|
||||
|
||||
/// PointerMayBeCaptured - Return true if this pointer value may be captured
|
||||
/// by the enclosing function (which is required to exist). This routine can
|
||||
@ -38,10 +35,10 @@ namespace llvm {
|
||||
/// automatically counts as capturing it or not.
|
||||
/// MaxUsesToExplore specifies how many uses should the analysis explore for
|
||||
/// one value before giving up due too "too many uses".
|
||||
bool PointerMayBeCaptured(const Value *V,
|
||||
bool ReturnCaptures,
|
||||
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures,
|
||||
bool StoreCaptures,
|
||||
unsigned MaxUsesToExplore = DefaultMaxUsesToExplore);
|
||||
unsigned MaxUsesToExplore =
|
||||
getDefaultMaxUsesToExploreForCaptureTracking());
|
||||
|
||||
/// PointerMayBeCapturedBefore - Return true if this pointer value may be
|
||||
/// captured by the enclosing function (which is required to exist). If a
|
||||
@ -55,10 +52,11 @@ namespace llvm {
|
||||
/// final parameter is true.
|
||||
/// MaxUsesToExplore specifies how many uses should the analysis explore for
|
||||
/// one value before giving up due too "too many uses".
|
||||
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
|
||||
bool StoreCaptures, const Instruction *I,
|
||||
const DominatorTree *DT, bool IncludeI = false,
|
||||
unsigned MaxUsesToExplore = DefaultMaxUsesToExplore);
|
||||
bool PointerMayBeCapturedBefore(
|
||||
const Value *V, bool ReturnCaptures, bool StoreCaptures,
|
||||
const Instruction *I, const DominatorTree *DT, bool IncludeI = false,
|
||||
unsigned MaxUsesToExplore =
|
||||
getDefaultMaxUsesToExploreForCaptureTracking());
|
||||
|
||||
/// This callback is used in conjunction with PointerMayBeCaptured. In
|
||||
/// addition to the interface here, you'll need to provide your own getters
|
||||
@ -94,7 +92,8 @@ namespace llvm {
|
||||
/// MaxUsesToExplore specifies how many uses should the analysis explore for
|
||||
/// one value before giving up due too "too many uses".
|
||||
void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
|
||||
unsigned MaxUsesToExplore = DefaultMaxUsesToExplore);
|
||||
unsigned MaxUsesToExplore =
|
||||
getDefaultMaxUsesToExploreForCaptureTracking());
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
@ -28,6 +28,21 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
/// 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.
|
||||
/// TODO: we should probably introduce a caching CaptureTracking analysis and
|
||||
/// use it where possible. The caching version can use much higher limit or
|
||||
/// don't have this cap at all.
|
||||
static cl::opt<unsigned>
|
||||
DefaultMaxUsesToExplore("capture-tracking-max-uses-to-explore", cl::Hidden,
|
||||
cl::desc("Maximal number of uses to explore."),
|
||||
cl::init(20));
|
||||
|
||||
unsigned llvm::getDefaultMaxUsesToExploreForCaptureTracking() {
|
||||
return DefaultMaxUsesToExplore;
|
||||
}
|
||||
|
||||
CaptureTracker::~CaptureTracker() {}
|
||||
|
||||
bool CaptureTracker::shouldExplore(const Use *U) { return true; }
|
||||
@ -215,8 +230,9 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
|
||||
void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
|
||||
unsigned MaxUsesToExplore) {
|
||||
assert(V->getType()->isPointerTy() && "Capture is for pointers only!");
|
||||
SmallVector<const Use *, DefaultMaxUsesToExplore> Worklist;
|
||||
SmallSet<const Use *, DefaultMaxUsesToExplore> Visited;
|
||||
SmallVector<const Use *, 20> Worklist;
|
||||
Worklist.reserve(getDefaultMaxUsesToExploreForCaptureTracking());
|
||||
SmallSet<const Use *, 20> Visited;
|
||||
|
||||
auto AddUses = [&](const Value *V) {
|
||||
unsigned Count = 0;
|
||||
|
@ -4170,7 +4170,8 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {
|
||||
// defined in AACaptureUseTracker, that can look at in-flight abstract
|
||||
// attributes and directly updates the assumed state.
|
||||
SmallVector<const Value *, 4> PotentialCopies;
|
||||
unsigned RemainingUsesToExplore = DefaultMaxUsesToExplore;
|
||||
unsigned RemainingUsesToExplore =
|
||||
getDefaultMaxUsesToExploreForCaptureTracking();
|
||||
AACaptureUseTracker Tracker(A, *this, IsDeadAA, T, PotentialCopies,
|
||||
RemainingUsesToExplore);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user