[llvm] 29f03bf - [GuardWidening] Require analyses only if necessary
Anna Thomas via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 08:55:37 PST 2023
Author: Anna Thomas
Date: 2023-11-08T11:54:10-05:00
New Revision: 29f03bf48dc128f4276d60124726fc19d625a2f9
URL: https://github.com/llvm/llvm-project/commit/29f03bf48dc128f4276d60124726fc19d625a2f9
DIFF: https://github.com/llvm/llvm-project/commit/29f03bf48dc128f4276d60124726fc19d625a2f9.diff
LOG: [GuardWidening] Require analyses only if necessary
We need to request analyses needed for guard widening only if there are
guards/widenable conditions.
Added:
Modified:
llvm/lib/Transforms/Scalar/GuardWidening.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
index d08820b632e5c1d..e6eccb4fbafd3e1 100644
--- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp
+++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
@@ -962,6 +962,15 @@ StringRef GuardWideningImpl::scoreTypeToString(WideningScore WS) {
PreservedAnalyses GuardWideningPass::run(Function &F,
FunctionAnalysisManager &AM) {
+ // Avoid requesting analyses if there are no guards or widenable conditions.
+ auto *GuardDecl = F.getParent()->getFunction(
+ Intrinsic::getName(Intrinsic::experimental_guard));
+ bool HasIntrinsicGuards = GuardDecl && !GuardDecl->use_empty();
+ auto *WCDecl = F.getParent()->getFunction(
+ Intrinsic::getName(Intrinsic::experimental_widenable_condition));
+ bool HasWidenableConditions = WCDecl && !WCDecl->use_empty();
+ if (!HasIntrinsicGuards && !HasWidenableConditions)
+ return PreservedAnalyses::all();
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
auto &LI = AM.getResult<LoopAnalysis>(F);
auto &PDT = AM.getResult<PostDominatorTreeAnalysis>(F);
More information about the llvm-commits
mailing list