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 2 3; REQUIRES: asserts 4 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 15; PDT). 16 17; CHECK-NOT: <badref> 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 28; CHECK-NOT: <badref> 29 30declare hidden i1 @compare(ptr) align 2 31declare hidden { i8, ptr } @getType(ptr) align 2 32 33define internal void @foo(ptr %TLI, ptr %DL, ptr %Ty, ptr %ValueVTs, ptr %Offsets, i64 %StartingOffset, i1 %arg) { 34entry: 35 %VT = alloca i64, align 8 36 br i1 false, label %if.then, label %if.end4 37 38if.then: ; preds = %entry 39 ret void 40 41if.end4: ; preds = %entry 42 %cmp = call zeroext i1 @compare(ptr undef) 43 br i1 %cmp, label %for.body, label %for.cond16 44 45for.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) 48 unreachable 49 50for.cond16: ; preds = %for.cond34, %if.end4 51 %call27 = call { i8, ptr } @getType(ptr %VT) 52 br label %for.cond34 53 54for.cond34: ; preds = %for.body37, %for.cond16 55 br i1 %arg, label %for.body37, label %for.cond16 56 57for.body37: ; preds = %for.cond34 58 %tobool39 = icmp ne ptr %Offsets, null 59 br label %for.cond34 60} 61 62define hidden { ptr, i32 } @bar(ptr %this) { 63entry: 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 67 68for.cond.cleanup27: ; preds = %entry 69 ret { ptr, i32 } undef 70 71for.body28: ; preds = %entry 72 %call33 = call zeroext i1 @compare(ptr undef) 73 br i1 %call33, label %if.then34, label %if.end106 74 75if.then34: ; preds = %for.body28 76 call void @foo(ptr %this, ptr undef, ptr undef, ptr undef, ptr null, i64 0) 77 unreachable 78 79if.end106: ; preds = %for.body28 80 call void @foo(ptr %this, ptr undef, ptr undef, ptr undef, ptr %Offsets, i64 0) 81 unreachable 82} 83 84