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> 2022-11-04 00:00:10-04:00
logcbed6bb08555222008e87cfb071adeed97b3f8a4
treee5824a89f3f037909cfceae8fee7b8bfc765af70
parent42755a1944f4c4a60fc7e5e66cf76e9cbdf1ce84

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 {...@@ -1578,7 +1578,7 @@ pub const Fn = struct {
1578 errors: ErrorSet.NameMap = .{},1578 errors: ErrorSet.NameMap = .{},
15791579
1580 /// Other inferred error sets which this inferred error set should include.1580 /// 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
1583 /// Whether the function returned anyerror. This is true if either of1583 /// Whether the function returned anyerror. This is true if either of
1584 /// the dependent functions returns anyerror.1584 /// the dependent functions returns anyerror.
src/Sema.zig+2-6
...@@ -27509,9 +27509,7 @@ fn analyzeIsNonErrComptimeOnly(...@@ -27509,9 +27509,7 @@ fn analyzeIsNonErrComptimeOnly(
27509 // Try to avoid resolving inferred error set if possible.27509 // Try to avoid resolving inferred error set if possible.
27510 if (ies.errors.count() != 0) break :blk;27510 if (ies.errors.count() != 0) break :blk;
27511 if (ies.is_anyerror) break :blk;27511 if (ies.is_anyerror) break :blk;
27512 var it = ies.inferred_error_sets.keyIterator();27512 for (ies.inferred_error_sets.keys()) |other_ies| {
27513 while (it.next()) |other_error_set_ptr| {
27514 const other_ies: *Module.Fn.InferredErrorSet = other_error_set_ptr.*;
27515 if (ies == other_ies) continue;27513 if (ies == other_ies) continue;
27516 try sema.resolveInferredErrorSet(block, src, other_ies);27514 try sema.resolveInferredErrorSet(block, src, other_ies);
27517 if (other_ies.is_anyerror) {27515 if (other_ies.is_anyerror) {
...@@ -29432,9 +29430,7 @@ fn resolveInferredErrorSet(...@@ -29432,9 +29430,7 @@ fn resolveInferredErrorSet(
2943229430
29433 ies.is_resolved = true;29431 ies.is_resolved = true;
2943429432
29435 var it = ies.inferred_error_sets.keyIterator();29433 for (ies.inferred_error_sets.keys()) |other_ies| {
29436 while (it.next()) |other_error_set_ptr| {
29437 const other_ies: *Module.Fn.InferredErrorSet = other_error_set_ptr.*;
29438 if (ies == other_ies) continue;29434 if (ies == other_ies) continue;
29439 try sema.resolveInferredErrorSet(block, src, other_ies);29435 try sema.resolveInferredErrorSet(block, src, other_ies);
2944029436