[PATCH] D11953: [LowerSwitch] Skip dead blocks for processSwitchInst()

Chen Li via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 11:37:40 PDT 2015


chenli created this revision.
chenli added reviewers: reames, hans.
chenli added a subscriber: llvm-commits.

This patch adds check for dead blocks and skip them for processSwitchInst(). This will help reduce compilation time.

http://reviews.llvm.org/D11953

Files:
  lib/Transforms/Utils/LowerSwitch.cpp

Index: lib/Transforms/Utils/LowerSwitch.cpp
===================================================================
--- lib/Transforms/Utils/LowerSwitch.cpp
+++ lib/Transforms/Utils/LowerSwitch.cpp
@@ -121,6 +121,13 @@
   for (Function::iterator I = F.begin(), E = F.end(); I != E; ) {
     BasicBlock *Cur = I++; // Advance over block so we don't traverse new blocks
 
+    // If the block has no more predecessors, it should be a dead Default block which
+    // will be erased later or dead block resulted from previous optimization passes.
+    // In either case, skip it and don't waste time processing it.
+    if (Cur != &F.getEntryBlock() && pred_begin(Cur) == pred_end(Cur)) {
+      continue;
+    }
+
     if (SwitchInst *SI = dyn_cast<SwitchInst>(Cur->getTerminator())) {
       Changed = true;
       processSwitchInst(SI, DeleteList);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11953.31842.patch
Type: text/x-patch
Size: 845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150811/564d4709/attachment.bin>


More information about the llvm-commits mailing list