diff options
| author | Xavier Bouchoux <xavierb@gmail.com> | 2023-06-24 10:47:20 +0000 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 12:57:46 -0700 |
| commit | f10b9e8fd72aae33b127c18e3f8a64a4f56b1b69 (patch) | |
| tree | e677f852c23f7123282d184ddb67181097588619 /src | |
| parent | a5e15eced0e9cb00871966ede74eed9b3a07183c (diff) | |
| download | zig-f10b9e8fd72aae33b127c18e3f8a64a4f56b1b69.tar.gz zig-f10b9e8fd72aae33b127c18e3f8a64a4f56b1b69.zip | |
update Liveness to detect that safety checks do not modify memory
followup to [25d3713b07a100d8fdb349317db97fd9d0c1e366]
Resolves #12215
Previous code didn't account for the extra unreach() that now exists in the air:
```
%29!= block(void, {
%30!= cond_br(%22!, {
%31!= br(%29, @Air.Inst.Ref.void_value)
}, {
%2! %15!
%27!= call(%26, [%19!, %21])
%28!= unreach()
})
} %22!)
```
Diffstat (limited to 'src')
| -rw-r--r-- | src/Liveness.zig | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Liveness.zig b/src/Liveness.zig index 2ba0291364..1141b8620c 100644 --- a/src/Liveness.zig +++ b/src/Liveness.zig @@ -621,11 +621,18 @@ pub fn categorizeOperand( if (inst_data.operand == operand_ref and operandDies(l, body[0], 0)) return .tomb; - if (cond_extra.data.then_body_len != 1 or cond_extra.data.else_body_len != 1) + if (cond_extra.data.then_body_len > 2 or cond_extra.data.else_body_len > 2) + return .complex; + + const then_body = air.extra[cond_extra.end..][0..cond_extra.data.then_body_len]; + const else_body = air.extra[cond_extra.end + cond_extra.data.then_body_len ..][0 .. cond_extra.data.then_body_len + cond_extra.data.else_body_len]; + if (then_body.len > 1 and air_tags[then_body[1]] != .unreach) + return .complex; + if (else_body.len > 1 and air_tags[else_body[1]] != .unreach) return .complex; var operand_live: bool = true; - for (air.extra[cond_extra.end..][0..2]) |cond_inst| { + for (&[_]u32{ then_body[0], else_body[0] }) |cond_inst| { if (l.categorizeOperand(air, cond_inst, operand, ip) == .tomb) operand_live = false; |
