# AstGen: avoid emitting multiple \`ret_type\` instructions · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/2e27967a81d325047e6d82f8c0722a8a654d1ac7)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 2e27967a81d325047e6d82f8c0722a8a654d1ac7

Requested commit: 2e27967a81d325047e6d82f8c0722a8a654d1ac7

Commit: 2e27967a81d325047e6d82f8c0722a8a654d1ac7

Tree: c22414dd9d53298085a27932f071edcbdde2b912

Author: mlugg

Committer: mlugg

## Message

```
AstGen: avoid emitting multiple `ret_type` instructions

This is a small optimization to generated ZIR. In any function where the
return type is not a trivial Ref, we know it is almost certainly not
`void` (unless the user aliased it or did something else weird to fool
AstGen), and thus the return type is very likely to be required for
return value RLS at some point. Thus, we can just emit one `ret_type` at
the start of the function and use it throughout.

This sees a very small improvement in overall ZIR bytes.

```

## Parents

- [51e96a823ce21a6b027bfdf55d94c3872a103703](https://git.cafe/gitcafe/zig/commit/51e96a823ce21a6b027bfdf55d94c3872a103703?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/2e27967a81d325047e6d82f8c0722a8a654d1ac7?format=markdown)
