Skip to content

Commit 8e580b7

Browse files
committed
[NFC][SetVector] Update some usages of SetVector to SmallSetVector
This patch is a continuation of D152497. It updates usages of SetVector that were found in llvm/ and clang/ which were originally specifying either SmallPtrSet or SmallVector to just using SmallSetVector, as the overhead of SetVector is reduced with D152497. This also helps clean up the code a fair bit, and gives a decent speed boost at -O0 (~0.2%): https://llvm-compile-time-tracker.com/compare.php?from=9ffdabecabcddde298ff313f5353f9e06590af62&to=97f1c0cde42ba85eaa67cbe89bec8fe45b801f21&stat=instructions%3Au Differential Revision: https://reviews.llvm.org/D152522
1 parent 6e3a872 commit 8e580b7

File tree

8 files changed

+11
-20
lines changed

8 files changed

+11
-20
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,7 @@ class Sema final {
792792
/// we won't know until all lvalue-to-rvalue and discarded value conversions
793793
/// have been applied to all subexpressions of the enclosing full expression.
794794
/// This is cleared at the end of each full expression.
795-
using MaybeODRUseExprSet = llvm::SetVector<Expr *, SmallVector<Expr *, 4>,
796-
llvm::SmallPtrSet<Expr *, 4>>;
795+
using MaybeODRUseExprSet = llvm::SmallSetVector<Expr *, 4>;
797796
MaybeODRUseExprSet MaybeODRUseExprs;
798797

799798
std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;

clang/lib/Sema/SemaOverload.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8024,8 +8024,7 @@ namespace {
80248024
/// enumeration types.
80258025
class BuiltinCandidateTypeSet {
80268026
/// TypeSet - A set of types.
8027-
typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
8028-
llvm::SmallPtrSet<QualType, 8>> TypeSet;
8027+
typedef llvm::SmallSetVector<QualType, 8> TypeSet;
80298028

80308029
/// PointerTypes - The set of pointer types that will be used in the
80318030
/// built-in candidates.

clang/lib/Sema/SemaStmt.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,7 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
17291729

17301730
namespace {
17311731
// Use SetVector since the diagnostic cares about the ordering of the Decl's.
1732-
using DeclSetVector =
1733-
llvm::SetVector<VarDecl *, llvm::SmallVector<VarDecl *, 8>,
1734-
llvm::SmallPtrSet<VarDecl *, 8>>;
1732+
using DeclSetVector = llvm::SmallSetVector<VarDecl *, 8>;
17351733

17361734
// This visitor will traverse a conditional statement and store all
17371735
// the evaluated decls into a vector. Simple is set to true if none

llvm/include/llvm/ADT/GenericCycleInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#ifndef LLVM_ADT_GENERICCYCLEINFO_H
2929
#define LLVM_ADT_GENERICCYCLEINFO_H
3030

31+
#include "llvm/ADT/DenseSet.h"
3132
#include "llvm/ADT/GenericSSAContext.h"
3233
#include "llvm/ADT/GraphTraits.h"
3334
#include "llvm/ADT/SetVector.h"
34-
#include "llvm/ADT/SmallPtrSet.h"
3535
#include "llvm/Support/Debug.h"
3636
#include "llvm/Support/raw_ostream.h"
3737

@@ -64,7 +64,7 @@ template <typename ContextT> class GenericCycle {
6464
/// Basic blocks that are contained in the cycle, including entry blocks,
6565
/// and including blocks that are part of a child cycle.
6666
using BlockSetVectorT = SetVector<BlockT *, SmallVector<BlockT *, 8>,
67-
SmallPtrSet<const BlockT *, 8>>;
67+
DenseSet<const BlockT *>, 8>;
6868
BlockSetVectorT Blocks;
6969

7070
/// Depth of the cycle in the tree. The root "cycle" is at depth 0.

llvm/include/llvm/CodeGen/LiveRangeEdit.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ class LiveRangeEdit : private MachineRegisterInfo::Delegate {
9797
/// a load, eliminate the register by folding the def into the use.
9898
bool foldAsLoad(LiveInterval *LI, SmallVectorImpl<MachineInstr *> &Dead);
9999

100-
using ToShrinkSet = SetVector<LiveInterval *, SmallVector<LiveInterval *, 8>,
101-
SmallPtrSet<LiveInterval *, 8>>;
100+
using ToShrinkSet = SmallSetVector<LiveInterval *, 8>;
102101

103102
/// Helper for eliminateDeadDefs.
104103
void eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink);

llvm/include/llvm/Transforms/Scalar/SROA.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class SROAPass : public PassInfoMixin<SROAPass> {
105105
/// directly promoted. Finally, each time we rewrite a use of an alloca other
106106
/// the one being actively rewritten, we add it back onto the list if not
107107
/// already present to ensure it is re-visited.
108-
SetVector<AllocaInst *, SmallVector<AllocaInst *, 16>> Worklist;
108+
SmallSetVector<AllocaInst *, 16> Worklist;
109109

110110
/// A collection of instructions to delete.
111111
/// We try to batch deletions to simplify code and make things a bit more
@@ -120,7 +120,7 @@ class SROAPass : public PassInfoMixin<SROAPass> {
120120
///
121121
/// Note that we have to be very careful to clear allocas out of this list in
122122
/// the event they are deleted.
123-
SetVector<AllocaInst *, SmallVector<AllocaInst *, 16>> PostPromotionWorklist;
123+
SmallSetVector<AllocaInst *, 16> PostPromotionWorklist;
124124

125125
/// A collection of alloca instructions we can directly promote.
126126
std::vector<AllocaInst *> PromotableAllocas;
@@ -130,7 +130,7 @@ class SROAPass : public PassInfoMixin<SROAPass> {
130130
/// All of these PHIs have been checked for the safety of speculation and by
131131
/// being speculated will allow promoting allocas currently in the promotable
132132
/// queue.
133-
SetVector<PHINode *, SmallVector<PHINode *, 8>> SpeculatablePHIs;
133+
SmallSetVector<PHINode *, 8> SpeculatablePHIs;
134134

135135
/// A worklist of select instructions to rewrite prior to promoting
136136
/// allocas.

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,9 +2680,7 @@ InlineResult CallAnalyzer::analyze() {
26802680
// basic blocks in a breadth-first order as we insert live successors. To
26812681
// accomplish this, prioritizing for small iterations because we exit after
26822682
// crossing our threshold, we use a small-size optimized SetVector.
2683-
typedef SetVector<BasicBlock *, SmallVector<BasicBlock *, 16>,
2684-
SmallPtrSet<BasicBlock *, 16>>
2685-
BBSetVector;
2683+
typedef SmallSetVector<BasicBlock *, 16> BBSetVector;
26862684
BBSetVector BBWorklist;
26872685
BBWorklist.insert(&F.getEntryBlock());
26882686

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ class DwarfDebug : public DebugHandlerBase {
318318

319319
/// This is a collection of subprogram MDNodes that are processed to
320320
/// create DIEs.
321-
SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
322-
SmallPtrSet<const DISubprogram *, 16>>
323-
ProcessedSPNodes;
321+
SmallSetVector<const DISubprogram *, 16> ProcessedSPNodes;
324322

325323
/// If nonnull, stores the current machine function we're processing.
326324
const MachineFunction *CurFn = nullptr;

0 commit comments

Comments
 (0)