1; RUN: opt < %s -disable-output -passes='jump-threading,print<domtree>' 2>&1 | FileCheck %s 2 3; REQUIRES: asserts 4 5; The idea behind this test case is to verify that the dominator tree is 6; updated in a deterministic way. Optimizations, at least EarlyCSE, are 7; iterating the vectors that hold child nodes in the DominatorTree. Thus, the 8; end result might differ depending on the order in which nodes are inserted 9; in the dominator tree. Unfortunately this test case is quite large, but it 10; happened to trigger a non-determinism quite often when being executed 11; multipe times (it was possible to see varying results when running the test 12; less that 10 times in a row). 13; The actual problem was tracked down to llvm::MergeBasicBlockIntoOnlyPred, so 14; the important property of the test is probably that it triggers a call to 15; that function, and that the PredsOfPredBB set that is used to populate 16; Updates for the DomTreeUpdater is populated with more than one entry. 17 18; CHECK: Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries. 19; CHECK-NEXT: [1] %entry {4294967295,4294967295} [0] 20; CHECK-NEXT: [2] %for.cond1 {4294967295,4294967295} [1] 21; CHECK-NEXT: [3] %for.inc19 {4294967295,4294967295} [2] 22; CHECK-NEXT: [3] %if.then {4294967295,4294967295} [2] 23; CHECK-NEXT: [4] %for.cond5.preheader {4294967295,4294967295} [3] 24; CHECK-NEXT: [5] %cleanup {4294967295,4294967295} [4] 25; CHECK-NEXT: [6] %cleanup16 {4294967295,4294967295} [5] 26; CHECK-NEXT: [7] %unreachable {4294967295,4294967295} [6] 27; CHECK-NEXT: [7] %for.end21 {4294967295,4294967295} [6] 28; CHECK-NEXT: [5] %for.body7 {4294967295,4294967295} [4] 29; CHECK-NEXT: [6] %for.inc {4294967295,4294967295} [5] 30; CHECK-NEXT: [5] %return {4294967295,4294967295} [4] 31; CHECK-NEXT: [3] %cleanup16.thread {4294967295,4294967295} [2] 32; CHECK-NEXT: [2] %infinite.loop {4294967295,4294967295} [1] 33; CHECK-NEXT: Roots: %entry 34 35 36@a = dso_local local_unnamed_addr global i16 0, align 1 37 38; Function Attrs: nounwind 39define dso_local i16 @g(i16 %a0, i16 %a1, i16 %a2, i16 %a3) local_unnamed_addr { 40entry: 41 %tobool.not = icmp eq i16 %a0, 0 42 br i1 %tobool.not, label %for.cond1, label %infinite.loop 43 44infinite.loop: ; preds = %infinite.loop, %entry 45 br label %infinite.loop 46 47for.cond1: ; preds = %for.inc19, %entry 48 %retval.0 = phi i16 [ %retval.3, %for.inc19 ], [ undef, %entry ] 49 %i.0 = phi i16 [ %i.3, %for.inc19 ], [ undef, %entry ] 50 %tobool2.not = icmp eq i16 %a1, 0 51 br i1 %tobool2.not, label %if.end15, label %if.then 52 53if.then: ; preds = %for.cond1 54 %tobool3.not = icmp eq i16 %a2, 0 55 br i1 %tobool3.not, label %if.end15, label %for.cond5.preheader 56 57for.cond5.preheader: ; preds = %if.then 58 %tobool8.not = icmp eq i16 %a3, 0 59 %tobool6.not31 = icmp eq i16 %i.0, 0 60 br i1 %tobool6.not31, label %for.end10, label %for.body7 61 62for.body7: ; preds = %for.inc, %for.cond5.preheader 63 %i.132 = phi i16 [ %inc, %for.inc ], [ %i.0, %for.cond5.preheader ] 64 br i1 %tobool8.not, label %for.inc, label %cleanup 65 66for.inc: ; preds = %for.body7 67 %inc = add i16 %i.132, 1 68 %tobool6.not = icmp eq i16 %inc, 0 69 br i1 %tobool6.not, label %for.end10, label %for.body7 70 71for.end10: ; preds = %for.inc, %for.cond5.preheader 72 %i.1.lcssa = phi i16 [ %i.0, %for.cond5.preheader ], [ 0, %for.inc ] 73 %.26 = select i1 %tobool8.not, i32 0, i32 4 74 br label %cleanup 75 76cleanup: ; preds = %for.end10, %for.body7 77 %i.128 = phi i16 [ %i.1.lcssa, %for.end10 ], [ %i.0, %for.body7 ] 78 %retval.1 = phi i16 [ %retval.0, %for.end10 ], [ 1, %for.body7 ] 79 %cond = phi i1 [ %tobool8.not, %for.end10 ], [ false, %for.body7 ] 80 %cleanup.dest.slot.0 = phi i32 [ %.26, %for.end10 ], [ 1, %for.body7 ] 81 br i1 %cond, label %if.end15, label %cleanup16 82 83if.end15: ; preds = %cleanup, %if.then, %for.cond1 84 %retval.2 = phi i16 [ %retval.1, %cleanup ], [ %retval.0, %if.then ], [ %retval.0, %for.cond1 ] 85 %i.2 = phi i16 [ %i.128, %cleanup ], [ %i.0, %if.then ], [ %i.0, %for.cond1 ] 86 store i16 0, ptr @a, align 1 87 br label %cleanup16 88 89cleanup16: ; preds = %if.end15, %cleanup 90 %retval.3 = phi i16 [ %retval.2, %if.end15 ], [ %retval.1, %cleanup ] 91 %i.3 = phi i16 [ %i.2, %if.end15 ], [ %i.128, %cleanup ] 92 %cleanup.dest.slot.1 = phi i32 [ 0, %if.end15 ], [ %cleanup.dest.slot.0, %cleanup ] 93 switch i32 %cleanup.dest.slot.1, label %unreachable [ 94 i32 0, label %for.inc19 95 i32 1, label %return 96 i32 4, label %for.end21 97 ] 98 99for.inc19: ; preds = %cleanup16 100 br label %for.cond1 101 102for.end21: ; preds = %cleanup16 103 br label %return 104 105return: ; preds = %for.end21, %cleanup16 106 %retval.4 = phi i16 [ 17, %for.end21 ], [ %retval.3, %cleanup16 ] 107 ret i16 %retval.4 108 109unreachable: ; preds = %cleanup16 110 unreachable 111} 112