authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-18 00:02:07-04:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-21 08:49:54+01:00
logb6eebb709fdb8aff62105f60b275527c306b97b8
tree262cbd4dd6de1e9f177fdf5748be97d8bfb6f156
parent30e1daa7463c766e23f57e6a89e4e0ffd4918be5

x86_64: fix OBO

These loops were skipping over the top stack entry, and there's already a function that does this correctly.

1 files changed, 3 insertions(+), 18 deletions(-)

src/arch/x86_64/CodeGen.zig+3-18
......@@ -5006,14 +5006,8 @@ fn canonicaliseBranches(self: *Self, parent_branch: *Branch, canon_branch: *Bran
50065006 if (target_value == .dead)
50075007 continue;
50085008 // The instruction is only overridden in the else branch.
5009 var i: usize = self.branch_stack.items.len - 1;
5010 while (true) {
5011 i -= 1; // If this overflows, the question is: why wasn't the instruction marked dead?
5012 if (self.branch_stack.items[i].inst_table.get(target_key)) |mcv| {
5013 assert(mcv != .dead);
5014 break :blk mcv;
5015 }
5016 }
5009 // If integer overflows occurs, the question is: why wasn't the instruction marked dead?
5010 break :blk self.getResolvedInstValue(target_key).?;
50175011 };
50185012 log.debug("consolidating target_entry {d} {}=>{}", .{ target_key, target_value, canon_mcv });
50195013 // TODO make sure the destination stack offset / register does not already have something
......@@ -5030,16 +5024,7 @@ fn canonicaliseBranches(self: *Self, parent_branch: *Branch, canon_branch: *Bran
50305024 log.debug("canon_value = {}", .{canon_value});
50315025 if (canon_value == .dead)
50325026 continue;
5033 const parent_mcv = blk: {
5034 var i: usize = self.branch_stack.items.len - 1;
5035 while (true) {
5036 i -= 1;
5037 if (self.branch_stack.items[i].inst_table.get(canon_key)) |mcv| {
5038 assert(mcv != .dead);
5039 break :blk mcv;
5040 }
5041 }
5042 };
5027 const parent_mcv = self.getResolvedInstValue(canon_key).?;
50435028 log.debug("consolidating canon_entry {d} {}=>{}", .{ canon_key, parent_mcv, canon_value });
50445029 // TODO make sure the destination stack offset / register does not already have something
50455030 // going on there.