[PATCH] D123997: [PowerPC] Bail out of FISel when lowering long calls
Nemanja Ivanovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 04:22:31 PDT 2022
nemanjai created this revision.
nemanjai added reviewers: umesh.kalappa0, PowerPC.
Herald added subscribers: shchenz, kbarton, hiraditya.
Herald added a project: All.
nemanjai requested review of this revision.
Herald added a project: LLVM.
We currently don't handle tail calls in fast-isel but we continue with the lowering when `-mlongcall` is specified and lower the calls normally. We should defer to SDISel for this so that it is lowered correctly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123997
Files:
llvm/lib/Target/PowerPC/PPCFastISel.cpp
llvm/test/CodeGen/PowerPC/longcall.ll
Index: llvm/test/CodeGen/PowerPC/longcall.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/longcall.ll
+++ llvm/test/CodeGen/PowerPC/longcall.ll
@@ -1,14 +1,29 @@
; RUN: llc < %s | FileCheck %s
+; RUN: llc --fast-isel < %s | FileCheck %s
target datalayout = "E-m:e-i64:64-n32:64"
target triple = "powerpc64-unknown-linux-gnu"
; Function Attrs: nounwind
-define void @bar() local_unnamed_addr #0 {
+define void @tail() local_unnamed_addr #0 {
entry:
tail call void @foo() #1
ret void
-; CHECK-LABEL: @bar
+; CHECK-LABEL: @tail
+; CHECK: ld [[FD:[0-9]+]], .LC0 at toc@l({{[0-9]+}})
+; CHECK: ld [[ADDR:[0-9]+]], 0([[FD]])
+; CHECK: mtctr [[ADDR]]
+; CHECK: bctrl
+; CHECK-NOT: bl foo
+; CHECK: blr
+}
+
+define void @notail() local_unnamed_addr #0 {
+entry:
+ call void @foo() #1
+ ret void
+
+; CHECK-LABEL: @notail
; CHECK: ld [[FD:[0-9]+]], .LC0 at toc@l({{[0-9]+}})
; CHECK: ld [[ADDR:[0-9]+]], 0([[FD]])
; CHECK: mtctr [[ADDR]]
Index: llvm/lib/Target/PowerPC/PPCFastISel.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCFastISel.cpp
+++ llvm/lib/Target/PowerPC/PPCFastISel.cpp
@@ -1555,8 +1555,8 @@
if (!Callee && !Symbol)
return false;
- // Allow SelectionDAG isel to handle tail calls.
- if (IsTailCall)
+ // Allow SelectionDAG isel to handle tail calls and long calls.
+ if (IsTailCall || Subtarget->useLongCalls())
return false;
// Let SDISel handle vararg functions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123997.423592.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220419/5621406a/attachment.bin>
More information about the llvm-commits
mailing list