summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-03-06 00:45:19 +0000
committerHal Finkel <hfinkel@anl.gov>2014-03-06 00:45:19 +0000
commit341ea7ddf6b09d77bfe3c65664773b683386156c (patch)
tree94517657c2e78b71685c98b397443b7ea9f3e0a0
parent028462964bdbfc2ab332de73c5439d547e01776a (diff)
downloadllvm-341ea7ddf6b09d77bfe3c65664773b683386156c.tar.gz
llvm-341ea7ddf6b09d77bfe3c65664773b683386156c.tar.bz2
llvm-341ea7ddf6b09d77bfe3c65664773b683386156c.tar.xz
Fixup PPC Darwin i1 argument handling
Like on other targets, we need to zero_extend/truncate i1 args before copying them to GPRs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203045 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/PPCISelLowering.cpp7
-rw-r--r--test/CodeGen/PowerPC/ppc32-i1-vaarg.ll5
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
index dce6051b18..680112da9a 100644
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -2777,6 +2777,10 @@ PPCTargetLowering::LowerFormalArguments_Darwin(
if (GPR_idx != Num_GPR_Regs) {
unsigned VReg = MF.addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
ArgVal = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32);
+
+ if (ObjectVT == MVT::i1)
+ ArgVal = DAG.getNode(ISD::TRUNCATE, dl, MVT::i1, ArgVal);
+
++GPR_idx;
} else {
needsLoad = true;
@@ -4414,6 +4418,9 @@ PPCTargetLowering::LowerCall_Darwin(SDValue Chain, SDValue Callee,
case MVT::i32:
case MVT::i64:
if (GPR_idx != NumGPRs) {
+ if (Arg.getValueType() == MVT::i1)
+ Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, PtrVT, Arg);
+
RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg));
} else {
LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset,
diff --git a/test/CodeGen/PowerPC/ppc32-i1-vaarg.ll b/test/CodeGen/PowerPC/ppc32-i1-vaarg.ll
index 096ea384f0..6e0aec27b7 100644
--- a/test/CodeGen/PowerPC/ppc32-i1-vaarg.ll
+++ b/test/CodeGen/PowerPC/ppc32-i1-vaarg.ll
@@ -1,4 +1,5 @@
; RUN: llc < %s -march=ppc32 -mcpu=ppc32 | FileCheck %s
+; RUN: llc < %s -march=ppc32 -mcpu=ppc32 -mtriple=powerpc-darwin | FileCheck %s -check-prefix=CHECK-D
target triple = "powerpc-unknown-linux-gnu"
declare void @printf(i8*, ...)
@@ -13,3 +14,7 @@ define void @main() {
; CHECK-DAG: crxor 6, 6, 6
; CHECK: bl printf
+; CHECK-D-LABEL: @main
+; CHECK-D: li r4, 0
+; CHECK-D: bl L_printf$stub
+