| ... | ... | @@ -443,14 +443,17 @@ fn gen(self: *Self) !void { |
| 443 | 443 | }); |
| 444 | 444 | |
| 445 | 445 | // exitlude jumps |
| 446 | | if (self.exitlude_jump_relocs.items.len == 1) { |
| 447 | | // There is only one relocation. Hence, |
| 448 | | // this relocation must be at the end of |
| 449 | | // the code. Therefore, we can just delete |
| 450 | | // the space initially reserved for the |
| 451 | | // jump |
| 452 | | self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.items[0]); |
| 453 | | } else for (self.exitlude_jump_relocs.items) |jmp_reloc| { |
| 446 | if (self.exitlude_jump_relocs.items.len > 0 and |
| 447 | self.exitlude_jump_relocs.items[self.exitlude_jump_relocs.items.len - 1] == self.mir_instructions.len - 2) |
| 448 | { |
| 449 | // If the last Mir instruction (apart from the |
| 450 | // dbg_epilogue_begin) is the last exitlude jump |
| 451 | // relocation (which would just jump one instruction |
| 452 | // further), it can be safely removed |
| 453 | self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.pop()); |
| 454 | } |
| 455 | |
| 456 | for (self.exitlude_jump_relocs.items) |jmp_reloc| { |
| 454 | 457 | self.mir_instructions.set(jmp_reloc, .{ |
| 455 | 458 | .tag = .b, |
| 456 | 459 | .data = .{ .inst = @intCast(u32, self.mir_instructions.len) }, |
| ... | ... | @@ -2958,7 +2961,17 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void { |
| 2958 | 2961 | const body = self.air.extra[extra.end..][0..extra.data.body_len]; |
| 2959 | 2962 | try self.genBody(body); |
| 2960 | 2963 | |
| 2961 | | for (self.blocks.getPtr(inst).?.relocs.items) |reloc| try self.performReloc(reloc); |
| 2964 | // relocations for `br` instructions |
| 2965 | const relocs = &self.blocks.getPtr(inst).?.relocs; |
| 2966 | if (relocs.items.len > 0 and relocs.items[relocs.items.len - 1] == self.mir_instructions.len - 1) { |
| 2967 | // If the last Mir instruction is the last relocation (which |
| 2968 | // would just jump one instruction further), it can be safely |
| 2969 | // removed |
| 2970 | self.mir_instructions.orderedRemove(relocs.pop()); |
| 2971 | } |
| 2972 | for (relocs.items) |reloc| { |
| 2973 | try self.performReloc(reloc); |
| 2974 | } |
| 2962 | 2975 | |
| 2963 | 2976 | const result = self.blocks.getPtr(inst).?.mcv; |
| 2964 | 2977 | return self.finishAir(inst, result, .{ .none, .none, .none }); |