Skip to content

Commit

Permalink
[PowerPC] Bail out of FISel when lowering long calls
Browse files Browse the repository at this point in the history
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.

Differential revision: https://reviews.llvm.org/D123997
  • Loading branch information
nemanjai committed Feb 16, 2023
1 parent c2e248c commit 56e41fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/PowerPC/PPCFastISel.cpp
Expand Up @@ -1555,8 +1555,8 @@ bool PPCFastISel::fastLowerCall(CallLoweringInfo &CLI) {
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.
Expand Down
19 changes: 17 additions & 2 deletions 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@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@toc@l({{[0-9]+}})
; CHECK: ld [[ADDR:[0-9]+]], 0([[FD]])
; CHECK: mtctr [[ADDR]]
Expand Down

0 comments on commit 56e41fc

Please sign in to comment.