authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-12 15:22:10-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-12 15:22:23-04:00
log69e60e351b8b44ca59f814334d6c5d07f1103d96
treea049638a7a963a9cc3c1660f8c3453befe09f663
parent687bd92f9c3d9f521c8fe5884627ef1b00320364

self-hosted: better IR for empty fn

avoids a void

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

src-self-hosted/ir.zig+2-5
...@@ -574,9 +574,7 @@ pub const Builder = struct {...@@ -574,9 +574,7 @@ pub const Builder = struct {
574 }574 }
575575
576 _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit);576 _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit);
577 const result = try Instruction.Const.buildVoid(irb, child_scope, false);577 return try Instruction.Const.buildVoid(irb, child_scope, true);
578 result.setGenerated();
579 return result;
580 }578 }
581579
582 fn genDefersForBlock(580 fn genDefersForBlock(
...@@ -648,8 +646,7 @@ pub async fn gen(module: *Module, body_node: *ast.Node, scope: *Scope, parsed_fi...@@ -648,8 +646,7 @@ pub async fn gen(module: *Module, body_node: *ast.Node, scope: *Scope, parsed_fi
648646
649 const result = try irb.genNode(body_node, scope, LVal.None);647 const result = try irb.genNode(body_node, scope, LVal.None);
650 if (!result.isNoReturn()) {648 if (!result.isNoReturn()) {
651 const void_inst = try Instruction.Const.buildVoid(&irb, scope, false);649 (try Instruction.Return.build(&irb, scope, result)).setGenerated();
652 (try Instruction.Return.build(&irb, scope, void_inst)).setGenerated();
653 }650 }
654651
655 return irb.finish();652 return irb.finish();