summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-10-09 20:32:21 +0000
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-10-09 20:32:21 +0000
commit0b565373227ad4e873449e70dd836edd26330d07 (patch)
tree166818c82cbadba5e90b0bc88eed0dec7f090384
parentae6c7d2be3c39179a93f89df0c1e819a753b7d32 (diff)
downloadpackages-0b565373227ad4e873449e70dd836edd26330d07.tar.gz
packages-0b565373227ad4e873449e70dd836edd26330d07.tar.bz2
packages-0b565373227ad4e873449e70dd836edd26330d07.tar.xz
packages-0b565373227ad4e873449e70dd836edd26330d07.zip
user/llvm6: fix ppc32 calling conventions
-rw-r--r--user/llvm6/APKBUILD4
-rw-r--r--user/llvm6/ppc32-calling-convention.patch69
2 files changed, 72 insertions, 1 deletions
diff --git a/user/llvm6/APKBUILD b/user/llvm6/APKBUILD
index 4372ac72f..5f7b04fad 100644
--- a/user/llvm6/APKBUILD
+++ b/user/llvm6/APKBUILD
@@ -26,6 +26,7 @@ source="http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.xz
secure-plt.patch
more-secure-plt.patch
even-more-secure-plt.patch
+ ppc32-calling-convention.patch
"
builddir="$srcdir/$_pkgname-$pkgver.src"
@@ -250,4 +251,5 @@ caeec8e4dbd92f5f74940780b69075f3879a267a8623822cbdc193fd14706eb089071e3a5a20d60c
e5ddbc4b6c4928e79846dc3c022eb7928aaa8fed40515c78f5f03b8ab8264f34f1eb8aa8bfc0f436450932f4917e54ad261603032092ea271d9590f11a37cf1e musl-ppc64-elfv2.patch
35d289641fa4d200b5a3f62f1d51da600a734641356b0dc6c54a3080dd89aec3b031e36af8b53be49c35346c1cbcce00268de7ec9b4f552bfd7bf84d3504d1c4 secure-plt.patch
3d4a0a478bf800ea262c577451e22a1dbd5a4258226e49c66a697559263c8aa4fc0fff642a3c80ac3dfbb3efd6d9c0dbeb41dae1250fc7946de821cfef1ce1f0 more-secure-plt.patch
-deb71762721ebc73bfdf23143b582f40c70eddcef3e337ed14499e8e336bee2906292d38d64fe98fa633430c1bcb66cf6a2e067258c8fbe6e931f99f6d10a6f7 even-more-secure-plt.patch"
+deb71762721ebc73bfdf23143b582f40c70eddcef3e337ed14499e8e336bee2906292d38d64fe98fa633430c1bcb66cf6a2e067258c8fbe6e931f99f6d10a6f7 even-more-secure-plt.patch
+c3f596a1578a07ce0ee40c4e2576fe05ca6ca0c1b4f94b1f74c55cb09603afe7c846db9294fe28d83ca48633086bad422218e6d06e0d92173143fb298e06fb38 ppc32-calling-convention.patch"
diff --git a/user/llvm6/ppc32-calling-convention.patch b/user/llvm6/ppc32-calling-convention.patch
new file mode 100644
index 000000000..2e6d66427
--- /dev/null
+++ b/user/llvm6/ppc32-calling-convention.patch
@@ -0,0 +1,69 @@
+Index: trunk/lib/Target/PowerPC/PPCISelLowering.cpp
+===================================================================
+--- trunk/lib/Target/PowerPC/PPCISelLowering.cpp
++++ trunk/lib/Target/PowerPC/PPCISelLowering.cpp
+@@ -3511,9 +3511,14 @@
+ // Argument stored in memory.
+ assert(VA.isMemLoc());
+
++ // Get the extended size of the argument type in stack
+ unsigned ArgSize = VA.getLocVT().getStoreSize();
+- int FI = MFI.CreateFixedObject(ArgSize, VA.getLocMemOffset(),
+- isImmutable);
++ // Get the actual size of the argument type
++ unsigned ObjSize = VA.getValVT().getStoreSize();
++ unsigned ArgOffset = VA.getLocMemOffset();
++ // Stack objects in PPC32 are right justified.
++ ArgOffset += ArgSize - ObjSize;
++ int FI = MFI.CreateFixedObject(ArgSize, ArgOffset, isImmutable);
+
+ // Create load nodes to retrieve arguments from the stack.
+ SDValue FIN = DAG.getFrameIndex(FI, PtrVT);
+@@ -5468,10 +5473,15 @@
+ Arg = PtrOff;
+ }
+
+- if (VA.isRegLoc()) {
+- if (Arg.getValueType() == MVT::i1)
+- Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i32, Arg);
++ // When useCRBits() is true, there can be i1 arguments.
++ // It is because getRegisterType(MVT::i1) => MVT::i1,
++ // and for other integer types getRegisterType() => MVT::i32.
++ // Extend i1 and ensure callee will get i32.
++ if (Arg.getValueType() == MVT::i1)
++ Arg = DAG.getNode(Flags.isSExt() ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND,
++ dl, MVT::i32, Arg);
+
++ if (VA.isRegLoc()) {
+ seenFloatArg |= VA.getLocVT().isFloatingPoint();
+ // Put argument in a physical register.
+ RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
+Index: trunk/test/CodeGen/PowerPC/ppc32-i1-stack-arguments-abi-bug.ll
+===================================================================
+--- trunk/test/CodeGen/PowerPC/ppc32-i1-stack-arguments-abi-bug.ll
++++ trunk/test/CodeGen/PowerPC/ppc32-i1-stack-arguments-abi-bug.ll
+@@ -0,0 +1,24 @@
++; RUN: llc -verify-machineinstrs < %s -mcpu=ppc32 -mattr=+crbits | FileCheck %s
++target triple = "powerpc-unknown-linux-gnu"
++
++define void @check_callee(
++ i32, i32, i32, i32,
++ i32, i32, i32, i32,
++ i1 zeroext %s1
++) {
++ call void @check_caller(
++ i32 9, i32 9, i32 9, i32 9,
++ i32 9, i32 9, i32 9, i32 9,
++ i1 zeroext %s1)
++ ret void
++}
++
++; CHECK-LABEL: @check_callee
++; CHECK: lbz {{[0-9]+}}, 27(1)
++; CHECK: stw {{[0-9]+}}, 8(1)
++
++declare void @check_caller(
++ i32, i32, i32, i32,
++ i32, i32, i32, i32,
++ i1 zeroext
++)