XCore target: fix bug in aligning 'byval i8*' on the stack
authorRobert Lytton <robert@xmos.com>
Tue, 12 Nov 2013 10:11:35 +0000 (10:11 +0000)
committerRobert Lytton <robert@xmos.com>
Tue, 12 Nov 2013 10:11:35 +0000 (10:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194466 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/XCore/XCoreISelLowering.cpp
test/CodeGen/XCore/byVal.ll

index 149652ff73385f23f24ffc04e626289c0358a916..a382a189cf3cb4a5c96f31daf9abe991b560bec6 100644 (file)
@@ -1224,7 +1224,7 @@ XCoreTargetLowering::LowerCCCArguments(SDValue Chain,
        ArgDI != ArgDE; ++ArgDI) {
     if (ArgDI->Flags.isByVal() && ArgDI->Flags.getByValSize()) {
       unsigned Size = ArgDI->Flags.getByValSize();
-      unsigned Align = ArgDI->Flags.getByValAlign();
+      unsigned Align = std::max(StackSlotSize, ArgDI->Flags.getByValAlign());
       // Create a new object on the stack and copy the pointee into it.
       int FI = MFI->CreateStackObject(Size, Align, false, false);
       SDValue FIN = DAG.getFrameIndex(FI, MVT::i32);
index a5d25d2d95b79c540802ed6e16a4813e26012866..e9612fd6021abb53dc559eac16bb52429818b22f 100644 (file)
@@ -56,3 +56,18 @@ entry:
   call void @f2(i32 %i, %struct.st2* %s2)
   ret void
 }
+
+; CHECK-LABEL: f3Test
+; CHECK: entsp 2
+; CHECK: ldc r1, 0
+; CHECK: ld8u r2, r0[r1]
+; CHECK: ldaw r0, sp[1]
+; CHECK: st8 r2, r0[r1]
+; CHECK: bl f
+; CHECK: retsp 2
+declare void @f3(i8*) nounwind
+define void @f3Test(i8* byval %v) nounwind {
+entry:
+  call void @f3(i8* %v) nounwind
+  ret void
+}