* Re: [4.6 PATCH] Fix DECL_COMDAT_GROUP of thunks (PR c++/50255)
@ 2011-09-08 3:10 Jason Merrill
2011-09-08 3:30 ` Jason Merrill
0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2011-09-08 3:10 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
Ok.
Jakub Jelinek <jakub@redhat.com> wrote:
Hi!
On various targets we emit thunks into the same section as the corresponding
method they are thunking to.
Unfortunately, the thunk_fndecl had a DECL_COMDAT_GROUP set earlier to the
thunk name, which results in assembly like:
.section .text._ZN1TI1WI1XEE1hEP1A,"axG",@progbits,_ZThn8_N1TI1WI1XEE1hEP1A,comdat
.weak _ZThn8_N1TI1WI1XEE1hEP1A
.type _ZThn8_N1TI1WI1XEE1hEP1A, @function
_ZThn8_N1TI1WI1XEE1hEP1A:
.LFB4:
.cfi_startproc
subq $8, %rdi
jmp .LTHUNK0
.cfi_endproc
.LFE4:
.size _ZThn8_N1TI1WI1XEE1hEP1A, .-_ZThn8_N1TI1WI1XEE1hEP1A
.align 2
.weak _ZN1TI1WI1XEE1hEP1A
.type _ZN1TI1WI1XEE1hEP1A, @function _ZN1TI1WI1XEE1hEP1A:
.LFB3:
.cfi_startproc
subq $40, %rsp
.cfi_def_cfa_offset 48
movl (%rsi), %edx
decl %edx
cmpl $4, %edx
ja .L3
movq 8(%rsi), %rax
jmp *.L8(,%rdx,8)
.section .rodata._ZN1TI1WI1XEE1hEP1A,"aG",@progbits,_ZN1TI1WI1XEE1hEP1A,comdat
.align 8
.align 4
.L8:
.quad .L4
Note the .text._ZN1TI1WI1XEE1hEP1A section uses incorrectly
_ZThn8_N1TI1WI1XEE1hEP1A comdat group instead of _ZN1TI1WI1XEE1hEP1A,
but e.g. the .rodata section for it already uses the right
comdat group name, therefore e.g. if the same method is compiled with
different optimization options with no need for .rodata in another
CU and that CU's _ZThn8_N1TI1WI1XEE1hEP1A would be picked and this
CU's _ZN1TI1WI1XEE1hEP1A, it will fail to link.
This patch makes sure it uses the right thunk name.
When mixing 4.6 compiled objects compiled before/after this patch,
if just the .text section is used, I think the worst thing that can happen
is that both comdat groups stay but as the symbols are weak, it will just
result in larger code. If more than one section is used for the
method+thunks and mixed comdat groups were used before, it was a problem
already before.
On the trunk this issue went away with Honza's cgraph thunk reorg, the
make_decl_one_only for the thunk's comdat group is gone and it does
cgraph_add_to_same_comdat_group.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for 4.6?
Maybe for 4.5 also afterwards (4.4 wasn't emitting comdat groups).
2011-09-07 Jakub Jelinek <jakub@redhat.com>
PR c++/50255
* method.c (use_thunk): If emitting thunk into the same section
as function, use the same DECL_COMDAT_GROUP as well.
--- gcc/cp/method.c.jj 2011-05-19 11:48:00.000000000 +0200
+++ gcc/cp/method.c 2011-09-07 17:15:37.000000000 +0200
@@ -360,6 +360,8 @@ use_thunk (tree thunk_fndecl, bool emit_
/* Output the thunk into the same section as function. */
DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
+ if (DECL_COMDAT_GROUP (function))
+ make_decl_one_only (thunk_fndecl, DECL_COMDAT_GROUP (function));
}
}
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [4.6 PATCH] Fix DECL_COMDAT_GROUP of thunks (PR c++/50255)
2011-09-08 3:10 [4.6 PATCH] Fix DECL_COMDAT_GROUP of thunks (PR c++/50255) Jason Merrill
@ 2011-09-08 3:30 ` Jason Merrill
0 siblings, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2011-09-08 3:30 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
Ok.
Jakub Jelinek <jakub@redhat.com> wrote:
Hi!
On various targets we emit thunks into the same section as the corresponding
method they are thunking to.
Unfortunately, the thunk_fndecl had a DECL_COMDAT_GROUP set earlier to the
thunk name, which results in assembly like:
.section .text._ZN1TI1WI1XEE1hEP1A,"axG",@progbits,_ZThn8_N1TI1WI1XEE1hEP1A,comdat
.weak _ZThn8_N1TI1WI1XEE1hEP1A
.type _ZThn8_N1TI1WI1XEE1hEP1A, @function
_ZThn8_N1TI1WI1XEE1hEP1A:
.LFB4:
.cfi_startproc
subq $8, %rdi
jmp .LTHUNK0
.cfi_endproc
.LFE4:
.size _ZThn8_N1TI1WI1XEE1hEP1A, .-_ZThn8_N1TI1WI1XEE1hEP1A
.align 2
.weak _ZN1TI1WI1XEE1hEP1A
.type _ZN1TI1WI1XEE1hEP1A, @function _ZN1TI1WI1XEE1hEP1A:
.LFB3:
.cfi_startproc
subq $40, %rsp
.cfi_def_cfa_offset 48
movl (%rsi), %edx
decl %edx
cmpl $4, %edx
ja .L3
movq 8(%rsi), %rax
jmp *.L8(,%rdx,8)
.section .rodata._ZN1TI1WI1XEE1hEP1A,"aG",@progbits,_ZN1TI1WI1XEE1hEP1A,comdat
.align 8
.align 4
.L8:
.quad .L4
Note the .text._ZN1TI1WI1XEE1hEP1A section uses incorrectly
_ZThn8_N1TI1WI1XEE1hEP1A comdat group instead of _ZN1TI1WI1XEE1hEP1A,
but e.g. the .rodata section for it already uses the right
comdat group name, therefore e.g. if the same method is compiled with
different optimization options with no need for .rodata in another
CU and that CU's _ZThn8_N1TI1WI1XEE1hEP1A would be picked and this
CU's _ZN1TI1WI1XEE1hEP1A, it will fail to link.
This patch makes sure it uses the right thunk name.
When mixing 4.6 compiled objects compiled before/after this patch,
if just the .text section is used, I think the worst thing that can happen
is that both comdat groups stay but as the symbols are weak, it will just
result in larger code. If more than one section is used for the
method+thunks and mixed comdat groups were used before, it was a problem
already before.
On the trunk this issue went away with Honza's cgraph thunk reorg, the
make_decl_one_only for the thunk's comdat group is gone and it does
cgraph_add_to_same_comdat_group.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for 4.6?
Maybe for 4.5 also afterwards (4.4 wasn't emitting comdat groups).
2011-09-07 Jakub Jelinek <jakub@redhat.com>
PR c++/50255
* method.c (use_thunk): If emitting thunk into the same section
as function, use the same DECL_COMDAT_GROUP as well.
--- gcc/cp/method.c.jj 2011-05-19 11:48:00.000000000 +0200
+++ gcc/cp/method.c 2011-09-07 17:15:37.000000000 +0200
@@ -360,6 +360,8 @@ use_thunk (tree thunk_fndecl, bool emit_
/* Output the thunk into the same section as function. */
DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
+ if (DECL_COMDAT_GROUP (function))
+ make_decl_one_only (thunk_fndecl, DECL_COMDAT_GROUP (function));
}
}
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* [4.6 PATCH] Fix DECL_COMDAT_GROUP of thunks (PR c++/50255)
@ 2011-09-07 21:04 Jakub Jelinek
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2011-09-07 21:04 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
On various targets we emit thunks into the same section as the corresponding
method they are thunking to.
Unfortunately, the thunk_fndecl had a DECL_COMDAT_GROUP set earlier to the
thunk name, which results in assembly like:
.section .text._ZN1TI1WI1XEE1hEP1A,"axG",@progbits,_ZThn8_N1TI1WI1XEE1hEP1A,comdat
.weak _ZThn8_N1TI1WI1XEE1hEP1A
.type _ZThn8_N1TI1WI1XEE1hEP1A, @function
_ZThn8_N1TI1WI1XEE1hEP1A:
.LFB4:
.cfi_startproc
subq $8, %rdi
jmp .LTHUNK0
.cfi_endproc
.LFE4:
.size _ZThn8_N1TI1WI1XEE1hEP1A, .-_ZThn8_N1TI1WI1XEE1hEP1A
.align 2
.weak _ZN1TI1WI1XEE1hEP1A
.type _ZN1TI1WI1XEE1hEP1A, @function _ZN1TI1WI1XEE1hEP1A:
.LFB3:
.cfi_startproc
subq $40, %rsp
.cfi_def_cfa_offset 48
movl (%rsi), %edx
decl %edx
cmpl $4, %edx
ja .L3
movq 8(%rsi), %rax
jmp *.L8(,%rdx,8)
.section .rodata._ZN1TI1WI1XEE1hEP1A,"aG",@progbits,_ZN1TI1WI1XEE1hEP1A,comdat
.align 8
.align 4
.L8:
.quad .L4
Note the .text._ZN1TI1WI1XEE1hEP1A section uses incorrectly
_ZThn8_N1TI1WI1XEE1hEP1A comdat group instead of _ZN1TI1WI1XEE1hEP1A,
but e.g. the .rodata section for it already uses the right
comdat group name, therefore e.g. if the same method is compiled with
different optimization options with no need for .rodata in another
CU and that CU's _ZThn8_N1TI1WI1XEE1hEP1A would be picked and this
CU's _ZN1TI1WI1XEE1hEP1A, it will fail to link.
This patch makes sure it uses the right thunk name.
When mixing 4.6 compiled objects compiled before/after this patch,
if just the .text section is used, I think the worst thing that can happen
is that both comdat groups stay but as the symbols are weak, it will just
result in larger code. If more than one section is used for the
method+thunks and mixed comdat groups were used before, it was a problem
already before.
On the trunk this issue went away with Honza's cgraph thunk reorg, the
make_decl_one_only for the thunk's comdat group is gone and it does
cgraph_add_to_same_comdat_group.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for 4.6?
Maybe for 4.5 also afterwards (4.4 wasn't emitting comdat groups).
2011-09-07 Jakub Jelinek <jakub@redhat.com>
PR c++/50255
* method.c (use_thunk): If emitting thunk into the same section
as function, use the same DECL_COMDAT_GROUP as well.
--- gcc/cp/method.c.jj 2011-05-19 11:48:00.000000000 +0200
+++ gcc/cp/method.c 2011-09-07 17:15:37.000000000 +0200
@@ -360,6 +360,8 @@ use_thunk (tree thunk_fndecl, bool emit_
/* Output the thunk into the same section as function. */
DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
+ if (DECL_COMDAT_GROUP (function))
+ make_decl_one_only (thunk_fndecl, DECL_COMDAT_GROUP (function));
}
}
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-08 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 3:10 [4.6 PATCH] Fix DECL_COMDAT_GROUP of thunks (PR c++/50255) Jason Merrill
2011-09-08 3:30 ` Jason Merrill
-- strict thread matches above, loose matches on Subject: below --
2011-09-07 21:04 Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).