Skip to content

Commit 29f03bf

Browse files
committed
[GuardWidening] Require analyses only if necessary
We need to request analyses needed for guard widening only if there are guards/widenable conditions.
1 parent 3d131f9 commit 29f03bf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llvm/lib/Transforms/Scalar/GuardWidening.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,15 @@ StringRef GuardWideningImpl::scoreTypeToString(WideningScore WS) {
962962

963963
PreservedAnalyses GuardWideningPass::run(Function &F,
964964
FunctionAnalysisManager &AM) {
965+
// Avoid requesting analyses if there are no guards or widenable conditions.
966+
auto *GuardDecl = F.getParent()->getFunction(
967+
Intrinsic::getName(Intrinsic::experimental_guard));
968+
bool HasIntrinsicGuards = GuardDecl && !GuardDecl->use_empty();
969+
auto *WCDecl = F.getParent()->getFunction(
970+
Intrinsic::getName(Intrinsic::experimental_widenable_condition));
971+
bool HasWidenableConditions = WCDecl && !WCDecl->use_empty();
972+
if (!HasIntrinsicGuards && !HasWidenableConditions)
973+
return PreservedAnalyses::all();
965974
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
966975
auto &LI = AM.getResult<LoopAnalysis>(F);
967976
auto &PDT = AM.getResult<PostDominatorTreeAnalysis>(F);

0 commit comments

Comments
 (0)