aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-07-17 17:03:24 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-07-20 13:12:20 -0700
commita8065a05a5bc3df4036f1d7abe0928901cf7f5df (patch)
tree1135e2d227b9695c0c4ce87781caf569dc5f8e94 /test
parent896472c20e33c81a010b21a6f900e721a2cf0839 (diff)
downloadzig-a8065a05a5bc3df4036f1d7abe0928901cf7f5df.tar.gz
zig-a8065a05a5bc3df4036f1d7abe0928901cf7f5df.zip
stage2: fix implementation of liveness operandDies()
Diffstat (limited to 'test')
-rw-r--r--test/stage2/compare_output.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/stage2/compare_output.zig b/test/stage2/compare_output.zig
index 4c8d23f3c6..6a6772f935 100644
--- a/test/stage2/compare_output.zig
+++ b/test/stage2/compare_output.zig
@@ -231,5 +231,41 @@ pub fn addCases(ctx: *TestContext) !void {
,
"",
);
+
+ // More stress on the liveness detection.
+ case.addCompareOutput(
+ \\export fn _start() noreturn {
+ \\ add(3, 4);
+ \\
+ \\ exit();
+ \\}
+ \\
+ \\fn add(a: u32, b: u32) void {
+ \\ const c = a + b; // 7
+ \\ const d = a + c; // 10
+ \\ const e = d + b; // 14
+ \\ const f = d + e; // 24
+ \\ const g = e + f; // 38
+ \\ const h = f + g; // 62
+ \\ const i = g + h; // 100
+ \\ assert(i == 100);
+ \\}
+ \\
+ \\pub fn assert(ok: bool) void {
+ \\ if (!ok) unreachable; // assertion failure
+ \\}
+ \\
+ \\fn exit() noreturn {
+ \\ asm volatile ("syscall"
+ \\ :
+ \\ : [number] "{rax}" (231),
+ \\ [arg1] "{rdi}" (0)
+ \\ : "rcx", "r11", "memory"
+ \\ );
+ \\ unreachable;
+ \\}
+ ,
+ "",
+ );
}
}