1*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as <%s | llvm-bcanalyzer -dump | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; Check that distinct nodes break uniquing cycles, so that uniqued subgraphs 3*9880d681SAndroid Build Coastguard Worker; are always in post-order. 4*9880d681SAndroid Build Coastguard Worker; 5*9880d681SAndroid Build Coastguard Worker; It may not be immediately obvious why this is an interesting graph. There 6*9880d681SAndroid Build Coastguard Worker; are three nodes in a cycle, and one of them (!1) is distinct. Because the 7*9880d681SAndroid Build Coastguard Worker; entry point is !2, a naive post-order traversal would give !3, !1, !2; but 8*9880d681SAndroid Build Coastguard Worker; this means when !3 is parsed the reader will need a forward reference for !2. 9*9880d681SAndroid Build Coastguard Worker; Forward references for uniqued node operands are expensive, whereas they're 10*9880d681SAndroid Build Coastguard Worker; cheap for distinct node operands. If the distinct node is emitted first, the 11*9880d681SAndroid Build Coastguard Worker; uniqued nodes don't need any forward references at all. 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Worker; Nodes in this testcase are numbered to match how they are referenced in 14*9880d681SAndroid Build Coastguard Worker; bitcode. !3 is referenced as opN=3. 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker; CHECK: <DISTINCT_NODE op0=3/> 17*9880d681SAndroid Build Coastguard Worker!1 = distinct !{!3} 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: <NODE op0=1/> 20*9880d681SAndroid Build Coastguard Worker!2 = !{!1} 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: <NODE op0=2/> 23*9880d681SAndroid Build Coastguard Worker!3 = !{!2} 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; Note: named metadata nodes are not cannot reference null so their operands 26*9880d681SAndroid Build Coastguard Worker; are numbered off-by-one. 27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: <NAME 28*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: <NAMED_NODE op0=1/> 29*9880d681SAndroid Build Coastguard Worker!named = !{!2} 30