llvm.org GIT mirror llvm / dbca326
Merging r294527: ------------------------------------------------------------------------ r294527 | arnolds | 2017-02-08 14:30:47 -0800 (Wed, 08 Feb 2017) | 14 lines [ARM/AArch ISel] SwiftCC: First parameters that are marked swiftself are not 'this returns' We mark X0 as preserved by a call that passes the returned parameter. x0 = ... fun(x0) // no implicit def of x0 This no longer is valid if we pass the parameter in a different register then the returned value as is the case with a swiftself parameter (passed in x20). x20 = ... fun(x20) // there should be an implict def of x8 rdar://30425845 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@295135 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
4 changed file(s) with 39 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
31543154 }
31553155
31563156 if (VA.isRegLoc()) {
3157 if (realArgIdx == 0 && Flags.isReturned() && Outs[0].VT == MVT::i64) {
3157 if (realArgIdx == 0 && Flags.isReturned() && !Flags.isSwiftSelf() &&
3158 Outs[0].VT == MVT::i64) {
31583159 assert(VA.getLocVT() == MVT::i64 &&
31593160 "unexpected calling convention register assignment");
31603161 assert(!Ins.empty() && Ins[0].VT == MVT::i64 &&
17861786 StackPtr, MemOpChains, Flags);
17871787 }
17881788 } else if (VA.isRegLoc()) {
1789 if (realArgIdx == 0 && Flags.isReturned() && Outs[0].VT == MVT::i32) {
1789 if (realArgIdx == 0 && Flags.isReturned() && !Flags.isSwiftSelf() &&
1790 Outs[0].VT == MVT::i32) {
17901791 assert(VA.getLocVT() == MVT::i32 &&
17911792 "unexpected calling convention register assignment");
17921793 assert(!Ins.empty() && Ins[0].VT == MVT::i32 &&
6464 %res = tail call i8* @swiftself_param(i8* swiftself %addr1)
6565 ret i8* %res
6666 }
67
68 ; We cannot pretend that 'x0' is alive across the thisreturn_attribute call as
69 ; we normally would. We marked the first parameter with swiftself which means it
70 ; will no longer be passed in x0.
71 declare swiftcc i8* @thisreturn_attribute(i8* returned swiftself)
72 ; OPT-LABEL: swiftself_nothisreturn:
73 ; OPT-DAG: ldr x20, [x20]
74 ; OPT-DAG: mov [[CSREG:x[1-9].*]], x8
75 ; OPT: bl {{_?}}thisreturn_attribute
76 ; OPT: str x0, {{\[}}[[CSREG]]
77 ; OPT: ret
78 define hidden swiftcc void @swiftself_nothisreturn(i8** noalias nocapture sret, i8** noalias nocapture readonly swiftself) {
79 entry:
80 %2 = load i8*, i8** %1, align 8
81 %3 = tail call swiftcc i8* @thisreturn_attribute(i8* swiftself %2)
82 store i8* %3, i8** %0, align 8
83 ret void
84 }
6262 %res = tail call i8* @swiftself_param(i8* swiftself %addr1)
6363 ret i8* %res
6464 }
65
66 ; We cannot pretend that 'r0' is alive across the thisreturn_attribute call as
67 ; we normally would. We marked the first parameter with swiftself which means it
68 ; will no longer be passed in r0.
69 declare swiftcc i8* @thisreturn_attribute(i8* returned swiftself)
70 ; OPT-LABEL: swiftself_nothisreturn:
71 ; OPT-DAG: mov [[CSREG:r[1-9].*]], r0
72 ; OPT-DAG: ldr r10, [r10]
73 ; OPT: bl {{_?}}thisreturn_attribute
74 ; OPT: str r0, {{\[}}[[CSREG]]
75 define hidden swiftcc void @swiftself_nothisreturn(i8** noalias nocapture sret, i8** noalias nocapture readonly swiftself) {
76 entry:
77 %2 = load i8*, i8** %1, align 8
78 %3 = tail call swiftcc i8* @thisreturn_attribute(i8* swiftself %2)
79 store i8* %3, i8** %0, align 8
80 ret void
81 }