LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 35361 - [GlobalISel][AArch64] Calling convention for small arguments passed on stack incorrect on big-endian targets
Summary: [GlobalISel][AArch64] Calling convention for small arguments passed on stack ...
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: GlobalISel (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Amara Emerson
URL:
Keywords:
Depends on: 26161
Blocks:
  Show dependency tree
 
Reported: 2017-11-20 03:01 PST by Oliver Stannard
Modified: 2017-12-04 07:43 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Stannard 2017-11-20 03:01:51 PST
Global-isel generates incorrect code when targeting big-endian AArch64 for this code:
  int foo(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7,
          int stack1) {
    return stack1;
  }

  int main() {
    int ret = foo(0,1,2,3,4,5,6,7,8);
    printf("%d\n", ret);
  }

Global isel thinks that the incoming value of stack1 is stored in bytes [0,4) above SP, but for big-endian targets this should be in bytes [4,8):

// /work/llvm/build/bin/clang --target=aarch64-arm-none-eabi -march=armv8-a -c callees.cpp -O0 -Wall -std=c++11 -mllvm -global-isel=true -mllvm -global-isel-abort=0 -mbig-endian -o - -S
_Z3fooiiiiiiiii:                        // @_Z3fooiiiiiiiii
// BB#0:                                // %entry
        sub     sp, sp, #48             // =48
        ldr     w8, [sp, #48]   // <= Should be [sp, #52]
        str     w0, [sp, #44]
        str     w1, [sp, #40]
        str     w2, [sp, #36]
        str     w3, [sp, #32]
        str     w4, [sp, #28]
        str     w5, [sp, #24]
        str     w6, [sp, #20]
        str     w7, [sp, #16]
        str     w8, [sp, #12]
        ldr     w0, [sp, #12]
        add     sp, sp, #48             // =48
        ret
Comment 1 Quentin Colombet 2017-11-27 09:42:56 PST
Hi Amara, could you take a look?
Thanks.
Comment 2 Amara Emerson 2017-12-04 07:43:11 PST
GISel big endian will be disabled until PR26161 is resolved.