1; RUN: opt -mergefunc -S < %s | FileCheck %s
2
3define i8 @call_with_range() {
4  bitcast i8 0 to i8 ; dummy to make the function large enough
5  %out = call i8 @dummy(), !range !0
6  ret i8 %out
7}
8
9define i8 @call_no_range() {
10; CHECK-LABEL: @call_no_range
11; CHECK-NEXT: bitcast i8 0 to i8
12; CHECK-NEXT: %out = call i8 @dummy()
13; CHECK-NEXT: ret i8 %out
14  bitcast i8 0 to i8
15  %out = call i8 @dummy()
16  ret i8 %out
17}
18
19define i8 @call_different_range() {
20; CHECK-LABEL: @call_different_range
21; CHECK-NEXT: bitcast i8 0 to i8
22; CHECK-NEXT: %out = call i8 @dummy(), !range !1
23; CHECK-NEXT: ret i8 %out
24  bitcast i8 0 to i8
25  %out = call i8 @dummy(), !range !1
26  ret i8 %out
27}
28
29define i8 @invoke_with_range() personality i8* undef {
30  %out = invoke i8 @dummy() to label %next unwind label %lpad, !range !0
31
32next:
33  ret i8 %out
34
35lpad:
36  %pad = landingpad { i8*, i32 } cleanup
37  resume { i8*, i32 } zeroinitializer
38}
39
40define i8 @invoke_no_range() personality i8* undef {
41; CHECK-LABEL: @invoke_no_range()
42; CHECK-NEXT: invoke i8 @dummy
43  %out = invoke i8 @dummy() to label %next unwind label %lpad
44
45next:
46  ret i8 %out
47
48lpad:
49  %pad = landingpad { i8*, i32 } cleanup
50  resume { i8*, i32 } zeroinitializer
51}
52
53define i8 @invoke_different_range() personality i8* undef {
54; CHECK-LABEL: @invoke_different_range()
55; CHECK-NEXT: invoke i8 @dummy
56  %out = invoke i8 @dummy() to label %next unwind label %lpad, !range !1
57
58next:
59  ret i8 %out
60
61lpad:
62  %pad = landingpad { i8*, i32 } cleanup
63  resume { i8*, i32 } zeroinitializer
64}
65
66define i8 @invoke_with_same_range() personality i8* undef {
67; CHECK-LABEL: @invoke_with_same_range()
68; CHECK: tail call i8 @invoke_with_range()
69  %out = invoke i8 @dummy() to label %next unwind label %lpad, !range !0
70
71next:
72  ret i8 %out
73
74lpad:
75  %pad = landingpad { i8*, i32 } cleanup
76  resume { i8*, i32 } zeroinitializer
77}
78
79define i8 @call_with_same_range() {
80; CHECK-LABEL: @call_with_same_range
81; CHECK: tail call i8 @call_with_range
82  bitcast i8 0 to i8
83  %out = call i8 @dummy(), !range !0
84  ret i8 %out
85}
86
87
88
89declare i8 @dummy();
90declare i32 @__gxx_personality_v0(...)
91
92!0 = !{i8 0, i8 2}
93!1 = !{i8 5, i8 7}
94