[PATCH] D132193: [FastISel] Respect musttail over "disable-tail-calls"
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 23 08:56:07 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd6cc7a5b462b: [FastISel] Respect musttail over "disable-tail-calls" (authored by aeubanks).
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.454865.patch
Type: text/x-patch
Size: 1868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220823/4f8f3fa7/attachment.bin>
More information about the llvm-commits
mailing list