| ... | ... | @@ -59,6 +59,7 @@ owner: Owner, |
| 59 | 59 | inline_func: InternPool.Index, |
| 60 | 60 | mod: *Package.Module, |
| 61 | 61 | err_msg: ?*ErrorMsg, |
| 62 | arg_index: u32, |
| 62 | 63 | args: []MCValue, |
| 63 | 64 | va_info: union { |
| 64 | 65 | sysv: struct { |
| ... | ... | @@ -71,7 +72,6 @@ va_info: union { |
| 71 | 72 | }, |
| 72 | 73 | ret_mcv: InstTracking, |
| 73 | 74 | fn_type: Type, |
| 74 | | arg_index: u32, |
| 75 | 75 | src_loc: Zcu.LazySrcLoc, |
| 76 | 76 | |
| 77 | 77 | eflags_inst: ?Air.Inst.Index = null, |
| ... | ... | @@ -802,11 +802,11 @@ pub fn generate( |
| 802 | 802 | .owner = .{ .nav_index = func.owner_nav }, |
| 803 | 803 | .inline_func = func_index, |
| 804 | 804 | .err_msg = null, |
| 805 | .arg_index = undefined, |
| 805 | 806 | .args = undefined, // populated after `resolveCallingConventionValues` |
| 806 | 807 | .va_info = undefined, // populated after `resolveCallingConventionValues` |
| 807 | 808 | .ret_mcv = undefined, // populated after `resolveCallingConventionValues` |
| 808 | 809 | .fn_type = fn_type, |
| 809 | | .arg_index = 0, |
| 810 | 810 | .src_loc = src_loc, |
| 811 | 811 | .end_di_line = func.rbrace_line, |
| 812 | 812 | .end_di_column = func.rbrace_column, |
| ... | ... | @@ -877,6 +877,7 @@ pub fn generate( |
| 877 | 877 | }), |
| 878 | 878 | ); |
| 879 | 879 | function.va_info = switch (cc) { |
| 880 | else => undefined, |
| 880 | 881 | .SysV => .{ .sysv = .{ |
| 881 | 882 | .gp_count = call_info.gp_count, |
| 882 | 883 | .fp_count = call_info.fp_count, |
| ... | ... | @@ -884,7 +885,6 @@ pub fn generate( |
| 884 | 885 | .reg_save_area = undefined, |
| 885 | 886 | } }, |
| 886 | 887 | .Win64 => .{ .win64 = .{} }, |
| 887 | | else => undefined, |
| 888 | 888 | }; |
| 889 | 889 | |
| 890 | 890 | function.gen() catch |err| switch (err) { |
| ... | ... | @@ -978,11 +978,11 @@ pub fn generateLazy( |
| 978 | 978 | .owner = .{ .lazy_sym = lazy_sym }, |
| 979 | 979 | .inline_func = undefined, |
| 980 | 980 | .err_msg = null, |
| 981 | .arg_index = undefined, |
| 981 | 982 | .args = undefined, |
| 982 | 983 | .va_info = undefined, |
| 983 | 984 | .ret_mcv = undefined, |
| 984 | 985 | .fn_type = undefined, |
| 985 | | .arg_index = undefined, |
| 986 | 986 | .src_loc = src_loc, |
| 987 | 987 | .end_di_line = undefined, // no debug info yet |
| 988 | 988 | .end_di_column = undefined, // no debug info yet |
| ... | ... | @@ -1482,6 +1482,8 @@ fn asmOpOnly(self: *Self, tag: Mir.Inst.FixedTag) !void { |
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | 1484 | fn asmPseudo(self: *Self, ops: Mir.Inst.Ops) !void { |
| 1485 | assert(std.mem.startsWith(u8, @tagName(ops), "pseudo_") and |
| 1486 | std.mem.endsWith(u8, @tagName(ops), "_none")); |
| 1485 | 1487 | _ = try self.addInst(.{ |
| 1486 | 1488 | .tag = .pseudo, |
| 1487 | 1489 | .ops = ops, |
| ... | ... | @@ -2101,6 +2103,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 2101 | 2103 | const ip = &mod.intern_pool; |
| 2102 | 2104 | const air_tags = self.air.instructions.items(.tag); |
| 2103 | 2105 | |
| 2106 | self.arg_index = 0; |
| 2104 | 2107 | for (body) |inst| { |
| 2105 | 2108 | wip_mir_log.debug("{}", .{self.fmtAir(inst)}); |
| 2106 | 2109 | verbose_tracking_log.debug("{}", .{self.fmtTracking()}); |
| ... | ... | @@ -2114,6 +2117,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 2114 | 2117 | self.checkInvariantsAfterAirInst(inst, old_air_bookkeeping); |
| 2115 | 2118 | } |
| 2116 | 2119 | |
| 2120 | if (self.arg_index == 0) try self.airDbgVarArgs(); |
| 2121 | self.arg_index = 0; |
| 2117 | 2122 | for (body) |inst| { |
| 2118 | 2123 | if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip)) continue; |
| 2119 | 2124 | wip_mir_log.debug("{}", .{self.fmtAir(inst)}); |
| ... | ... | @@ -12055,11 +12060,25 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void { |
| 12055 | 12060 | } |
| 12056 | 12061 | |
| 12057 | 12062 | fn airDbgArg(self: *Self, inst: Air.Inst.Index) !void { |
| 12058 | | defer self.finishAirBookkeeping(); |
| 12059 | | if (self.debug_output == .none) return; |
| 12060 | | const name = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.name; |
| 12061 | | if (name != .none) try self.genLocalDebugInfo(inst, self.getResolvedInstValue(inst).short); |
| 12062 | | if (self.liveness.isUnused(inst)) try self.processDeath(inst); |
| 12063 | // skip zero-bit arguments as they don't have a corresponding arg instruction |
| 12064 | var arg_index = self.arg_index; |
| 12065 | while (self.args[arg_index] == .none) arg_index += 1; |
| 12066 | self.arg_index = arg_index + 1; |
| 12067 | |
| 12068 | if (self.debug_output != .none) { |
| 12069 | const name = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.name; |
| 12070 | if (name != .none) try self.genLocalDebugInfo(inst, self.getResolvedInstValue(inst).short); |
| 12071 | if (self.liveness.isUnused(inst)) try self.processDeath(inst); |
| 12072 | } |
| 12073 | for (self.args[self.arg_index..]) |arg| { |
| 12074 | if (arg != .none) break; |
| 12075 | } else try self.airDbgVarArgs(); |
| 12076 | self.finishAirBookkeeping(); |
| 12077 | } |
| 12078 | |
| 12079 | fn airDbgVarArgs(self: *Self) !void { |
| 12080 | if (self.pt.zcu.typeToFunc(self.fn_type).?.is_var_args) |
| 12081 | try self.asmPseudo(.pseudo_dbg_var_args_none); |
| 12063 | 12082 | } |
| 12064 | 12083 | |
| 12065 | 12084 | fn genLocalDebugInfo( |