From 69e60e351b8b44ca59f814334d6c5d07f1103d96 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 12 Jul 2018 15:22:10 -0400 Subject: [PATCH] self-hosted: better IR for empty fn avoids a void --- src-self-hosted/ir.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src-self-hosted/ir.zig b/src-self-hosted/ir.zig index f517dfe57..19bb01847 100644 --- a/src-self-hosted/ir.zig +++ b/src-self-hosted/ir.zig @@ -574,9 +574,7 @@ pub const Builder = struct { } _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit); - const result = try Instruction.Const.buildVoid(irb, child_scope, false); - result.setGenerated(); - return result; + return try Instruction.Const.buildVoid(irb, child_scope, true); } fn genDefersForBlock( @@ -648,8 +646,7 @@ pub async fn gen(module: *Module, body_node: *ast.Node, scope: *Scope, parsed_fi const result = try irb.genNode(body_node, scope, LVal.None); if (!result.isNoReturn()) { - const void_inst = try Instruction.Const.buildVoid(&irb, scope, false); - (try Instruction.Return.build(&irb, scope, void_inst)).setGenerated(); + (try Instruction.Return.build(&irb, scope, result)).setGenerated(); } return irb.finish();