authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-03 02:42:18-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-09 13:47:41-07:00
log6165de9a6149293af13d6bd3ab707a30041bff93
tree65c58fa33d9b57e77d2353d31b7744c4334b60ea
parent0848d33d782d47bfa564b23e25c141738b9e22e3

Sema: make `InferredErrorSet` deterministic

Empirically, this `AutoHashMapUnmanaged` -> `AutoArrayHashMapUnmanaged` change fixes all non-determinism in `ReleaseFast` build artifacts. Closes #12183

2 files changed, 3 insertions(+), 7 deletions(-)

src/Module.zig+1-1
......@@ -1578,7 +1578,7 @@ pub const Fn = struct {
15781578 errors: ErrorSet.NameMap = .{},
15791579
15801580 /// Other inferred error sets which this inferred error set should include.
1581 inferred_error_sets: std.AutoHashMapUnmanaged(*InferredErrorSet, void) = .{},
1581 inferred_error_sets: std.AutoArrayHashMapUnmanaged(*InferredErrorSet, void) = .{},
15821582
15831583 /// Whether the function returned anyerror. This is true if either of
15841584 /// the dependent functions returns anyerror.
src/Sema.zig+2-6
......@@ -27509,9 +27509,7 @@ fn analyzeIsNonErrComptimeOnly(
2750927509 // Try to avoid resolving inferred error set if possible.
2751027510 if (ies.errors.count() != 0) break :blk;
2751127511 if (ies.is_anyerror) break :blk;
27512 var it = ies.inferred_error_sets.keyIterator();
27513 while (it.next()) |other_error_set_ptr| {
27514 const other_ies: *Module.Fn.InferredErrorSet = other_error_set_ptr.*;
27512 for (ies.inferred_error_sets.keys()) |other_ies| {
2751527513 if (ies == other_ies) continue;
2751627514 try sema.resolveInferredErrorSet(block, src, other_ies);
2751727515 if (other_ies.is_anyerror) {
......@@ -29432,9 +29430,7 @@ fn resolveInferredErrorSet(
2943229430
2943329431 ies.is_resolved = true;
2943429432
29435 var it = ies.inferred_error_sets.keyIterator();
29436 while (it.next()) |other_error_set_ptr| {
29437 const other_ies: *Module.Fn.InferredErrorSet = other_error_set_ptr.*;
29433 for (ies.inferred_error_sets.keys()) |other_ies| {
2943829434 if (ies == other_ies) continue;
2943929435 try sema.resolveInferredErrorSet(block, src, other_ies);
2944029436