brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · e3c0cc6 Raw
79 lines · plain
1; RUN: llvm-as < %s -bitcode-mdindex-threshold=0 | llvm-bcanalyzer -dump | FileCheck %s2; Test that metadata only used by a single function is serialized in that3; function instead of in the global pool.4;5; In order to make the bitcode records easy to follow, nodes in this testcase6; are named after the ids they are given in the bitcode.  Nodes local to a7; function have offsets of 100 or 200 (depending on the function) so that they8; remain unique within this textual IR.9 10; Check for strings in the global pool.11; CHECK:      <METADATA_BLOCK12; CHECK-NEXT:   <STRINGS13; 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 block23; CHECK-NEXT:   <INDEX_OFFSET24 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:    <NODE38; CHECK:      </METADATA_BLOCK39 40; Look at metadata local to @foo, starting with strings.41; CHECK:      <FUNCTION_BLOCK42; CHECK:        <METADATA_BLOCK43; CHECK-NEXT:     <STRINGS44; 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_BLOCK56define void @foo() !foo !110 {57  unreachable58}59 60; Look at metadata local to @bar, starting with strings.61; CHECK:    <FUNCTION_BLOCK62; CHECK:      <METADATA_BLOCK63; CHECK-NEXT:   <STRINGS64; 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_BLOCK76define void @bar() {77  unreachable, !bar !21078}79