[LLVMdev] Question about SPARC target status

Peter Shugalev peter at shugalev.com
Tue Nov 11 15:51:21 PST 2008

Owen Anderson wrote:
> If you configure it as a cross-compiler for 64-bit x86 Linux and feed it 
> the appropriate header files, it will produce the same output on any 
> platform.  However, that output will not be executable on most 
> platforms, just on 64-bit x86 Linux.  The problems go beyond pointer 
> size.  The size of int is implementation dependent, etc.  The layout and 
> padding of structs is implementation dependent.  While all 
> implementations on a given target-triple will generally agree to ensure 
> binary compatibility, there is no guarantee of things being the same 
> once you go to another target-triple.

Do you mean that cross-target execution CAN break on examples like this 
one? [eventually on this example it doesn't]

   struct X {
     void *a;
     int b;
   } x;

   *(int *) ((char *)&x + sizeof(void*)) = 1;

However this one will work because getelementptr is wise enough:

   struct X {
     void *a;
     int b;
   } x;

   x.b = 1;

Now I avoid the former code sample and likes of it and figure out every 
problem of alignment. Do I have the chance to run the same LLVM IR on 
platform of different bitness?

BTW: is there a plan to introduce expressions as constants (including 
sizeof() operation) in IR? It will rule out some of llvm-gcc compile 
time optimizations but the resulting code will be much more portable.

Best Regards
Peter Shugalev

More information about the llvm-dev mailing list