Skip to content

Commit

Permalink
self-hosted: better IR for empty fn
Browse files Browse the repository at this point in the history
avoids a void
  • Loading branch information
andrewrk committed Jul 12, 2018
1 parent 687bd92 commit 69e60e3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src-self-hosted/ir.zig
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 69e60e3

Please sign in to comment.