Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/AST/CXXInheritance.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ struct UniqueVirtualMethod {
/// subobject in which that virtual function occurs).
class OverridingMethods {
using ValuesT = SmallVector<UniqueVirtualMethod, 4>;
using MapType = llvm::MapVector<unsigned, ValuesT>;
using MapType = llvm::SmallMapVector<unsigned, ValuesT, 16>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is nested inside another MapVector. I'd drop this one if it doesn't have significant effect.


MapType Overrides;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ class CXXNameMangler {
AbiTagState *AbiTags = nullptr;
AbiTagState AbiTagsRoot;

llvm::DenseMap<uintptr_t, unsigned> Substitutions;
llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
llvm::SmallDenseMap<uintptr_t, unsigned, 16> Substitutions;
llvm::SmallDenseMap<StringRef, unsigned, 16> ModuleSubstitutions;

ASTContext &getASTContext() const { return Context.getASTContext(); }

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/SCCIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class scc_iterator : public iterator_facade_base<
///
/// nodeVisitNumbers are per-node visit numbers, also used as DFS flags.
unsigned visitNum;
DenseMap<NodeRef, unsigned> nodeVisitNumbers;
SmallDenseMap<NodeRef, unsigned, 16> nodeVisitNumbers;

/// Stack holding nodes of the SCC.
std::vector<NodeRef> SCCNodeStack;
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ConstraintSystem {

/// A map of variables (IR values) to their corresponding index in the
/// constraint system.
DenseMap<Value *, unsigned> Value2Index;
SmallDenseMap<Value *, unsigned, 16> Value2Index;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a using/typedef for this one, especially as it needs to be synchronized with ConstraintElimination.


// Eliminate constraints from the system using Fourier–Motzkin elimination.
bool eliminateUsingFM();
Expand All @@ -70,7 +70,7 @@ class ConstraintSystem {
Value2Index.insert({Arg, Value2Index.size() + 1});
}
}
ConstraintSystem(const DenseMap<Value *, unsigned> &Value2Index)
ConstraintSystem(const SmallDenseMap<Value *, unsigned, 16> &Value2Index)
: NumVariables(Value2Index.size()), Value2Index(Value2Index) {}

bool addVariableRow(ArrayRef<int64_t> R) {
Expand All @@ -92,8 +92,8 @@ class ConstraintSystem {
return true;
}

DenseMap<Value *, unsigned> &getValue2Index() { return Value2Index; }
const DenseMap<Value *, unsigned> &getValue2Index() const {
SmallDenseMap<Value *, unsigned, 16> &getValue2Index() { return Value2Index; }
const SmallDenseMap<Value *, unsigned, 16> &getValue2Index() const {
return Value2Index;
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/DominanceFrontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class DominanceFrontierBase {
public:
// Dom set for a bb. Use SetVector to make iterating dom frontiers of a bb
// deterministic.
using DomSetType = SetVector<BlockT *>;
using DomSetMapType = DenseMap<BlockT *, DomSetType>; // Dom set map
using DomSetType = SmallSetVector<BlockT *, 16>;
using DomSetMapType = SmallDenseMap<BlockT *, DomSetType, 16>; // Dom set map

protected:
using BlockTraits = GraphTraits<BlockT *>;
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/DominanceFrontierImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void DominanceFrontierBase<BlockT, IsPostDom>::print(raw_ostream &OS) const {
OS << " <<exit node>>";
OS << " is:\t";

const SetVector<BlockT *> &BBs = I->second;
const SmallSetVector<BlockT *, 16> &BBs = I->second;

for (const BlockT *BB : BBs) {
OS << ' ';
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/LoopIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ struct LoopBodyTraits {
class LoopBlocksDFS {
public:
/// Postorder list iterators.
typedef std::vector<BasicBlock*>::const_iterator POIterator;
typedef std::vector<BasicBlock*>::const_reverse_iterator RPOIterator;
typedef SmallVector<BasicBlock*, 16>::const_iterator POIterator;
typedef SmallVector<BasicBlock*, 16>::const_reverse_iterator RPOIterator;

friend class LoopBlocksTraversal;

Expand All @@ -108,8 +108,8 @@ class LoopBlocksDFS {
/// Map each block to its postorder number. A block is only mapped after it is
/// preorder visited by DFS. It's postorder number is initially zero and set
/// to nonzero after it is finished by postorder traversal.
DenseMap<BasicBlock*, unsigned> PostNumbers;
std::vector<BasicBlock*> PostBlocks;
SmallDenseMap<BasicBlock*, unsigned, 16> PostNumbers;
SmallVector<BasicBlock*, 16> PostBlocks;

public:
LoopBlocksDFS(Loop *Container) :
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/MemorySSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ class MemorySSA {
Loop *L = nullptr;

// Memory SSA mappings
DenseMap<const Value *, MemoryAccess *> ValueToMemoryAccess;
SmallDenseMap<const Value *, MemoryAccess *, 16> ValueToMemoryAccess;

// These two mappings contain the main block to access/def mappings for
// MemorySSA. The list contained in PerBlockAccesses really owns all the
Expand All @@ -895,7 +895,7 @@ class MemorySSA {
// Note that the numbering is local to a block, even though the map is
// global.
mutable SmallPtrSet<const BasicBlock *, 16> BlockNumberingValid;
mutable DenseMap<const MemoryAccess *, unsigned long> BlockNumbering;
mutable SmallDenseMap<const MemoryAccess *, unsigned long, 16> BlockNumbering;

// Memory SSA building info
std::unique_ptr<ClobberWalkerBase> WalkerBase;
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/MustExecute.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ class raw_ostream;
/// methods except for computeLoopSafetyInfo is undefined.
class LoopSafetyInfo {
// Used to update funclet bundle operands.
DenseMap<BasicBlock *, ColorVector> BlockColors;
BlockColorMapT BlockColors;

protected:
/// Computes block colors.
void computeBlockColors(const Loop *CurLoop);

public:
/// Returns block colors map that is used to update funclet operand bundles.
const DenseMap<BasicBlock *, ColorVector> &getBlockColors() const;
const BlockColorMapT &getBlockColors() const;

/// Copy colors of block \p Old into the block \p New.
void copyColors(BasicBlock *New, BasicBlock *Old);
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/IR/EHPersonalities.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ inline bool isNoOpWithoutInvoke(EHPersonality Pers) {
bool canSimplifyInvokeNoUnwind(const Function *F);

typedef TinyPtrVector<BasicBlock *> ColorVector;
typedef SmallDenseMap<BasicBlock *, ColorVector, 16> BlockColorMapT;

/// If an EH funclet personality is in use (see isFuncletEHPersonality),
/// this will recompute which blocks are in which funclet. It is possible that
/// some blocks are in multiple funclets. Consider this analysis to be
/// expensive.
DenseMap<BasicBlock *, ColorVector> colorEHFunclets(Function &F);
BlockColorMapT colorEHFunclets(Function &F);

} // end namespace llvm

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/PredIteratorCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace llvm {
/// wants the predecessor list for the same blocks.
class PredIteratorCache {
/// Cached list of predecessors, allocated in Memory.
DenseMap<BasicBlock *, ArrayRef<BasicBlock *>> BlockToPredsMap;
SmallDenseMap<BasicBlock *, ArrayRef<BasicBlock *>, 16> BlockToPredsMap;

/// Memory - This is the space that holds cached preds.
BumpPtrAllocator Memory;
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/Utils/Cloning.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct ClonedCodeInfo {
/// Like VMap, but maps only unsimplified instructions. Values in the map
/// may be dangling, it is only intended to be used via isSimplified(), to
/// check whether the main VMap mapping involves simplification or not.
DenseMap<const Value *, const Value *> OrigVMap;
SmallDenseMap<const Value *, const Value *, 16> OrigVMap;

ClonedCodeInfo() = default;

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SSAUpdaterImpl {
: BB(ThisBB), AvailableVal(V), DefBB(V ? this : nullptr) {}
};

using AvailableValsTy = DenseMap<BlkT *, ValT>;
using AvailableValsTy = SmallDenseMap<BlkT *, ValT, 16>;

AvailableValsTy *AvailableVals;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/InlineCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
/// The mapping of caller Alloca values to their accumulated cost savings. If
/// we have to disable SROA for one of the allocas, this tells us how much
/// cost must be added.
DenseMap<AllocaInst *, int> SROAArgCosts;
SmallDenseMap<AllocaInst *, int, 16> SROAArgCosts;

/// Return true if \p Call is a cold callsite.
bool isColdCallSite(CallBase &Call, BlockFrequencyInfo *CallerBFI);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/LazyValueInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class LazyValueInfoImpl {
SmallVector<std::pair<BasicBlock*, Value*>, 8> BlockValueStack;

/// Keeps track of which block-value pairs are in BlockValueStack.
DenseSet<std::pair<BasicBlock*, Value*> > BlockValueSet;
SmallDenseSet<std::pair<BasicBlock*, Value*>, 16> BlockValueSet;

/// Push BV onto BlockValueStack unless it's already in there.
/// Returns true on success.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/MustExecute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace llvm;

#define DEBUG_TYPE "must-execute"

const DenseMap<BasicBlock *, ColorVector> &
const BlockColorMapT &
LoopSafetyInfo::getBlockColors() const {
return BlockColors;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4151,7 +4151,7 @@ std::optional<ValueIDNum> InstrRefBasedLDV::resolveDbgPHIsImpl(
// Adapted LLVM SSA Updater:
LDVSSAUpdater Updater(Loc, MLiveIns);
// Map of which Def or PHI is the current value in each block.
DenseMap<LDVSSABlock *, BlockValueNum> AvailableValues;
SmallDenseMap<LDVSSABlock *, BlockValueNum, 16> AvailableValues;
// Set of PHIs that we have created along the way.
SmallVector<LDVSSAPhi *, 8> CreatedPHIs;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineSSAUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace llvm;

#define DEBUG_TYPE "machine-ssaupdater"

using AvailableValsTy = DenseMap<MachineBasicBlock *, Register>;
using AvailableValsTy = SmallDenseMap<MachineBasicBlock *, Register, 16>;

static AvailableValsTy &getAvailableVals(void *AV) {
return *static_cast<AvailableValsTy*>(AV);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/WinEHPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class WinEHPrepareImpl {
EHPersonality Personality = EHPersonality::Unknown;

const DataLayout *DL = nullptr;
DenseMap<BasicBlock *, ColorVector> BlockColors;
BlockColorMapT BlockColors;
MapVector<BasicBlock *, std::vector<BasicBlock *>> FuncletBlocks;
};

Expand Down Expand Up @@ -189,7 +189,7 @@ static BasicBlock *getCleanupRetUnwindDest(const CleanupPadInst *CleanupPad) {
static void calculateStateNumbersForInvokes(const Function *Fn,
WinEHFuncInfo &FuncInfo) {
auto *F = const_cast<Function *>(Fn);
DenseMap<BasicBlock *, ColorVector> BlockColors = colorEHFunclets(*F);
BlockColorMapT BlockColors = colorEHFunclets(*F);
for (BasicBlock &BB : *F) {
auto *II = dyn_cast<InvokeInst>(BB.getTerminator());
if (!II)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/EHPersonalities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ bool llvm::canSimplifyInvokeNoUnwind(const Function *F) {
return !EHa && !isAsynchronousEHPersonality(Personality);
}

DenseMap<BasicBlock *, ColorVector> llvm::colorEHFunclets(Function &F) {
BlockColorMapT llvm::colorEHFunclets(Function &F) {
SmallVector<std::pair<BasicBlock *, BasicBlock *>, 16> Worklist;
BasicBlock *EntryBlock = &F.getEntryBlock();
DenseMap<BasicBlock *, ColorVector> BlockColors;
BlockColorMapT BlockColors;

// Build up the color map, which maps each block to its set of 'colors'.
// For any block B the "colors" of B are the set of funclets F (possibly
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {

/// Cache which blocks are in which funclet, if an EH funclet personality is
/// in use. Otherwise empty.
DenseMap<BasicBlock *, ColorVector> BlockEHFuncletColors;
BlockColorMapT BlockEHFuncletColors;

/// Cache of constants visited in search of ConstantExprs.
SmallPtrSet<const Constant *, 32> ConstantExprVisited;
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Target/X86/X86WinEHState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class WinEHStatePass : public FunctionPass {
bool isStateStoreNeeded(EHPersonality Personality, CallBase &Call);
void rewriteSetJmpCall(IRBuilder<> &Builder, Function &F, CallBase &Call,
Value *State);
int getBaseStateForBB(DenseMap<BasicBlock *, ColorVector> &BlockColors,
int getBaseStateForBB(BlockColorMapT &BlockColors,
WinEHFuncInfo &FuncInfo, BasicBlock *BB);
int getStateForCall(DenseMap<BasicBlock *, ColorVector> &BlockColors,
int getStateForCall(BlockColorMapT &BlockColors,
WinEHFuncInfo &FuncInfo, CallBase &Call);

// Module-level type getters.
Expand Down Expand Up @@ -501,7 +501,7 @@ void WinEHStatePass::rewriteSetJmpCall(IRBuilder<> &Builder, Function &F,

// Figure out what state we should assign calls in this block.
int WinEHStatePass::getBaseStateForBB(
DenseMap<BasicBlock *, ColorVector> &BlockColors, WinEHFuncInfo &FuncInfo,
BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
BasicBlock *BB) {
int BaseState = ParentBaseState;
auto &BBColors = BlockColors[BB];
Expand All @@ -520,7 +520,7 @@ int WinEHStatePass::getBaseStateForBB(

// Calculate the state a call-site is in.
int WinEHStatePass::getStateForCall(
DenseMap<BasicBlock *, ColorVector> &BlockColors, WinEHFuncInfo &FuncInfo,
BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
CallBase &Call) {
if (auto *II = dyn_cast<InvokeInst>(&Call)) {
// Look up the state number of the EH pad this unwinds to.
Expand Down Expand Up @@ -644,7 +644,7 @@ void WinEHStatePass::addStateStores(Function &F, WinEHFuncInfo &FuncInfo) {
calculateWinCXXEHStateNumbers(&F, FuncInfo);

// Iterate all the instructions and emit state number stores.
DenseMap<BasicBlock *, ColorVector> BlockColors = colorEHFunclets(F);
BlockColorMapT BlockColors = colorEHFunclets(F);
ReversePostOrderTraversal<Function *> RPOT(&F);

// InitialStates yields the state of the first call-site for a BasicBlock.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5307,7 +5307,7 @@ bool InstCombinerImpl::prepareWorklist(Function &F) {
bool MadeIRChange = false;
SmallPtrSet<BasicBlock *, 32> LiveBlocks;
SmallVector<Instruction *, 128> InstrsForInstructionWorklist;
DenseMap<Constant *, Constant *> FoldedConstants;
SmallDenseMap<Constant *, Constant *, 16> FoldedConstants;
AliasScopeTracker SeenAliasScopes;

auto HandleOnlyLiveSuccessor = [&](BasicBlock *BB, BasicBlock *LiveSucc) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ class RuntimeCallInserter {
return;
assert(TrackInsertedCalls && "Calls were wrongly tracked");

DenseMap<BasicBlock *, ColorVector> BlockColors = colorEHFunclets(*OwnerFn);
BlockColorMapT BlockColors = colorEHFunclets(*OwnerFn);
for (CallInst *CI : InsertedCalls) {
BasicBlock *BB = CI->getParent();
assert(BB && "Instruction doesn't belong to a BasicBlock");
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ BasicBlock *FuncPGOInstrumentation<Edge, BBInfo>::getInstrBB(Edge *E) {
// value profiling call for the value profile candidate call.
static void
populateEHOperandBundle(VPCandidateInfo &Cand,
DenseMap<BasicBlock *, ColorVector> &BlockColors,
BlockColorMapT &BlockColors,
SmallVectorImpl<OperandBundleDef> &OpBundles) {
auto *OrigCall = dyn_cast<CallBase>(Cand.AnnotatedInst);
if (!OrigCall)
Expand Down Expand Up @@ -1006,7 +1006,7 @@ void FunctionInstrumenter::instrument() {
// Windows exception handling attached to them. However, if value profiling is
// inserted for one of these calls, then a funclet value will need to be set
// on the instrumentation call based on the funclet coloring.
DenseMap<BasicBlock *, ColorVector> BlockColors;
BlockColorMapT BlockColors;
if (F.hasPersonalityFn() &&
isScopedEHPersonality(classifyEHPersonality(F.getPersonalityFn())))
BlockColors = colorEHFunclets(F);
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace llvm::objcarc;
CallInst *objcarc::createCallInstWithColors(
FunctionCallee Func, ArrayRef<Value *> Args, const Twine &NameStr,
BasicBlock::iterator InsertBefore,
const DenseMap<BasicBlock *, ColorVector> &BlockColors) {
const BlockColorMapT &BlockColors) {
FunctionType *FTy = Func.getFunctionType();
Value *Callee = Func.getCallee();
SmallVector<OperandBundleDef, 1> OpBundles;
Expand Down Expand Up @@ -73,13 +73,13 @@ BundledRetainClaimRVs::insertAfterInvokes(Function &F, DominatorTree *DT) {

CallInst *BundledRetainClaimRVs::insertRVCall(BasicBlock::iterator InsertPt,
CallBase *AnnotatedCall) {
DenseMap<BasicBlock *, ColorVector> BlockColors;
BlockColorMapT BlockColors;
return insertRVCallWithColors(InsertPt, AnnotatedCall, BlockColors);
}

CallInst *BundledRetainClaimRVs::insertRVCallWithColors(
BasicBlock::iterator InsertPt, CallBase *AnnotatedCall,
const DenseMap<BasicBlock *, ColorVector> &BlockColors) {
const BlockColorMapT &BlockColors) {
IRBuilder<> Builder(InsertPt->getParent(), InsertPt);
Function *Func = *objcarc::getAttachedARCFunction(AnnotatedCall);
assert(Func && "operand isn't a Function");
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/ObjCARC/ObjCARC.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static inline MDString *getRVInstMarker(Module &M) {
CallInst *createCallInstWithColors(
FunctionCallee Func, ArrayRef<Value *> Args, const Twine &NameStr,
BasicBlock::iterator InsertBefore,
const DenseMap<BasicBlock *, ColorVector> &BlockColors);
const BlockColorMapT &BlockColors);

class BundledRetainClaimRVs {
public:
Expand All @@ -119,7 +119,7 @@ class BundledRetainClaimRVs {
/// Insert a retainRV/claimRV call with colors.
CallInst *insertRVCallWithColors(
BasicBlock::iterator InsertPt, CallBase *AnnotatedCall,
const DenseMap<BasicBlock *, ColorVector> &BlockColors);
const BlockColorMapT &BlockColors);

/// See if an instruction is a bundled retainRV/claimRV call.
bool contains(const Instruction *I) const {
Expand Down
Loading
Loading