summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Pass.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2019-02-28 04:00:55 +0000
committerRichard Trieu <rtrieu@google.com>2019-02-28 04:00:55 +0000
commitb37a70f40e1229d44b967c339f65f4acfd56b0ce (patch)
tree77aca85d12ab502d09cec645c3e871d8b1fefb5b /llvm/lib/IR/Pass.cpp
parent14d58f598691b8c27d8b4a4cf6181178f1a8c295 (diff)
downloadbcm5719-llvm-b37a70f40e1229d44b967c339f65f4acfd56b0ce.tar.gz
bcm5719-llvm-b37a70f40e1229d44b967c339f65f4acfd56b0ce.zip
Fix IR/Analysis layering issue with OptBisect
OptBisect is in IR due to LLVMContext using it. However, it uses IR units from Analysis as well. This change moves getDescription functions from OptBisect to their respective IR units. Generating names for IR units will now be up to the callers, keeping the Analysis IR units in Analysis. To prevent unnecessary string generation, isEnabled function is added so that callers know when the description needs to be generated. Differential Revision: https://reviews.llvm.org/D58406 llvm-svn: 355068
Diffstat (limited to 'llvm/lib/IR/Pass.cpp')
-rw-r--r--llvm/lib/IR/Pass.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp
index e9a0c68495b..4038205e044 100644
--- a/llvm/lib/IR/Pass.cpp
+++ b/llvm/lib/IR/Pass.cpp
@@ -55,8 +55,13 @@ PassManagerType ModulePass::getPotentialPassManagerType() const {
return PMT_ModulePassManager;
}
+static std::string getDescription(const Module &M) {
+ return "module (" + M.getName().str() + ")";
+}
+
bool ModulePass::skipModule(Module &M) const {
- return !M.getContext().getOptPassGate().shouldRunPass(this, M);
+ OptPassGate &Gate = M.getContext().getOptPassGate();
+ return Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(M));
}
bool Pass::mustPreserveAnalysisID(char &AID) const {
@@ -154,8 +159,13 @@ PassManagerType FunctionPass::getPotentialPassManagerType() const {
return PMT_FunctionPassManager;
}
+static std::string getDescription(const Function &F) {
+ return "function (" + F.getName().str() + ")";
+}
+
bool FunctionPass::skipFunction(const Function &F) const {
- if (!F.getContext().getOptPassGate().shouldRunPass(this, F))
+ OptPassGate &Gate = F.getContext().getOptPassGate();
+ if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(F)))
return true;
if (F.hasFnAttribute(Attribute::OptimizeNone)) {
@@ -185,11 +195,17 @@ bool BasicBlockPass::doFinalization(Function &) {
return false;
}
+static std::string getDescription(const BasicBlock &BB) {
+ return "basic block (" + BB.getName().str() + ") in function (" +
+ BB.getParent()->getName().str() + ")";
+}
+
bool BasicBlockPass::skipBasicBlock(const BasicBlock &BB) const {
const Function *F = BB.getParent();
if (!F)
return false;
- if (!F->getContext().getOptPassGate().shouldRunPass(this, BB))
+ OptPassGate &Gate = F->getContext().getOptPassGate();
+ if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(BB)))
return true;
if (F->hasFnAttribute(Attribute::OptimizeNone)) {
// Report this only once per function.
OpenPOWER on IntegriCloud