[PATCH] D132193: [FastISel] Respect musttail over "disable-tail-calls"

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 12:40:01 PDT 2022


aeubanks updated this revision to Diff 454081.
aeubanks added a comment.
Herald added a subscriber: jdoerfert.

add langref clarification


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132193

Files:
  llvm/docs/LangRef.rst
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/test/CodeGen/X86/fast-isel-disable-tail-calls.ll


Index: llvm/test/CodeGen/X86/fast-isel-disable-tail-calls.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/fast-isel-disable-tail-calls.ll
@@ -0,0 +1,9 @@
+; RUN: llc -O0 -fast-isel -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
+
+; CHECK-NOT: retq
+; CHECK: jmpq
+
+define void @f(ptr %this) "disable-tail-calls"="true" {
+  musttail call void %this(ptr %this)
+  ret void
+}
Index: llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1139,9 +1139,8 @@
   bool IsTailCall = CI->isTailCall();
   if (IsTailCall && !isInTailCallPosition(*CI, TM))
     IsTailCall = false;
-  if (IsTailCall && MF->getFunction()
-                            .getFnAttribute("disable-tail-calls")
-                            .getValueAsBool())
+  if (IsTailCall && !CI->isMustTailCall() &&
+      MF->getFunction().getFnAttribute("disable-tail-calls").getValueAsBool())
     IsTailCall = false;
 
   CallLoweringInfo CLI;
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -11657,7 +11657,8 @@
    should perform tail call optimization. The ``tail`` marker is a hint that
    `can be ignored <CodeGenerator.html#sibcallopt>`_. The ``musttail`` marker
    means that the call must be tail call optimized in order for the program to
-   be correct. The ``musttail`` marker provides these guarantees:
+   be correct. This is true even in the presence of attributes like
+   "disable-tail-calls". The ``musttail`` marker provides these guarantees:
 
    #. The call will not cause unbounded stack growth if it is part of a
       recursive cycle in the call graph.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132193.454081.patch
Type: text/x-patch
Size: 1868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220819/97969cd1/attachment.bin>


More information about the llvm-commits mailing list