Skip to content

Commit ea0eec6

Browse files
committed
IR+AArch64: add a "swiftasync" argument attribute.
This extends any frame record created in the function to include that parameter, passed in X22. The new record looks like [X22, FP, LR] in memory, and FP is stored with 0b0001 in bits 63:60 (CodeGen assumes they are 0b0000 in normal operation). The effect of this is that tools walking the stack should expect to see one of three values there: * 0b0000 => a normal, non-extended record with just [FP, LR] * 0b0001 => the extended record [X22, FP, LR] * 0b1111 => kernel space, and a non-extended record. All other values are currently reserved. If compiling for arm64e this context pointer is address-discriminated with the discriminator 0xc31a and the DB (process-specific) key. There is also an "i8** @llvm.swift.async.context.addr()" intrinsic providing front-ends access to this slot (and forcing its creation initialized to nullptr if necessary).
1 parent 079bbea commit ea0eec6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+575
-30
lines changed

llvm/docs/LangRef.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,12 @@ Currently, only the following parameter attributes are defined:
12781278
a valid attribute for return values and can only be applied to one
12791279
parameter.
12801280

1281+
``swiftasync``
1282+
This indicates that the parameter is the asynchronous context parameter and
1283+
triggers the creation of a target-specific extended frame record to store
1284+
this pointer. This is not a valid attribute for return values and can only
1285+
be applied to one parameter.
1286+
12811287
``swifterror``
12821288
This attribute is motivated to model and optimize Swift error handling. It
12831289
can be applied to a parameter with pointer to pointer type or a
@@ -12360,6 +12366,29 @@ Note that calling this intrinsic does not prevent function inlining or
1236012366
other aggressive transformations, so the value returned may not be that
1236112367
of the obvious source-language caller.
1236212368

12369+
'``llvm.swift.async.context.addr``' Intrinsic
12370+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12371+
12372+
Syntax:
12373+
"""""""
12374+
12375+
::
12376+
12377+
declare i8** @llvm.swift.async.context.addr()
12378+
12379+
Overview:
12380+
"""""""""
12381+
12382+
The '``llvm.swift.async.context.addr``' intrinsic returns a pointer to
12383+
the part of the extended frame record containing the asynchronous
12384+
context of a Swift execution.
12385+
12386+
Semantics:
12387+
""""""""""
12388+
12389+
If the function has a ``swiftasync`` parameter, that argument will initially
12390+
be stored at the returned address. If not, it will be initialized to null.
12391+
1236312392
'``llvm.localescape``' and '``llvm.localrecover``' Intrinsics
1236412393
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1236512394

