[llvm] [llvm] Construct SmallVector with ArrayRef (NFC) (PR #102712)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 19:37:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/102712.diff
5 Files Affected:
- (modified) llvm/include/llvm/Analysis/ScalarEvolution.h (+1-3)
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+1-2)
- (modified) llvm/lib/Transforms/Utils/LCSSA.cpp (+2-3)
- (modified) llvm/utils/TableGen/Common/DAGISelMatcher.cpp (+3-3)
- (modified) llvm/utils/TableGen/Common/DAGISelMatcher.h (+1-1)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/102712
More information about the llvm-commits
mailing list