Patchwork PR/50076 make c-c++-common/cxxbitfields-3.c work in Darwin

login
register
mail settings
Submitter Aldy Hernandez
Date Dec. 9, 2011, 5:35 p.m.
Message ID <4EE246FD.2000704@redhat.com>
Download mbox | patch
Permalink /patch/130438/
State New
Headers show

Comments

Aldy Hernandez - Dec. 9, 2011, 5:35 p.m.
This test is somewhat problematic in that it's entirely dependent on the 
assembler output.  It's not reproducible on non-x86, so I couldn't make 
it part of the simulate-thread framework.

What we're really testing is that the last move into "var" happens as a 
32/64 bit quantity:

         movl    var(%rip), %eax
         andb    $15, %al
         orl     $80, %eax
         movl    %eax, var(%rip)		<-- good

Currently the regexp is testing a movl into "var", however on Darwin 
there is an extra level of indirection through GOTPCREL, so we don't 
explicitly store into "var".  The result is correct, but doesn't match 
the regexp:

     movq    _var@GOTPCREL(%rip), %rdx
     movl    (%rdx), %eax
     andb    $15, %al
     orl    $80, %eax
     movl    %eax, (%rdx)		<-- bad, no "var"

The two simple solutions I can think of are (a) modifying the regexp as 
below (b) XFAILing on Darwin.  I would prefer (a), but I want to make 
sure I'm not overlooking something.

Does this seem reasonable or is another approach preferable?

testsuite/
	* c-c++-common/cxxbitfields-3.c: Adjust regexp.
IainS - Dec. 9, 2011, 5:41 p.m.
On 9 Dec 2011, at 17:35, Aldy Hernandez wrote:

> This test is somewhat problematic in that it's entirely dependent on  
> the assembler output.  It's not reproducible on non-x86, so I  
> couldn't make it part of the simulate-thread framework.
>
> What we're really testing is that the last move into "var" happens  
> as a 32/64 bit quantity:
>
>        movl    var(%rip), %eax
>        andb    $15, %al
>        orl     $80, %eax
>        movl    %eax, var(%rip)		<-- good
>
> Currently the regexp is testing a movl into "var", however on Darwin  
> there is an extra level of indirection through GOTPCREL, so we don't  
> explicitly store into "var".  The result is correct, but doesn't  
> match the regexp:
>
>    movq    _var@GOTPCREL(%rip), %rdx
>    movl    (%rdx), %eax
>    andb    $15, %al
>    orl    $80, %eax
>    movl    %eax, (%rdx)		<-- bad, no "var"
>
> The two simple solutions I can think of are (a) modifying the regexp  
> as below (b) XFAILing on Darwin.  I would prefer (a), but I want to  
> make sure I'm not overlooking something.
>
> Does this seem reasonable or is another approach preferable?
>
> testsuite/
> 	* c-c++-common/cxxbitfields-3.c: Adjust regexp.
>
> Index: testsuite/c-c++-common/cxxbitfields-3.c
> ===================================================================
> --- testsuite/c-c++-common/cxxbitfields-3.c	(revision 182028)
> +++ testsuite/c-c++-common/cxxbitfields-3.c	(working copy)
> @@ -18,4 +18,4 @@ void setit()
>   var.j = 5;
> }
>
> -/* { dg-final { scan-assembler "movl.*, var" } } */
> +/* { dg-final { scan-assembler "movl.*, (var|\\(%)" } } */

scan-assembler can be target-dependent if that would (as I read the  
above) help.
Iain

Patch

Index: testsuite/c-c++-common/cxxbitfields-3.c
===================================================================
--- testsuite/c-c++-common/cxxbitfields-3.c	(revision 182028)
+++ testsuite/c-c++-common/cxxbitfields-3.c	(working copy)
@@ -18,4 +18,4 @@  void setit()
    var.j = 5;
  }

-/* { dg-final { scan-assembler "movl.*, var" } } */
+/* { dg-final { scan-assembler "movl.*, (var|\\(%)" } } */