diff mbox

[PR58066] preferred_stack_boundary update for tls expanded call

Message ID CA+4CFy4OWmDqS=mK1VtJsGGCZLA0sNCfsG7Ldyu9bhh=So+hCA@mail.gmail.com
State New
Headers show

Commit Message

Wei Mi May 12, 2014, 5:38 p.m. UTC
>> Here is a patch for the test. It contains two changes:
>> 1. For emutls, there will be an explicit call generated at expand
>> pass, and no stack adjustment is needed. So add /* {
>> dg-require-effective-target tls_native } */ in the test.
>> 2. Replace cfi_def_cfa_offset with insn sequence check.
>>
>> Is it ok?
>
> No, the test FAILs for 32-bit i386-pc-solaris2.11 with Sun as/ld:
>
> FAIL: gcc.target/i386/pr58066.c scan-assembler sub[^\r\n]*8[^\r\n]*sp.*call[^\r\n]*__tls_get_addr.*sub[^\r\n]*8[^\r\n]*sp.*call[^\r\n]*__tls_get_addr
>
> The TLS code sequence is different here:
>
>         subl    $8, %esp
>         leal    ccc1@tlsgd(,%ebx,1), %eax
>         call    ccc1@tlsgdplt
>
> I fear this insn scanning is going to be extremely fragile.
>
>         Rainer

Thanks for trying the testcase. rtl scanning will be slightly better
than assembly scanning. So how about this one?

Thanks,
Wei.

goo.*set\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*plus\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*const_int
-8.*UNSPEC_TLS" "final" } } */
+/* { dg-final { cleanup-rtl-dump "final" } } */

Comments

Rainer Orth May 13, 2014, 8:39 a.m. UTC | #1
Wei Mi <wmi@google.com> writes:

> Thanks for trying the testcase. rtl scanning will be slightly better
> than assembly scanning. So how about this one?

This one works fine for me.

Thanks.
        Rainer
Wei Mi May 14, 2014, 7:53 p.m. UTC | #2
Can I checkin this testcase fix?

Thanks,
Wei.


On Tue, May 13, 2014 at 1:39 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> Wei Mi <wmi@google.com> writes:
>
>> Thanks for trying the testcase. rtl scanning will be slightly better
>> than assembly scanning. So how about this one?
>
> This one works fine for me.
>
> Thanks.
>         Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
Rainer Orth May 15, 2014, 8:28 a.m. UTC | #3
Wei Mi <wmi@google.com> writes:

> Can I checkin this testcase fix?

I think this is for Uros to approve.

	Rainer
Uros Bizjak May 17, 2014, 9:58 a.m. UTC | #4
On Mon, May 12, 2014 at 7:38 PM, Wei Mi <wmi@google.com> wrote:
>>> Here is a patch for the test. It contains two changes:
>>> 1. For emutls, there will be an explicit call generated at expand
>>> pass, and no stack adjustment is needed. So add /* {
>>> dg-require-effective-target tls_native } */ in the test.
>>> 2. Replace cfi_def_cfa_offset with insn sequence check.
>>>
>>> Is it ok?
>>
>> No, the test FAILs for 32-bit i386-pc-solaris2.11 with Sun as/ld:
>>
>> FAIL: gcc.target/i386/pr58066.c scan-assembler sub[^\r\n]*8[^\r\n]*sp.*call[^\r\n]*__tls_get_addr.*sub[^\r\n]*8[^\r\n]*sp.*call[^\r\n]*__tls_get_addr
>>
>> The TLS code sequence is different here:
>>
>>         subl    $8, %esp
>>         leal    ccc1@tlsgd(,%ebx,1), %eax
>>         call    ccc1@tlsgdplt
>>
>> I fear this insn scanning is going to be extremely fragile.
>>
>>         Rainer
>
> Thanks for trying the testcase. rtl scanning will be slightly better
> than assembly scanning. So how about this one?

This is OK, with a small effective-target addition, as shown below.

Thanks,
Uros.


> Index: testsuite/gcc.target/i386/pr58066.c
> ===================================================================
> --- testsuite/gcc.target/i386/pr58066.c (revision 210222)
> +++ testsuite/gcc.target/i386/pr58066.c (working copy)
> @@ -1,5 +1,6 @@
>  /* { dg-do compile } */
> -/* { dg-options "-fPIC -O2" } */
> +/* { dg-require-effective-target tls_native } */

Please also add

/* { dg-require-effective-target fpic } */

> +/* { dg-options "-fPIC -fomit-frame-pointer -O2 -fdump-rtl-final" } */
>
>  /* Check whether the stack frame starting addresses of tls expanded calls
>     in foo and goo are 16bytes aligned.  */
> @@ -15,4 +16,6 @@ void* goo()
>   return &ccc2;
>  }
>
> -/* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 16" 2 } } */
> +/* { dg-final { scan-rtl-dump "Function
> foo.*set\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*plus\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*const_int
> -8.*UNSPEC_TLS.*Function goo" "final" } } */
> +/* { dg-final { scan-rtl-dump "Function
> goo.*set\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*plus\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*const_int
> -8.*UNSPEC_TLS" "final" } } */
> +/* { dg-final { cleanup-rtl-dump "final" } } */
diff mbox

Patch

Index: testsuite/gcc.target/i386/pr58066.c
===================================================================
--- testsuite/gcc.target/i386/pr58066.c (revision 210222)
+++ testsuite/gcc.target/i386/pr58066.c (working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-do compile } */
-/* { dg-options "-fPIC -O2" } */
+/* { dg-require-effective-target tls_native } */
+/* { dg-options "-fPIC -fomit-frame-pointer -O2 -fdump-rtl-final" } */

 /* Check whether the stack frame starting addresses of tls expanded calls
    in foo and goo are 16bytes aligned.  */
@@ -15,4 +16,6 @@  void* goo()
  return &ccc2;
 }

-/* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 16" 2 } } */
+/* { dg-final { scan-rtl-dump "Function
foo.*set\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*plus\[^\r\n\]*sp\\)\[\r\n\]\[^\r\n\]*const_int
-8.*UNSPEC_TLS.*Function goo" "final" } } */
+/* { dg-final { scan-rtl-dump "Function