1; RUN: llc -march=hexagon -enable-save-restore-long -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
2
3; Check that the -long-calls feature is supported by the backend.
4
5; CHECK: call ##foo
6; CHECK: jump ##__restore
7define i64 @test_longcall(i32 %x, i32 %y) #0 {
8entry:
9  %add = add nsw i32 %x, 5
10  %call = tail call i64 @foo(i32 %add) #1
11  %conv = sext i32 %y to i64
12  %add1 = add nsw i64 %call, %conv
13  ret i64 %add1
14}
15
16; CHECK: jump ##foo
17define i64 @test_longtailcall(i32 %x, i32 %y) #1 {
18entry:
19  %add = add nsw i32 %x, 5
20  %call = tail call i64 @foo(i32 %add) #1
21  ret i64 %call
22}
23
24; CHECK: call ##bar
25define i64 @test_longnoret(i32 %x, i32 %y) #2 {
26entry:
27  %add = add nsw i32 %x, 5
28  %0 = tail call i64 @bar(i32 %add) #6
29  unreachable
30}
31
32; CHECK: call foo
33; CHECK: jump ##__restore
34; The restore call will still be long because of the enable-save-restore-long
35; option being used.
36define i64 @test_shortcall(i32 %x, i32 %y) #3 {
37entry:
38  %add = add nsw i32 %x, 5
39  %call = tail call i64 @foo(i32 %add) #1
40  %conv = sext i32 %y to i64
41  %add1 = add nsw i64 %call, %conv
42  ret i64 %add1
43}
44
45; CHECK: jump foo
46define i64 @test_shorttailcall(i32 %x, i32 %y) #4 {
47entry:
48  %add = add nsw i32 %x, 5
49  %call = tail call i64 @foo(i32 %add) #1
50  ret i64 %call
51}
52
53; CHECK: call bar
54define i64 @test_shortnoret(i32 %x, i32 %y) #5 {
55entry:
56  %add = add nsw i32 %x, 5
57  %0 = tail call i64 @bar(i32 %add) #6
58  unreachable
59}
60
61declare i64 @foo(i32) #1
62declare i64 @bar(i32) #6
63
64attributes #0 = { minsize nounwind "target-cpu"="hexagonv60" "target-features"="+long-calls" }
65attributes #1 = { nounwind "target-cpu"="hexagonv60" "target-features"="+long-calls" }
66attributes #2 = { noreturn nounwind "target-cpu"="hexagonv60" "target-features"="+long-calls" }
67
68attributes #3 = { minsize nounwind "target-cpu"="hexagonv60" "target-features"="-long-calls" }
69attributes #4 = { nounwind "target-cpu"="hexagonv60" "target-features"="-long-calls" }
70attributes #5 = { noreturn nounwind "target-cpu"="hexagonv60" "target-features"="-long-calls" }
71
72attributes #6 = { noreturn nounwind "target-cpu"="hexagonv60" }
73