https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80759

--- Comment #49 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot 
Uni-Bielefeld.DE> ---
> --- Comment #47 from Daniel Santos <daniel.santos at pobox dot com> ---
[...]
> I'm sorry for the delay again.  I've been having some health problems
> infringing upon my hacking time.

No worries at all: don't even think about this stuff before you're well again!

> I wanted to study the use of __USER_LABEL_PREFIX__ to make sure I understand
> the implications.  I'm not completely clear on rather or not this is
> automatically applied when a back end uses gen_rtx_SYMBOL_REF (or some such),
> but guess is that it is.  It is also plausible to omit Darwin support for now,

That's my understanding as well.

> as I've learned that 64-bit Wine isn't yet working for Darwin either.  If 
> there
> are further problems, then that might be the smartest way to go since I don't
> have access to such a machine witch which I can test, experiment, debug, etc. 
> But if this does the trick, then all the better.

We're getting considerably closer with this latest patch.  I'll describe
the current issues below; maybe some of them are issues even beyond Darwin.

> I changed the C() macro to ASMNAME() just because I prefer helpful names and I
> decided to yank out all of the FUNC_BEGIN/FUNC_END macros from ms-sysv.c and
> just use #if directives directly in the string definition.  There's no sense 
> in
> maintaining a separate set of asm support macros dealing in strings when
> there's only one use site.

Fine with me.  The new names are certainly more expressive, while I'd
just ripped the definitions out of libffi to see if I could something
working that way at all.

> I also noticed a possible "gotcha" with the #if __x86_64__ and __SSE2__ -- not
> that I would expect necessarily expect it to happen.

I'm not sure this is even possible...

> In hopes of making your review easier, below is a delta between this new (v6)
> patch set and your last posted patches.

The new patch works fine for me on both x86_64-pc-linux-gnu (as
expected) and i386-pc-solaris2.12.

On x86_64-apple-darwin11.4.2, there are a couple of isues, some of which
I'd already resolved before you posted the revised patch.

* Initially all tests SEGVed like this (e.g. with -p0 and compiled with -O2):

Program received signal SIGSEGV, Segmentation fault.
0x000000010004664d in regs_to_mem ()
1: x/i $pc
=> 0x10004664d <regs_to_mem>:   movaps %xmm6,(%rax)
(gdb) where
#0  0x000000010004664d in regs_to_mem ()
#1  0x00000001000465df in do_test_body ()
#2  0x000000010002f227 in do_tests_0000 ()
#3  0x00000001000468e3 in main ()

  Here, %rax is 0x0.

  This happens because some setup happens between do_test_body0 and
  do_test_body, and do_test_aligned jumps directly to do_test_body:

        .globl _do_test_body0
        .no_dead_strip _do_test_body0
_do_test_body0:
        movq    _test_data@GOTPCREL(%rip), %rax

        .globl _do_test_body
_do_test_body:

        # Save registers.
        lea     (%rax), %rax
        call    _regs_to_mem

  By that jump, you bypass the setup of %rax and make the test FAIL.  I
  managed to avoid this by changing the jmp to do_test_body0 instead.
  This gets me past this failure, and works on Linux/x86_64, too.
  However, this makes the tests FAIL on Solaris/x86, supposedly due to
  the -fomit-frame-pointer/-fno-omit-frame-pointer difference (though I
  haven't looked more closely).

* With the do_test_body0 jump, I hit the next issue on Darwin with -O0:
  the test SEGVs here:

Program received signal SIGSEGV, Segmentation fault.
0x0000000100031c4e in do_test_body0 ()
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c:163
163       __asm__ ("\n"
1: x/i $pc
=> 0x100031c4e <do_test_body0+21>:      mov    %rax,0x2a8(%rdi)
(gdb) where
(gdb) p/x $rdi
$1 = 0x5dc3340b214ef45c

  which is no wonder since %rdi got clobbered just before.  Here's the
  assembler output:

        .globl _do_test_body0
        .no_dead_strip _do_test_body0
_do_test_body0:
        pushq   %rbp
        movq    %rsp, %rbp
        movq    _test_data@GOTPCREL(%rip), %rax
        movq    _test_data@GOTPCREL(%rip), %rdx
        movq    _test_data@GOTPCREL(%rip), %rcx
        movq    _test_data@GOTPCREL(%rip), %rsi
        movq    _test_data@GOTPCREL(%rip), %rdi

        .globl _do_test_body
_do_test_body:

        # Save registers.
        lea     (%rax), %rax
        call    _regs_to_mem

        # Load registers with random data.
        lea     224(%rdx), %rax
        call    _mem_to_regs

        # Save original return address.
        pop     %rax
        movq    %rax, 680(%rdi)

        # Call the test function
        call    *672(%rsi)

        # Restore the original return address.
        movq    680(%rdi), %rcx
        push    %rcx

  By clobbering %rdi (and %rsi), you cause the SEGV above.  To work
  around this, I've wrapped the save/restore of those regs in !__APPLE__
  which gets me a bit further.

* Now I hit another SEGV here:

Program received signal SIGSEGV, Segmentation fault.
0x0000000100001922 in msabi_00_0 ()
    at
/var/gcc/regression/trunk/10.7-gcc/build/gcc/testsuite/gcc/ms-sysv/ms-sysv-generated.h:16
16      {
1: x/i $pc
=> 0x100001922 <msabi_00_0+13>: movaps %xmm6,(%rsp)
(gdb) where
#0  0x0000000100001922 in msabi_00_0 ()
    at
/var/gcc/regression/trunk/10.7-gcc/build/gcc/testsuite/gcc/ms-sysv/ms-sysv-generated.h:16
#1  0x0000000100031c77 in do_test_body0 ()
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c:163
Cannot access memory at address 0x6fdc16ba5f5f46bc

  At this point I gave up for now...

Here's the snippet I've been using to get that far:

diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
--- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
+++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
@@ -69,8 +69,10 @@ FUNC_BEGIN(regs_to_mem)
        MOVAPS  %xmm13, 0x70(%rax)
        MOVAPS  %xmm14, 0x80(%rax)
        MOVAPS  %xmm15, 0x90(%rax)
+#ifndef __APPLE__
        mov     %rsi, 0xa0(%rax)
        mov     %rdi, 0xa8(%rax)
+#endif
        mov     %rbx, 0xb0(%rax)
        mov     %rbp, 0xb8(%rax)
        mov     %r12, 0xc0(%rax)
@@ -91,8 +93,10 @@ FUNC_BEGIN(mem_to_regs)
        MOVAPS  0x70(%rax),%xmm13
        MOVAPS  0x80(%rax),%xmm14
        MOVAPS  0x90(%rax),%xmm15
+#ifndef __APPLE__
        mov     0xa0(%rax),%rsi
        mov     0xa8(%rax),%rdi
+#endif
        mov     0xb0(%rax),%rbx
        mov     0xb8(%rax),%rbp
        mov     0xc0(%rax),%r12
@@ -121,7 +125,11 @@ FUNC_BEGIN(do_test_aligned)
        int     $3              # Stack not aligned
 L0:
        popf
+#ifdef __APPLE__
+       jmp     ASMNAME(do_test_body0)
+#else
        jmp     ASMNAME(do_test_body)
+#endif
 FUNC_END(do_test_aligned)
 FUNC_END(do_test_unaligned)

        Rainer

Reply via email to