Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2257,6 +2257,7 @@ pub const Key = union(enum) {
/// The `Nav` corresponding to this extern symbol.
/// This is ignored by hashing and equality.
owner_nav: Nav.Index,
source: Tag.Extern.Flags.Source,
};

pub const Func = struct {
Expand Down Expand Up @@ -2859,7 +2860,7 @@ pub const Key = union(enum) {
asBytes(&e.is_threadlocal) ++ asBytes(&e.is_dll_import) ++
asBytes(&e.relocation) ++
asBytes(&e.is_const) ++ asBytes(&e.alignment) ++ asBytes(&e.@"addrspace") ++
asBytes(&e.zir_index)),
asBytes(&e.zir_index) ++ &[1]u8{@intFromEnum(e.source)}),
};
}

Expand Down Expand Up @@ -2958,7 +2959,8 @@ pub const Key = union(enum) {
a_info.is_const == b_info.is_const and
a_info.alignment == b_info.alignment and
a_info.@"addrspace" == b_info.@"addrspace" and
a_info.zir_index == b_info.zir_index;
a_info.zir_index == b_info.zir_index and
a_info.source == b_info.source;
},
.func => |a_info| {
const b_info = b.func;
Expand Down Expand Up @@ -5967,7 +5969,10 @@ pub const Tag = enum(u8) {
is_threadlocal: bool,
is_dll_import: bool,
relocation: std.builtin.ExternOptions.Relocation,
_: u25 = 0,
source: Source,
_: u24 = 0,

pub const Source = enum(u1) { builtin, syntax };
};
};

Expand Down Expand Up @@ -7320,6 +7325,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
.@"addrspace" = nav.status.fully_resolved.@"addrspace",
.zir_index = extra.zir_index,
.owner_nav = extra.owner_nav,
.source = extra.flags.source,
} };
},
.func_instance => .{ .func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), data) },
Expand Down Expand Up @@ -9212,6 +9218,7 @@ pub fn getExtern(
.is_threadlocal = key.is_threadlocal,
.is_dll_import = key.is_dll_import,
.relocation = key.relocation,
.source = key.source,
},
.zir_index = key.zir_index,
.owner_nav = owner_nav,
Expand Down
1 change: 1 addition & 0 deletions src/Sema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25768,6 +25768,7 @@ fn zirBuiltinExtern(
},
},
.owner_nav = undefined, // ignored by `getExtern`
.source = .builtin,
});

const uncasted_ptr = try sema.analyzeNavRef(block, src, ip.indexToKey(extern_val).@"extern".owner_nav);
Expand Down
2 changes: 2 additions & 0 deletions src/Zcu/PerThread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ fn analyzeNavVal(pt: Zcu.PerThread, nav_id: InternPool.Nav.Index) Zcu.CompileErr
.@"addrspace" = modifiers.@"addrspace",
.zir_index = old_nav.analysis.?.zir_index, // `declaration` instruction
.owner_nav = undefined, // ignored by `getExtern`
.source = .syntax,
}));
},
};
Expand Down Expand Up @@ -3435,6 +3436,7 @@ pub fn getCoerced(pt: Zcu.PerThread, val: Value, new_ty: Type) Allocator.Error!V
.@"addrspace" = e.@"addrspace",
.zir_index = e.zir_index,
.owner_nav = undefined, // ignored by `getExtern`.
.source = e.source,
});
return Value.fromInterned(coerced);
},
Expand Down
Loading