1 ; RUN: opt -passes="ipsccp<func-spec>,print<postdomtree>" -force-specialization -funcspec-max-iters=2 -funcspec-max-clones=1 -funcspec-for-literal-constant=true -S < %s 2>&1 | FileCheck %s
5 ; This test case is trying to validate that the postdomtree is preserved
6 ; correctly by the ipsccp pass. A tricky bug was introduced in commit
7 ; 1b1232047e83b69561 when PDT would be fetched using getCachedAnalysis in order
8 ; to setup a DomTreeUpdater (to update the PDT during transformation in order
9 ; to preserve the analysis). But given that commit the PDT could end up being
10 ; required and calculated via BlockFrequency analysis. So the problem was that
11 ; when setting up the DomTreeUpdater we used a nullptr in case PDT wasn't
12 ; cached at the beginning of IPSCCP, to indicate that no updates were needed
13 ; for PDT. But then the PDT was calculated, given the input IR, and preserved
14 ; using the non-updated state (as the DTU wasn't configured for updating the
18 ; CHECK: Inorder PostDominator Tree: DFSNumbers invalid: 0 slow queries.
19 ; CHECK-NEXT: [1] <<exit node>> {4294967295,4294967295} [0]
20 ; CHECK-NEXT: [2] %for.body {4294967295,4294967295} [1]
21 ; CHECK-NEXT: [2] %if.end4 {4294967295,4294967295} [1]
22 ; CHECK-NEXT: [3] %entry {4294967295,4294967295} [2]
23 ; CHECK-NEXT: [2] %for.body37 {4294967295,4294967295} [1]
24 ; CHECK-NEXT: [3] %for.cond34 {4294967295,4294967295} [2]
25 ; CHECK-NEXT: [4] %for.cond16 {4294967295,4294967295} [3]
26 ; CHECK-NEXT: Roots: %for.body %for.body37
27 ; CHECK-NEXT: PostDominatorTree for function: bar
30 declare hidden i1 @compare(ptr) align 2
31 declare hidden { i8, ptr } @getType(ptr) align 2
33 define internal void @foo(ptr %TLI, ptr %DL, ptr %Ty, ptr %ValueVTs, ptr %Offsets, i64 %StartingOffset, i1 %arg) {
35 %VT = alloca i64, align 8
36 br i1 false, label %if.then, label %if.end4
38 if.then: ; preds = %entry
41 if.end4: ; preds = %entry
42 %cmp = call zeroext i1 @compare(ptr undef)
43 br i1 %cmp, label %for.body, label %for.cond16
45 for.body: ; preds = %if.end4
46 %add13 = add i64 %StartingOffset, undef
47 call void @foo(ptr %TLI, ptr %DL, ptr undef, ptr %ValueVTs, ptr %Offsets, i64 %add13)
50 for.cond16: ; preds = %for.cond34, %if.end4
51 %call27 = call { i8, ptr } @getType(ptr %VT)
54 for.cond34: ; preds = %for.body37, %for.cond16
55 br i1 %arg, label %for.body37, label %for.cond16
57 for.body37: ; preds = %for.cond34
58 %tobool39 = icmp ne ptr %Offsets, null
62 define hidden { ptr, i32 } @bar(ptr %this) {
64 %Offsets = alloca i64, align 8
65 %cmp26 = call zeroext i1 @compare(ptr undef)
66 br i1 %cmp26, label %for.body28, label %for.cond.cleanup27
68 for.cond.cleanup27: ; preds = %entry
69 ret { ptr, i32 } undef
71 for.body28: ; preds = %entry
72 %call33 = call zeroext i1 @compare(ptr undef)
73 br i1 %call33, label %if.then34, label %if.end106
75 if.then34: ; preds = %for.body28
76 call void @foo(ptr %this, ptr undef, ptr undef, ptr undef, ptr null, i64 0)
79 if.end106: ; preds = %for.body28
80 call void @foo(ptr %this, ptr undef, ptr undef, ptr undef, ptr %Offsets, i64 0)