[LLVMdev] question about alignment of structures on the stack (arm 32)

Tim Northover t.p.northover at gmail.com
Fri May 1 07:07:03 PDT 2015


On 1 May 2015 at 01:55, Alexey Perevalov <alexey.perevalov at hotmail.com> wrote:
> clang -target arm-apple-darwin10 -mabi=apcs-gnu -fPIC -o main_36.llvm main.c -O1 -mfloat-abi=soft -emit-llvm

The most reliable way to emit ARM code that's compatible with iOS is probably:
    clang -target x86_64-apple-macosx10.10 -arch armv7s ...

With that you certainly won't need to override the float-abi or abi.
I've been meaning to get "thumbv7s-apple-ios8.0" or whatever working
for a while too, but at the moment you need to specify x86 and then
"-arch" to set the real target for best results.

> in APCS convention, but not AAPCS, and function itself expects second argument in r1, r2.

Unfortunately, it looks like attribute((pcs("aapcs"))) doesn't work
when the general compilation environment is APCS. The immediate reason
is that it looks for the 64-bit alignment of the i64 to decide whether
to leave a hole (see ARMCallingConv.td:124), but i64 is only 32-bit
aligned in APCS. This particular issue could be fixed.

At a higher level though, it was designed as an attribute to interwork
between hard and soft-float versions of otherwise compatible ABIs.
There's no way it could reliably work on APCS (e.g. what do you do
when passing "struct { int a; long long b; }", where the layouts are
different on either side).

Cheers.

Tim.



More information about the llvm-dev mailing list