| ... | @@ -5771,6 +5771,9 @@ fn canonicaliseBranches( | ... | @@ -5771,6 +5771,9 @@ fn canonicaliseBranches( |
| 5771 | comptime set_values: bool, | 5771 | comptime set_values: bool, |
| 5772 | comptime assert_same_deaths: bool, | 5772 | comptime assert_same_deaths: bool, |
| 5773 | ) !void { | 5773 | ) !void { |
| | 5774 | var hazard_map = std.AutoHashMap(MCValue, void).init(self.gpa); |
| | 5775 | defer hazard_map.deinit(); |
| | 5776 | |
| 5774 | const parent_branch = | 5777 | const parent_branch = |
| 5775 | if (update_parent) &self.branch_stack.items[self.branch_stack.items.len - 1] else undefined; | 5778 | if (update_parent) &self.branch_stack.items[self.branch_stack.items.len - 1] else undefined; |
| 5776 | | 5779 | |
| ... | @@ -5804,8 +5807,10 @@ fn canonicaliseBranches( | ... | @@ -5804,8 +5807,10 @@ fn canonicaliseBranches( |
| 5804 | break :blk self.getResolvedInstValue(target_key).?.*; | 5807 | break :blk self.getResolvedInstValue(target_key).?.*; |
| 5805 | }; | 5808 | }; |
| 5806 | log.debug("consolidating target_entry {d} {}=>{}", .{ target_key, target_value, canon_mcv }); | 5809 | log.debug("consolidating target_entry {d} {}=>{}", .{ target_key, target_value, canon_mcv }); |
| 5807 | // TODO make sure the destination stack offset / register does not already have something | 5810 | // TODO handle the case where the destination stack offset / register has something |
| 5808 | // going on there. | 5811 | // going on there. |
| | 5812 | assert(!hazard_map.contains(target_value)); |
| | 5813 | try hazard_map.putNoClobber(canon_mcv, {}); |
| 5809 | if (set_values) { | 5814 | if (set_values) { |
| 5810 | try self.setRegOrMem(self.air.typeOfIndex(target_key), canon_mcv, target_value); | 5815 | try self.setRegOrMem(self.air.typeOfIndex(target_key), canon_mcv, target_value); |
| 5811 | } else self.getValue(canon_mcv, target_key); | 5816 | } else self.getValue(canon_mcv, target_key); |
| ... | @@ -5824,8 +5829,10 @@ fn canonicaliseBranches( | ... | @@ -5824,8 +5829,10 @@ fn canonicaliseBranches( |
| 5824 | if (canon_value != .dead) self.getResolvedInstValue(canon_key).?.* else undefined; | 5829 | if (canon_value != .dead) self.getResolvedInstValue(canon_key).?.* else undefined; |
| 5825 | if (canon_value != .dead) { | 5830 | if (canon_value != .dead) { |
| 5826 | log.debug("consolidating canon_entry {d} {}=>{}", .{ canon_key, parent_mcv, canon_value }); | 5831 | log.debug("consolidating canon_entry {d} {}=>{}", .{ canon_key, parent_mcv, canon_value }); |
| 5827 | // TODO make sure the destination stack offset / register does not already have something | 5832 | // TODO handle the case where the destination stack offset / register has something |
| 5828 | // going on there. | 5833 | // going on there. |
| | 5834 | assert(!hazard_map.contains(parent_mcv)); |
| | 5835 | try hazard_map.putNoClobber(canon_value, {}); |
| 5829 | if (set_values) { | 5836 | if (set_values) { |
| 5830 | try self.setRegOrMem(self.air.typeOfIndex(canon_key), canon_value, parent_mcv); | 5837 | try self.setRegOrMem(self.air.typeOfIndex(canon_key), canon_value, parent_mcv); |
| 5831 | } else self.getValue(canon_value, canon_key); | 5838 | } else self.getValue(canon_value, canon_key); |