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 {
3633736337/// be resolved.
3633836338pub fn resolveStructFully(sema: *Sema, ty: Type) SemaError!void {
3633936339 try sema.resolveStructLayout(ty);
36340 try sema.resolveStructFieldInits(ty);
3634036341
3634136342 const pt = sema.pt;
3634236343 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 {
12401240 };
12411241 }
12421242
1243 const nav_already_populated, const queue_linker_work, const resolve_type = switch (ip.indexToKey(decl_val.toIntern())) {
1244 .func => |f| .{ f.owner_nav == nav_index, true, false },
1245 .variable => |v| .{ false, v.owner_nav == nav_index, true },
1246 .@"extern" => .{ false, false, false },
1247 else => .{ false, true, true },
1243 const nav_already_populated, const queue_linker_work = switch (ip.indexToKey(decl_val.toIntern())) {
1244 .func => |f| .{ f.owner_nav == nav_index, true },
1245 .variable => |v| .{ false, v.owner_nav == nav_index },
1246 .@"extern" => .{ false, false },
1247 else => .{ false, true },
12481248 };
12491249
12501250 if (nav_already_populated) {
......@@ -1317,16 +1317,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
13171317 queue_codegen: {
13181318 if (!queue_linker_work) break :queue_codegen;
13191319
1320 if (resolve_type) {
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)) {
1320 if (!try decl_ty.hasRuntimeBitsSema(pt)) {
13301321 if (zcu.comp.config.use_llvm) break :queue_codegen;
13311322 if (file.mod.strip) break :queue_codegen;
13321323 }