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

            Bug ID: 63607
           Summary: run fail with -flto -mfloat-abi=softfp for
                    armeb-linux-gnueabi-gcc
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fei.yang0953 at gmail dot com

testsuite/gcc.dg/torture/stackalign/builtin-apply-4.c:

/* PR tree-optimization/20076 */
/* { dg-do run } */

extern void abort (void);

double
foo (int arg)
{
  if (arg != 116)
    abort();
  return arg + 1;
}

inline double
bar (int arg)
{
  foo (arg);
  __builtin_return (__builtin_apply ((void (*) ()) foo,
                                     __builtin_apply_args (), 16));
}

int
main (int argc, char **argv)
{
  if (bar (116) != 117.0)
    abort ();

  return 0;
}

Compile option: armeb-linux-gnueabi-gcc builtin-apply-4.c -static
-mfloat-abi=softfp -flto 

Disassembly:
0000076c <main>:
76c:  e92d4800     push   {fp, lr}
770:  e28db004     add    fp, sp, #4
774:  e3a02113     mov    r2, #-1073741820    ; 0xc0000004
778:  e30a3aaa     movw   r3, #43690   ; 0xaaaa
77c:  e34a3aaa     movt   r3, #43690   ; 0xaaaa
780:  e5823000     str    r3, [r2]
784:  e3a00074     mov    r0, #116     ; 0x74
788:  ebffffaa     bl     638 <bar.4066>
78c: eeb06b40    vmov.f64    d6, d0
790:  ed9f7b0a     vldr   d7, [pc, #40] ; 7c0 <main+0x54>
794:  eeb46b47     vcmp.f64     d6, d7

Analysis: Return value is not passed correctly. As we can see from line 790,
main gets the return value from d0 register, which is wrong as we use
-mfloat-abi=softfp here.

Reply via email to