# stage2: further cleanups regarding zir.Inst.Ref · gitcafe/zig

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

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

Visibility: public

Requested revision: 180dae419630114b56f2ccd3a80d72c38bd8cad8

Requested commit: 180dae419630114b56f2ccd3a80d72c38bd8cad8

Commit: 180dae419630114b56f2ccd3a80d72c38bd8cad8

Tree: 7197650ca92db5ece9416b1fb1da99886cb6bc6e

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: further cleanups regarding zir.Inst.Ref

 * Introduce helper functions on Module.WipZirCode and zir.Code
 * Move some logic around
 * re-introduce ref_start_index
 * prefer usize for local variables + `@intCast` at the end.
   Empirically this is easier to optimize.
 * Avoid using mem.{bytesAsSlice,sliceAsBytes} because it incurs an
   unnecessary multiplication/division which may cause problems for the
   optimizer.
 * Use a regular enum, not packed, for `Ref`. Memory layout is
   guaranteed for enums which specify their tag type. Packed enums have
   ABI alignment of 1 byte which is too small.

```

## Parents

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

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