xref: /llvm-project/llvm/test/Transforms/GlobalOpt/musttail_cc.ll (revision 8ebb3eac02a926ffa4298c12834c57aefb2e8579)
1*8ebb3eacSBjorn Pettersson; RUN: opt < %s -passes=globalopt -S | FileCheck %s
2cee313d2SEric Christopher; PR36546
3cee313d2SEric Christopher
4cee313d2SEric Christopher; Check that musttail callee preserves its calling convention
5cee313d2SEric Christopher
6cee313d2SEric Christopherdefine i32 @test(i32 %a) {
7cee313d2SEric Christopher  ; CHECK: %ca = musttail call i32 @foo(i32 %a)
8cee313d2SEric Christopher  %ca = musttail call i32 @foo(i32 %a)
9cee313d2SEric Christopher  ret i32 %ca
10cee313d2SEric Christopher}
11cee313d2SEric Christopher
12cee313d2SEric Christopher; CHECK-LABEL: define internal i32 @foo(i32 %a)
13cee313d2SEric Christopherdefine internal i32 @foo(i32 %a) {
14cee313d2SEric Christopher  ret i32 %a
15cee313d2SEric Christopher}
16cee313d2SEric Christopher
17cee313d2SEric Christopher; Check that musttail caller preserves its calling convention
18cee313d2SEric Christopher
19cee313d2SEric Christopherdefine i32 @test2(i32 %a) {
20cee313d2SEric Christopher  %ca = call i32 @foo1(i32 %a)
21cee313d2SEric Christopher  ret i32 %ca
22cee313d2SEric Christopher}
23cee313d2SEric Christopher
24cee313d2SEric Christopher; CHECK-LABEL: define internal i32 @foo1(i32 %a)
25cee313d2SEric Christopherdefine internal i32 @foo1(i32 %a) {
26cee313d2SEric Christopher  ; CHECK: %ca = musttail call i32 @foo2(i32 %a)
27cee313d2SEric Christopher  %ca = musttail call i32 @foo2(i32 %a)
28cee313d2SEric Christopher  ret i32 %ca
29cee313d2SEric Christopher}
30cee313d2SEric Christopher
31cee313d2SEric Christopher; CHECK-LABEL: define internal i32 @foo2(i32 %a)
32cee313d2SEric Christopherdefine internal i32 @foo2(i32 %a) {
33cee313d2SEric Christopher  ret i32 %a
34cee313d2SEric Christopher}
35