; RUN: llvm-as < %s | llvm-bcanalyzer -dump | FileCheck %s
; Test that metadata only used by a single function is serialized in that
; function instead of in the global pool.
;
; In order to make the bitcode records easy to follow, nodes in this testcase
; are named after the ids they are given in the bitcode. Nodes local to a
; function have offsets of 100 or 200 (depending on the function) so that they
; remain unique within this textual IR.
; Check for strings in the global pool.
; CHECK: num-strings = 3 {
; CHECK-NEXT: 'named'
; CHECK-NEXT: 'named and foo'
; CHECK-NEXT: 'foo and bar'
; CHECK-NEXT: }
; Each node gets a new number. Bottom-up traversal of nodes.
!named = !{!6}
; CHECK-NEXT:
!4 = !{!"named"}
; CHECK-NEXT:
!5 = !{!"named and foo"}
; CHECK-NEXT:
!6 = !{!"named", !4, !5}
; CHECK-NEXT:
!7 = !{!"foo and bar"}
; CHECK-NOT: num-strings = 1 {
; CHECK-NEXT: 'foo'
; CHECK-NEXT: }
; Function-local nodes start at 9 (strings at 8).
; CHECK-NEXT:
!109 = !{!"foo"}
; CHECK-NEXT:
!110 = !{!"foo", !"foo and bar", !109, !7, !5}
; CHECK-NEXT: num-strings = 1 {
; CHECK-NEXT: 'bar'
; CHECK-NEXT: }
; Function-local nodes start at 9 (strings at 8).
; CHECK-NEXT:
!209 = !{!"bar"}
; CHECK-NEXT:
!210 = !{!"bar", !"foo and bar", !209, !7}
; CHECK-NEXT: