[llvm] [CGP] Consider arguments and ret values in `dupRetToEnableTailCallOpts` (PR #76613)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 11 22:08:24 PST 2024


================
@@ -2631,8 +2685,12 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB,
       if (Instruction *I = Pred->rbegin()->getPrevNonDebugInstruction(true)) {
         CallInst *CI = dyn_cast<CallInst>(I);
         if (CI && CI->use_empty() && TLI->mayBeEmittedAsTailCall(CI) &&
-            attributesPermitTailCall(F, CI, RetI, *TLI))
-          TailCallBBs.push_back(Pred);
+            attributesPermitTailCall(F, CI, RetI, *TLI)) {
+          // Either we return void or the value must be the first argument of a
+          // known intrinsic or library function.
----------------
antoniofrighetto wrote:

Right. I thought checking that `V` exists would suffice, but it’s not the case. Checking directly that `V` is the first argument, adding another test case.

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


More information about the llvm-commits mailing list