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) {...@@ -2257,6 +2257,7 @@ pub const Key = union(enum) {
2257 /// The `Nav` corresponding to this extern symbol.2257 /// The `Nav` corresponding to this extern symbol.
2258 /// This is ignored by hashing and equality.2258 /// This is ignored by hashing and equality.
2259 owner_nav: Nav.Index,2259 owner_nav: Nav.Index,
2260 source: Tag.Extern.Flags.Source,
2260 };2261 };
22612262
2262 pub const Func = struct {2263 pub const Func = struct {
...@@ -2859,7 +2860,7 @@ pub const Key = union(enum) {...@@ -2859,7 +2860,7 @@ pub const Key = union(enum) {
2859 asBytes(&e.is_threadlocal) ++ asBytes(&e.is_dll_import) ++2860 asBytes(&e.is_threadlocal) ++ asBytes(&e.is_dll_import) ++
2860 asBytes(&e.relocation) ++2861 asBytes(&e.relocation) ++
2861 asBytes(&e.is_const) ++ asBytes(&e.alignment) ++ asBytes(&e.@"addrspace") ++2862 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)}),
2863 };2864 };
2864 }2865 }
28652866
...@@ -2958,7 +2959,8 @@ pub const Key = union(enum) {...@@ -2958,7 +2959,8 @@ pub const Key = union(enum) {
2958 a_info.is_const == b_info.is_const and2959 a_info.is_const == b_info.is_const and
2959 a_info.alignment == b_info.alignment and2960 a_info.alignment == b_info.alignment and
2960 a_info.@"addrspace" == b_info.@"addrspace" and2961 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;
2962 },2964 },
2963 .func => |a_info| {2965 .func => |a_info| {
2964 const b_info = b.func;2966 const b_info = b.func;
...@@ -5967,7 +5969,10 @@ pub const Tag = enum(u8) {...@@ -5967,7 +5969,10 @@ pub const Tag = enum(u8) {
5967 is_threadlocal: bool,5969 is_threadlocal: bool,
5968 is_dll_import: bool,5970 is_dll_import: bool,
5969 relocation: std.builtin.ExternOptions.Relocation,5971 relocation: std.builtin.ExternOptions.Relocation,
5970 _: u25 = 0,5972 source: Source,
5973 _: u24 = 0,
5974
5975 pub const Source = enum(u1) { builtin, syntax };
5971 };5976 };
5972 };5977 };
59735978
...@@ -7320,6 +7325,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -7320,6 +7325,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
7320 .@"addrspace" = nav.status.fully_resolved.@"addrspace",7325 .@"addrspace" = nav.status.fully_resolved.@"addrspace",
7321 .zir_index = extra.zir_index,7326 .zir_index = extra.zir_index,
7322 .owner_nav = extra.owner_nav,7327 .owner_nav = extra.owner_nav,
7328 .source = extra.flags.source,
7323 } };7329 } };
7324 },7330 },
7325 .func_instance => .{ .func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), data) },7331 .func_instance => .{ .func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), data) },
...@@ -9212,6 +9218,7 @@ pub fn getExtern(...@@ -9212,6 +9218,7 @@ pub fn getExtern(
9212 .is_threadlocal = key.is_threadlocal,9218 .is_threadlocal = key.is_threadlocal,
9213 .is_dll_import = key.is_dll_import,9219 .is_dll_import = key.is_dll_import,
9214 .relocation = key.relocation,9220 .relocation = key.relocation,
9221 .source = key.source,
9215 },9222 },
9216 .zir_index = key.zir_index,9223 .zir_index = key.zir_index,
9217 .owner_nav = owner_nav,9224 .owner_nav = owner_nav,
src/Sema.zig+1
...@@ -25768,6 +25768,7 @@ fn zirBuiltinExtern(...@@ -25768,6 +25768,7 @@ fn zirBuiltinExtern(
25768 },25768 },
25769 },25769 },
25770 .owner_nav = undefined, // ignored by `getExtern`25770 .owner_nav = undefined, // ignored by `getExtern`
25771 .source = .builtin,
25771 });25772 });
2577225773
25773 const uncasted_ptr = try sema.analyzeNavRef(block, src, ip.indexToKey(extern_val).@"extern".owner_nav);25774 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...@@ -1249,6 +1249,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
1249 .@"addrspace" = modifiers.@"addrspace",1249 .@"addrspace" = modifiers.@"addrspace",
1250 .zir_index = old_nav.analysis.?.zir_index, // `declaration` instruction1250 .zir_index = old_nav.analysis.?.zir_index, // `declaration` instruction
1251 .owner_nav = undefined, // ignored by `getExtern`1251 .owner_nav = undefined, // ignored by `getExtern`
1252 .source = .syntax,
1252 }));1253 }));
1253 },1254 },
1254 };1255 };
...@@ -3435,6 +3436,7 @@ pub fn getCoerced(pt: Zcu.PerThread, val: Value, new_ty: Type) Allocator.Error!V...@@ -3435,6 +3436,7 @@ pub fn getCoerced(pt: Zcu.PerThread, val: Value, new_ty: Type) Allocator.Error!V
3435 .@"addrspace" = e.@"addrspace",3436 .@"addrspace" = e.@"addrspace",
3436 .zir_index = e.zir_index,3437 .zir_index = e.zir_index,
3437 .owner_nav = undefined, // ignored by `getExtern`.3438 .owner_nav = undefined, // ignored by `getExtern`.
3439 .source = e.source,
3438 });3440 });
3439 return Value.fromInterned(coerced);3441 return Value.fromInterned(coerced);
3440 },3442 },