[PATCH] D11480: [RewriteStatepointsForGC] Use a worklist algorithm for first part of base pointer algorithm [NFC]
Sanjoy Das
sanjoy at playingwithpointers.com
Thu Jul 23 16:39:33 PDT 2015
sanjoy added inline comments.
================
Comment at: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:731
@@ +730,3 @@
+ /* scope */ {
+ SetVector<Value *> Visited;
+ SmallVector<Value*, 16> Worklist;
----------------
Why does this need to be a `SetVector` (as opposed to some variant of a set)?
================
Comment at: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:734
@@ +733,3 @@
+ Worklist.push_back(def);
+ Visited.insert(def);
+ while (!Worklist.empty()) {
----------------
I'd put an `assert(!isKnownBaseResult(Base))` to make it obvious what's going on.
================
Comment at: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:750
@@ +749,3 @@
+ return;
+ Visited.insert(Base);
+ Worklist.push_back(Base);
----------------
`insert` (for SetVector and other set variants) returns a bool stating if the value was present in the set. So you don't need to call both `.count` and `.insert`.
http://reviews.llvm.org/D11480
More information about the llvm-commits
mailing list