[PATCH] D123116: Don't partially inline a musttail libcall.

Bert Abrath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 5 04:31:21 PDT 2022


babrath created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
babrath edited the summary of this revision.
babrath edited the summary of this revision.
babrath edited the summary of this revision.
babrath added a reviewer: chandlerc.
babrath published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Partially inlining a libcall that has the musttail attribute leads to broken LLVM IR, triggering an assertion in the IR verifier. Compiling this file with -O2 -c should trigger the assertion. The proposed  changes fix the issue, although I'm not 100% certain simply forgoing the optimization for musttail calls is the proper approach. F22679623: test.c <https://reviews.llvm.org/F22679623>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123116

Files:
  llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp


Index: llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -125,6 +125,9 @@
       if (Call->isNoBuiltin() || Call->isStrictFP())
         continue;
 
+      if (Call->isMustTailCall())
+        continue;
+
       // Skip if function either has local linkage or is not a known library
       // function.
       LibFunc LF;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123116.420443.patch
Type: text/x-patch
Size: 516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220405/0ea5e35f/attachment.bin>


More information about the llvm-commits mailing list