Index: lib/Transforms/IPO/PassManagerBuilder.cpp =================================================================== --- lib/Transforms/IPO/PassManagerBuilder.cpp +++ lib/Transforms/IPO/PassManagerBuilder.cpp @@ -661,6 +661,11 @@ MPM.add(createLoopSinkPass()); // Get rid of LCSSA nodes. MPM.add(createInstructionSimplifierPass()); + + // LoopSink (and other loop passes since the last simplifyCFG) might have + // resulted in single-entry-single-exit or empty blocks. Clean up the CFG. + MPM.add(createCFGSimplificationPass()); + addExtensionsToPM(EP_OptimizerLast, MPM); } Index: test/Other/pass-pipelines.ll =================================================================== --- test/Other/pass-pipelines.ll +++ test/Other/pass-pipelines.ll @@ -85,6 +85,7 @@ ; CHECK-O2: FunctionPass Manager ; CHECK-O2: Loop Pass Manager ; CHECK-O2-NEXT: Loop Sink +; CHECK-O2: Simplify the CFG ; CHECK-O2-NOT: Manager ; ; FIXME: There really shouldn't be another pass manager, especially one that