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

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 18:23:53 PDT 2022


aeubanks created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132193

Files:
  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;


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


More information about the llvm-commits mailing list