[PATCH] D87142: Fix return status of SimplifyCFG

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 06:42:20 PDT 2020


serge-sans-paille created this revision.
serge-sans-paille added a reviewer: dmajor.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
serge-sans-paille requested review of this revision.

When a switch case is folded into default's case, that's an IR change that should be reported, update ConstantFoldTerminator accordingly.


https://reviews.llvm.org/D87142

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
@@ -182,6 +182,8 @@
       TheOnlyDest = SI->case_begin()->getCaseSuccessor();
     }
 
+    bool Changed = false;
+
     // Figure out which case it goes to.
     for (auto i = SI->case_begin(), e = SI->case_end(); i != e;) {
       // Found case matching a constant operand?
@@ -220,6 +222,7 @@
         DefaultDest->removePredecessor(ParentBB);
         i = SI->removeCase(i);
         e = SI->case_end();
+        Changed = true;
         if (DTU)
           DTU->applyUpdatesPermissive(
               {{DominatorTree::Delete, ParentBB, DefaultDest}});
@@ -308,7 +311,7 @@
       SI->eraseFromParent();
       return true;
     }
-    return false;
+    return Changed;
   }
 
   if (auto *IBI = dyn_cast<IndirectBrInst>(T)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87142.289939.patch
Type: text/x-patch
Size: 923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200904/2435d6f5/attachment.bin>


More information about the llvm-commits mailing list