authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-08-12 22:36:58+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-08-15 18:23:40-04:00
log8ef82e83551cfca60698eb82dc180118e64b8fde
tree821b2658f972b92eea5fc3cd1f3c8f53c5e8bd08
parentd835a6ba9ac11773f8ae1c3b2c5e9241cf875ee9

what if we kissed by the extern source bit


3 files changed, 13 insertions(+), 3 deletions(-)

src/InternPool.zig+10-3
......@@ -2257,6 +2257,7 @@ pub const Key = union(enum) {
22572257 /// The `Nav` corresponding to this extern symbol.
22582258 /// This is ignored by hashing and equality.
22592259 owner_nav: Nav.Index,
2260 source: Tag.Extern.Flags.Source,
22602261 };
22612262
22622263 pub const Func = struct {
......@@ -2859,7 +2860,7 @@ pub const Key = union(enum) {
28592860 asBytes(&e.is_threadlocal) ++ asBytes(&e.is_dll_import) ++
28602861 asBytes(&e.relocation) ++
28612862 asBytes(&e.is_const) ++ asBytes(&e.alignment) ++ asBytes(&e.@"addrspace") ++
2862 asBytes(&e.zir_index)),
2863 asBytes(&e.zir_index) ++ &[1]u8{@intFromEnum(e.source)}),
28632864 };
28642865 }
28652866
......@@ -2958,7 +2959,8 @@ pub const Key = union(enum) {
29582959 a_info.is_const == b_info.is_const and
29592960 a_info.alignment == b_info.alignment and
29602961 a_info.@"addrspace" == b_info.@"addrspace" and
2961 a_info.zir_index == b_info.zir_index;
2962 a_info.zir_index == b_info.zir_index and
2963 a_info.source == b_info.source;
29622964 },
29632965 .func => |a_info| {
29642966 const b_info = b.func;
......@@ -5967,7 +5969,10 @@ pub const Tag = enum(u8) {
59675969 is_threadlocal: bool,
59685970 is_dll_import: bool,
59695971 relocation: std.builtin.ExternOptions.Relocation,
5970 _: u25 = 0,
5972 source: Source,
5973 _: u24 = 0,
5974
5975 pub const Source = enum(u1) { builtin, syntax };
59715976 };
59725977 };
59735978
......@@ -7320,6 +7325,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
73207325 .@"addrspace" = nav.status.fully_resolved.@"addrspace",
73217326 .zir_index = extra.zir_index,
73227327 .owner_nav = extra.owner_nav,
7328 .source = extra.flags.source,
73237329 } };
73247330 },
73257331 .func_instance => .{ .func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), data) },
......@@ -9212,6 +9218,7 @@ pub fn getExtern(
92129218 .is_threadlocal = key.is_threadlocal,
92139219 .is_dll_import = key.is_dll_import,
92149220 .relocation = key.relocation,
9221 .source = key.source,
92159222 },
92169223 .zir_index = key.zir_index,
92179224 .owner_nav = owner_nav,
src/Sema.zig+1
......@@ -25768,6 +25768,7 @@ fn zirBuiltinExtern(
2576825768 },
2576925769 },
2577025770 .owner_nav = undefined, // ignored by `getExtern`
25771 .source = .builtin,
2577125772 });
2577225773
2577325774 const uncasted_ptr = try sema.analyzeNavRef(block, src, ip.indexToKey(extern_val).@"extern".owner_nav);
src/Zcu/PerThread.zig+2
......@@ -1249,6 +1249,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
12491249 .@"addrspace" = modifiers.@"addrspace",
12501250 .zir_index = old_nav.analysis.?.zir_index, // `declaration` instruction
12511251 .owner_nav = undefined, // ignored by `getExtern`
1252 .source = .syntax,
12521253 }));
12531254 },
12541255 };
......@@ -3435,6 +3436,7 @@ pub fn getCoerced(pt: Zcu.PerThread, val: Value, new_ty: Type) Allocator.Error!V
34353436 .@"addrspace" = e.@"addrspace",
34363437 .zir_index = e.zir_index,
34373438 .owner_nav = undefined, // ignored by `getExtern`.
3439 .source = e.source,
34383440 });
34393441 return Value.fromInterned(coerced);
34403442 },