From b37a70f40e1229d44b967c339f65f4acfd56b0ce Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Thu, 28 Feb 2019 04:00:55 +0000 Subject: 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 --- llvm/lib/Analysis/RegionPass.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Analysis/RegionPass.cpp') diff --git a/llvm/lib/Analysis/RegionPass.cpp b/llvm/lib/Analysis/RegionPass.cpp index 0e43af65e6c..901adbf27d9 100644 --- a/llvm/lib/Analysis/RegionPass.cpp +++ b/llvm/lib/Analysis/RegionPass.cpp @@ -278,9 +278,14 @@ Pass *RegionPass::createPrinterPass(raw_ostream &O, return new PrintRegionPass(Banner, O); } +static std::string getDescription(const Region &R) { + return "region"; +} + bool RegionPass::skipRegion(Region &R) const { Function &F = *R.getEntry()->getParent(); - if (!F.getContext().getOptPassGate().shouldRunPass(this, R)) + OptPassGate &Gate = F.getContext().getOptPassGate(); + if (Gate.isEnabled() && Gate.shouldRunPass(this, getDescription(R))) return true; if (F.hasFnAttribute(Attribute::OptimizeNone)) { -- cgit v1.2.3