This is an archive of the discontinued LLVM Phabricator instance.

AArch64 - Narrow arguments passed in wrong position on the stack in big-endian mode (aarch64_pcs)
ClosedPublic

Authored by rmaprath on Aug 15 2014, 3:13 AM.

Details

Summary

Consider the following snippet:

int f(
      long x0, long x1, long x2, long x3,
      long x4, long x5, long x6, long x7,
      char c, short s
      ) {
  return c + s;
}

int g() {
  return f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
}

When compiled with: --target=aarch64-none-eabi -mbig-endian -O2 -fno-inline -S

The following assembly is produced:

f:                                      // @f
        ;...
	ldrb	w8, [sp, #4] ; @@@ should be '#7'
	ldrsh	w9, [sp, #12] ; @@@ should be '#14'
        ;...
g:                                      // @g
        ; ...
	strh	w8, [sp, #12] ; @@@ should be '#14'
	strb	w9, [sp, #4] ; @@@ should be '#7'
	bl	f
        ; ...

The actual argument positions on the stack should be as in the comments (as per aarch64_pcs - C14, C15). The attached patch fixes this issue.

Diff Detail

Event Timeline

rmaprath updated this revision to Diff 12544.Aug 15 2014, 3:13 AM
rmaprath retitled this revision from to AArch64 - Narrow arguments passed in wrong position on the stack in big-endian mode (aarch64_pcs).
rmaprath updated this object.
rmaprath edited the test plan for this revision. (Show Details)
rmaprath added a subscriber: Unknown Object (MLST).

Hi Asiri,

This looks fine to me. Do you need someone to commit it for you?

Cheers.

Tim.

t.p.northover accepted this revision.Aug 15 2014, 5:49 AM
t.p.northover added a reviewer: t.p.northover.
This revision is now accepted and ready to land.Aug 15 2014, 5:49 AM

Thanks Tim!

Amara agreed to commit the patch.

  • Asiri

Excellent! Well, thanks for writing it!

Tim.

aemerson closed this revision.Aug 15 2014, 7:39 AM
aemerson updated this revision to Diff 12556.

Closed by commit rL215716 (authored by @aemerson).