llvm.org GIT mirror llvm / 01b8fcc
ByVal arguments are passed on stack. Make sure to allocate a slot using size and alignment information on the parameter attribute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45897 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
1 changed file(s) with 20 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
114114 int Size = Action->getValueAsInt("Size");
115115 int Align = Action->getValueAsInt("Align");
116116
117 O << IndentStr << "unsigned Offset" << ++Counter
118 << " = State.AllocateStack(";
117 O << IndentStr << "unsigned Size = ";
119118 if (Size)
120 O << Size << ", ";
119 O << Size;
121120 else
122 O << "\n" << IndentStr << " State.getTarget().getTargetData()"
123 "->getABITypeSize(MVT::getTypeForValueType(LocVT)), ";
121 O << "State.getTarget().getTargetData()"
122 "->getABITypeSize(MVT::getTypeForValueType(LocVT))";
123 O << ";\n"
124 << IndentStr << "unsigned Align = ";
124125 if (Align)
125126 O << Align;
126127 else
127 O << "\n" << IndentStr << " State.getTarget().getTargetData()"
128 O << "State.getTarget().getTargetData()"
128129 "->getABITypeAlignment(MVT::getTypeForValueType(LocVT))";
129 O << ");\n" << IndentStr
130 O << ";\n";
131 O << IndentStr << "if (ArgFlags & ISD::ParamFlags::ByVal) {\n";
132 O << IndentStr << " " <<
133 "Size = (ArgFlags & ISD::ParamFlags::ByValSize) >> "
134 "ISD::ParamFlags::ByValSizeOffs;\n";
135 O << IndentStr << " " <<
136 "unsigned ParamAlign = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) "
137 ">> ISD::ParamFlags::ByValAlignOffs);\n";
138 O << IndentStr << " Align = std::max(Align, ParamAlign);\n"
139 << IndentStr << "}\n";
140 O << IndentStr << "unsigned Offset" << ++Counter
141 << " = State.AllocateStack(Size, Align);\n";
142 O << IndentStr
130143 << "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
131144 << Counter << ", LocVT, LocInfo));\n";
132145 O << IndentStr << "return false;\n";