1*e98f9258SMehdi Amini; RUN: llvm-as <%s -bitcode-mdindex-threshold=0 | llvm-bcanalyzer -dump | FileCheck %s 230805b24SDuncan P. N. Exon Smith; Check that distinct nodes break uniquing cycles, so that uniqued subgraphs 330805b24SDuncan P. N. Exon Smith; are always in post-order. 430805b24SDuncan P. N. Exon Smith; 530805b24SDuncan P. N. Exon Smith; It may not be immediately obvious why this is an interesting graph. There 630805b24SDuncan P. N. Exon Smith; are three nodes in a cycle, and one of them (!1) is distinct. Because the 730805b24SDuncan P. N. Exon Smith; entry point is !2, a naive post-order traversal would give !3, !1, !2; but 830805b24SDuncan P. N. Exon Smith; this means when !3 is parsed the reader will need a forward reference for !2. 930805b24SDuncan P. N. Exon Smith; Forward references for uniqued node operands are expensive, whereas they're 1030805b24SDuncan P. N. Exon Smith; cheap for distinct node operands. If the distinct node is emitted first, the 1130805b24SDuncan P. N. Exon Smith; uniqued nodes don't need any forward references at all. 1230805b24SDuncan P. N. Exon Smith 1330805b24SDuncan P. N. Exon Smith; Nodes in this testcase are numbered to match how they are referenced in 1430805b24SDuncan P. N. Exon Smith; bitcode. !3 is referenced as opN=3. 1530805b24SDuncan P. N. Exon Smith 1630805b24SDuncan P. N. Exon Smith; CHECK: <DISTINCT_NODE op0=3/> 1730805b24SDuncan P. N. Exon Smith!1 = distinct !{!3} 1830805b24SDuncan P. N. Exon Smith 1930805b24SDuncan P. N. Exon Smith; CHECK-NEXT: <NODE op0=1/> 2030805b24SDuncan P. N. Exon Smith!2 = !{!1} 2130805b24SDuncan P. N. Exon Smith 2230805b24SDuncan P. N. Exon Smith; CHECK-NEXT: <NODE op0=2/> 2330805b24SDuncan P. N. Exon Smith!3 = !{!2} 2430805b24SDuncan P. N. Exon Smith 25*e98f9258SMehdi Amini; Before the named records we emit the index containing the position of the 26*e98f9258SMehdi Amini; previously emitted records 27*e98f9258SMehdi Amini; CHECK-NEXT: <INDEX {{.*}} (offset match) 28*e98f9258SMehdi Amini 2930805b24SDuncan P. N. Exon Smith; Note: named metadata nodes are not cannot reference null so their operands 3030805b24SDuncan P. N. Exon Smith; are numbered off-by-one. 3130805b24SDuncan P. N. Exon Smith; CHECK-NEXT: <NAME 3230805b24SDuncan P. N. Exon Smith; CHECK-NEXT: <NAMED_NODE op0=1/> 3330805b24SDuncan P. N. Exon Smith!named = !{!2} 34