blob: e3c0cc674210e976b46f3cb3b73a36c29774de2f [file] [log] [blame]
Mehdi Amini89bf9692016-12-28 22:30:28 +00001; RUN: llvm-as < %s -bitcode-mdindex-threshold=0 | llvm-bcanalyzer -dump | FileCheck %s
Duncan P. N. Exon Smithbe4ea762016-04-02 15:22:57 +00002; 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
Mehdi Amini89bf9692016-12-28 22:30:28 +000022; Before the records we emit an offset to the index for the block
23; CHECK-NEXT: <INDEX_OFFSET
24
Duncan P. N. Exon Smith1372f532016-04-19 03:46:51 +000025; CHECK-NEXT: <NODE op0=1/>
Duncan P. N. Exon Smithe33a1a52016-04-21 01:55:12 +000026!4 = !{!"named"}
Duncan P. N. Exon Smith1372f532016-04-19 03:46:51 +000027
Duncan P. N. Exon Smithe33a1a52016-04-21 01:55:12 +000028; CHECK-NEXT: <NODE op0=2/>
29!5 = !{!"named and foo"}
30
31; CHECK-NEXT: <NODE op0=1 op1=4 op2=5/>
32!6 = !{!"named", !4, !5}
Duncan P. N. Exon Smithbe4ea762016-04-02 15:22:57 +000033
34; CHECK-NEXT: <NODE op0=3/>
35!7 = !{!"foo and bar"}
36
37; CHECK-NOT: <NODE
38; CHECK: </METADATA_BLOCK
39
40; Look at metadata local to @foo, starting with strings.
41; CHECK: <FUNCTION_BLOCK
42; CHECK: <METADATA_BLOCK
43; CHECK-NEXT: <STRINGS
44; CHECK-SAME: /> num-strings = 1 {
45; CHECK-NEXT: 'foo'
46; CHECK-NEXT: }
47
48; Function-local nodes start at 9 (strings at 8).
49; CHECK-NEXT: <NODE op0=8/>
50!109 = !{!"foo"}
51
52; CHECK-NEXT: <NODE op0=8 op1=3 op2=9 op3=7 op4=5/>
53!110 = !{!"foo", !"foo and bar", !109, !7, !5}
54
55; CHECK-NEXT: </METADATA_BLOCK
56define void @foo() !foo !110 {
57 unreachable
58}
59
60; Look at metadata local to @bar, starting with strings.
61; CHECK: <FUNCTION_BLOCK
62; CHECK: <METADATA_BLOCK
63; CHECK-NEXT: <STRINGS
64; CHECK-SAME: /> num-strings = 1 {
65; CHECK-NEXT: 'bar'
66; CHECK-NEXT: }
67
68; Function-local nodes start at 9 (strings at 8).
69; CHECK-NEXT: <NODE op0=8/>
70!209 = !{!"bar"}
71
72; CHECK-NEXT: <NODE op0=8 op1=3 op2=9 op3=7/>
73!210 = !{!"bar", !"foo and bar", !209, !7}
74
75; CHECK-NEXT: </METADATA_BLOCK
76define void @bar() {
77 unreachable, !bar !210
78}