authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-10-30 15:57:18+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-10-30 15:58:13+02:00
log22ec5e085914d9fd7b17a28a8d3ad01258f3ad03
tree879d000c06fc7dbf771f56e3d9d9e3484450383d
parent4ed2c52fb7b3b6d541235b6e9096a6e72b99ca2a
signaturelock-open Commit is signed but in an unrecognized format.

stage2: fix typo in liveness; add comptime switch test


2 files changed, 39 insertions(+), 1 deletions(-)

src/liveness.zig+2-1
......@@ -189,7 +189,8 @@ fn analyzeInst(
189189 for (case_tables) |*ct_inner, j| {
190190 if (i == j) continue;
191191 if (!ct_inner.contains(case_death)) {
192 try case_deaths[i].append(case_death);
192 // instruction is not referenced in this case
193 try case_deaths[j].append(case_death);
193194 }
194195 }
195196 // undo resetting the table
test/stage2/test.zig+37
......@@ -974,6 +974,43 @@ pub fn addCases(ctx: *TestContext) !void {
974974 ,
975975 "hello\nhello\nhello\nhello\nhello\n",
976976 );
977
978 // comptime switch
979
980 // Basic for loop
981 case.addCompareOutput(
982 \\pub export fn _start() noreturn {
983 \\ assert(foo() == 1);
984 \\ exit();
985 \\}
986 \\
987 \\fn foo() u32 {
988 \\ const a: comptime_int = 1;
989 \\ var b: u32 = 0;
990 \\ switch (a) {
991 \\ 1 => b = 1,
992 \\ 2 => b = 2,
993 \\ else => unreachable,
994 \\ }
995 \\ return b;
996 \\}
997 \\
998 \\pub fn assert(ok: bool) void {
999 \\ if (!ok) unreachable; // assertion failure
1000 \\}
1001 \\
1002 \\fn exit() noreturn {
1003 \\ asm volatile ("syscall"
1004 \\ :
1005 \\ : [number] "{rax}" (231),
1006 \\ [arg1] "{rdi}" (0)
1007 \\ : "rcx", "r11", "memory"
1008 \\ );
1009 \\ unreachable;
1010 \\}
1011 ,
1012 "",
1013 );
9771014 }
9781015
9791016 {