[PATCH] D83908: [Local] Fix removeUnreachableBlocks change reporting

Jon Roelofs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 14:29:52 PDT 2020


jroelofs created this revision.
jroelofs added a reviewer: fhahn.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

I believe this might be the cause of the assertion failures in the `EXPENSIVE_CHECKS` bot on GreenDragon. See build #16770 <http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/16770>. I can't reproduce that failure myself, but this ought to be more precise, even if it's not what's triggering that particular issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83908

Files:
  llvm/lib/Transforms/Utils/Local.cpp


Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -2307,10 +2307,15 @@
       assert(TI && "Basic block should have a terminator");
       // Terminators like invoke can have users. We have to replace their users,
       // before removing them.
-      if (!TI->use_empty())
+      if (!TI->use_empty()) {
         TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
-      TI->eraseFromParent();
-      new UnreachableInst(BB->getContext(), BB);
+        Changed = true;
+      }
+      if (!isa<UnreachableInst>(TI)) {
+        TI->eraseFromParent();
+        new UnreachableInst(BB->getContext(), BB);
+        Changed = true;
+      }
       assert(succ_empty(BB) && "The successor list of BB isn't empty before "
                                "applying corresponding DTU updates.");
     }
@@ -2327,7 +2332,7 @@
       DTU->deleteBB(BB);
     }
     if (!Deleted)
-      return false;
+      return Changed;
   } else {
     for (auto *BB : DeadBlockSet)
       BB->eraseFromParent();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83908.278309.patch
Type: text/x-patch
Size: 1140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/25ebdaea/attachment.bin>


More information about the llvm-commits mailing list