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(Cur->getTerminator())) { Changed = true; processSwitchInst(SI, DeleteList);