From 00c4dbd10e8b7c8e223bc0841012d98a4c1cde0c Mon Sep 17 00:00:00 2001 From: James Molloy Date: Thu, 8 May 2014 12:53:50 +0000 Subject: [PATCH] [ARM64-BE] Teach fast-isel about how to set up sub-word stack arguments for big endian calls. SelectionDAG already knows about this, but fast-isel was ignorant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208307 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM64/ARM64FastISel.cpp | 8 +++++++- test/CodeGen/ARM64/fast-isel-call.ll | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Target/ARM64/ARM64FastISel.cpp b/lib/Target/ARM64/ARM64FastISel.cpp index 0d4001ebf67..f8b54d033f7 100644 --- a/lib/Target/ARM64/ARM64FastISel.cpp +++ b/lib/Target/ARM64/ARM64FastISel.cpp @@ -1250,10 +1250,16 @@ bool ARM64FastISel::ProcessCallArgs(SmallVectorImpl &Args, assert(VA.isMemLoc() && "Assuming store on stack."); // Need to store on the stack. + unsigned ArgSize = VA.getLocVT().getSizeInBits() / 8; + + unsigned BEAlign = 0; + if (ArgSize < 8 && !Subtarget->isLittleEndian()) + BEAlign = 8 - ArgSize; + Address Addr; Addr.setKind(Address::RegBase); Addr.setReg(ARM64::SP); - Addr.setOffset(VA.getLocMemOffset()); + Addr.setOffset(VA.getLocMemOffset() + BEAlign); if (!EmitStore(ArgVT, Arg, Addr)) return false; diff --git a/test/CodeGen/ARM64/fast-isel-call.ll b/test/CodeGen/ARM64/fast-isel-call.ll index 637ce2898f9..8d756ae5461 100644 --- a/test/CodeGen/ARM64/fast-isel-call.ll +++ b/test/CodeGen/ARM64/fast-isel-call.ll @@ -1,4 +1,5 @@ ; RUN: llc < %s -O0 -fast-isel-abort -mtriple=arm64-apple-darwin | FileCheck %s +; RUN: llc < %s -O0 -fast-isel-abort -mtriple=arm64_be-linux-gnu | FileCheck %s --check-prefix=CHECK-BE define void @call0() nounwind { entry: @@ -89,3 +90,11 @@ entry: } declare i32 @func2(i64 zeroext, i32 signext, i16 zeroext, i8 signext, i1 zeroext, i1 zeroext) + +declare void @callee_b0f(i8 %bp10, i8 %bp11, i8 %bp12, i8 %bp13, i8 %bp14, i8 %bp15, i8 %bp17, i8 %bp18, i8 %bp19) +define void @caller_b1f() { +entry: + ; CHECK-BE: strb w{{.*}}, [sp, #7] + call void @callee_b0f(i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 42) + ret void +} -- 2.34.1