mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-16 02:16:23 +00:00

The tail call optimization was being used without proper consideration of ABI requirements for saving and restoring the GP. This patch restricts tail call optimization to functions within the same translation unit. Reviewers: vkalintiris Differential Revision: https://reviews.llvm.org/D24763 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287505 91177308-0d34-0410-b5e6-96231b3b80d8
42 lines
1.0 KiB
LLVM
42 lines
1.0 KiB
LLVM
; RUN: llc -march=mipsel -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck %s
|
|
|
|
; CHECK-LABEL: foo6:
|
|
; CHECK: %while.body
|
|
; CHECK: lw $25, %call16(foo2)(${{[0-9]+}})
|
|
; CHECK: jalr $25
|
|
; CHECK: %while.end
|
|
|
|
define void @foo6(i32 %n) {
|
|
entry:
|
|
%tobool1 = icmp eq i32 %n, 0
|
|
br i1 %tobool1, label %while.end, label %while.body
|
|
|
|
while.body: ; preds = %entry, %while.body
|
|
%n.addr.02 = phi i32 [ %dec, %while.body ], [ %n, %entry ]
|
|
%dec = add nsw i32 %n.addr.02, -1
|
|
tail call void @foo2()
|
|
%tobool = icmp eq i32 %dec, 0
|
|
br i1 %tobool, label %while.end, label %while.body
|
|
|
|
while.end: ; preds = %while.body, %entry
|
|
ret void
|
|
}
|
|
|
|
declare void @foo2()
|
|
|
|
; CHECK-LABEL: foo1:
|
|
; CHECK: lw $25, %call16(foo2)(${{[0-9]+}})
|
|
; CHECK: jalr $25
|
|
; CHECK: lw $25, %call16(foo2)(${{[0-9]+}})
|
|
; CHECK: jalr $25
|
|
; CHECK: lw $25, %call16(foo2)(${{[0-9]+}})
|
|
; CHECK: jalr $25
|
|
|
|
define void @foo1() {
|
|
entry:
|
|
tail call void @foo2()
|
|
tail call void @foo2()
|
|
tail call void @foo2()
|
|
ret void
|
|
}
|