Skip to content

Commit 23eeb5a

Browse files
committed
SwiftAsync: only change callee-saved registers for swifttailcc.
We had decided that any function taking a `swiftasync` parameter reduced the set of callee-saved registers because I thought at the time it was needed to adopt `swiftasync` before `swifttailcc`. This isn't so, it's just a slight optimization, and a confusing one at that. So remove that special case.
1 parent 7a994d5 commit 23eeb5a

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ AArch64RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
100100
MF->getFunction().getAttributes().hasAttrSomewhere(
101101
Attribute::SwiftError))
102102
return CSR_AArch64_AAPCS_SwiftError_SaveList;
103-
if (MF->getFunction().getAttributes().hasAttrSomewhere(
104-
Attribute::SwiftAsync) ||
105-
MF->getFunction().getCallingConv() == CallingConv::SwiftTail)
103+
if (MF->getFunction().getCallingConv() == CallingConv::SwiftTail)
106104
return CSR_AArch64_AAPCS_SwiftTail_SaveList;
107105
if (MF->getFunction().getCallingConv() == CallingConv::PreserveMost)
108106
return CSR_AArch64_RT_MostRegs_SaveList;
@@ -138,9 +136,7 @@ AArch64RegisterInfo::getDarwinCalleeSavedRegs(const MachineFunction *MF) const {
138136
MF->getFunction().getAttributes().hasAttrSomewhere(
139137
Attribute::SwiftError))
140138
return CSR_Darwin_AArch64_AAPCS_SwiftError_SaveList;
141-
if (MF->getFunction().getAttributes().hasAttrSomewhere(
142-
Attribute::SwiftAsync) ||
143-
MF->getFunction().getCallingConv() == CallingConv::SwiftTail)
139+
if (MF->getFunction().getCallingConv() == CallingConv::SwiftTail)
144140
return CSR_Darwin_AArch64_AAPCS_SwiftTail_SaveList;
145141
if (MF->getFunction().getCallingConv() == CallingConv::PreserveMost)
146142
return CSR_Darwin_AArch64_RT_MostRegs_SaveList;
@@ -207,9 +203,7 @@ AArch64RegisterInfo::getDarwinCallPreservedMask(const MachineFunction &MF,
207203
->supportSwiftError() &&
208204
MF.getFunction().getAttributes().hasAttrSomewhere(Attribute::SwiftError))
209205
return CSR_Darwin_AArch64_AAPCS_SwiftError_RegMask;
210-
if (MF.getFunction().getAttributes().hasAttrSomewhere(
211-
Attribute::SwiftAsync) ||
212-
CC == CallingConv::SwiftTail)
206+
if (CC == CallingConv::SwiftTail)
213207
return CSR_Darwin_AArch64_AAPCS_SwiftTail_RegMask;
214208
if (CC == CallingConv::PreserveMost)
215209
return CSR_Darwin_AArch64_RT_MostRegs_RegMask;
@@ -245,9 +239,7 @@ AArch64RegisterInfo::getCallPreservedMask(const MachineFunction &MF,
245239
MF.getFunction().getAttributes().hasAttrSomewhere(Attribute::SwiftError))
246240
return SCS ? CSR_AArch64_AAPCS_SwiftError_SCS_RegMask
247241
: CSR_AArch64_AAPCS_SwiftError_RegMask;
248-
if (MF.getFunction().getAttributes().hasAttrSomewhere(
249-
Attribute::SwiftAsync) ||
250-
CC == CallingConv::SwiftTail) {
242+
if (CC == CallingConv::SwiftTail) {
251243
if (SCS)
252244
report_fatal_error("ShadowCallStack attribute not supported with swifttail");
253245
return CSR_AArch64_AAPCS_SwiftTail_RegMask;

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,6 @@ X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
384384
return IsWin64 ? CSR_Win64_SwiftError_SaveList
385385
: CSR_64_SwiftError_SaveList;
386386

387-
if (F.getAttributes().hasAttrSomewhere(Attribute::SwiftAsync) ||
388-
F.getCallingConv() == CallingConv::SwiftTail)
389-
return IsWin64 ? CSR_Win64_SwiftTail_SaveList
390-
: CSR_64_SwiftTail_SaveList;
391-
392387
if (IsWin64)
393388
return HasSSE ? CSR_Win64_SaveList : CSR_Win64_NoSSE_SaveList;
394389
if (CallsEHReturn)
@@ -507,9 +502,6 @@ X86RegisterInfo::getCallPreservedMask(const MachineFunction &MF,
507502
if (IsSwiftCC)
508503
return IsWin64 ? CSR_Win64_SwiftError_RegMask : CSR_64_SwiftError_RegMask;
509504

510-
if (F.getAttributes().hasAttrSomewhere(Attribute::SwiftAsync))
511-
return IsWin64 ? CSR_Win64_SwiftTail_RegMask : CSR_64_SwiftTail_RegMask;
512-
513505
return IsWin64 ? CSR_Win64_RegMask : CSR_64_RegMask;
514506
}
515507

llvm/test/CodeGen/AArch64/swifttail-async.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define swifttailcc void @swifttail() {
1212

1313
define void @has_swiftasync(i8* swiftasync %in) {
1414
; CHECK-LABEL: has_swiftasync:
15-
; CHECK-NOT: ld{{.*}}x22
15+
; CHECK: ld{{.*}}x22
1616
call void asm "","~{x22}"()
1717
ret void
1818
}

llvm/test/CodeGen/X86/swifttail-async.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define swifttailcc void @swifttail() {
1212

1313
define void @has_swiftasync(i8* swiftasync %in) {
1414
; CHECK-LABEL: has_swiftasync:
15-
; CHECK-NOT: popq %r14
15+
; CHECK: popq %r14
1616
call void asm "","~{r14}"()
1717
ret void
1818
}

0 commit comments

Comments
 (0)