From b865a761cbc2cfdffbcb1f60607da73172bc9772 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sun, 15 Aug 2021 14:26:14 -0400 Subject: [PATCH] add regression test --- ...issue-88043-bb-does-not-have-terminator.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/ui/codegen/issue-88043-bb-does-not-have-terminator.rs diff --git a/src/test/ui/codegen/issue-88043-bb-does-not-have-terminator.rs b/src/test/ui/codegen/issue-88043-bb-does-not-have-terminator.rs new file mode 100644 index 00000000000..1a6aadc662b --- /dev/null +++ b/src/test/ui/codegen/issue-88043-bb-does-not-have-terminator.rs @@ -0,0 +1,25 @@ +// build-pass +// compile-flags: -Copt-level=0 + +// Regression test for #88043: LLVM crash when the RemoveZsts mir-opt pass is enabled. +// We should not see the error: +// `Basic Block in function '_ZN4main10take_until17h0067b8a660429bc9E' does not have terminator!` + +fn bump() -> Option { + unreachable!() +} + +fn take_until(terminate: impl Fn() -> bool) { + loop { + if terminate() { + return; + } else { + bump(); + } + } +} + +// CHECK-LABEL: @main +fn main() { + take_until(|| true); +}