This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR rtl-optimization/32219: optimizer causes wrong code in pic/hidden/weak symbol checking
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jack Howarth <howarth dot at dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Mike Stump <mikestump at comcast dot net>, Iain Sandoe <iain at codesourcery dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Tue, 10 Feb 2015 13:25:52 -0800
- Subject: Re: [PATCH] PR rtl-optimization/32219: optimizer causes wrong code in pic/hidden/weak symbol checking
- Authentication-results: sourceware.org; auth=none
- References: <20150206162314 dot GA12597 at intel dot com> <CAJMcOU9UbX=C2t=6X+DOTynkCurczbGNG3dqZRwjmRe8_U1fCg at mail dot gmail dot com> <CAMe9rOqHHZFHS4YMOAdN16aNyn4hi6eyzxGUrMue2uDn76ydGg at mail dot gmail dot com> <CAJMcOU9+x47s7jwRL4uniLs2z9EHR_Ajfk==HX1mObm97qytCg at mail dot gmail dot com> <CAMe9rOr5Ktk_yhfFX9DHAb6Sq=v2SORaY6TbahSiKF9dB1LNSQ at mail dot gmail dot com> <CAJMcOU-hPQYF1k58CXP4E5K2_-3F50RaMV_rHm3f5R_hXxivWQ at mail dot gmail dot com> <20150207122739 dot GA25185 at gmail dot com> <CAJMcOU-Bk1i9LeaHLpZGspWjDcY_n2qFcNgnCbbEsq30ZPTipA at mail dot gmail dot com> <20150207155606 dot GA14159 at gmail dot com> <20150207164507 dot GA19402 at gmail dot com> <54DA75D2 dot 40402 at redhat dot com>
On Tue, Feb 10, 2015 at 1:19 PM, Richard Henderson <rth@redhat.com> wrote:
>> @@ -7445,9 +7465,10 @@ default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
>> {
>> /* We output the name if and only if TREE_SYMBOL_REFERENCED is
>> set in order to avoid putting out names that are never really
>> - used. */
>> + used. Always output visibility specified in the source. */
>> if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
>> - && targetm.binds_local_p (decl))
>> + && (DECL_VISIBILITY_SPECIFIED (decl)
>> + || targetm.binds_local_p (decl)))
>> maybe_assemble_visibility (decl);
>
> Explain?
>
This is for the new testcase in my patch:
[hjl@gnu-mic-2 testsuite]$ cat gcc.dg/visibility-23.c
/* PR target/32219 */
/* { dg-do compile } */
/* { dg-require-visibility "" } */
/* { dg-final { scan-hidden "foo" } } */
/* { dg-options "-O2 -fPIC" { target fpic } } */
/* { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" "*-*-darwin*" } "*" { "" } } */
extern void foo () __attribute__((weak,visibility("hidden")));
int
main()
{
if (foo)
foo ();
return 0;
}
[hjl@gnu-mic-2 testsuite]$
Here targetm.binds_local_p now returns false. But we must
emit ".hidden foo" even if foo isn't defined in the TU. Otherwise,
foo wont be hidden if it isn't defined in another TU.
--
H.J.