Skip to content

Commit f652e1b

Browse files
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 285737e commit f652e1b

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
@@ -3316,7 +3316,24 @@ static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) {
33163316
return Copy;
33173317
}
33183318

3319+
static cl::opt<bool>
3320+
EnableSwiftTailCCMustTailCheck("enable-swifttailcc-musttail-check",
3321+
cl::init(false), cl::desc("Check that tail calls from swifttailcc functions to"
3322+
" swifttailcc functions are marked musttail."));
3323+
33193324
void Verifier::verifyMustTailCall(CallInst &CI) {
3325+
if (!CI.isMustTailCall()) {
3326+
if (EnableSwiftTailCCMustTailCheck &&
3327+
CI.getCallingConv() == CallingConv::SwiftTail &&
3328+
CI.getCaller()->getCallingConv() == CallingConv::SwiftTail &&
3329+
isa_and_nonnull<ReturnInst>(CI.getNextNode())) {
3330+
Assert(
3331+
false, "tail call from swifttail->swiftail should be marked musttail",
3332+
&CI);
3333+
}
3334+
return;
3335+
}
3336+
33203337
Assert(!CI.isInlineAsm(), "cannot use musttail call with inline asm", &CI);
33213338

33223339
Function *F = CI.getParent()->getParent();
@@ -3401,9 +3418,7 @@ void Verifier::verifyMustTailCall(CallInst &CI) {
34013418

34023419
void Verifier::visitCallInst(CallInst &CI) {
34033420
visitCallBase(CI);
3404-
3405-
if (CI.isMustTailCall())
3406-
verifyMustTailCall(CI);
3421+
verifyMustTailCall(CI);
34073422
}
34083423

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

0 commit comments

Comments
 (0)