[PATCH] D70752: LowerDbgDeclare: look through bitcasts.

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 14:55:56 PST 2019


vsk added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:1425
+    SmallVector<const Value *, 8> WorkList;
+    WorkList.push_back(AI);
+    while (!WorkList.empty()) {
----------------
aprantl wrote:
> aprantl wrote:
> > vsk wrote:
> > > aprantl wrote:
> > > > I think the worklist is overkill here, since it will contain at most one element. How about turning the loop body into a helper function/lambda and calling it recursively?
> > > I think the worklist would contain more than one element in this case:
> > > ```
> > > %a = alloca
> > > %c1 = bitcast %a to ...
> > > call void @use(%c1)
> > > %c2 = bitcast %a to ...
> > > call void @use(%c2)
> > > ```
> > > That is probably worth a test, though.
> > But that would also work fine with the recursive implementation, right?
> Unless we are expecting very deep recursion I would prefer the recursive solution over the worklist since it is much easier to understand.
Yes, a recursive approach would work fine. Fwiw, the patch as-written seems idiomatic to me (the alloca use visitation logic in both CaptureTracking & PtrUseVisitor look like this).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70752/new/

https://reviews.llvm.org/D70752





More information about the llvm-commits mailing list