# stage2: Teach Liveness that safety checks do not modify memory · gitcafe/zig

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

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

Visibility: public

Requested revision: 25d3713b07a100d8fdb349317db97fd9d0c1e366

Requested commit: 25d3713b07a100d8fdb349317db97fd9d0c1e366

Commit: 25d3713b07a100d8fdb349317db97fd9d0c1e366

Tree: e714bd6365744e115b5c5e78caceb70046469482

Author: Cody Tapscott

Committer: Andrew Kelley

## Message

```
stage2: Teach Liveness that safety checks do not modify memory

This change adds to Liveness a simple pattern match for the
try-like `.condbr` blocks emitted by Sema's safety checks. This
allows us to determine that these do not modify memory, which
permits us to elide additional loads in the backend.

As @Vexu points out in the main issue, this is probably not a
complete solution on its own. We'll still want a way to reliably
narrow the load/copy when performing several consecutive accesses,
such as `foo.arr[x][y].z`

Resolves https://github.com/ziglang/zig/issues/12215

```

## Parents

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

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