about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-25 09:10:44 +0000
committerbors <bors@rust-lang.org>2023-11-25 09:10:44 +0000
commitfad6bb80fa89100e839ea7cbb4e9999188c0ac0d (patch)
tree5ffbf5d3499613d04ba5307d99428cae79e1e6e4 /tests/ui
parente2e978f713665663c0129f935168b06c79dfbb4d (diff)
parent329d015014a314f6131214d83d10b9d3b17d387d (diff)
downloadrust-fad6bb80fa89100e839ea7cbb4e9999188c0ac0d.tar.gz
rust-fad6bb80fa89100e839ea7cbb4e9999188c0ac0d.zip
Auto merge of #118075 - tmiasko:validate-critical-call-edges, r=cjgillot
Validate there are no critical call edges in optimized MIR
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/mir/validate/critical-edge.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/mir/validate/critical-edge.rs b/tests/ui/mir/validate/critical-edge.rs
new file mode 100644
index 00000000000..9ef655cd1bb
--- /dev/null
+++ b/tests/ui/mir/validate/critical-edge.rs
@@ -0,0 +1,31 @@
+// Optimized MIR shouldn't have critical call edges
+//
+// build-fail
+// edition: 2021
+// compile-flags: --crate-type=lib
+// failure-status: 101
+// dont-check-compiler-stderr
+// error-pattern: encountered critical edge in `Call` terminator
+#![feature(custom_mir, core_intrinsics)]
+use core::intrinsics::mir::*;
+
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+#[inline(always)]
+pub fn f(a: u32) -> u32 {
+    mir!(
+        {
+            match a {
+                0 => bb1,
+                _ => bb2,
+            }
+        }
+        bb1 = {
+            Call(RET = f(1), bb2, UnwindTerminate(ReasonAbi))
+        }
+
+        bb2 = {
+            RET = 2;
+            Return()
+        }
+    )
+}