[llvm-commits] [llvm] r166273 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h test/CodeGen/ARM/2012-10-18-PR14099-ByvalFrameAddress.ll
Stepan Dyatkovskiy
stpworld at narod.ru
Fri Oct 19 01:23:07 PDT 2012
Author: dyatkovskiy
Date: Fri Oct 19 03:23:06 2012
New Revision: 166273
URL: http://llvm.org/viewvc/llvm-project?rev=166273&view=rev
Log:
ARM:
Removed extra stack frame object for fixed byval arguments,
VarArgsStyleRegisters invocation was reworked due to some improper usage in
past. PR14099 also demonstrates it.
Added:
llvm/trunk/test/CodeGen/ARM/2012-10-18-PR14099-ByvalFrameAddress.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Target/ARM/ARMISelLowering.h
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=166273&r1=166272&r2=166273&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Oct 19 03:23:06 2012
@@ -2554,7 +2554,8 @@
DebugLoc dl, SDValue &Chain,
const Value *OrigArg,
unsigned OffsetFromOrigArg,
- unsigned ArgOffset) const {
+ unsigned ArgOffset,
+ bool ForceMutable) const {
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo();
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
@@ -2603,7 +2604,8 @@
&MemOps[0], MemOps.size());
} else
// This will point to the next argument passed via stack.
- AFI->setVarArgsFrameIndex(MFI->CreateFixedObject(4, ArgOffset, true));
+ AFI->setVarArgsFrameIndex(
+ MFI->CreateFixedObject(4, ArgOffset, !ForceMutable));
}
SDValue
@@ -2729,15 +2731,20 @@
// Since they could be overwritten by lowering of arguments in case of
// a tail call.
if (Flags.isByVal()) {
- unsigned VARegSize, VARegSaveSize;
- computeRegArea(CCInfo, MF, VARegSize, VARegSaveSize);
- VarArgStyleRegisters(CCInfo, DAG,
- dl, Chain, CurOrigArg, Ins[VA.getValNo()].PartOffset, 0);
- unsigned Bytes = Flags.getByValSize() - VARegSize;
- if (Bytes == 0) Bytes = 1; // Don't create zero-sized stack objects.
- int FI = MFI->CreateFixedObject(Bytes,
- VA.getLocMemOffset(), false);
- InVals.push_back(DAG.getFrameIndex(FI, getPointerTy()));
+ ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
+ if (!AFI->getVarArgsFrameIndex()) {
+ VarArgStyleRegisters(CCInfo, DAG,
+ dl, Chain, CurOrigArg,
+ Ins[VA.getValNo()].PartOffset,
+ VA.getLocMemOffset(),
+ true /*force mutable frames*/);
+ int VAFrameIndex = AFI->getVarArgsFrameIndex();
+ InVals.push_back(DAG.getFrameIndex(VAFrameIndex, getPointerTy()));
+ } else {
+ int FI = MFI->CreateFixedObject(Flags.getByValSize(),
+ VA.getLocMemOffset(), false);
+ InVals.push_back(DAG.getFrameIndex(FI, getPointerTy()));
+ }
} else {
int FI = MFI->CreateFixedObject(VA.getLocVT().getSizeInBits()/8,
VA.getLocMemOffset(), true);
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=166273&r1=166272&r2=166273&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Fri Oct 19 03:23:06 2012
@@ -469,7 +469,8 @@
DebugLoc dl, SDValue &Chain,
const Value *OrigArg,
unsigned OffsetFromOrigArg,
- unsigned ArgOffset)
+ unsigned ArgOffset,
+ bool ForceMutable = false)
const;
void computeRegArea(CCState &CCInfo, MachineFunction &MF,
Added: llvm/trunk/test/CodeGen/ARM/2012-10-18-PR14099-ByvalFrameAddress.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2012-10-18-PR14099-ByvalFrameAddress.ll?rev=166273&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/2012-10-18-PR14099-ByvalFrameAddress.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/2012-10-18-PR14099-ByvalFrameAddress.ll Fri Oct 19 03:23:06 2012
@@ -0,0 +1,29 @@
+; RUN: llc < %s -mtriple=armv7-linux-gnueabi | FileCheck %s
+
+%struct.s = type { [4 x i32] }
+ at v = constant %struct.s zeroinitializer;
+
+declare void @f(%struct.s* %p);
+
+; CHECK: t:
+define void @t(i32 %a, %struct.s* byval %s) nounwind {
+entry:
+
+; Here we need to only check proper start address of restored %s argument.
+; CHECK: sub sp, sp, #16
+; CHECK: push {r11, lr}
+; CHECK: add r0, sp, #12
+; CHECK: stm r0, {r1, r2, r3}
+; CHECK: add r0, sp, #12
+; CHECK-NEXT: bl f
+ call void @f(%struct.s* %s)
+ ret void
+}
+
+; CHECK: caller:
+define void @caller() {
+
+; CHECK: ldm r0, {r1, r2, r3}
+ call void @t(i32 0, %struct.s* @v);
+ ret void
+}
More information about the llvm-commits
mailing list