Skip to content

Commit 69e60e3

Browse files
committedJul 12, 2018
self-hosted: better IR for empty fn
avoids a void
1 parent 687bd92 commit 69e60e3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
 

‎src-self-hosted/ir.zig

+2-5
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,7 @@ pub const Builder = struct {
574574
}
575575

576576
_ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit);
577-
const result = try Instruction.Const.buildVoid(irb, child_scope, false);
578-
result.setGenerated();
579-
return result;
577+
return try Instruction.Const.buildVoid(irb, child_scope, true);
580578
}
581579

582580
fn genDefersForBlock(
@@ -648,8 +646,7 @@ pub async fn gen(module: *Module, body_node: *ast.Node, scope: *Scope, parsed_fi
648646

649647
const result = try irb.genNode(body_node, scope, LVal.None);
650648
if (!result.isNoReturn()) {
651-
const void_inst = try Instruction.Const.buildVoid(&irb, scope, false);
652-
(try Instruction.Return.build(&irb, scope, void_inst)).setGenerated();
649+
(try Instruction.Return.build(&irb, scope, result)).setGenerated();
653650
}
654651

655652
return irb.finish();

0 commit comments

Comments
 (0)
Please sign in to comment.