1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=attributor -S < %s | FileCheck %s --check-prefixes=CHECK
3 ; RUN: opt -passes=attributor -attributor-print-call-graph -S -disable-output < %s | FileCheck %s --check-prefixes=DOT
5 define dso_local void @func1() {
7 ; CHECK-NEXT: br label [[TMP2:%.*]]
9 ; CHECK-NEXT: unreachable
11 ; CHECK-NEXT: call void @func3()
12 ; CHECK-NEXT: ret void
15 br i1 %1, label %2, label %3
29 define dso_local void @func2() {
30 ; CHECK-LABEL: @func2(
31 ; CHECK-NEXT: call void @func4()
32 ; CHECK-NEXT: ret void
39 define void @func5(i32 %0) {
40 ; CHECK-LABEL: @func5(
41 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
42 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], void ()* @func4, void ()* @func3
43 ; CHECK-NEXT: call void [[TMP3]]()
44 ; CHECK-NEXT: ret void
46 %2 = icmp ne i32 %0, 0
47 %3 = select i1 %2, void ()* @func4, void ()* @func3
52 define void @broker(void ()* %unknown) !callback !0 {
53 ; CHECK-LABEL: @broker(
54 ; CHECK-NEXT: call void [[UNKNOWN:%.*]]()
55 ; CHECK-NEXT: ret void
61 define void @func6() {
62 ; CHECK-LABEL: @func6(
63 ; CHECK-NEXT: call void @broker(void ()* nocapture nofree noundef @func3)
64 ; CHECK-NEXT: ret void
66 call void @broker(void ()* @func3)
70 define void @func7(void ()* %unknown) {
71 ; CHECK-LABEL: @func7(
72 ; CHECK-NEXT: call void [[UNKNOWN:%.*]](), !callees !2
73 ; CHECK-NEXT: ret void
75 call void %unknown(), !callees !2
80 !1 = !{i64 0, i1 false}
81 !2 = !{void ()* @func3, void ()* @func4}
85 ; DOT-DAG: Node[[FUNC1:0x[a-z0-9]+]] [shape=record,label="{func1}"];
86 ; DOT-DAG: Node[[FUNC2:0x[a-z0-9]+]] [shape=record,label="{func2}"];
87 ; DOT-DAG: Node[[FUNC3:0x[a-z0-9]+]] [shape=record,label="{func3}"];
88 ; DOT-DAG: Node[[FUNC4:0x[a-z0-9]+]] [shape=record,label="{func4}"];
89 ; DOT-DAG: Node[[FUNC5:0x[a-z0-9]+]] [shape=record,label="{func5}"];
90 ; DOT-DAG: Node[[FUNC6:0x[a-z0-9]+]] [shape=record,label="{func6}"];
91 ; DOT-DAG: Node[[FUNC7:0x[a-z0-9]+]] [shape=record,label="{func7}"];
93 ; DOT-DAG: Node[[BROKER:0x[a-z0-9]+]] [shape=record,label="{broker}"];
95 ; DOT-DAG: Node[[FUNC1]] -> Node[[FUNC3]];
96 ; DOT-DAG: Node[[FUNC2]] -> Node[[FUNC4]];
97 ; DOT-DAG: Node[[FUNC5]] -> Node[[FUNC3]];
98 ; DOT-DAG: Node[[FUNC5]] -> Node[[FUNC4]];
100 ; DOT-DAG: Node[[FUNC6]] -> Node[[BROKER]];
102 ; This one gets added because of the callback metadata.
103 ; DOT-DAG: Node[[FUNC6]] -> Node[[FUNC3]];
105 ; These ones are added because of the callees metadata.
106 ; DOT-DAG: Node[[FUNC7]] -> Node[[FUNC3]];
107 ; DOT-DAG: Node[[FUNC7]] -> Node[[FUNC4]];