[llvm] 28f27dd - Check users of instrinsics instead of traversing entire function.NFC
Anna Thomas via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 09:28:56 PDT 2022
Author: Anna Thomas
Date: 2022-04-13T12:28:51-04:00
New Revision: 28f27dd2641739e328ef0bec68a577ff44cbec33
URL: https://github.com/llvm/llvm-project/commit/28f27dd2641739e328ef0bec68a577ff44cbec33
DIFF: https://github.com/llvm/llvm-project/commit/28f27dd2641739e328ef0bec68a577ff44cbec33.diff
LOG: Check users of instrinsics instead of traversing entire function.NFC
Updated LowerGuardIntrinsic and LowerWidenableCondition to check for
users of the respective intrinsic, instead of checking for guards and
widenable conditions by traversing the entire function.
This is an NFC. Should save some compile time.
Added:
Modified:
llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp
llvm/lib/Transforms/Scalar/LowerWidenableCondition.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp
index f9d9c80d03f35..8dc037b10cc8b 100644
--- a/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp
@@ -48,9 +48,13 @@ static bool lowerGuardIntrinsic(Function &F) {
return false;
SmallVector<CallInst *, 8> ToLower;
- for (auto &I : instructions(F))
- if (isGuard(&I))
- ToLower.push_back(cast<CallInst>(&I));
+ // Traverse through the users of GuardDecl.
+ // This is presumably cheaper than traversing all instructions in the
+ // function.
+ for (auto *U : GuardDecl->users())
+ if (auto *CI = dyn_cast<CallInst>(U))
+ if (CI->getFunction() == &F)
+ ToLower.push_back(CI);
if (ToLower.empty())
return false;
diff --git a/llvm/lib/Transforms/Scalar/LowerWidenableCondition.cpp b/llvm/lib/Transforms/Scalar/LowerWidenableCondition.cpp
index 644bf3b8d215c..e2de322933bc1 100644
--- a/llvm/lib/Transforms/Scalar/LowerWidenableCondition.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerWidenableCondition.cpp
@@ -47,9 +47,13 @@ static bool lowerWidenableCondition(Function &F) {
using namespace llvm::PatternMatch;
SmallVector<CallInst *, 8> ToLower;
- for (auto &I : instructions(F))
- if (match(&I, m_Intrinsic<Intrinsic::experimental_widenable_condition>()))
- ToLower.push_back(cast<CallInst>(&I));
+ // Traverse through the users of WCDecl.
+ // This is presumably cheaper than traversing all instructions in the
+ // function.
+ for (auto *U : WCDecl->users())
+ if (auto *CI = dyn_cast<CallInst>(U))
+ if (CI->getFunction() == &F)
+ ToLower.push_back(CI);
if (ToLower.empty())
return false;
More information about the llvm-commits
mailing list