This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug 85667 - (x86_64) ms_abi rules aren't followed when returning short structs with float values


在 2018/9/19 16:52, lokesh janghel 写道:
Hi,

I am starting to looking into this issue.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85667#c0


We did some analysis about that issue and found that the problem occurs may
be in the code generation phase in GCC.
ABI says that struct type uses the integer register  (like clang )or memory
to return not the  SSE registers.

Before we go ahead and fix this issue and we would like to know the
community views/comments on the same.



This happens on not only x64, but x86 too:

```
typedef struct
{
  float x;
} Float;

#ifdef _MSC_VER
#  define MSABI
#else
#  define MSABI __attribute__((ms_abi))
#endif

Float MSABI fn1()
{
  Float v;
  v.x = 3.145;
  return v;
}
```


```
E:\Desktop>cl /nologo /c /O2 /Fo:test-cl.obj test.c && objdump -dMintel-mneomic test-cl.obj

test-cl.obj:     file format pe-i386


Disassembly of section .text$mn:

00000000 <_fn1>:
   0:   51                      push   ecx
   1:   c7 04 24 ae 47 49 40    mov    DWORD PTR [esp],0x404947ae
   8:   8b 04 24                mov    eax,DWORD PTR [esp]
   b:   59                      pop    ecx
   c:   c3                      ret

E:\Desktop>gcc -c -O2 -o test-gcc.o test.c && objdump -dMintel-mneomic test-gcc.o

test-gcc.o:     file format pe-i386


Disassembly of section .text:

00000000 <_fn1>:
   0:   d9 05 00 00 00 00       fld    DWORD PTR ds:0x0
   6:   c3                      ret
   7:   90                      nop

E:\Desktop>
```


--
Best regards,
LH_Mouse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]