authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-09-15 13:54:36+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-09-15 16:03:56+01:00
logbab6bf4194511c609210624d53b6601268719ac9
tree929196f8a12d7ca4618a5aabf1389c26c537b1ac
parent4d81e8ee915c3e012131cf90ed87cc8c6a01a934
signaturelock-open Commit is signed but in an unrecognized format.

compiler: always resolve field inits, remove unnecessary eager resolution

Resolves: #21362

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

src/Sema.zig+1
...@@ -36337,6 +36337,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {...@@ -36337,6 +36337,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
36337/// be resolved.36337/// be resolved.
36338pub fn resolveStructFully(sema: *Sema, ty: Type) SemaError!void {36338pub fn resolveStructFully(sema: *Sema, ty: Type) SemaError!void {
36339 try sema.resolveStructLayout(ty);36339 try sema.resolveStructLayout(ty);
36340 try sema.resolveStructFieldInits(ty);
3634036341
36341 const pt = sema.pt;36342 const pt = sema.pt;
36342 const zcu = pt.zcu;36343 const zcu = pt.zcu;
src/Zcu/PerThread.zig+6-15
...@@ -1240,11 +1240,11 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1240,11 +1240,11 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1240 };1240 };
1241 }1241 }
12421242
1243 const nav_already_populated, const queue_linker_work, const resolve_type = switch (ip.indexToKey(decl_val.toIntern())) {1243 const nav_already_populated, const queue_linker_work = switch (ip.indexToKey(decl_val.toIntern())) {
1244 .func => |f| .{ f.owner_nav == nav_index, true, false },1244 .func => |f| .{ f.owner_nav == nav_index, true },
1245 .variable => |v| .{ false, v.owner_nav == nav_index, true },1245 .variable => |v| .{ false, v.owner_nav == nav_index },
1246 .@"extern" => .{ false, false, false },1246 .@"extern" => .{ false, false },
1247 else => .{ false, true, true },1247 else => .{ false, true },
1248 };1248 };
12491249
1250 if (nav_already_populated) {1250 if (nav_already_populated) {
...@@ -1317,16 +1317,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1317,16 +1317,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1317 queue_codegen: {1317 queue_codegen: {
1318 if (!queue_linker_work) break :queue_codegen;1318 if (!queue_linker_work) break :queue_codegen;
13191319
1320 if (resolve_type) {1320 if (!try decl_ty.hasRuntimeBitsSema(pt)) {
1321 // Needed for codegen_nav which will call updateDecl and then the
1322 // codegen backend wants full access to the Decl Type.
1323 // We also need this for the `isFnOrHasRuntimeBits` check below.
1324 // TODO: we could make the language more lenient by deferring this work
1325 // to the `codegen_nav` job.
1326 try decl_ty.resolveFully(pt);
1327 }
1328
1329 if (!resolve_type or !decl_ty.hasRuntimeBits(zcu)) {
1330 if (zcu.comp.config.use_llvm) break :queue_codegen;1321 if (zcu.comp.config.use_llvm) break :queue_codegen;
1331 if (file.mod.strip) break :queue_codegen;1322 if (file.mod.strip) break :queue_codegen;
1332 }1323 }