[llvm-dev] question about ARM 32 big endian

Strahinja Petrovic via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 17 03:22:26 PDT 2016


Hi everyone,

I have a question about ARM 32 big endian calling convention. It's about 
sending small structures as function argument.
For example if passing 3 chars in a structure should alignment in 
register (argument register for passing those chars in function) be 
right-adjusted ?
LLVM (trunk version) is passing those chars left-adjusted in register, 
and trying to read them  like they are right-adjusted and there is a 
problem.
GCC is passing chars in register left-adjusted and works properly.

Here is the example:

#include <stdarg.h>

struct tiny
{
   char c;
   char d;
   char e;
};

f (int n, ...)
{
   struct tiny x;

   va_list ap;
   va_start (ap,n);
   x = va_arg (ap,struct tiny);
   if (x.c !=  10)
       abort();
   if (x.d !=  11)
       abort();
   if(x.e != 12)
     abort();
   va_end (ap);
}
main ()
{
   struct tiny x[3];
   x[0].c = 10;
   x[0].d = 11;
   x[0].e = 12;
   f (3, x[0]);
   exit(0);
}





More information about the llvm-dev mailing list