authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 21:46:30-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-18 21:46:30-07:00
log9262b6076f38eb614fb45c1f69f125665f0fa8d9
treed7a5263287cc1c4c7ed9588ebba01c61c462b085
parentc597ba32d930df0c2d5be846f3b14a19a5c440c5

Sema: fix generic function instances not respecting linksection


2 files changed, 10 insertions(+), 1 deletions(-)

src/InternPool.zig+5-1
......@@ -4705,6 +4705,7 @@ pub const GetFuncInstanceKey = struct {
47054705 bare_return_type: Index,
47064706 cc: std.builtin.CallingConvention,
47074707 alignment: Alignment,
4708 section: OptionalNullTerminatedString,
47084709 is_noinline: bool,
47094710 generic_owner: Index,
47104711 inferred_error_set: bool,
......@@ -4782,6 +4783,7 @@ pub fn getFuncInstance(ip: *InternPool, gpa: Allocator, arg: GetFuncInstanceKey)
47824783 func_extra_index,
47834784 arg.generation,
47844785 func_ty,
4786 arg.section,
47854787 );
47864788}
47874789
......@@ -4911,6 +4913,7 @@ pub fn getFuncInstanceIes(
49114913 func_extra_index,
49124914 arg.generation,
49134915 func_ty,
4916 arg.section,
49144917 );
49154918}
49164919
......@@ -4922,6 +4925,7 @@ fn finishFuncInstance(
49224925 func_extra_index: u32,
49234926 generation: u32,
49244927 func_ty: Index,
4928 section: OptionalNullTerminatedString,
49254929) Allocator.Error!Index {
49264930 const fn_owner_decl = ip.declPtr(ip.funcDeclOwner(generic_owner));
49274931 const decl_index = try ip.createDecl(gpa, .{
......@@ -4934,7 +4938,7 @@ fn finishFuncInstance(
49344938 .ty = func_ty.toType(),
49354939 .val = func_index.toValue(),
49364940 .alignment = .none,
4937 .@"linksection" = fn_owner_decl.@"linksection",
4941 .@"linksection" = section,
49384942 .@"addrspace" = fn_owner_decl.@"addrspace",
49394943 .analysis = .complete,
49404944 .deletion_flag = false,
src/Sema.zig+5
......@@ -8846,6 +8846,11 @@ fn funcCommon(
88468846 .bare_return_type = bare_return_type.toIntern(),
88478847 .cc = cc_resolved,
88488848 .alignment = alignment.?,
8849 .section = switch (section) {
8850 .generic => unreachable,
8851 .default => .none,
8852 .explicit => |x| x.toOptional(),
8853 },
88498854 .is_noinline = is_noinline,
88508855 .inferred_error_set = inferred_error_set,
88518856 .generic_owner = sema.generic_owner,