[PATCH] D70509: [JumpThreading] Use profile data even with the new pass manager
Kazu Hirata via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 13:37:35 PST 2019
kazu created this revision.
kazu added reviewers: wmi, eli.friedman.
Herald added subscribers: jfb, hiraditya.
Herald added a project: LLVM.
Without this patch, the jump threading pass ignores profiling data
whenever we invoke the pass with the new pass manager.
Specifically, JumpThreadingPass::run calls runImpl with class variable
HasProfileData always set to false. In turn, runImpl sets
HasProfileData to false again:
HasProfileData = HasProfileData_;
In the end, we don't use profiling data at all with the new pass
manager.
This patch fixes the problem by passing F.hasProfileData() to runImpl.
The bug appears to have been introduced at:
https://reviews.llvm.org/D41461
which removed local variable HasProfileData in JumpThreadingPass::run
even though there was one more use left in the same function. As a
result, the remaining use ended referring to the class variable
instead.
Note that F.hasProfileData is an extremely lightweight function, so I
don't see the need to cache its result. Once this patch is approved,
I'm planning to stop caching the result of F.hasProfileData in
runOnFunction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70509
Files:
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/test/Transforms/JumpThreading/update-edge-weight.ll
Index: llvm/test/Transforms/JumpThreading/update-edge-weight.ll
===================================================================
--- llvm/test/Transforms/JumpThreading/update-edge-weight.ll
+++ llvm/test/Transforms/JumpThreading/update-edge-weight.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -jump-threading %s | FileCheck %s
+; RUN: opt -S -passes=jump-threading %s | FileCheck %s
; Test if edge weights are properly updated after jump threading.
Index: llvm/lib/Transforms/Scalar/JumpThreading.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -340,7 +340,7 @@
BFI.reset(new BlockFrequencyInfo(F, *BPI, LI));
}
- bool Changed = runImpl(F, &TLI, &LVI, &AA, &DTU, HasProfileData,
+ bool Changed = runImpl(F, &TLI, &LVI, &AA, &DTU, F.hasProfileData(),
std::move(BFI), std::move(BPI));
if (!Changed)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70509.230324.patch
Type: text/x-patch
Size: 962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191120/07c80dd1/attachment.bin>
More information about the llvm-commits
mailing list