[Verifier] Avoid asserting on invalid cleanuppad chain

The invalid undef value already triggers a verifier failure, but
then the upwards scan from the cleanuppad ends up asserting. Make
sure this is handled gacefully instead.
This commit is contained in:
Nikita Popov 2022-01-14 12:08:33 +01:00
parent cc79d603c9
commit ed30a968b5
2 changed files with 23 additions and 0 deletions

View File

@ -3999,6 +3999,11 @@ void Verifier::visitEHPadPredecessors(Instruction &I) {
"A single unwind edge may only enter one EH pad", TI);
Assert(Seen.insert(FromPad).second,
"EH pad jumps through a cycle of pads", FromPad);
// This will be diagnosed on the corresponding instruction already. We
// need the extra check here to make sure getParentPad() works.
Assert(isa<FuncletPadInst>(FromPad) || isa<CatchSwitchInst>(FromPad),
"Parent pad must be catchpad/cleanuppad/catchswitch", TI);
}
}
}

View File

@ -0,0 +1,18 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: CleanupReturnInst needs to be provided a CleanupPad
; CHECK-NEXT: cleanupret from undef unwind label %bb2
; CHECK-NEXT: token undef
; CHECK: Parent pad must be catchpad/cleanuppad/catchswitch
; CHECK-NEXT: cleanupret from undef unwind label %bb2
define void @test() personality i32 (...)* undef {
br label %bb1
bb1:
cleanupret from undef unwind label %bb2
bb2:
%pad = cleanuppad within none []
cleanupret from %pad unwind to caller
}