blob: 628362783c9c0c35b4e56e22158741bfb5ddbe49 [file] [log] [blame]
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +00001; RUN: llc -march=hexagon -enable-save-restore-long -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +00002
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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000010 %call = tail call i64 @foo(i32 %add) #1
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000011 %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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000020 %call = tail call i64 @foo(i32 %add) #1
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000021 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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000028 %0 = tail call i64 @bar(i32 %add) #6
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000029 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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000039 %call = tail call i64 @foo(i32 %add) #1
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000040 %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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000049 %call = tail call i64 @foo(i32 %add) #1
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000050 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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000057 %0 = tail call i64 @bar(i32 %add) #6
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000058 unreachable
59}
60
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000061declare i64 @foo(i32) #1
62declare i64 @bar(i32) #6
Krzysztof Parzyszek080bebd2016-07-25 14:42:11 +000063
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
Krzysztof Parzyszekd91a9e22018-08-02 22:17:53 +000072attributes #6 = { noreturn nounwind "target-cpu"="hexagonv60" }