[PATCH] D103275: Update musttail verification to check all swiftasync->swiftasync tail calls.
Varun Gandhi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 11:59:40 PDT 2021
varungandhi-apple created this revision.
varungandhi-apple added reviewers: aschwaighofer, davezarzycki.
Herald added subscribers: dexonsmith, hiraditya.
varungandhi-apple requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When `-enable-swifttailcc-musttail-check` is passed (off by default), we will
check that all swiftasync->swiftasync tail calls are marked `musttail`.
This can be used to catch codegen bugs with a missing `musttail`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103275
Files:
llvm/lib/IR/Verifier.cpp
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3419,7 +3419,26 @@
return Copy;
}
+static cl::opt<bool>
+EnableSwiftTailCCMustTailCheck("enable-swifttailcc-musttail-check",
+cl::init(false), cl::desc("Check that tail calls from swifttailcc functions to"
+ " swifttailcc functions are marked musttail."));
+
void Verifier::verifyMustTailCall(CallInst &CI) {
+ if (!CI.isMustTailCall()) {
+#ifndef NDEBUG
+ if (EnableSwiftTailCCMustTailCheck &&
+ CI.getCallingConv() == CallingConv::SwiftTail &&
+ CI.getCaller()->getCallingConv() == CallingConv::SwiftTail &&
+ isa_and_nonnull<ReturnInst>(CI.getNextNode())) {
+ Assert(
+ false, "tail call from swifttail->swiftail should be marked musttail",
+ &CI);
+ }
+#endif
+ return;
+ }
+
Assert(!CI.isInlineAsm(), "cannot use musttail call with inline asm", &CI);
// - The caller and callee prototypes must match. Pointer types of
@@ -3485,9 +3504,7 @@
void Verifier::visitCallInst(CallInst &CI) {
visitCallBase(CI);
-
- if (CI.isMustTailCall())
- verifyMustTailCall(CI);
+ verifyMustTailCall(CI);
}
void Verifier::visitInvokeInst(InvokeInst &II) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103275.348348.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210527/1354d072/attachment.bin>
More information about the llvm-commits
mailing list