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. 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 22 ; Before the records we emit an offset to the index for the block 23 ; CHECK-NEXT: <INDEX_OFFSET 24 25 ; CHECK-NEXT: <NODE op0=1/> 26 !4 = !{!"named"} 27 28 ; 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} 33 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 56 define 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 76 define void @bar() { 77 unreachable, !bar !210 78 } 79