1 ; RUN: llvm-as < %s -bitcode-mdindex-threshold=0 | 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.
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.
10 ; Check for strings in the global pool.
11 ; CHECK: <METADATA_BLOCK
12 ; CHECK-NEXT: <STRINGS
13 ; CHECK-SAME: /> num-strings = 3 {
15 ; CHECK-NEXT: 'named and foo'
16 ; CHECK-NEXT: 'foo and bar'
19 ; Each node gets a new number. Bottom-up traversal of nodes.
22 ; Before the records we emit an offset to the index for the block
23 ; CHECK-NEXT: <INDEX_OFFSET
25 ; CHECK-NEXT: <NODE op0=1/>
28 ; CHECK-NEXT: <NODE op0=2/>
29 !5 = !{!"named and foo"}
31 ; CHECK-NEXT: <NODE op0=1 op1=4 op2=5/>
32 !6 = !{!"named", !4, !5}
34 ; CHECK-NEXT: <NODE op0=3/>
35 !7 = !{!"foo and bar"}
38 ; CHECK: </METADATA_BLOCK
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 {
48 ; Function-local nodes start at 9 (strings at 8).
49 ; CHECK-NEXT: <NODE op0=8/>
52 ; CHECK-NEXT: <NODE op0=8 op1=3 op2=9 op3=7 op4=5/>
53 !110 = !{!"foo", !"foo and bar", !109, !7, !5}
55 ; CHECK-NEXT: </METADATA_BLOCK
56 define void @foo() !foo !110 {
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 {
68 ; Function-local nodes start at 9 (strings at 8).
69 ; CHECK-NEXT: <NODE op0=8/>
72 ; CHECK-NEXT: <NODE op0=8 op1=3 op2=9 op3=7/>
73 !210 = !{!"bar", !"foo and bar", !209, !7}
75 ; CHECK-NEXT: </METADATA_BLOCK
77 unreachable, !bar !210