mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
AstGen: short-circuit rvalue() if code is unreachable
This avoids generating instructions which will never be reached.
This commit is contained in:
parent
4bb5d17edc
commit
7b863aa8ac
@ -8389,7 +8389,7 @@ fn nodeImpliesRuntimeBits(tree: *const ast.Tree, start_node: ast.Node.Index) boo
|
||||
}
|
||||
}
|
||||
|
||||
/// Applies `rl` semantics to `inst`. Expressions which do not do their own handling of
|
||||
/// Applies `rl` semantics to `result`. Expressions which do not do their own handling of
|
||||
/// result locations must call this function on their result.
|
||||
/// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer.
|
||||
/// If the `ResultLoc` is `ty`, it will coerce the result to the type.
|
||||
@ -8399,6 +8399,7 @@ fn rvalue(
|
||||
result: Zir.Inst.Ref,
|
||||
src_node: ast.Node.Index,
|
||||
) InnerError!Zir.Inst.Ref {
|
||||
if (gz.endsWithNoReturn()) return result;
|
||||
switch (rl) {
|
||||
.none, .none_or_ref, .coerced_ty => return result,
|
||||
.discard => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user