[llvm] e9a47a6 - [llvm] Construct SmallVector with ArrayRef (NFC) (#102712)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 21:39:17 PDT 2024
Author: Kazu Hirata
Date: 2024-08-09T21:39:13-07:00
New Revision: e9a47a664a67b188c553e04232f9b445890a83b2
URL: https://github.com/llvm/llvm-project/commit/e9a47a664a67b188c553e04232f9b445890a83b2
DIFF: https://github.com/llvm/llvm-project/commit/e9a47a664a67b188c553e04232f9b445890a83b2.diff
LOG: [llvm] Construct SmallVector with ArrayRef (NFC) (#102712)
Without this patch, the constructor arguments come from
SmallVectorImpl, not ArrayRef. This patch switches them to ArrayRef
so that we can construct SmallVector with a single argument.
Note that LLVM Programmer’s Manual prefers ArrayRef to SmallVectorImpl
for flexibility.
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Transforms/Utils/LCSSA.cpp
llvm/utils/TableGen/Common/DAGISelMatcher.cpp
llvm/utils/TableGen/Common/DAGISelMatcher.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 1081357e734a6a..f413e77877f903 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -427,9 +427,7 @@ class SCEVUnionPredicate final : public SCEVPredicate {
public:
SCEVUnionPredicate(ArrayRef<const SCEVPredicate *> Preds);
- const SmallVectorImpl<const SCEVPredicate *> &getPredicates() const {
- return Preds;
- }
+ ArrayRef<const SCEVPredicate *> getPredicates() const { return Preds; }
/// Implementation of the SCEVPredicate interface
bool isAlwaysTrue() const override;
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a5ebd5c554c3d9..632b298576aabe 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -14914,8 +14914,7 @@ void PredicatedScalarEvolution::addPredicate(const SCEVPredicate &Pred) {
if (Preds->implies(&Pred))
return;
- auto &OldPreds = Preds->getPredicates();
- SmallVector<const SCEVPredicate*, 4> NewPreds(OldPreds.begin(), OldPreds.end());
+ SmallVector<const SCEVPredicate *, 4> NewPreds(Preds->getPredicates());
NewPreds.push_back(&Pred);
Preds = std::make_unique<SCEVUnionPredicate>(NewPreds);
updateGeneration();
diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp
index f92e921949a080..d76a0c2e4ce75c 100644
--- a/llvm/lib/Transforms/Utils/LCSSA.cpp
+++ b/llvm/lib/Transforms/Utils/LCSSA.cpp
@@ -335,12 +335,11 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist,
// Compute the set of BasicBlocks in the loop `L` dominating at least one exit.
static void computeBlocksDominatingExits(
- Loop &L, const DominatorTree &DT,
- const SmallVectorImpl<BasicBlock *> &ExitBlocks,
+ Loop &L, const DominatorTree &DT, ArrayRef<BasicBlock *> ExitBlocks,
SmallSetVector<BasicBlock *, 8> &BlocksDominatingExits) {
// We start from the exit blocks, as every block trivially dominates itself
// (not strictly).
- SmallVector<BasicBlock *, 8> BBWorklist(ExitBlocks.begin(), ExitBlocks.end());
+ SmallVector<BasicBlock *, 8> BBWorklist(ExitBlocks);
while (!BBWorklist.empty()) {
BasicBlock *BB = BBWorklist.pop_back_val();
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
index 71bbeaaba9a91e..d235114871b52c 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
@@ -91,10 +91,10 @@ SwitchTypeMatcher::~SwitchTypeMatcher() {
delete C.second;
}
-CheckPredicateMatcher::CheckPredicateMatcher(
- const TreePredicateFn &pred, const SmallVectorImpl<unsigned> &Ops)
+CheckPredicateMatcher::CheckPredicateMatcher(const TreePredicateFn &pred,
+ ArrayRef<unsigned> Ops)
: Matcher(CheckPredicate), Pred(pred.getOrigPatFragRecord()),
- Operands(Ops.begin(), Ops.end()) {}
+ Operands(Ops) {}
TreePredicateFn CheckPredicateMatcher::getPredicate() const {
return TreePredicateFn(Pred);
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.h b/llvm/utils/TableGen/Common/DAGISelMatcher.h
index d001a5ad8084bf..999206e995d166 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.h
@@ -452,7 +452,7 @@ class CheckPredicateMatcher : public Matcher {
public:
CheckPredicateMatcher(const TreePredicateFn &pred,
- const SmallVectorImpl<unsigned> &Operands);
+ ArrayRef<unsigned> Operands);
TreePredicateFn getPredicate() const;
unsigned getNumOperands() const;
More information about the llvm-commits
mailing list