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 {...@@ -4705,6 +4705,7 @@ pub const GetFuncInstanceKey = struct {
4705 bare_return_type: Index,4705 bare_return_type: Index,
4706 cc: std.builtin.CallingConvention,4706 cc: std.builtin.CallingConvention,
4707 alignment: Alignment,4707 alignment: Alignment,
4708 section: OptionalNullTerminatedString,
4708 is_noinline: bool,4709 is_noinline: bool,
4709 generic_owner: Index,4710 generic_owner: Index,
4710 inferred_error_set: bool,4711 inferred_error_set: bool,
...@@ -4782,6 +4783,7 @@ pub fn getFuncInstance(ip: *InternPool, gpa: Allocator, arg: GetFuncInstanceKey)...@@ -4782,6 +4783,7 @@ pub fn getFuncInstance(ip: *InternPool, gpa: Allocator, arg: GetFuncInstanceKey)
4782 func_extra_index,4783 func_extra_index,
4783 arg.generation,4784 arg.generation,
4784 func_ty,4785 func_ty,
4786 arg.section,
4785 );4787 );
4786}4788}
47874789
...@@ -4911,6 +4913,7 @@ pub fn getFuncInstanceIes(...@@ -4911,6 +4913,7 @@ pub fn getFuncInstanceIes(
4911 func_extra_index,4913 func_extra_index,
4912 arg.generation,4914 arg.generation,
4913 func_ty,4915 func_ty,
4916 arg.section,
4914 );4917 );
4915}4918}
49164919
...@@ -4922,6 +4925,7 @@ fn finishFuncInstance(...@@ -4922,6 +4925,7 @@ fn finishFuncInstance(
4922 func_extra_index: u32,4925 func_extra_index: u32,
4923 generation: u32,4926 generation: u32,
4924 func_ty: Index,4927 func_ty: Index,
4928 section: OptionalNullTerminatedString,
4925) Allocator.Error!Index {4929) Allocator.Error!Index {
4926 const fn_owner_decl = ip.declPtr(ip.funcDeclOwner(generic_owner));4930 const fn_owner_decl = ip.declPtr(ip.funcDeclOwner(generic_owner));
4927 const decl_index = try ip.createDecl(gpa, .{4931 const decl_index = try ip.createDecl(gpa, .{
...@@ -4934,7 +4938,7 @@ fn finishFuncInstance(...@@ -4934,7 +4938,7 @@ fn finishFuncInstance(
4934 .ty = func_ty.toType(),4938 .ty = func_ty.toType(),
4935 .val = func_index.toValue(),4939 .val = func_index.toValue(),
4936 .alignment = .none,4940 .alignment = .none,
4937 .@"linksection" = fn_owner_decl.@"linksection",4941 .@"linksection" = section,
4938 .@"addrspace" = fn_owner_decl.@"addrspace",4942 .@"addrspace" = fn_owner_decl.@"addrspace",
4939 .analysis = .complete,4943 .analysis = .complete,
4940 .deletion_flag = false,4944 .deletion_flag = false,
src/Sema.zig+5
...@@ -8846,6 +8846,11 @@ fn funcCommon(...@@ -8846,6 +8846,11 @@ fn funcCommon(
8846 .bare_return_type = bare_return_type.toIntern(),8846 .bare_return_type = bare_return_type.toIntern(),
8847 .cc = cc_resolved,8847 .cc = cc_resolved,
8848 .alignment = alignment.?,8848 .alignment = alignment.?,
8849 .section = switch (section) {
8850 .generic => unreachable,
8851 .default => .none,
8852 .explicit => |x| x.toOptional(),
8853 },
8849 .is_noinline = is_noinline,8854 .is_noinline = is_noinline,
8850 .inferred_error_set = inferred_error_set,8855 .inferred_error_set = inferred_error_set,
8851 .generic_owner = sema.generic_owner,8856 .generic_owner = sema.generic_owner,