authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-08-28 23:18:47+02:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-08-29 08:59:27+00:00
log7b863aa8ac6d48092c8d5b3c8713d9f8a9cfbdf3
tree31d86d703f717419c5224f129c4bfc2788ce96ec
parent4bb5d17edc85eac74626224810d6a44a3c73cca3

AstGen: short-circuit rvalue() if code is unreachable

This avoids generating instructions which will never be reached.

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

src/AstGen.zig+2-1
......@@ -8389,7 +8389,7 @@ fn nodeImpliesRuntimeBits(tree: *const ast.Tree, start_node: ast.Node.Index) boo
83898389 }
83908390}
83918391
8392/// Applies `rl` semantics to `inst`. Expressions which do not do their own handling of
8392/// Applies `rl` semantics to `result`. Expressions which do not do their own handling of
83938393/// result locations must call this function on their result.
83948394/// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer.
83958395/// If the `ResultLoc` is `ty`, it will coerce the result to the type.
......@@ -8399,6 +8399,7 @@ fn rvalue(
83998399 result: Zir.Inst.Ref,
84008400 src_node: ast.Node.Index,
84018401) InnerError!Zir.Inst.Ref {
8402 if (gz.endsWithNoReturn()) return result;
84028403 switch (rl) {
84038404 .none, .none_or_ref, .coerced_ty => return result,
84048405 .discard => {