Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c7dfa21

Browse files
dccialexcrichton
authored andcommitted
[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
1 parent 241dc46 commit c7dfa21

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/Transforms/Scalar/JumpThreading.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ ImplicationSearchThreshold(
6464
"condition to use to thread over a weaker condition"),
6565
cl::init(3), cl::Hidden);
6666

67+
static cl::opt<bool> PrintLVIAfterJumpThreading(
68+
"print-lvi-after-jump-threading",
69+
cl::desc("Print the LazyValueInfo cache after JumpThreading"), cl::init(false),
70+
cl::Hidden);
71+
6772
namespace {
6873
/// This pass performs 'jump threading', which looks at blocks that have
6974
/// multiple predecessors and multiple successors. If one or more of the
@@ -93,6 +98,8 @@ namespace {
9398
bool runOnFunction(Function &F) override;
9499

95100
void getAnalysisUsage(AnalysisUsage &AU) const override {
101+
if (PrintLVIAfterJumpThreading)
102+
AU.addRequired<DominatorTreeWrapperPass>();
96103
AU.addRequired<AAResultsWrapperPass>();
97104
AU.addRequired<LazyValueInfoWrapperPass>();
98105
AU.addPreserved<LazyValueInfoWrapperPass>();
@@ -137,8 +144,14 @@ bool JumpThreading::runOnFunction(Function &F) {
137144
BFI.reset(new BlockFrequencyInfo(F, *BPI, LI));
138145
}
139146

140-
return Impl.runImpl(F, TLI, LVI, AA, HasProfileData, std::move(BFI),
141-
std::move(BPI));
147+
bool Changed = Impl.runImpl(F, TLI, LVI, AA, HasProfileData, std::move(BFI),
148+
std::move(BPI));
149+
if (PrintLVIAfterJumpThreading) {
150+
dbgs() << "LVI for function '" << F.getName() << "':\n";
151+
LVI->printLVI(F, getAnalysis<DominatorTreeWrapperPass>().getDomTree(),
152+
dbgs());
153+
}
154+
return Changed;
142155
}
143156

144157
PreservedAnalyses JumpThreadingPass::run(Function &F,

test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -jump-threading -print-lazy-value-info -disable-output 2>&1 | FileCheck %s
1+
; RUN: opt < %s -jump-threading -print-lvi-after-jump-threading -disable-output 2>&1 | FileCheck %s
22

33
; Testing LVI cache after jump-threading
44

@@ -19,13 +19,10 @@ entry:
1919
; CHECK-NEXT: ; LatticeVal for: 'i32 %a' is: overdefined
2020
; CHECK-NEXT: ; LatticeVal for: 'i32 %length' is: overdefined
2121
; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%backedge' is: constantrange<0, 400>
22-
; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%exit' is: constantrange<399, 400>
2322
; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
2423
; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%backedge' is: constantrange<1, 401>
25-
; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%exit' is: constantrange<400, 401>
2624
; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1
2725
; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%backedge' is: overdefined
28-
; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%exit' is: constantrange<0, -1>
2926
; CHECK-NEXT: %cont = icmp slt i32 %iv.next, 400
3027
; CHECK-NOT: loop
3128
loop:

0 commit comments

Comments
 (0)