llvm.org GIT mirror llvm / 55e9587
Fix eabi calling convention when a 64 bit value shadows r3. Without this what was happening was: * R3 is not marked as "used" * ARM backend thinks it has to save it to the stack because of vaarg * Offset computation correctly ignores it * Offsets are wrong git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110446 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 9 years ago
5 changed file(s) with 30 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
274274 return Result;
275275 }
276276
277 /// Version of AllocateStack with extra register to be shadowed.
278 unsigned AllocateStack(unsigned Size, unsigned Align, unsigned ShadowReg) {
279 MarkAllocated(ShadowReg);
280 return AllocateStack(Size, Align);
281 }
282
277283 // HandleByVal - Allocate a stack slot large enough to pass an argument by
278284 // value. The size and alignment information of the argument is encoded in its
279285 // parameter attribute.
8888 int Align = align;
8989 }
9090
91 /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a register
92 /// to be shadowed.
93 class CCAssignToStackWithShadow :
94 CCAssignToStack {
95 Register ShadowReg = reg;
96 }
97
9198 /// CCPassByVal - This action always matches: it assigns the value to a stack
9299 /// slot to implement ByVal aggregate parameter passing. Size and alignment
93100 /// specify the minimum size and alignment for the stack slot.
6767 "ArgFlags.getOrigAlign() != 8",
6868 CCAssignToReg<[R0, R1, R2, R3]>>>,
6969
70 CCIfType<[i32], CCIfAlign<"8", CCAssignToStack<4, 8>>>,
70 CCIfType<[i32], CCIfAlign<"8", CCAssignToStackWithShadow<4, 8, R3>>>,
7171 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
7272 CCIfType<[f64], CCAssignToStack<8, 8>>,
7373 CCIfType<[v2f64], CCAssignToStack<16, 8>>
2323 ret i32 %.0
2424 }
2525
26 ; test that on gnueabi a 64 bit value at this position will cause r3 to go
27 ; unused and the value stored in [sp]
28 ; ELF: f3:
29 ; ELF: ldr r0, [sp]
30 ; ELF-NEXT: mov pc, lr
31 ; DARWIN: f3:
32 ; DARWIN: mov r0, r3
33 ; DARWIN-NEXT: mov pc, lr
34 define i32 @f3(i32 %i, i32 %j, i32 %k, i64 %l, ...) {
35 entry:
36 %0 = trunc i64 %l to i32
37 ret i32 %0
38 }
39
2640 declare i32 @g1(i64)
2741
2842 declare i32 @g2(i32 %i, ...)
168168 else
169169 O << "\n" << IndentStr << " State.getTarget().getTargetData()"
170170 "->getABITypeAlignment(LocVT.getTypeForEVT(State.getContext()))";
171 if (Action->isSubClassOf("CCAssignToStackWithShadow"))
172 O << ", " << getQualifiedName(Action->getValueAsDef("ShadowReg"));
171173 O << ");\n" << IndentStr
172174 << "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
173175 << Counter << ", LocVT, LocInfo));\n";