llvm.org GIT mirror llvm / 7313cf8
[JumpThreading] Add an option to dump LazyValueInfo after the run. Differential Revision: https://reviews.llvm.org/D35973 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309353 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 2 years ago
2 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
6363 "condition to use to thread over a weaker condition"),
6464 cl::init(3), cl::Hidden);
6565
66 static cl::opt PrintLVIAfterJumpThreading(
67 "print-lvi-after-jump-threading",
68 cl::desc("Print the LazyValueInfo cache after JumpThreading"), cl::init(false),
69 cl::Hidden);
70
6671 namespace {
6772 /// This pass performs 'jump threading', which looks at blocks that have
6873 /// multiple predecessors and multiple successors. If one or more of the
9297 bool runOnFunction(Function &F) override;
9398
9499 void getAnalysisUsage(AnalysisUsage &AU) const override {
100 if (PrintLVIAfterJumpThreading)
101 AU.addRequired();
95102 AU.addRequired();
96103 AU.addRequired();
97104 AU.addPreserved();
136143 BFI.reset(new BlockFrequencyInfo(F, *BPI, LI));
137144 }
138145
139 return Impl.runImpl(F, TLI, LVI, AA, HasProfileData, std::move(BFI),
140 std::move(BPI));
146 bool Changed = Impl.runImpl(F, TLI, LVI, AA, HasProfileData, std::move(BFI),
147 std::move(BPI));
148 if (PrintLVIAfterJumpThreading) {
149 dbgs() << "LVI for function '" << F.getName() << "':\n";
150 LVI->printLVI(F, getAnalysis().getDomTree(),
151 dbgs());
152 }
153 return Changed;
141154 }
142155
143156 PreservedAnalyses JumpThreadingPass::run(Function &F,
None ; RUN: opt < %s -jump-threading -print-lazy-value-info -disable-output 2>&1 | FileCheck %s
0 ; RUN: opt < %s -jump-threading -print-lvi-after-jump-threading -disable-output 2>&1 | FileCheck %s
11
22 ; Testing LVI cache after jump-threading
33
1818 ; CHECK-NEXT: ; LatticeVal for: 'i32 %a' is: overdefined
1919 ; CHECK-NEXT: ; LatticeVal for: 'i32 %length' is: overdefined
2020 ; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%backedge' is: constantrange<0, 400>
21 ; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%exit' is: constantrange<399, 400>
2221 ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
2322 ; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%backedge' is: constantrange<1, 401>
24 ; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%exit' is: constantrange<400, 401>
2523 ; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1
2624 ; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%backedge' is: overdefined
27 ; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%exit' is: constantrange<0, -1>
2825 ; CHECK-NEXT: %cont = icmp slt i32 %iv.next, 400
2926 ; CHECK-NOT: loop
3027 loop: