# stage2: change how defers are stored in Zir · gitcafe/zig

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

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

Visibility: public

Requested revision: e323cf1264f390911dcc2efea71d46be1d631d92

Requested commit: e323cf1264f390911dcc2efea71d46be1d631d92

Commit: e323cf1264f390911dcc2efea71d46be1d631d92

Tree: ffe4c716e299e94ef1ed797f32aed8451e8090c9

Author: Veikka Tuominen

Committer: Andrew Kelley

## Message

```
stage2: change how defers are stored in Zir

Storing defers this way has the benefits that the defer doesn't get
analyzed multiple times in AstGen, it takes up less space, and it
makes Sema aware of defers allowing for 'unreachable else prong'
error on error sets in generic code.

The disadvantage is that it is a bit more complex and errdefers with
payloads now emit a placeholder instruction (but those are rare).

Sema.zig before:
  Total ZIR bytes:    3.7794370651245117MiB
  Instructions:       238996 (2.051319122314453MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   430144 (1.640869140625MiB)
Sema.zig after:
  Total ZIR bytes:    3.3344192504882812MiB
  Instructions:       211829 (1.8181428909301758MiB)
  String Table Bytes: 89.2802734375KiB
  Extra Data Items:   374611 (1.4290275573730469MiB)

```

## Parents

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

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