Skip to content

Commit e9a47a6

Browse files
[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.
1 parent e0ddd42 commit e9a47a6

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ class SCEVUnionPredicate final : public SCEVPredicate {
427427
public:
428428
SCEVUnionPredicate(ArrayRef<const SCEVPredicate *> Preds);
429429

430-
const SmallVectorImpl<const SCEVPredicate *> &getPredicates() const {
431-
return Preds;
432-
}
430+
ArrayRef<const SCEVPredicate *> getPredicates() const { return Preds; }
433431

434432
/// Implementation of the SCEVPredicate interface
435433
bool isAlwaysTrue() const override;

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14914,8 +14914,7 @@ void PredicatedScalarEvolution::addPredicate(const SCEVPredicate &Pred) {
1491414914
if (Preds->implies(&Pred))
1491514915
return;
1491614916

14917-
auto &OldPreds = Preds->getPredicates();
14918-
SmallVector<const SCEVPredicate*, 4> NewPreds(OldPreds.begin(), OldPreds.end());
14917+
SmallVector<const SCEVPredicate *, 4> NewPreds(Preds->getPredicates());
1491914918
NewPreds.push_back(&Pred);
1492014919
Preds = std::make_unique<SCEVUnionPredicate>(NewPreds);
1492114920
updateGeneration();

llvm/lib/Transforms/Utils/LCSSA.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,11 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist,
335335

336336
// Compute the set of BasicBlocks in the loop `L` dominating at least one exit.
337337
static void computeBlocksDominatingExits(
338-
Loop &L, const DominatorTree &DT,
339-
const SmallVectorImpl<BasicBlock *> &ExitBlocks,
338+
Loop &L, const DominatorTree &DT, ArrayRef<BasicBlock *> ExitBlocks,
340339
SmallSetVector<BasicBlock *, 8> &BlocksDominatingExits) {
341340
// We start from the exit blocks, as every block trivially dominates itself
342341
// (not strictly).
343-
SmallVector<BasicBlock *, 8> BBWorklist(ExitBlocks.begin(), ExitBlocks.end());
342+
SmallVector<BasicBlock *, 8> BBWorklist(ExitBlocks);
344343

345344
while (!BBWorklist.empty()) {
346345
BasicBlock *BB = BBWorklist.pop_back_val();

llvm/utils/TableGen/Common/DAGISelMatcher.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ SwitchTypeMatcher::~SwitchTypeMatcher() {
9191
delete C.second;
9292
}
9393

94-
CheckPredicateMatcher::CheckPredicateMatcher(
95-
const TreePredicateFn &pred, const SmallVectorImpl<unsigned> &Ops)
94+
CheckPredicateMatcher::CheckPredicateMatcher(const TreePredicateFn &pred,
95+
ArrayRef<unsigned> Ops)
9696
: Matcher(CheckPredicate), Pred(pred.getOrigPatFragRecord()),
97-
Operands(Ops.begin(), Ops.end()) {}
97+
Operands(Ops) {}
9898

9999
TreePredicateFn CheckPredicateMatcher::getPredicate() const {
100100
return TreePredicateFn(Pred);

llvm/utils/TableGen/Common/DAGISelMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class CheckPredicateMatcher : public Matcher {
452452

453453
public:
454454
CheckPredicateMatcher(const TreePredicateFn &pred,
455-
const SmallVectorImpl<unsigned> &Operands);
455+
ArrayRef<unsigned> Operands);
456456

457457
TreePredicateFn getPredicate() const;
458458
unsigned getNumOperands() const;

0 commit comments

Comments
 (0)