[PATCH] D80206: [IR] Clean up dead instructions after simplifying a conditional branch

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 05:26:59 PDT 2020


foad marked an inline comment as done.
foad added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:476
   for (; S != E; ++S) {
-    auto *I = cast<Instruction>(DeadInsts[S]);
-    if (!isInstructionTriviallyDead(I)) {
+    auto *I = dyn_cast<Instruction>(DeadInsts[S]);
+    if (!I || !isInstructionTriviallyDead(I)) {
----------------
fhahn wrote:
> Why change this to a dyn_cast? Looks like only Instructions are added in `removePredecessor`?
`removePredecessor` only adds Instructions, but then in some cases it will `replaceAllUsesWith` one of those Instructions with an arbitrary Value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80206





More information about the llvm-commits mailing list