[PATCH] D136289: llvm-reduce: Don't turn switches into returns

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 16:28:46 PDT 2022


aeubanks added inline comments.


================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp:98
   if (!BBsToKeep.count(SwInst.getDefaultDest())) {
-    auto *FnRetTy = SwInst.getParent()->getParent()->getReturnType();
-    ReturnInst::Create(SwInst.getContext(),
-                       FnRetTy->isVoidTy() ? nullptr : getDefaultValue(FnRetTy),
-                       SwInst.getParent());
-    SwInst.eraseFromParent();
-  } else
-    for (int I = 0, E = SwInst.getNumCases(); I != E; ++I) {
-      auto Case = SwInst.case_begin() + I;
-      if (!BBsToKeep.count(Case->getCaseSuccessor())) {
-        SwInst.removeCase(Case);
-        --I;
-        --E;
-      }
+    if (SwInst.getNumCases() == 0) {
+      auto *FnRetTy = SwInst.getParent()->getParent()->getReturnType();
----------------
do we have a test for this part?


================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp:114
+    for (PHINode &SuccPHI : NewDefault->phis()) {
+      SuccPHI.addIncoming(SuccPHI.getIncomingValueForBlock(SwInst.getParent()),
+                          SwInst.getParent());
----------------
if `NewDefault` was already a successor, doesn't its phis already have values from this block?


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

https://reviews.llvm.org/D136289



More information about the llvm-commits mailing list