self-hosted: better IR for empty fn

avoids a void
This commit is contained in:
Andrew Kelley 2018-07-12 15:22:10 -04:00
parent 687bd92f9c
commit 69e60e351b

View File

@ -574,9 +574,7 @@ pub const Builder = struct {
} }
_ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit); _ = try irb.genDefersForBlock(child_scope, outer_block_scope, Scope.Defer.Kind.ScopeExit);
const result = try Instruction.Const.buildVoid(irb, child_scope, false); return try Instruction.Const.buildVoid(irb, child_scope, true);
result.setGenerated();
return result;
} }
fn genDefersForBlock( 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); const result = try irb.genNode(body_node, scope, LVal.None);
if (!result.isNoReturn()) { if (!result.isNoReturn()) {
const void_inst = try Instruction.Const.buildVoid(&irb, scope, false); (try Instruction.Return.build(&irb, scope, result)).setGenerated();
(try Instruction.Return.build(&irb, scope, void_inst)).setGenerated();
} }
return irb.finish(); return irb.finish();