[PATCH] D38648: Make the hardcoded Threshold value in capture tracking configurable via a hidden option
Patrick Walton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 15:17:59 PDT 2017
pcwalton created this revision.
Herald added a subscriber: JDevlieghere.
It was found that the Rust "serde" framework benefits from higher thresholds than the default value of 20. See discussion:
https://github.com/rust-lang/rust/issues/45068
I discussed with @sunfish about whether it was better to make this an option or fix the TODO, but I was told that the TODO is blocked on the new pass manager, so I went with this quick fix.
Please feel free to adjust reviewers as necessary. Thank you :)
https://reviews.llvm.org/D38648
Files:
lib/Analysis/CaptureTracking.cpp
Index: lib/Analysis/CaptureTracking.cpp
===================================================================
--- lib/Analysis/CaptureTracking.cpp
+++ lib/Analysis/CaptureTracking.cpp
@@ -30,6 +30,14 @@
using namespace llvm;
+/// TODO: Write a new FunctionPass AliasAnalysis so that it can keep
+/// a cache. Then we can move the code from BasicAliasAnalysis into
+/// that path, and remove this threshold.
+static cl::opt<unsigned> Threshold(
+ "capture-tracking-threshold", cl::Hidden, cl::init(20),
+ cl::desc("The maximum number of uses that the capture tracker"
+ "will consider trying to walk past (default = 20)"));
+
CaptureTracker::~CaptureTracker() {}
bool CaptureTracker::shouldExplore(const Use *U) { return true; }
@@ -206,15 +214,10 @@
return CB.Captured;
}
-/// TODO: Write a new FunctionPass AliasAnalysis so that it can keep
-/// a cache. Then we can move the code from BasicAliasAnalysis into
-/// that path, and remove this threshold.
-static int const Threshold = 20;
-
void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
assert(V->getType()->isPointerTy() && "Capture is for pointers only!");
- SmallVector<const Use *, Threshold> Worklist;
- SmallSet<const Use *, Threshold> Visited;
+ SmallVector<const Use *, 20> Worklist;
+ SmallSet<const Use *, 20> Visited;
int Count = 0;
for (const Use &U : V->uses()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38648.118093.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171006/3c5b002e/attachment.bin>
More information about the llvm-commits
mailing list