[PATCH] PR rtl-optimization/32219: optimizer causees wrong code in pic/hidden/weak symbol checking

H.J. Lu hjl.tools@gmail.com
Thu Feb 19 13:12:00 GMT 2015


On Wed, Feb 18, 2015 at 6:17 AM, Alex Velenko <Alex.Velenko@arm.com> wrote:
> On 13/02/15 05:11, Richard Henderson wrote:
>>
>> On 02/12/2015 08:14 PM, H.J. Lu wrote:
>>>
>>> I tried the second patch.  Results look good on Linux/x86-64.
>>
>>
>> Thanks.  My results concurr.  I went ahead and installed the patch as
>> posted.
>>
>>
>> r~
>>
>>
>> 2015-02-12  H.J. Lu  <hongjiu.lu@intel.com>
>>              Richard Henderson  <rth@redhat.com>
>>
>>          PR rtl/32219
>>          * cgraphunit.c (cgraph_node::finalize_function): Set definition
>>          before notice_global_symbol.
>>          (varpool_node::finalize_decl): Likewise.
>>          * varasm.c (default_binds_local_p_2): Rename from
>>          default_binds_local_p_1, add weak_dominate argument.  Use direct
>>          returns instead of assigning to local variable.  Unify varpool
>> and
>>          cgraph paths via symtab_node.  Reject undef weak variables before
>>          testing visibility.  Reorder tests for simplicity.
>>          (default_binds_local_p): Use default_binds_local_p_2.
>>          (default_binds_local_p_1): Likewise.
>>          (decl_binds_to_current_def_p): Unify varpool and cgraph paths
>>          via symtab_node.
>>          (default_elf_asm_output_external): Emit visibility when
>> specified.
>>
>> 2015-02-12  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>          PR rtl/32219
>>          * gcc.dg/visibility-22.c: New test.
>>          * gcc.dg/visibility-23.c: New test.
>>          * gcc.target/i386/pr32219-1.c: New test.
>>          * gcc.target/i386/pr32219-2.c: New test.
>>          * gcc.target/i386/pr32219-3.c: New test.
>>          * gcc.target/i386/pr32219-4.c: New test.
>>          * gcc.target/i386/pr32219-5.c: New test.
>>          * gcc.target/i386/pr32219-6.c: New test.
>>          * gcc.target/i386/pr32219-7.c: New test.
>>          * gcc.target/i386/pr32219-8.c: New test.
>>          * gcc.target/i386/pr64317.c: Expect GOTOFF, not GOT.
>>
>
> Hi all,
> By changing behaviour of varasm.c:default_binds_local_p, this patch changes
> behaviour of gcc/config/arm/arm.c:arm_function_in_section_p and through it
> breaks gcc/config/arm/arm.c:arm_is_long_call_p for weak symbols.
>
> As a result, I get regression for gcc.target/arm/long-calls-1.c on
> arm-none-eabi:
> FAIL: gcc.target/arm/long-calls-1.c scan-assembler-not \tbl?\tweak_l1\n
> FAIL: gcc.target/arm/long-calls-1.c scan-assembler-not \tbl?\tweak_l3\n
>
> In https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html there
> is a description for -mlong-calls.

I know nothing about arm.  I built a cross compiler and got:

[hjl@gnu-tools-1 gcc]$ cat /tmp/z.i
const char *
__attribute__((long_call)) __attribute__((noinline))
strong_l1 (void) { return "strong_l1"; }
const char * call_strong_l1 (void) { return strong_l1 () + 1; }
const char * sibcall_strong_l1 (void) { return strong_l1 (); }
const char *
__attribute__((weak)) __attribute__((long_call)) __attribute__((noinline))
weak_l1 (void) { return "weak_l1"; }
const char * call_weak_l1 (void) { return weak_l1 () + 1; }
const char * sibcall_weak_l1 (void) { return weak_l1 (); }
[hjl@gnu-tools-1 gcc]$ ./xgcc -B./ -S -O2 /tmp/z.i
[hjl@gnu-tools-1 gcc]$ grep "b.*        strong_l1" z.s
.global strong_l1
bl strong_l1
b strong_l1
[hjl@gnu-tools-1 gcc]$ grep "b.*        weak_l1" z.s
bl weak_l1
bl weak_l1
[hjl@gnu-tools-1 gcc]$

Can someone tell me what is wrong with the output and why?

-- 
H.J.



More information about the Gcc-patches mailing list