# std.zig.Zir: improve instruction tracking · gitcafe/zig

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

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

Visibility: public

Requested revision: 8f849684f46ad0835bd9591f420e49e212880cb2

Requested commit: 8f849684f46ad0835bd9591f420e49e212880cb2

Commit: 8f849684f46ad0835bd9591f420e49e212880cb2

Tree: ebf5d639609a744108f4e9a356d0074c25a640d9

Author: mlugg

Committer: mlugg

## Message

```
std.zig.Zir: improve instruction tracking

The main change here is to partition tracked instructions found within a
declaration. It's very unlikely that, for instance, a `struct { ... }`
type declaration was intentionally turned into a reification or an
anonymous initialization, so it makes sense to track things in a few
different arrays.

In particular, this fixes an issue where a `func` instruction could
wrongly be mapped to something else if the types of function parameters
changed. This would cause huge problems further down the pipeline; we
expect that if a `declaration` is tracked, and it previously contained a
`func`/`func_inferred`/`func_fancy`, then this instruction is either
tracked to another `func`/`func_inferred`/`func_fancy` instruction, or
is lost.

Also, this commit takes the opportunity to rename the functions actually
doing this logic. `Zir.findDecls` was a name that might have made sense
at some point, but nowadays, it's definitely not finding declarations,
and it's not *exclusively* finding type declarations. Instead, the point
is to find instructions which we want to track; hence the new name,
`Zir.findTrackable`.

Lastly, a nice side effect of partitioning the output of `findTrackable`
is that `Zir.declIterator` no longer needs to accept input instructions
which aren't type declarations (e.g. `reify`, `func`).

```

## Parents

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

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