Skip to content

Commit 07eb7b7

Browse files
[llvm] Replace SmallSet with SmallPtrSet (NFC) (#154068)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>. Note that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer element types: template <typename PointeeType, unsigned N> class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {}; We only have 140 instances that rely on this "redirection", with the vast majority of them under llvm/. Since relying on the redirection doesn't improve readability, this patch replaces SmallSet with SmallPtrSet for pointer element types.
1 parent 0e52092 commit 07eb7b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+120
-123
lines changed

llvm/include/llvm/Analysis/GenericDomTreeUpdaterImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ void GenericDomTreeUpdater<DerivedT, DomTreeT, PostDomTreeT>::
383383
// field of all the elements of Edges.
384384
// I.e., forall elt in Edges, it exists BB in NewBBs
385385
// such as BB == elt.NewBB.
386-
SmallSet<BasicBlockT *, 32> NewBBs;
386+
SmallPtrSet<BasicBlockT *, 32> NewBBs;
387387
for (auto &Edge : Edges)
388388
NewBBs.insert(Edge.NewBB);
389389
// For each element in Edges, remember whether or not element

llvm/include/llvm/CodeGen/GlobalISel/LoadStoreOpt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class LLVM_ABI LoadStoreOpt : public MachineFunctionPass {
162162
DenseMap<unsigned, BitVector> LegalStoreSizes;
163163
bool IsPreLegalizer = false;
164164
/// Contains instructions to be erased at the end of a block scan.
165-
SmallSet<MachineInstr *, 16> InstsToErase;
165+
SmallPtrSet<MachineInstr *, 16> InstsToErase;
166166

167167
public:
168168
LoadStoreOpt();

llvm/include/llvm/CodeGen/MachinePipeliner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ class SMSchedule {
830830
return ScheduledInstrs[cycle];
831831
}
832832

833-
SmallSet<SUnit *, 8>
833+
SmallPtrSet<SUnit *, 8>
834834
computeUnpipelineableNodes(SwingSchedulerDAG *SSD,
835835
TargetInstrInfo::PipelinerLoopInfo *PLI);
836836

llvm/include/llvm/CodeGen/ScheduleDAG.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class TargetRegisterInfo;
237237
};
238238

239239
/// Keep record of which SUnit are in the same cluster group.
240-
typedef SmallSet<SUnit *, 8> ClusterInfo;
240+
typedef SmallPtrSet<SUnit *, 8> ClusterInfo;
241241
constexpr unsigned InvalidClusterId = ~0u;
242242

243243
/// Return whether the input cluster ID's are the same and valid.

llvm/lib/Analysis/CallPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CallGraphDOTInfo {
7070

7171
for (Function &F : M->getFunctionList()) {
7272
uint64_t localSumFreq = 0;
73-
SmallSet<Function *, 16> Callers;
73+
SmallPtrSet<Function *, 16> Callers;
7474
for (User *U : F.users())
7575
if (isa<CallInst>(U))
7676
Callers.insert(cast<Instruction>(U)->getFunction());
@@ -99,7 +99,7 @@ class CallGraphDOTInfo {
9999

100100
bool FoundParallelEdge = true;
101101
while (FoundParallelEdge) {
102-
SmallSet<Function *, 16> Visited;
102+
SmallPtrSet<Function *, 16> Visited;
103103
FoundParallelEdge = false;
104104
for (auto CI = Node->begin(), CE = Node->end(); CI != CE; CI++) {
105105
if (!(Visited.insert(CI->second->getFunction())).second) {

llvm/lib/Analysis/CaptureTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
405405

406406
SmallVector<const Use *, 20> Worklist;
407407
Worklist.reserve(getDefaultMaxUsesToExploreForCaptureTracking());
408-
SmallSet<const Use *, 20> Visited;
408+
SmallPtrSet<const Use *, 20> Visited;
409409

410410
auto AddUses = [&](const Value *V) {
411411
for (const Use &U : V->uses()) {

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7284,7 +7284,7 @@ ScalarEvolution::getDefiningScopeBound(ArrayRef<const SCEV *> Ops,
72847284
bool &Precise) {
72857285
Precise = true;
72867286
// Do a bounded search of the def relation of the requested SCEVs.
7287-
SmallSet<const SCEV *, 16> Visited;
7287+
SmallPtrSet<const SCEV *, 16> Visited;
72887288
SmallVector<const SCEV *> Worklist;
72897289
auto pushOp = [&](const SCEV *S) {
72907290
if (!Visited.insert(S).second)

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7785,7 +7785,7 @@ bool llvm::mustExecuteUBIfPoisonOnPathTo(Instruction *Root,
77857785

77867786
// The set of all recursive users we've visited (which are assumed to all be
77877787
// poison because of said visit)
7788-
SmallSet<const Value *, 16> KnownPoison;
7788+
SmallPtrSet<const Value *, 16> KnownPoison;
77897789
SmallVector<const Instruction*, 16> Worklist;
77907790
Worklist.push_back(Root);
77917791
while (!Worklist.empty()) {
@@ -8140,8 +8140,8 @@ static bool programUndefinedIfUndefOrPoison(const Value *V,
81408140

81418141
// Set of instructions that we have proved will yield poison if Inst
81428142
// does.
8143-
SmallSet<const Value *, 16> YieldsPoison;
8144-
SmallSet<const BasicBlock *, 4> Visited;
8143+
SmallPtrSet<const Value *, 16> YieldsPoison;
8144+
SmallPtrSet<const BasicBlock *, 4> Visited;
81458145

81468146
YieldsPoison.insert(V);
81478147
Visited.insert(BB);

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ class CodeGenPrepare {
377377
/// to be optimized again.
378378
/// Note: Consider building time in this pass, when a BB updated, we need
379379
/// to insert such BB into FreshBBs for huge function.
380-
SmallSet<BasicBlock *, 32> FreshBBs;
380+
SmallPtrSet<BasicBlock *, 32> FreshBBs;
381381

382382
void releaseMemory() {
383383
// Clear per function information.
@@ -1105,7 +1105,7 @@ bool CodeGenPrepare::canMergeBlocks(const BasicBlock *BB,
11051105

11061106
/// Replace all old uses with new ones, and push the updated BBs into FreshBBs.
11071107
static void replaceAllUsesWith(Value *Old, Value *New,
1108-
SmallSet<BasicBlock *, 32> &FreshBBs,
1108+
SmallPtrSet<BasicBlock *, 32> &FreshBBs,
11091109
bool IsHuge) {
11101110
auto *OldI = dyn_cast<Instruction>(Old);
11111111
if (OldI) {
@@ -2135,7 +2135,7 @@ static bool isRemOfLoopIncrementWithLoopInvariant(
21352135
// Rem = rem == RemAmtLoopInvariant ? 0 : Rem;
21362136
static bool foldURemOfLoopIncrement(Instruction *Rem, const DataLayout *DL,
21372137
const LoopInfo *LI,
2138-
SmallSet<BasicBlock *, 32> &FreshBBs,
2138+
SmallPtrSet<BasicBlock *, 32> &FreshBBs,
21392139
bool IsHuge) {
21402140
Value *AddOffset, *RemAmt, *AddInst;
21412141
PHINode *LoopIncrPN;
@@ -2534,11 +2534,10 @@ static bool OptimizeExtractBits(BinaryOperator *ShiftI, ConstantInt *CI,
25342534
/// %ctz = phi i64 [ 64, %entry ], [ %z, %cond.false ]
25352535
///
25362536
/// If the transform is performed, return true and set ModifiedDT to true.
2537-
static bool despeculateCountZeros(IntrinsicInst *CountZeros,
2538-
LoopInfo &LI,
2537+
static bool despeculateCountZeros(IntrinsicInst *CountZeros, LoopInfo &LI,
25392538
const TargetLowering *TLI,
25402539
const DataLayout *DL, ModifyDT &ModifiedDT,
2541-
SmallSet<BasicBlock *, 32> &FreshBBs,
2540+
SmallPtrSet<BasicBlock *, 32> &FreshBBs,
25422541
bool IsHugeFunc) {
25432542
// If a zero input is undefined, it doesn't make sense to despeculate that.
25442543
if (match(CountZeros->getOperand(1), m_One()))
@@ -4351,7 +4350,7 @@ class AddressingModeCombiner {
43514350
PhiNodeSet &PhiNodesToMatch) {
43524351
SmallVector<PHIPair, 8> WorkList;
43534352
Matcher.insert({PHI, Candidate});
4354-
SmallSet<PHINode *, 8> MatchedPHIs;
4353+
SmallPtrSet<PHINode *, 8> MatchedPHIs;
43554354
MatchedPHIs.insert(PHI);
43564355
WorkList.push_back({PHI, Candidate});
43574356
SmallSet<PHIPair, 8> Visited;
@@ -8635,7 +8634,7 @@ static bool tryUnmergingGEPsAcrossIndirectBr(GetElementPtrInst *GEPI,
86358634
}
86368635

86378636
static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
8638-
SmallSet<BasicBlock *, 32> &FreshBBs,
8637+
SmallPtrSet<BasicBlock *, 32> &FreshBBs,
86398638
bool IsHugeFunc) {
86408639
// Try and convert
86418640
// %c = icmp ult %x, 8

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3517,7 +3517,7 @@ void IRTranslator::finishPendingPhis() {
35173517
Verifier.setCurrentInst(PI);
35183518
#endif // ifndef NDEBUG
35193519

3520-
SmallSet<const MachineBasicBlock *, 16> SeenPreds;
3520+
SmallPtrSet<const MachineBasicBlock *, 16> SeenPreds;
35213521
for (unsigned i = 0; i < PI->getNumIncomingValues(); ++i) {
35223522
auto IRPred = PI->getIncomingBlock(i);
35233523
ArrayRef<Register> ValRegs = getOrCreateVRegs(*PI->getIncomingValue(i));

0 commit comments

Comments
 (0)