[PATCH] D109221: [LowerConstantIntrinsics] Fix heap-use-after-free bug in worklist

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 7 14:30:33 PDT 2021


nickdesaulniers added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp:61-68
+  // UnsimplifiedUsers can contain PHI nodes that may be removed when
+  // replacing the branch instructions, so use a value handle worklist
+  // to handle those possibly removed instructions.
+  SmallVector<WeakVH, 8> Worklist(UnsimplifiedUsers.begin(),
+                                  UnsimplifiedUsers.end());
+
+  for (auto &VH : Worklist) {
----------------
Why make a copy of the worklist? Should we just be using `dyn_cast_or_null` rather than `dyn_cast` (ie. without all of the other changes)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109221



More information about the llvm-commits mailing list