llvm/include/llvm/AsmParser/LLToken.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ enum Kind {
239239
kw_strictfp,
240240
kw_swifterror,
241241
kw_swiftself,
242+
kw_swiftasync,
242243
kw_uwtable,
243244
kw_vscale_range,
244245
kw_willreturn,

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ enum AttributeKindCodes {
665665
ATTR_KIND_HOT = 72,
666666
ATTR_KIND_NO_PROFILE = 73,
667667
ATTR_KIND_VSCALE_RANGE = 74,
668+
ATTR_KIND_SWIFT_ASYNC = 75,
668669
};
669670

670671
enum ComdatSelectionKindCodes {

llvm/include/llvm/CodeGen/TargetCallingConv.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace ISD {
3939
unsigned IsPreallocated : 1; ///< ByVal without the copy
4040
unsigned IsSplitEnd : 1; ///< Last part of a split
4141
unsigned IsSwiftSelf : 1; ///< Swift self parameter
42+
unsigned IsSwiftAsync : 1; ///< Swift async context parameter
4243
unsigned IsSwiftError : 1; ///< Swift error parameter
4344
unsigned IsCFGuardTarget : 1; ///< Control Flow Guard target
4445
unsigned IsHva : 1; ///< HVA field for
@@ -58,11 +59,12 @@ namespace ISD {
5859

5960
public:
6061
ArgFlagsTy()
61-
: IsZExt(0), IsSExt(0), IsInReg(0), IsSRet(0), IsByVal(0), IsByRef(0),
62-
IsNest(0), IsReturned(0), IsSplit(0), IsInAlloca(0), IsPreallocated(0),
63-
IsSplitEnd(0), IsSwiftSelf(0), IsSwiftError(0), IsCFGuardTarget(0),
64-
IsHva(0), IsHvaStart(0), IsSecArgPass(0), MemAlign(0),
65-
OrigAlign(0), IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
62+
: IsZExt(0), IsSExt(0), IsInReg(0), IsSRet(0), IsByVal(0), IsByRef(0),
63+
IsNest(0), IsReturned(0), IsSplit(0), IsInAlloca(0),
64+
IsPreallocated(0), IsSplitEnd(0), IsSwiftSelf(0), IsSwiftAsync(0),
65+
IsSwiftError(0), IsCFGuardTarget(0), IsHva(0), IsHvaStart(0),
66+
IsSecArgPass(0), MemAlign(0), OrigAlign(0),
67+
IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
6668
IsCopyElisionCandidate(0), IsPointer(0), ByValOrByRefSize(0),
6769
PointerAddrSpace(0) {
6870
static_assert(sizeof(*this) == 3 * sizeof(unsigned), "flags are too big");
@@ -95,6 +97,9 @@ namespace ISD {
9597
bool isSwiftSelf() const { return IsSwiftSelf; }
9698
void setSwiftSelf() { IsSwiftSelf = 1; }
9799

100+
bool isSwiftAsync() const { return IsSwiftAsync; }
101+
void setSwiftAsync() { IsSwiftAsync = 1; }
102+
98103
bool isSwiftError() const { return IsSwiftError; }
99104
void setSwiftError() { IsSwiftError = 1; }
100105

llvm/include/llvm/CodeGen/TargetFrameLowering.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ class TargetFrameLowering {
149149
/// returns false, spill slots will be assigned using generic implementation.
150150
/// assignCalleeSavedSpillSlots() may add, delete or rearrange elements of
151151
/// CSI.
152+
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF,
153+
const TargetRegisterInfo *TRI,
154+
std::vector<CalleeSavedInfo> &CSI,
155+
unsigned &MinCSFrameIndex,
156+
unsigned &MaxCSFrameIndex) const {
157+
return assignCalleeSavedSpillSlots(MF, TRI, CSI);
158+
}
159+
152160
virtual bool
153161
assignCalleeSavedSpillSlots(MachineFunction &MF,
154162
const TargetRegisterInfo *TRI,

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ class TargetLoweringBase {
284284
bool IsPreallocated : 1;
285285
bool IsReturned : 1;
286286
bool IsSwiftSelf : 1;
287+
bool IsSwiftAsync : 1;
287288
bool IsSwiftError : 1;
288289
bool IsCFGuardTarget : 1;
289290
MaybeAlign Alignment = None;
@@ -294,7 +295,7 @@ class TargetLoweringBase {
294295
: IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
295296
IsNest(false), IsByVal(false), IsByRef(false), IsInAlloca(false),
296297
IsPreallocated(false), IsReturned(false), IsSwiftSelf(false),
297-
IsSwiftError(false), IsCFGuardTarget(false) {}
298+
IsSwiftAsync(false), IsSwiftError(false), IsCFGuardTarget(false) {}
298299

299300
void setAttributes(const CallBase *Call, unsigned ArgIdx);
300301
};

llvm/include/llvm/IR/Attributes.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ def SwiftError : EnumAttr<"swifterror">;
244244
/// Argument is swift self/context.
245245
def SwiftSelf : EnumAttr<"swiftself">;
246246

247+
/// Argument is swift async context.
248+
def SwiftAsync : EnumAttr<"swiftasync">;
249+
247250
/// Function must be in a unwind table.
248251
def UWTable : EnumAttr<"uwtable">;
249252

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,12 @@ def int_objc_arc_annotation_bottomup_bbstart : Intrinsic<[],
479479
def int_objc_arc_annotation_bottomup_bbend : Intrinsic<[],
480480
[llvm_ptrptr_ty,
481481
llvm_ptrptr_ty]>;
482+
//===--------------- Swift asynchronous context intrinsics ----------------===//
482483

484+
// Returns the location of the Swift asynchronous context (usually stored just
485+
// before the frame pointer), and triggers the creation of a null context if it
486+
// would otherwise be unneeded.
487+
def int_swift_async_context_addr : Intrinsic<[llvm_ptrptr_ty], [], [IntrNoMem]>;
483488

484489
//===--------------------- Code Generator Intrinsics ----------------------===//
485490
//

llvm/include/llvm/Target/TargetCallingConv.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class CCIfPreallocated<CCAction A> : CCIf<"ArgFlags.isPreallocated()", A> {
5151
class CCIfSwiftSelf<CCAction A> : CCIf<"ArgFlags.isSwiftSelf()", A> {
5252
}
5353

54+
/// CCIfSwiftAsync - If the current argument has swiftasync parameter attribute,
55+
/// apply Action A.
56+
class CCIfSwiftAsync<CCAction A> : CCIf<"ArgFlags.isSwiftAsync()", A> {
57+
}
58+
5459
/// CCIfSwiftError - If the current argument has swifterror parameter attribute,
5560
/// apply Action A.
5661
class CCIfSwiftError<CCAction A> : CCIf<"ArgFlags.isSwiftError()", A> {

llvm/lib/AsmParser/LLLexer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ lltok::Kind LLLexer::LexIdentifier() {
696696
KEYWORD(speculative_load_hardening);
697697
KEYWORD(swifterror);
698698
KEYWORD(swiftself);
699+
KEYWORD(swiftasync);
699700
KEYWORD(uwtable);
700701
KEYWORD(vscale_range);
701702
KEYWORD(willreturn);

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,7 @@ bool LLParser::parseFnAttributeValuePairs(AttrBuilder &B,
14601460
case lltok::kw_sret:
14611461
case lltok::kw_swifterror:
14621462
case lltok::kw_swiftself:
1463+
case lltok::kw_swiftasync:
14631464
case lltok::kw_immarg:
14641465
case lltok::kw_byref:
14651466
HaveError |=
@@ -1799,6 +1800,7 @@ bool LLParser::parseOptionalParamAttrs(AttrBuilder &B) {
17991800
case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
18001801
case lltok::kw_swifterror: B.addAttribute(Attribute::SwiftError); break;
18011802
case lltok::kw_swiftself: B.addAttribute(Attribute::SwiftSelf); break;
1803+
case lltok::kw_swiftasync: B.addAttribute(Attribute::SwiftAsync); break;
18021804
case lltok::kw_writeonly: B.addAttribute(Attribute::WriteOnly); break;
18031805
case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
18041806
case lltok::kw_immarg: B.addAttribute(Attribute::ImmArg); break;
@@ -1905,6 +1907,7 @@ bool LLParser::parseOptionalReturnAttrs(AttrBuilder &B) {
19051907
case lltok::kw_sret:
19061908
case lltok::kw_swifterror:
19071909
case lltok::kw_swiftself:
1910+
case lltok::kw_swiftasync:
19081911
case lltok::kw_immarg:
19091912
case lltok::kw_byref:
19101913
HaveError |=

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
15241524
return Attribute::SwiftError;
15251525
case bitc::ATTR_KIND_SWIFT_SELF:
15261526
return Attribute::SwiftSelf;
1527+
case bitc::ATTR_KIND_SWIFT_ASYNC:
1528+
return Attribute::SwiftAsync;
15271529
case bitc::ATTR_KIND_UW_TABLE:
15281530
return Attribute::UWTable;
15291531
case bitc::ATTR_KIND_VSCALE_RANGE:

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
736736
return bitc::ATTR_KIND_SWIFT_ERROR;
737737
case Attribute::SwiftSelf:
738738
return bitc::ATTR_KIND_SWIFT_SELF;
739+
case Attribute::SwiftAsync:
740+
return bitc::ATTR_KIND_SWIFT_ASYNC;
739741
case Attribute::UWTable:
740742
return bitc::ATTR_KIND_UW_TABLE;
741743
case Attribute::VScaleRange:

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ addFlagsUsingAttrFn(ISD::ArgFlagsTy &Flags,
5454
Flags.setReturned();
5555
if (AttrFn(Attribute::SwiftSelf))
5656
Flags.setSwiftSelf();
57+
if (AttrFn(Attribute::SwiftAsync))
58+
Flags.setSwiftAsync();
5759
if (AttrFn(Attribute::SwiftError))
5860
Flags.setSwiftError();
5961
}

llvm/lib/CodeGen/PrologEpilogInserter.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ static void assignCalleeSavedSpillSlots(MachineFunction &F,
399399

400400
const TargetFrameLowering *TFI = F.getSubtarget().getFrameLowering();
401401
MachineFrameInfo &MFI = F.getFrameInfo();
402-
if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI)) {
402+
if (!TFI->assignCalleeSavedSpillSlots(F, RegInfo, CSI, MinCSFrameIndex,
403+
MaxCSFrameIndex)) {
403404
// If target doesn't implement this, use generic code.
404405

405406
if (CSI.empty())
@@ -677,10 +678,12 @@ computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown,
677678
// StackSlot scavenging is only implemented for the default stack.
678679
if (MFI.getStackID(i) == TargetStackID::Default)
679680
AllocatedFrameSlots.push_back(i);
680-
// Add callee-save objects.
681-
for (int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
682-
if (MFI.getStackID(i) == TargetStackID::Default)
683-
AllocatedFrameSlots.push_back(i);
681+
// Add callee-save objects if there are any.
682+
if (MinCSFrameIndex <= MaxCSFrameIndex) {
683+
for (int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
684+
if (MFI.getStackID(i) == TargetStackID::Default)
685+
AllocatedFrameSlots.push_back(i);
686+
}
684687

685688
for (int i : AllocatedFrameSlots) {
686689
// These are converted from int64_t, but they should always fit in int
@@ -833,7 +836,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) {
833836

834837
// First assign frame offsets to stack objects that are used to spill
835838
// callee saved registers.
836-
if (StackGrowsDown) {
839+
if (StackGrowsDown && MaxCSFrameIndex >= MinCSFrameIndex) {
837840
for (unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
838841
if (MFI.getStackID(i) !=
839842
TargetStackID::Default) // Only allocate objects on the default stack.

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,8 @@ bool FastISel::lowerCallTo(CallLoweringInfo &CLI) {
10481048
Flags.setSRet();
10491049
if (Arg.IsSwiftSelf)
10501050
Flags.setSwiftSelf();
1051+
if (Arg.IsSwiftAsync)
1052+
Flags.setSwiftAsync();
10511053
if (Arg.IsSwiftError)
10521054
Flags.setSwiftError();
10531055
if (Arg.IsCFGuardTarget)

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9385,6 +9385,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
93859385
Entry.IsByRef = false;
93869386
Entry.IsReturned = false;
93879387
Entry.IsSwiftSelf = false;
9388+
Entry.IsSwiftAsync = false;
93889389
Entry.IsSwiftError = false;
93899390
Entry.IsCFGuardTarget = false;
93909391
Entry.Alignment = Alignment;
@@ -9498,6 +9499,8 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
94989499
Flags.setSRet();
94999500
if (Args[i].IsSwiftSelf)
95009501
Flags.setSwiftSelf();
9502+
if (Args[i].IsSwiftAsync)
9503+
Flags.setSwiftAsync();
95019504
if (Args[i].IsSwiftError)
95029505
Flags.setSwiftError();
95039506
if (Args[i].IsCFGuardTarget)
@@ -10035,6 +10038,8 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
1003510038
Flags.setSRet();
1003610039
if (Arg.hasAttribute(Attribute::SwiftSelf))
1003710040
Flags.setSwiftSelf();
10041+
if (Arg.hasAttribute(Attribute::SwiftAsync))
10042+
Flags.setSwiftAsync();
1003810043
if (Arg.hasAttribute(Attribute::SwiftError))
1003910044
Flags.setSwiftError();
1004010045
if (Arg.hasAttribute(Attribute::ByVal))

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void TargetLoweringBase::ArgListEntry::setAttributes(const CallBase *Call,
115115
IsNest = Attrs.hasParamAttribute(ArgIdx, Attribute::Nest);
116116
IsReturned = Attrs.hasParamAttribute(ArgIdx, Attribute::Returned);
117117
IsSwiftSelf = Attrs.hasParamAttribute(ArgIdx, Attribute::SwiftSelf);
118+
IsSwiftAsync = Attrs.hasParamAttr(ArgIdx, Attribute::SwiftAsync);
118119
IsSwiftError = Attrs.hasParamAttribute(ArgIdx, Attribute::SwiftError);
119120
Alignment = Attrs.getParamStackAlignment(ArgIdx);
120121

llvm/lib/IR/Attributes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
384384
return "swifterror";
385385
if (hasAttribute(Attribute::SwiftSelf))
386386
return "swiftself";
387+
if (hasAttribute(Attribute::SwiftAsync))
388+
return "swiftasync";
387389
if (hasAttribute(Attribute::InaccessibleMemOnly))
388390
return "inaccessiblememonly";
389391
if (hasAttribute(Attribute::InaccessibleMemOrArgMemOnly))

llvm/lib/IR/Verifier.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,7 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
19101910
bool SawReturned = false;
19111911
bool SawSRet = false;
19121912
bool SawSwiftSelf = false;
1913+
bool SawSwiftAsync = false;
19131914
bool SawSwiftError = false;
19141915

19151916
// Verify return value attributes.
@@ -1924,11 +1925,12 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
19241925
!RetAttrs.hasAttribute(Attribute::Preallocated) &&
19251926
!RetAttrs.hasAttribute(Attribute::ByRef) &&
19261927
!RetAttrs.hasAttribute(Attribute::SwiftSelf) &&
1928+
!RetAttrs.hasAttribute(Attribute::SwiftAsync) &&
19271929
!RetAttrs.hasAttribute(Attribute::SwiftError)),
19281930
"Attributes 'byval', 'inalloca', 'preallocated', 'byref', "
19291931
"'nest', 'sret', 'nocapture', 'nofree', "
1930-
"'returned', 'swiftself', and 'swifterror' do not apply to return "
1931-
"values!",
1932+
"'returned', 'swiftself', 'swiftasync', and 'swifterror'"
1933+
" do not apply to return values!",
19321934
V);
19331935
Assert((!RetAttrs.hasAttribute(Attribute::ReadOnly) &&
19341936
!RetAttrs.hasAttribute(Attribute::WriteOnly) &&
@@ -1976,6 +1978,11 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
19761978
SawSwiftSelf = true;
19771979
}
19781980

1981+
if (ArgAttrs.hasAttribute(Attribute::SwiftAsync)) {
1982+
Assert(!SawSwiftAsync, "Cannot have multiple 'swiftasync' parameters!", V);
1983+
SawSwiftAsync = true;
1984+
}
1985+
19791986
if (ArgAttrs.hasAttribute(Attribute::SwiftError)) {
19801987
Assert(!SawSwiftError, "Cannot have multiple 'swifterror' parameters!",
19811988
V);
@@ -3370,9 +3377,10 @@ static bool isTypeCongruent(Type *L, Type *R) {
33703377

33713378
static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) {
33723379
static const Attribute::AttrKind ABIAttrs[] = {
3373-
Attribute::StructRet, Attribute::ByVal, Attribute::InAlloca,
3374-
Attribute::InReg, Attribute::SwiftSelf, Attribute::SwiftError,
3375-
Attribute::Preallocated, Attribute::ByRef, Attribute::StackAlignment};
3380+
Attribute::StructRet, Attribute::ByVal, Attribute::InAlloca,
3381+
Attribute::InReg, Attribute::SwiftSelf, Attribute::SwiftAsync,
3382+
Attribute::SwiftError, Attribute::SwiftAsync, Attribute::Preallocated,
3383+
Attribute::ByRef};
33763384
AttrBuilder Copy;
33773385
for (auto AK : ABIAttrs) {
33783386
if (Attrs.hasParamAttribute(I, AK))

llvm/lib/Target/AArch64/AArch64CallingConvention.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def CC_AArch64_AAPCS : CallingConv<[
6969
// A SwiftError is passed in X21.
7070
CCIfSwiftError<CCIfType<[i64], CCAssignToRegWithShadow<[X21], [W21]>>>,
7171

72+
// Pass SwiftAsync in an otherwise callee saved register so that it will be
73+
// preserved for normal function calls.
74+
CCIfSwiftAsync<CCIfType<[i64], CCAssignToRegWithShadow<[X22], [W22]>>>,
75+
7276
CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Block">>,
7377

7478
CCIfType<[nxv16i8, nxv8i16, nxv4i32, nxv2i64, nxv2f16, nxv4f16, nxv8f16,
@@ -203,6 +207,10 @@ def CC_AArch64_DarwinPCS : CallingConv<[
203207
// A SwiftError is passed in X21.
204208
CCIfSwiftError<CCIfType<[i64], CCAssignToRegWithShadow<[X21], [W21]>>>,
205209

210+
// Pass SwiftAsync in an otherwise callee saved register so that it will be
211+
// preserved for normal function calls.
212+
CCIfSwiftAsync<CCIfType<[i64], CCAssignToRegWithShadow<[X22], [W22]>>>,
213+
206214
CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Block">>,
207215

208216
// Handle i1, i8, i16, i32, i64, f32, f64 and v2f64 by passing in registers,

0 commit comments

Comments
 (0)