mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Sema: Prevent tail calls of std.builtin.returnError().
LLVM 20 started tail-calling it in some of our test cases, resulting in:
error: AndMyCarIsOutOfGas
/home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103ef9d in main (repro)
return error.TheSkyIsFalling;
^
/home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103efa5 in main (repro)
return error.AndMyCarIsOutOfGas;
^
/home/alexrp/Source/ziglang/zig-llvm20/lib/std/start.zig:656:37: 0x103ee83 in posixCallMainAndExit (repro)
const result = root.main() catch |err| {
^
instead of the expected:
error: AndMyCarIsOutOfGas
/home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103f00d in main (repro)
return error.TheSkyIsFalling;
^
/home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103f015 in main (repro)
return error.AndMyCarIsOutOfGas;
^
/home/alexrp/Source/ziglang/zig-llvm20/repro.zig:11:9: 0x103f01d in main (repro)
try bar();
^
This commit is contained in:
parent
82b9d9c0f6
commit
7415739e36
@ -19226,7 +19226,7 @@ fn retWithErrTracing(
|
|||||||
const return_err_fn = Air.internedToRef(try sema.getBuiltin(src, .returnError));
|
const return_err_fn = Air.internedToRef(try sema.getBuiltin(src, .returnError));
|
||||||
|
|
||||||
if (!need_check) {
|
if (!need_check) {
|
||||||
try sema.callBuiltin(block, src, return_err_fn, .never_inline, &.{}, .@"error return");
|
try sema.callBuiltin(block, src, return_err_fn, .never_tail, &.{}, .@"error return");
|
||||||
_ = try block.addUnOp(ret_tag, operand);
|
_ = try block.addUnOp(ret_tag, operand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -19237,7 +19237,7 @@ fn retWithErrTracing(
|
|||||||
|
|
||||||
var else_block = block.makeSubBlock();
|
var else_block = block.makeSubBlock();
|
||||||
defer else_block.instructions.deinit(gpa);
|
defer else_block.instructions.deinit(gpa);
|
||||||
try sema.callBuiltin(&else_block, src, return_err_fn, .never_inline, &.{}, .@"error return");
|
try sema.callBuiltin(&else_block, src, return_err_fn, .never_tail, &.{}, .@"error return");
|
||||||
_ = try else_block.addUnOp(ret_tag, operand);
|
_ = try else_block.addUnOp(ret_tag, operand);
|
||||||
|
|
||||||
try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
|
try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user