xref: /aosp_15_r20/external/llvm/test/Bitcode/mdnodes-in-post-order.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as <%s | llvm-bcanalyzer -dump | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; Check that nodes are emitted in post-order to minimize the need for temporary
3*9880d681SAndroid Build Coastguard Worker; nodes.  The graph structure is designed to foil naive implementations of
4*9880d681SAndroid Build Coastguard Worker; iteratitive post-order traersals: the leaves, !3 and !4, are reachable from
5*9880d681SAndroid Build Coastguard Worker; the entry node, !6, as well as from !5.  There is one leaf on either side to
6*9880d681SAndroid Build Coastguard Worker; be sure it tickles bugs whether operands are visited forward or reverse.
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker; Nodes in this testcase are numbered to match how they are referenced in
9*9880d681SAndroid Build Coastguard Worker; bitcode.  !3 is referenced as opN=3.
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker; We don't care about the order of the strings (or of !3 and !4).  Let's just
12*9880d681SAndroid Build Coastguard Worker; make sure the strings are first and make it clear that there are two of them.
13*9880d681SAndroid Build Coastguard Worker; CHECK:       <STRINGS {{.*}} num-strings = 2 {
14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    'leaf
15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    'leaf
16*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  }
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; The leafs should come first (in either order).
19*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  <NODE op0=1/>
20*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  <NODE op0=2/>
21*9880d681SAndroid Build Coastguard Worker!3 = !{!"leaf3"}
22*9880d681SAndroid Build Coastguard Worker!4 = !{!"leaf4"}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  <NODE op0=3 op1=4/>
25*9880d681SAndroid Build Coastguard Worker!5 = !{!3, !4}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  <NODE op0=3 op1=5 op2=4/>
28*9880d681SAndroid Build Coastguard Worker!6 = !{!3, !5, !4}
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; Note: named metadata nodes are not cannot reference null so their operands
31*9880d681SAndroid Build Coastguard Worker; are numbered off-by-one.
32*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  <NAME
33*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  <NAMED_NODE op0=5/>
34*9880d681SAndroid Build Coastguard Worker!named = !{!6}
35