blob: f3e83c5074d1731bef8a49c4cbaaa07bea9368ec [file] [log] [blame]
Duncan P. N. Exon Smith520f8542016-04-02 15:22:57 +00001; RUN: llvm-as < %s | llvm-bcanalyzer -dump | FileCheck %s
2; Test that metadata only used by a single function is serialized in that
3; function instead of in the global pool.
4;
5; In order to make the bitcode records easy to follow, nodes in this testcase
6; are named after the ids they are given in the bitcode. Nodes local to a
7; function have offsets of 100 or 200 (depending on the function) so that they
8; remain unique within this textual IR.
9
10; Check for strings in the global pool.
11; CHECK: <METADATA_BLOCK
12; CHECK-NEXT: <STRINGS
13; CHECK-SAME: /> num-strings = 3 {
14; CHECK-NEXT: 'named'
15; CHECK-NEXT: 'named and foo'
16; CHECK-NEXT: 'foo and bar'
17; CHECK-NEXT: }
18
19; Each node gets a new number. Bottom-up traversal of nodes.
20!named = !{!6}
21
Duncan P. N. Exon Smith9695eb32016-04-19 03:46:51 +000022; CHECK-NEXT: <NODE op0=1/>
Duncan P. N. Exon Smithc1965312016-04-21 01:55:12 +000023!4 = !{!"named"}
Duncan P. N. Exon Smith9695eb32016-04-19 03:46:51 +000024
Duncan P. N. Exon Smithc1965312016-04-21 01:55:12 +000025; CHECK-NEXT: <NODE op0=2/>
26!5 = !{!"named and foo"}
27
28; CHECK-NEXT: <NODE op0=1 op1=4 op2=5/>
29!6 = !{!"named", !4, !5}
Duncan P. N. Exon Smith520f8542016-04-02 15:22:57 +000030
31; CHECK-NEXT: <NODE op0=3/>
32!7 = !{!"foo and bar"}
33
34; CHECK-NOT: <NODE
35; CHECK: </METADATA_BLOCK
36
37; Look at metadata local to @foo, starting with strings.
38; CHECK: <FUNCTION_BLOCK
39; CHECK: <METADATA_BLOCK
40; CHECK-NEXT: <STRINGS
41; CHECK-SAME: /> num-strings = 1 {
42; CHECK-NEXT: 'foo'
43; CHECK-NEXT: }
44
45; Function-local nodes start at 9 (strings at 8).
46; CHECK-NEXT: <NODE op0=8/>
47!109 = !{!"foo"}
48
49; CHECK-NEXT: <NODE op0=8 op1=3 op2=9 op3=7 op4=5/>
50!110 = !{!"foo", !"foo and bar", !109, !7, !5}
51
52; CHECK-NEXT: </METADATA_BLOCK
53define void @foo() !foo !110 {
54 unreachable
55}
56
57; Look at metadata local to @bar, starting with strings.
58; CHECK: <FUNCTION_BLOCK
59; CHECK: <METADATA_BLOCK
60; CHECK-NEXT: <STRINGS
61; CHECK-SAME: /> num-strings = 1 {
62; CHECK-NEXT: 'bar'
63; CHECK-NEXT: }
64
65; Function-local nodes start at 9 (strings at 8).
66; CHECK-NEXT: <NODE op0=8/>
67!209 = !{!"bar"}
68
69; CHECK-NEXT: <NODE op0=8 op1=3 op2=9 op3=7/>
70!210 = !{!"bar", !"foo and bar", !209, !7}
71
72; CHECK-NEXT: </METADATA_BLOCK
73define void @bar() {
74 unreachable, !bar !210
75}