mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
stage2: disable error return tracing on unsupported targets
This commit is contained in:
parent
eee8fffec7
commit
66c3988e5e
@ -92,9 +92,9 @@ pub fn main() void {
|
||||
fail_count += 1;
|
||||
progress.log("FAIL ({s})\n", .{@errorName(err)});
|
||||
if (!have_tty) std.debug.print("FAIL ({s})\n", .{@errorName(err)});
|
||||
if (builtin.zig_backend != .stage2_llvm) if (@errorReturnTrace()) |trace| {
|
||||
if (@errorReturnTrace()) |trace| {
|
||||
std.debug.dumpStackTrace(trace.*);
|
||||
};
|
||||
}
|
||||
test_node.end();
|
||||
},
|
||||
}
|
||||
|
||||
20
src/Sema.zig
20
src/Sema.zig
@ -1412,6 +1412,12 @@ fn analyzeAsType(
|
||||
}
|
||||
|
||||
pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) !void {
|
||||
const backend_supports_error_return_tracing = false;
|
||||
if (!backend_supports_error_return_tracing) {
|
||||
// TODO implement this feature in all the backends and then delete this branch
|
||||
return;
|
||||
}
|
||||
|
||||
var err_trace_block = block.makeSubBlock();
|
||||
err_trace_block.is_comptime = false;
|
||||
defer err_trace_block.instructions.deinit(sema.gpa);
|
||||
@ -12655,7 +12661,12 @@ fn analyzeRet(
|
||||
return always_noreturn;
|
||||
}
|
||||
|
||||
if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing) {
|
||||
// TODO implement this feature in all the backends and then delete this check.
|
||||
const backend_supports_error_return_tracing = false;
|
||||
|
||||
if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing and
|
||||
backend_supports_error_return_tracing)
|
||||
{
|
||||
const return_err_fn = try sema.getBuiltin(block, src, "returnError");
|
||||
const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace");
|
||||
const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty);
|
||||
@ -13397,9 +13408,14 @@ fn zirErrorReturnTrace(
|
||||
const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace");
|
||||
const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty);
|
||||
const opt_ptr_stack_trace_ty = try Type.Tag.optional_single_mut_pointer.create(sema.arena, stack_trace_ty);
|
||||
|
||||
// TODO implement this feature in all the backends and then delete this check.
|
||||
const backend_supports_error_return_tracing = false;
|
||||
|
||||
if (sema.owner_func != null and
|
||||
sema.owner_func.?.calls_or_awaits_errorable_fn and
|
||||
sema.mod.comp.bin_file.options.error_return_tracing)
|
||||
sema.mod.comp.bin_file.options.error_return_tracing and
|
||||
backend_supports_error_return_tracing)
|
||||
{
|
||||
return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty);
|
||||
}
|
||||
|
||||
@ -2333,21 +2333,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
_ = inst;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
return self.finishAir(inst, result, .{ .none, .none, .none });
|
||||
}
|
||||
|
||||
fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
_ = inst;
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
@ -1846,21 +1846,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
_ = inst;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
return self.finishAir(inst, result, .{ .none, .none, .none });
|
||||
}
|
||||
|
||||
fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
_ = inst;
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
}
|
||||
|
||||
/// T to E!T
|
||||
|
||||
@ -1270,21 +1270,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
_ = inst;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
return self.finishAir(inst, result, .{ .none, .none, .none });
|
||||
}
|
||||
|
||||
fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
_ = inst;
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
@ -1858,21 +1858,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
_ = inst;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
return self.finishAir(inst, result, .{ .none, .none, .none });
|
||||
}
|
||||
|
||||
fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst))
|
||||
.dead
|
||||
else
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
_ = inst;
|
||||
return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch});
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
@ -3451,33 +3451,11 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
|
||||
fn airErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
if (f.liveness.isUnused(inst)) return CValue.none;
|
||||
|
||||
const un_op = f.air.instructions.items(.data)[inst].un_op;
|
||||
const writer = f.object.writer();
|
||||
const inst_ty = f.air.typeOfIndex(inst);
|
||||
const operand = try f.resolveInst(un_op);
|
||||
const local = try f.allocLocal(inst_ty, .Const);
|
||||
|
||||
try writer.writeAll(" = ");
|
||||
|
||||
_ = operand;
|
||||
_ = local;
|
||||
return f.fail("TODO: C backend: implement airErrReturnTrace", .{});
|
||||
}
|
||||
|
||||
fn airSetErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
if (f.liveness.isUnused(inst)) return CValue.none;
|
||||
|
||||
const un_op = f.air.instructions.items(.data)[inst].un_op;
|
||||
const writer = f.object.writer();
|
||||
const inst_ty = f.air.typeOfIndex(inst);
|
||||
const operand = try f.resolveInst(un_op);
|
||||
const local = try f.allocLocal(inst_ty, .Const);
|
||||
|
||||
try writer.writeAll(" = ");
|
||||
|
||||
_ = operand;
|
||||
_ = local;
|
||||
_ = inst;
|
||||
return f.fail("TODO: C backend: implement airSetErrReturnTrace", .{});
|
||||
}
|
||||
|
||||
|
||||
@ -637,7 +637,7 @@ pub const Object = struct {
|
||||
const gpa = dg.gpa;
|
||||
|
||||
const err_return_tracing = fn_info.return_type.isError() and
|
||||
dg.module.comp.bin_file.options.error_return_tracing;
|
||||
dg.module.comp.bin_file.options.error_return_tracing and false;
|
||||
|
||||
const err_ret_trace = if (err_return_tracing)
|
||||
llvm_func.getParam(@boolToInt(ret_ptr != null))
|
||||
@ -1765,7 +1765,7 @@ pub const Object = struct {
|
||||
}
|
||||
|
||||
if (fn_info.return_type.isError() and
|
||||
o.module.comp.bin_file.options.error_return_tracing)
|
||||
o.module.comp.bin_file.options.error_return_tracing and false)
|
||||
{
|
||||
var ptr_ty_payload: Type.Payload.ElemType = .{
|
||||
.base = .{ .tag = .single_mut_pointer },
|
||||
@ -2018,7 +2018,7 @@ pub const DeclGen = struct {
|
||||
}
|
||||
|
||||
const err_return_tracing = fn_info.return_type.isError() and
|
||||
dg.module.comp.bin_file.options.error_return_tracing;
|
||||
dg.module.comp.bin_file.options.error_return_tracing and false;
|
||||
|
||||
if (err_return_tracing) {
|
||||
dg.addArgAttr(llvm_fn, @boolToInt(sret), "nonnull");
|
||||
@ -2484,7 +2484,7 @@ pub const DeclGen = struct {
|
||||
}
|
||||
|
||||
if (fn_info.return_type.isError() and
|
||||
dg.module.comp.bin_file.options.error_return_tracing)
|
||||
dg.module.comp.bin_file.options.error_return_tracing and false)
|
||||
{
|
||||
var ptr_ty_payload: Type.Payload.ElemType = .{
|
||||
.base = .{ .tag = .single_mut_pointer },
|
||||
@ -3796,7 +3796,7 @@ pub const FuncGen = struct {
|
||||
};
|
||||
|
||||
if (fn_info.return_type.isError() and
|
||||
self.dg.module.comp.bin_file.options.error_return_tracing)
|
||||
self.dg.module.comp.bin_file.options.error_return_tracing and false)
|
||||
{
|
||||
try llvm_args.append(self.err_ret_trace.?);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user