[PATCH] D11852: [LowerSwitch] Fix a bug when LowerSwitch deletes the default block

Chen Li via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 11:13:15 PDT 2015


chenli added inline comments.

================
Comment at: lib/Transforms/Utils/LowerSwitch.cpp:528
@@ -522,3 +527,3 @@
   if (pred_begin(OldDefault) == pred_end(OldDefault))
-    DeleteDeadBlock(OldDefault);
+    DeleteList.push_back(OldDefault);
 }
----------------
hans wrote:
> I don't think maintaining a DeleteList is very nice, and as you say it has the problem that we might call processSwitchInst on a block even if it's dead.
> 
> How about we remove the DeleteDeadBlock call here, and in the loop in runOnFunction(), we add something like:
> 
> 
> ```
> if (block has no predecessors) {
>   delete it
>   continue
> }
> ```
Yes, I think that should work too. Though we need to handle carefully with entry block, which also has no predecessors. 


http://reviews.llvm.org/D11852





More information about the llvm-commits mailing list