ARM struct byval size > 64 triggers failure

Hi Renato,

Thanks for reply, please find the my comments and qurey inline.



------- Original Message -------

Sender : Renato

Title : Re: [LLVMdev] ARM struct byval size > 64 triggers failure

Hi Rajesh,

Stepan and Manman were changing that part of the code recently, so they can have better answer than I do.

Output on arm :


values 0x10861, 0x4071706f
which is wrong.

This works on my Chromebook, is this soft-float? Can you show us your compilation options and to which target you’re compiling to, please?

Yes, its soft-float, below is verbose of my command,

“$HOME/svn_3_3/install/bin/clang” -cc1 -triple armv4t–linux-gnueabi -S -disable-free -main-file-name check114.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-abi aapcs-linux -target-cpu arm7tdmi -mfloat-abi soft -target-feature +soft-float-abi -target-linker-version -v -g -coverage-file /tmp/check114-gebP2Y.s -resource-dir $HOME/svn_3_3/install/bin/…/lib/clang/3.3 -D SKIP_DECIMAL_FLOAT -I $HOME/ROOTSTRAP_PATH/rootstraps/target-arm/usr/include -isysroot $HOME/ROOTSTRAP_PATH/rootstraps/target-arm -internal-isystem $HOME/ROOTSTRAP_PATH/rootstraps/target-arm/usr/local/include -internal-isystem $HOME/svn_3_3/install/bin/…/lib/clang/3.3/include -internal-externc-isystem $HOME/ROOTSTRAP_PATH/rootstraps/target-arm/include -internal-externc-isystem $HOME/ROOTSTRAP_PATH/rootstraps/target-arm/usr/include -Wno-abi -Wno-unused-value -Wno-return-type -Wno-constant-logical-operand -w -fno-dwarf-directory-asm -fdebug-compilation-dir $HOME/tests -ferror-limit 19 -fmessage-length 0 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/check114-gebP2Y.s -x c check114.c

When the offset(#76) for the instruction, “ldr r1, [r11, #76] ; 0x4c” is calculated, 4 bytes alignment is considered.
In prologue stackpointer calculation 8 byte alignment is considered.

Due to this mimatch of alignment, If try to access any parameter after byval which results wrong value.

Issue(or offset of 4 bytes) wont occur if even number of register used for byval spilling.
struct S114 check114 (int a, struct S114 arg0, struct S114* arg1) { // accessing arg1 is fine in this case


This looks like a bug. :wink:

  1. Is this 8 byte alignment mandatory ? Is this due to " ARM AAPCS Stack constraints at a public interface" ? Can this be removed?

I’m not sure what you want removed here. AAPCS should be followed to guarantee compatibility. It looks to me as though the code is considering different constraints in different places, and all we need to do is to match the logic on both places.

One query here, “public interface” in AAPCS doc meant for global functions ?

  1. We will leave alignment as it is but in prologue we will adjust SP once again, this is little meaningless.

  2. While accessing arg1 we will consider alignment and add extra offset → looks better.

I think both are bad fixes, as they don’t fix the correct problem. Once the bug is fixed on trunk, can you use trunk LLVM? Or do you have to use a point-version?

Anything is fine, Could you share bug id if you have.

Anyway, changing your code to work around compiler issues is always a bad idea…

Offset to access arg1 is calculated by selection DAG that will be target independent. But Alignment adjustment should be done by target lowering. Any suggestions on how to fix this ?

I’m not too familiar with that part of the code, but Manman or Stepan can give you a hand here.