[PATCH] D51108: [PowerPC] Fix wrong ABI for i1 stack arguments on PPC32
Lion Yang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 23 23:29:14 PDT 2018
LionNatsu updated this revision to Diff 162324.
LionNatsu retitled this revision from "[PowerPC] Fix wrong ABI for i1 stack arguments for PPC32" to "[PowerPC] Fix wrong ABI for i1 stack arguments on PPC32".
LionNatsu edited the summary of this revision.
LionNatsu added a comment.
Use SIGN_EXTEND in LowerCall_32SVR4 if explicitly specified, update summary.
Repository:
rL LLVM
https://reviews.llvm.org/D51108
Files:
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/ppc32-i1-stack-arguments-abi-bug.ll
Index: test/CodeGen/PowerPC/ppc32-i1-stack-arguments-abi-bug.ll
===================================================================
--- /dev/null
+++ 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 zeroext i1 @check_callee(
+ i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext,
+ i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext,
+ i1 zeroext %s1
+) {
+ call void @check_caller(
+ i1 zeroext true, i1 zeroext true, i1 zeroext true, i1 zeroext true,
+ i1 zeroext true, i1 zeroext true, i1 zeroext true, i1 zeroext true,
+ i1 zeroext %s1)
+ ret i1 true
+}
+
+; CHECK-LABEL: @check_callee
+; CHECK: lbz {{[0-9]+}}, 27(1)
+; CHECK: stw {{[0-9]+}}, 8(1)
+
+declare void @check_caller(
+ i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext,
+ i1 zeroext, i1 zeroext, i1 zeroext, i1 zeroext,
+ i1 zeroext
+)
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.cpp
+++ lib/Target/PowerPC/PPCISelLowering.cpp
@@ -3505,9 +3505,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);
@@ -5462,10 +5467,12 @@
Arg = PtrOff;
}
- if (VA.isRegLoc()) {
- if (Arg.getValueType() == MVT::i1)
- Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i32, Arg);
+ // Ensure callee will get either 0x00000001 or 0x00000000.
+ 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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51108.162324.patch
Type: text/x-patch
Size: 2553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180824/9e6ef39b/attachment.bin>
More information about the llvm-commits
mailing list