[clang] [CIR] Implement musttail cleanup handling (PR #224169)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 06:02:26 PDT 2026


================
@@ -1430,14 +1431,20 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
       return getUndefRValue(retTy);
     }
 
-    // Musttail is required to return immediately. Classic codegen does some
-    // work here to go through the exception handling scopes to put them before
-    // the call (it seems?) since musttail must be the last op before the
-    // return.  For now, skip this so we an do it later.
-    if (ehStack.stable_begin() != prologueCleanupDepth) {
-      cgm.errorNYI(mustTailCall->getBeginLoc(),
-                   "musttail call that skips cleanups");
-      return getUndefRValue(retTy);
+    // Musttail is required to return immediately, so no cleanup can run
+    // between the call and the return. Cleanups that the return makes
+    // unnecessary are simply skipped. Anything else cannot be expressed.
+    assert(!cir::MissingFeatures::dynamicExceptionSpec());
+    assert(!cir::MissingFeatures::fakeUseCleanup());
----------------
erichkeane wrote:

Classic does a diagnostic here, right?  It emits a `diag::err_musttail_noexcept_mismatch` I think.  Is that covered in one of the 'missing features'? 

https://github.com/llvm/llvm-project/pull/224169


More information about the cfe-commits mailing list