mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 23:23:07 +00:00
zir-memory-layout: fix @setEvalBranchQuota
also make emitBackwardBranch fail correctly
This commit is contained in:
parent
099af0e008
commit
e430f3f7e0
10
src/Sema.zig
10
src/Sema.zig
@ -599,8 +599,8 @@ fn zirSetEvalBranchQuota(
|
||||
const src = inst_data.src();
|
||||
try sema.requireFunctionBlock(block, src);
|
||||
const quota = try sema.resolveAlreadyCoercedInt(block, src, inst_data.operand, u32);
|
||||
if (b.branch_quota.* < quota)
|
||||
b.branch_quota.* = quota;
|
||||
if (sema.branch_quota < quota)
|
||||
sema.branch_quota = quota;
|
||||
return sema.mod.constVoid(block.arena, .unneeded);
|
||||
}
|
||||
|
||||
@ -2960,11 +2960,9 @@ fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: Pani
|
||||
fn emitBackwardBranch(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void {
|
||||
const shared = block.inlining.?.shared;
|
||||
shared.branch_count += 1;
|
||||
if (shared.branch_count > block.branch_quota.*) {
|
||||
if (shared.branch_count > sema.branch_quota) {
|
||||
// TODO show the "called from here" stack
|
||||
return mod.fail(&block.base, src, "evaluation exceeded {d} backwards branches", .{
|
||||
block.branch_quota.*,
|
||||
});
|
||||
return sema.mod.fail(&block.base, src, "evaluation exceeded {d} backwards branches", .{sema.branch_quota});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user