ARM struct byval size > 64 triggers failure

Hi,

Handling of pass by val of struct size >64 bytes case is seems wrong for arm targets.

Summary:

Incase of struct pass by value for size > 64 along with other function params, failure seen in some corner cases. Access to function params result in wrong stack location access.

Stack pointer adjustment done by prologue emitter and offset used to access function params have different logics for calculaton.

Test code

201301101351858_QKNMBDIF.gif

Hi Rajesh,

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

Hi Rajesh,

The callee code looks okay to me

Assembly for check114

sub sp, sp, #16
push {r11, lr}
mov r11, sp
sub sp, sp, #8
str r3, [r11, #20]
str r2, [r11, #16]
str r1, [r11, #12]
ldr r1, [r11, #76]

VARegSaveSize is 16 because we store the first 16 bytes of struct byval in r0 to r3.
Align in computeRegArea is 8 since ABI says the stack pointer needs to be 8 byte aligned at function entry point.
But the second argument does not have to be 8 byte aligned, in fact it is 4 byte aligned for i32.

r11, #76 is equivalent to sp_at_entry + 52 since r11 = spat_entry - 16 - 8, which is 4-byte aligned after
storing the leftover (67-16=51) bytes of struct byval.

Can you also paste the assembly for the caller side and check whether the second argument is stored
at sp_at_entry+52?

As Renato suggested, please file a bug report.

Thanks,
Manman

Hi all,
One more interesting job :slight_smile:
I’ll look too at this case tomorrow. Today my brain is about to be exploded…

-Stepan.