clang vector_size attribute compatibilty with gcc on x86

Hello all,
I have attached the test case for which variable with attribute vector_size when passed by value from clang to gcc or vice versa is causing compatibility issue. Incase of clang for vector_size attr, SIMD instructions are emitted as follows
movaps -0x18(%ebp),%xmm0
movdqa %xmm0,-0x28(%ebp)
clang sends vector data by value, using vector registers, in the above case xmm0. gcc always uses stack to pass vector data by value for vector_size attr vars (even with -O3). clang and gcc don't understand each other's calling convention when vector by value is passed to functions.
To preserve compatibility one solution is to compile clang without SIMD using flags like "-mno-mmx -mno-sse" to pass vector value completely on stack. Still the calling conventions between clang and gcc don't agree. When clang passes vector completely on stack for char sized items clang writes consecutive vector bytes in non contiguous locations on stack. For e.g to pass a vector of char like 0xab 0xcd clang will write in stack as
  Address X : 0xab 00 00 00
           X+4: 0xcd 00 00 00
  Whereas gcc will expect from clang the same data arranged as Address X : 0xab 0xcd . Looks like clang sends char data with 3 byte padding for speeding up reads as word read instruction. Also forcing no SIMD is meaningless for vector_size attr.

  What is the good approach to achieve compatibility between gcc and clang when vector_size is used?

  PS: attachment has compilation steps used. Also test case was simplified from gcc compatibility tests. Tests were done on 32 bit ubuntu X86, gcc version 4.4.5.

Senthil Kumar

v2.tar.gz (973 Bytes)

What platform are you using? Clang has (at least) two calling conventions for passing vectors on x86 as, for example, Darwin and Linux differ in how they do this.


No it doesn't.