Index: lib/CodeGen/WinEHPrepare.cpp =================================================================== --- lib/CodeGen/WinEHPrepare.cpp +++ lib/CodeGen/WinEHPrepare.cpp @@ -3245,14 +3245,15 @@ } else { // Note that this is a member of the given color. FuncletBlocks[Color].insert(Visiting); - TerminatorInst *Terminator = Visiting->getTerminator(); - if (isa(Terminator) || - isa(Terminator) || - isa(Terminator)) { - // These block's successors have already been queued with the parent - // color. - continue; - } + } + + TerminatorInst *Terminator = Visiting->getTerminator(); + if (isa(Terminator) || + isa(Terminator) || + isa(Terminator)) { + // These block's successors have already been queued with the parent + // color. + continue; } for (BasicBlock *Succ : successors(Visiting)) { if (isa(Succ->getFirstNonPHI())) { Index: test/CodeGen/WinEH/wineh-cloning.ll =================================================================== --- test/CodeGen/WinEH/wineh-cloning.ll +++ test/CodeGen/WinEH/wineh-cloning.ll @@ -382,3 +382,39 @@ ; whichever case was correct execute correctly. ; CHECK-LABEL: @test9( ; TODO: CHECKs + +define void @test10() personality i32 (...)* @__CxxFrameHandler3 { +entry: + invoke void @f() + to label %unreachable unwind label %inner +inner: + %cleanup = cleanuppad [] + ; make sure we don't overlook this cleanupret and try to process + ; successor %outer as a child of inner. + cleanupret %cleanup unwind label %outer +outer: + %catch = catchpad [] to label %catch.body unwind label %endpad +catch.body: + catchret %catch to label %exit +endpad: + catchendpad unwind to caller +exit: + ret void +unreachable: + unreachable +} +; CHECK-LABEL: @test10 +; CHECK-NEXT: entry: +; CHECK-NEXT: invoke +; CHECK-NEXT: to label %unreachable unwind label %inner +; CHECK: inner: +; CHECK-NEXT: %cleanup = cleanuppad +; CHECK-NEXT: cleanupret %cleanup unwind label %outer +; CHECK: outer: +; CHECK-NEXT: %catch = catchpad [] to label %catch.body unwind label %endpad +; CHECK: catch.body: +; CHECK-NEXT: catchret %catch to label %exit +; CHECK: endpad: +; CHECK-NEXT: catchendpad unwind to caller +; CHECK: exit: +; CHECK-NEXT: ret void