mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: Preliminary support for 'apply [noasync]' calls
Refactor SILGen's ApplyOptions into an OptionSet, add a DoesNotAwait flag to go with DoesNotThrow, and sink it all down into SILInstruction.h. Then, replace the isNonThrowing() flag in ApplyInst and BeginApplyInst with getApplyOptions(), and plumb it through to TryApplyInst as well. Set the flag when SILGen emits a sync call to a reasync function. When set, this disables the SIL verifier check against calling async functions from sync functions. Finally, this allows us to add end-to-end tests for rdar://problem/71098795.
This commit is contained in:
@@ -1084,11 +1084,12 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
|
||||
Builder.setCurrentDebugScope(Fn->getDebugScope());
|
||||
unsigned RawOpCode = 0, TyCategory = 0, TyCategory2 = 0, TyCategory3 = 0,
|
||||
Attr = 0, Attr2 = 0, Attr3 = 0, Attr4 = 0, NumSubs = 0,
|
||||
NumConformances = 0, IsNonThrowingApply = 0;
|
||||
NumConformances = 0;
|
||||
ValueID ValID, ValID2, ValID3;
|
||||
TypeID TyID, TyID2, TyID3;
|
||||
TypeID ConcreteTyID;
|
||||
SourceLoc SLoc;
|
||||
ApplyOptions ApplyOpts;
|
||||
ArrayRef<uint64_t> ListOfValues;
|
||||
SILLocation Loc = RegularLocation(SLoc);
|
||||
|
||||
@@ -1146,10 +1147,10 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
|
||||
TyID3);
|
||||
break;
|
||||
case SIL_INST_APPLY: {
|
||||
unsigned IsPartial;
|
||||
SILInstApplyLayout::readRecord(scratch, IsPartial, NumSubs, TyID, TyID2,
|
||||
unsigned Kind, RawApplyOpts;
|
||||
SILInstApplyLayout::readRecord(scratch, Kind, RawApplyOpts, NumSubs, TyID, TyID2,
|
||||
ValID, ListOfValues);
|
||||
switch (IsPartial) {
|
||||
switch (Kind) {
|
||||
case SIL_APPLY:
|
||||
RawOpCode = (unsigned)SILInstructionKind::ApplyInst;
|
||||
break;
|
||||
@@ -1162,21 +1163,15 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
|
||||
case SIL_TRY_APPLY:
|
||||
RawOpCode = (unsigned)SILInstructionKind::TryApplyInst;
|
||||
break;
|
||||
case SIL_NON_THROWING_APPLY:
|
||||
RawOpCode = (unsigned)SILInstructionKind::ApplyInst;
|
||||
IsNonThrowingApply = true;
|
||||
break;
|
||||
case SIL_BEGIN_APPLY:
|
||||
RawOpCode = (unsigned)SILInstructionKind::BeginApplyInst;
|
||||
break;
|
||||
case SIL_NON_THROWING_BEGIN_APPLY:
|
||||
RawOpCode = (unsigned)SILInstructionKind::BeginApplyInst;
|
||||
IsNonThrowingApply = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
llvm_unreachable("unexpected apply inst kind");
|
||||
}
|
||||
|
||||
ApplyOpts = ApplyOptions(ApplyFlags(RawApplyOpts));
|
||||
break;
|
||||
}
|
||||
case SIL_INST_NO_OPERAND:
|
||||
@@ -1522,11 +1517,10 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
|
||||
if (OpCode == SILInstructionKind::ApplyInst) {
|
||||
ResultInst =
|
||||
Builder.createApply(Loc, getLocalValue(ValID, FnTy), Substitutions,
|
||||
Args, IsNonThrowingApply != 0);
|
||||
Args, ApplyOpts);
|
||||
} else {
|
||||
ResultInst = Builder.createBeginApply(Loc, getLocalValue(ValID, FnTy),
|
||||
Substitutions, Args,
|
||||
IsNonThrowingApply != 0);
|
||||
Substitutions, Args, ApplyOpts);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user