authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-07 16:31:52-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-07 16:31:52-05:00
log39ee1f4b97053cdc080ddf3562cefc6bed2071a8
treec83df676c1bcb69d576a6788aa706573aab3d14c
parent4a606893097748123c053a2df329e70050a70487
signaturelock-open Commit is signed but in an unrecognized format.

fix invalid behavior tests from prev commit

and fix "no-op casts" from incorrectly spilling

2 files changed, 10 insertions(+), 4 deletions(-)

src/analyze.cpp+6
...@@ -6369,6 +6369,12 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {...@@ -6369,6 +6369,12 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
6369 // This instruction does its own spilling specially, or otherwise doesn't need it.6369 // This instruction does its own spilling specially, or otherwise doesn't need it.
6370 continue;6370 continue;
6371 }6371 }
6372 if (instruction->id == IrInstGenIdCast &&
6373 reinterpret_cast<IrInstGenCast *>(instruction)->cast_op == CastOpNoop)
6374 {
6375 // The IR instruction exists only to change the type according to Zig. No spill needed.
6376 continue;
6377 }
6372 if (instruction->value->special != ConstValSpecialRuntime)6378 if (instruction->value->special != ConstValSpecialRuntime)
6373 continue;6379 continue;
6374 if (instruction->base.ref_count == 0)6380 if (instruction->base.ref_count == 0)
test/stage1/behavior/async_fn.zig+4-4
...@@ -1336,7 +1336,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {...@@ -1336,7 +1336,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
1336 var global_int: i32 = 0;1336 var global_int: i32 = 0;
13371337
1338 fn foo() void {1338 fn foo() void {
1339 _ = async bar(1, .{});1339 bar(1, .{}) catch unreachable;
1340 }1340 }
13411341
1342 fn bar(x: i32, args: var) anyerror!void {1342 fn bar(x: i32, args: var) anyerror!void {
...@@ -1345,7 +1345,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {...@@ -1345,7 +1345,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
1345 global_int = x;1345 global_int = x;
1346 }1346 }
1347 };1347 };
1348 S.foo();1348 _ = async S.foo();
1349 resume S.global_frame;1349 resume S.global_frame;
1350 expect(S.global_int == 1);1350 expect(S.global_int == 1);
1351}1351}
...@@ -1357,7 +1357,7 @@ test "async function passed align(16) arg after align(8) arg" {...@@ -1357,7 +1357,7 @@ test "async function passed align(16) arg after align(8) arg" {
13571357
1358 fn foo() void {1358 fn foo() void {
1359 var a: u128 = 99;1359 var a: u128 = 99;
1360 _ = async bar(10, .{a});1360 bar(10, .{a}) catch unreachable;
1361 }1361 }
13621362
1363 fn bar(x: u64, args: var) anyerror!void {1363 fn bar(x: u64, args: var) anyerror!void {
...@@ -1367,7 +1367,7 @@ test "async function passed align(16) arg after align(8) arg" {...@@ -1367,7 +1367,7 @@ test "async function passed align(16) arg after align(8) arg" {
1367 global_int = args[0];1367 global_int = args[0];
1368 }1368 }
1369 };1369 };
1370 S.foo();1370 _ = async S.foo();
1371 resume S.global_frame;1371 resume S.global_frame;
1372 expect(S.global_int == 99);1372 expect(S.global_int == 99);
1373}1373}