Skip to content

Commit efc787b

Browse files
committed
Fix small remarks
1 parent 586066d commit efc787b

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

llvm/include/llvm/Analysis/AliasSetTracker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class AliasSet : public ilist_node<AliasSet> {
5454
AliasSet *Forward = nullptr;
5555

5656
/// Memory locations in this alias set.
57-
std::vector<MemoryLocation> MemoryLocs;
57+
SmallVector<MemoryLocation, 0> MemoryLocs;
5858

5959
/// All instructions without a specific address in this alias set.
6060
std::vector<AssertingVH<Instruction>> UnknownInsts;
@@ -119,7 +119,7 @@ class AliasSet : public ilist_node<AliasSet> {
119119

120120
// Alias Set iteration - Allow access to all of the memory locations which are
121121
// part of this alias set.
122-
using iterator = std::vector<MemoryLocation>::const_iterator;
122+
using iterator = SmallVectorImpl<MemoryLocation>::const_iterator;
123123
iterator begin() const { return MemoryLocs.begin(); }
124124
iterator end() const { return MemoryLocs.end(); }
125125

llvm/lib/Analysis/AliasSetTracker.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "llvm/Analysis/AliasSetTracker.h"
14+
#include "llvm/ADT/SetVector.h"
1415
#include "llvm/ADT/StringExtras.h"
1516
#include "llvm/Analysis/AliasAnalysis.h"
1617
#include "llvm/Analysis/GuardUtils.h"
@@ -201,23 +202,10 @@ ModRefInfo AliasSet::aliasesUnknownInst(const Instruction *Inst,
201202
}
202203

203204
AliasSet::PointerVector AliasSet::getPointers() const {
204-
// To deduplicate pointer values, use a linear scan if the number of elements
205-
// is small, or a set if large. This is the same idea as SmallSetVector. In
206-
// addition, we can allocate space for the result vector upfront.
207-
PointerVector Result;
208-
if (MemoryLocs.size() <= Result.capacity()) {
209-
for (const MemoryLocation &MemLoc : MemoryLocs)
210-
if (llvm::find(Result, MemLoc.Ptr) == Result.end())
211-
Result.push_back(MemLoc.Ptr);
212-
} else {
213-
Result.reserve(MemoryLocs.size());
214-
DenseSet<const Value *> Seen;
215-
Seen.reserve(MemoryLocs.size());
216-
for (const MemoryLocation &MemLoc : MemoryLocs)
217-
if (Seen.insert(MemLoc.Ptr).second)
218-
Result.push_back(MemLoc.Ptr);
219-
}
220-
return Result;
205+
SmallSetVector<const Value *, 8> Pointers;
206+
for (const MemoryLocation &MemLoc : MemoryLocs)
207+
Pointers.insert(MemLoc.Ptr);
208+
return Pointers.takeVector();
221209
}
222210

223211
void AliasSetTracker::clear() {

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck,
11431143
(NumWritePtrChecks == 1 && NumReadPtrChecks == 0)) {
11441144
assert((ASPointers.size() <= 1 ||
11451145
all_of(ASPointers,
1146-
[this](auto Ptr) {
1146+
[this](const Value *Ptr) {
11471147
MemAccessInfo AccessWrite(const_cast<Value *>(Ptr),
11481148
true);
11491149
return DepCands.findValue(AccessWrite) == DepCands.end();

0 commit comments

Comments
 (0)