[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 12:48:01 PDT 2021


varungandhi-apple updated this revision to Diff 348362.
varungandhi-apple added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103275/new/

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.348362.patch
Type: text/x-patch
Size: 1315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210527/1a0085fc/attachment.bin>


More information about the llvm-commits mailing list