Skip to content

Commit bdad919

Browse files
varungandhi-appleetcwilde
authored andcommitted
Update musttail verification to check all swiftasync->swiftasync tail calls.
When -enable-swifttailcc-musttail-check is passed (off by default), we will check that all swiftasync->swiftasync tail calls are marked musttail. Fixes rdar://75899279.
1 parent 422c1ec commit bdad919

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,7 +3430,24 @@ static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) {
34303430
return Copy;
34313431
}
34323432

3433+
static cl::opt<bool>
3434+
EnableSwiftTailCCMustTailCheck("enable-swifttailcc-musttail-check",
3435+
cl::init(false), cl::desc("Check that tail calls from swifttailcc functions to"
3436+
" swifttailcc functions are marked musttail."));
3437+
34333438
void Verifier::verifyMustTailCall(CallInst &CI) {
3439+
if (!CI.isMustTailCall()) {
3440+
if (EnableSwiftTailCCMustTailCheck &&
3441+
CI.getCallingConv() == CallingConv::SwiftTail &&
3442+
CI.getCaller()->getCallingConv() == CallingConv::SwiftTail &&
3443+
isa_and_nonnull<ReturnInst>(CI.getNextNode())) {
3444+
Assert(
3445+
false, "tail call from swifttail->swiftail should be marked musttail",
3446+
&CI);
3447+
}
3448+
return;
3449+
}
3450+
34343451
Assert(!CI.isInlineAsm(), "cannot use musttail call with inline asm", &CI);
34353452

34363453
Function *F = CI.getParent()->getParent();
@@ -3515,9 +3532,7 @@ void Verifier::verifyMustTailCall(CallInst &CI) {
35153532

35163533
void Verifier::visitCallInst(CallInst &CI) {
35173534
visitCallBase(CI);
3518-
3519-
if (CI.isMustTailCall())
3520-
verifyMustTailCall(CI);
3535+
verifyMustTailCall(CI);
35213536
}
35223537

35233538
void Verifier::visitInvokeInst(InvokeInst &II) {

0 commit comments

Comments
 (0)