Use SmallPtrSet explicitly for SmallSets with pointer types (NFC).
Currently SmallSet<PointerTy> inherits from SmallPtrSet<PointerTy>. This patch replaces such types with SmallPtrSet, because IMO it is slightly clearer and allows us to get rid of unnecessarily including SmallSet.h Reviewers: dblaikie, craig.topper Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D47836 llvm-svn: 334492
This commit is contained in:
parent
74fb5e6789
commit
a1cc848399
|
@ -18,7 +18,6 @@
|
|||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
|
@ -406,7 +405,7 @@ static Attribute::AttrKind
|
|||
determinePointerReadAttrs(Argument *A,
|
||||
const SmallPtrSet<Argument *, 8> &SCCNodes) {
|
||||
SmallVector<Use *, 32> Worklist;
|
||||
SmallSet<Use *, 32> Visited;
|
||||
SmallPtrSet<Use *, 32> Visited;
|
||||
|
||||
// inalloca arguments are always clobbered by the call.
|
||||
if (A->hasInAllocaAttr())
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
|
@ -1747,8 +1746,8 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool deleteIfDead(GlobalValue &GV,
|
||||
SmallSet<const Comdat *, 8> &NotDiscardableComdats) {
|
||||
static bool deleteIfDead(
|
||||
GlobalValue &GV, SmallPtrSetImpl<const Comdat *> &NotDiscardableComdats) {
|
||||
GV.removeDeadConstantUsers();
|
||||
|
||||
if (!GV.isDiscardableIfUnused() && !GV.isDeclaration())
|
||||
|
@ -2228,7 +2227,7 @@ OptimizeFunctions(Module &M, TargetLibraryInfo *TLI,
|
|||
function_ref<TargetTransformInfo &(Function &)> GetTTI,
|
||||
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
|
||||
function_ref<DominatorTree &(Function &)> LookupDomTree,
|
||||
SmallSet<const Comdat *, 8> &NotDiscardableComdats) {
|
||||
SmallPtrSetImpl<const Comdat *> &NotDiscardableComdats) {
|
||||
|
||||
bool Changed = false;
|
||||
|
||||
|
@ -2323,7 +2322,7 @@ OptimizeFunctions(Module &M, TargetLibraryInfo *TLI,
|
|||
static bool
|
||||
OptimizeGlobalVars(Module &M, TargetLibraryInfo *TLI,
|
||||
function_ref<DominatorTree &(Function &)> LookupDomTree,
|
||||
SmallSet<const Comdat *, 8> &NotDiscardableComdats) {
|
||||
SmallPtrSetImpl<const Comdat *> &NotDiscardableComdats) {
|
||||
bool Changed = false;
|
||||
|
||||
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
|
||||
|
@ -2566,7 +2565,7 @@ static int compareNames(Constant *const *A, Constant *const *B) {
|
|||
}
|
||||
|
||||
static void setUsedInitializer(GlobalVariable &V,
|
||||
const SmallPtrSet<GlobalValue *, 8> &Init) {
|
||||
const SmallPtrSetImpl<GlobalValue *> &Init) {
|
||||
if (Init.empty()) {
|
||||
V.eraseFromParent();
|
||||
return;
|
||||
|
@ -2719,7 +2718,7 @@ static bool hasUsesToReplace(GlobalAlias &GA, const LLVMUsed &U,
|
|||
|
||||
static bool
|
||||
OptimizeGlobalAliases(Module &M,
|
||||
SmallSet<const Comdat *, 8> &NotDiscardableComdats) {
|
||||
SmallPtrSetImpl<const Comdat *> &NotDiscardableComdats) {
|
||||
bool Changed = false;
|
||||
LLVMUsed Used(M);
|
||||
|
||||
|
@ -2902,7 +2901,7 @@ static bool optimizeGlobalsInModule(
|
|||
function_ref<TargetTransformInfo &(Function &)> GetTTI,
|
||||
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
|
||||
function_ref<DominatorTree &(Function &)> LookupDomTree) {
|
||||
SmallSet<const Comdat *, 8> NotDiscardableComdats;
|
||||
SmallPtrSet<const Comdat *, 8> NotDiscardableComdats;
|
||||
bool Changed = false;
|
||||
bool LocalChange = true;
|
||||
while (LocalChange) {
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/IR/Argument.h"
|
||||
|
@ -874,7 +874,7 @@ void MergeFunctions::remove(Function *F) {
|
|||
void MergeFunctions::removeUsers(Value *V) {
|
||||
std::vector<Value *> Worklist;
|
||||
Worklist.push_back(V);
|
||||
SmallSet<Value*, 8> Visited;
|
||||
SmallPtrSet<Value*, 8> Visited;
|
||||
Visited.insert(V);
|
||||
while (!Worklist.empty()) {
|
||||
Value *V = Worklist.back();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DepthFirstIterator.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
|
@ -2509,7 +2509,7 @@ bool AddressSanitizer::runOnFunction(Function &F) {
|
|||
|
||||
// We want to instrument every address only once per basic block (unless there
|
||||
// are calls between uses).
|
||||
SmallSet<Value *, 16> TempsToInstrument;
|
||||
SmallPtrSet<Value *, 16> TempsToInstrument;
|
||||
SmallVector<Instruction *, 16> ToInstrument;
|
||||
SmallVector<Instruction *, 8> NoReturnCalls;
|
||||
SmallVector<BasicBlock *, 16> AllBlocks;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// The rest is handled by the run-time library.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
|
@ -339,7 +339,7 @@ bool ThreadSanitizer::addrPointsToConstantData(Value *Addr) {
|
|||
void ThreadSanitizer::chooseInstructionsToInstrument(
|
||||
SmallVectorImpl<Instruction *> &Local, SmallVectorImpl<Instruction *> &All,
|
||||
const DataLayout &DL) {
|
||||
SmallSet<Value*, 8> WriteTargets;
|
||||
SmallPtrSet<Value*, 8> WriteTargets;
|
||||
// Iterate from the end.
|
||||
for (Instruction *I : reverse(Local)) {
|
||||
if (StoreInst *Store = dyn_cast<StoreInst>(I)) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DepthFirstIterator.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
|
@ -179,7 +179,7 @@ public:
|
|||
// forward and backward dependences qualify. Disqualify loads that have
|
||||
// other unknown dependences.
|
||||
|
||||
SmallSet<Instruction *, 4> LoadsWithUnknownDepedence;
|
||||
SmallPtrSet<Instruction *, 4> LoadsWithUnknownDepedence;
|
||||
|
||||
for (const auto &Dep : *Deps) {
|
||||
Instruction *Source = Dep.getSource(LAI);
|
||||
|
@ -302,7 +302,7 @@ public:
|
|||
/// We need a check if one is a pointer for a candidate load and the other is
|
||||
/// a pointer for a possibly intervening store.
|
||||
bool needsChecking(unsigned PtrIdx1, unsigned PtrIdx2,
|
||||
const SmallSet<Value *, 4> &PtrsWrittenOnFwdingPath,
|
||||
const SmallPtrSet<Value *, 4> &PtrsWrittenOnFwdingPath,
|
||||
const std::set<Value *> &CandLoadPtrs) {
|
||||
Value *Ptr1 =
|
||||
LAI.getRuntimePointerChecking()->getPointerInfo(PtrIdx1).PointerValue;
|
||||
|
@ -316,7 +316,7 @@ public:
|
|||
/// forwarding store to a load.
|
||||
///
|
||||
/// These pointers need to be alias-checked against the forwarding candidates.
|
||||
SmallSet<Value *, 4> findPointersWrittenOnForwardingPath(
|
||||
SmallPtrSet<Value *, 4> findPointersWrittenOnForwardingPath(
|
||||
const SmallVectorImpl<StoreToLoadForwardingCandidate> &Candidates) {
|
||||
// From FirstStore to LastLoad neither of the elimination candidate loads
|
||||
// should overlap with any of the stores.
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
// We're looking for stores after the first forwarding store until the end
|
||||
// of the loop, then from the beginning of the loop until the last
|
||||
// forwarded-to load. Collect the pointer for the stores.
|
||||
SmallSet<Value *, 4> PtrsWrittenOnFwdingPath;
|
||||
SmallPtrSet<Value *, 4> PtrsWrittenOnFwdingPath;
|
||||
|
||||
auto InsertStorePtr = [&](Instruction *I) {
|
||||
if (auto *S = dyn_cast<StoreInst>(I))
|
||||
|
@ -374,11 +374,11 @@ public:
|
|||
SmallVector<RuntimePointerChecking::PointerCheck, 4> collectMemchecks(
|
||||
const SmallVectorImpl<StoreToLoadForwardingCandidate> &Candidates) {
|
||||
|
||||
SmallSet<Value *, 4> PtrsWrittenOnFwdingPath =
|
||||
SmallPtrSet<Value *, 4> PtrsWrittenOnFwdingPath =
|
||||
findPointersWrittenOnForwardingPath(Candidates);
|
||||
|
||||
// Collect the pointers of the candidate loads.
|
||||
// FIXME: SmallSet does not work with std::inserter.
|
||||
// FIXME: SmallPtrSet does not work with std::inserter.
|
||||
std::set<Value *> CandLoadPtrs;
|
||||
transform(Candidates,
|
||||
std::inserter(CandLoadPtrs, CandLoadPtrs.begin()),
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AssumptionCache.h"
|
||||
|
@ -1042,7 +1042,7 @@ bool LoopUnswitch::TryTrivialLoopUnswitch(bool &Changed) {
|
|||
// until it finds the trivial condition candidate (condition that is not a
|
||||
// constant). Since unswitching generates branches with constant conditions,
|
||||
// this scenario could be very common in practice.
|
||||
SmallSet<BasicBlock*, 8> Visited;
|
||||
SmallPtrSet<BasicBlock*, 8> Visited;
|
||||
|
||||
while (true) {
|
||||
// If we exit loop or reach a previous visited block, then
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Transforms/Scalar/SpeculativeExecution.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Analysis/GlobalsModRef.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
|
@ -252,7 +252,7 @@ static unsigned ComputeSpeculationCost(const Instruction *I,
|
|||
|
||||
bool SpeculativeExecutionPass::considerHoistingFromTo(
|
||||
BasicBlock &FromBlock, BasicBlock &ToBlock) {
|
||||
SmallSet<const Instruction *, 8> NotHoisted;
|
||||
SmallPtrSet<const Instruction *, 8> NotHoisted;
|
||||
const auto AllPrecedingUsesFromBlockHoisted = [&NotHoisted](User *U) {
|
||||
for (Value* V : U->operand_values()) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V)) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Hashing.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
|
@ -925,7 +924,7 @@ FunctionComparator::FunctionHash FunctionComparator::functionHash(Function &F) {
|
|||
H.add(F.arg_size());
|
||||
|
||||
SmallVector<const BasicBlock *, 8> BBs;
|
||||
SmallSet<const BasicBlock *, 16> VisitedBBs;
|
||||
SmallPtrSet<const BasicBlock *, 16> VisitedBBs;
|
||||
|
||||
// Walk the blocks in the same order as FunctionComparator::cmpBasicBlocks(),
|
||||
// accumulating the hash of the function "structure." (BB and opcode sequence)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/LoopIterator.h"
|
||||
|
@ -765,7 +765,7 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
|
|||
// values from the cloned region. Also update the dominator info for
|
||||
// OtherExits and their immediate successors, since we have new edges into
|
||||
// OtherExits.
|
||||
SmallSet<BasicBlock*, 8> ImmediateSuccessorsOfExitBlocks;
|
||||
SmallPtrSet<BasicBlock*, 8> ImmediateSuccessorsOfExitBlocks;
|
||||
for (auto *BB : OtherExits) {
|
||||
for (auto &II : *BB) {
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
@ -5306,7 +5305,7 @@ LoopVectorizationCostModel::calculateRegisterUsage(ArrayRef<unsigned> VFs) {
|
|||
// Marks the end of each interval.
|
||||
IntervalMap EndPoint;
|
||||
// Saves the list of instruction indices that are used in the loop.
|
||||
SmallSet<Instruction *, 8> Ends;
|
||||
SmallPtrSet<Instruction *, 8> Ends;
|
||||
// Saves the list of values that are used in the loop but are
|
||||
// defined outside the loop, such as arguments and constants.
|
||||
SmallPtrSet<Value *, 8> LoopInvariants;
|
||||
|
|
|
@ -2615,7 +2615,7 @@ int BoUpSLP::getTreeCost() {
|
|||
Cost += C;
|
||||
}
|
||||
|
||||
SmallSet<Value *, 16> ExtractCostCalculated;
|
||||
SmallPtrSet<Value *, 16> ExtractCostCalculated;
|
||||
int ExtractCost = 0;
|
||||
for (ExternalUser &EU : ExternalUses) {
|
||||
// We only add extract cost once for the same scalar.
|
||||
|
@ -3132,7 +3132,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
|
|||
|
||||
// PHINodes may have multiple entries from the same block. We want to
|
||||
// visit every block once.
|
||||
SmallSet<BasicBlock*, 4> VisitedBBs;
|
||||
SmallPtrSet<BasicBlock*, 4> VisitedBBs;
|
||||
|
||||
for (unsigned i = 0, e = PH->getNumIncomingValues(); i < e; ++i) {
|
||||
ValueList Operands;
|
||||
|
@ -6071,7 +6071,7 @@ static bool tryToVectorizeHorReductionOrInstOperands(
|
|||
// Interrupt the process if the Root instruction itself was vectorized or all
|
||||
// sub-trees not higher that RecursionMaxDepth were analyzed/vectorized.
|
||||
SmallVector<std::pair<WeakTrackingVH, unsigned>, 8> Stack(1, {Root, 0});
|
||||
SmallSet<Value *, 8> VisitedInstrs;
|
||||
SmallPtrSet<Value *, 8> VisitedInstrs;
|
||||
bool Res = false;
|
||||
while (!Stack.empty()) {
|
||||
Value *V;
|
||||
|
@ -6212,7 +6212,7 @@ bool SLPVectorizerPass::vectorizeSimpleInstructions(
|
|||
bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
|
||||
bool Changed = false;
|
||||
SmallVector<Value *, 4> Incoming;
|
||||
SmallSet<Value *, 16> VisitedInstrs;
|
||||
SmallPtrSet<Value *, 16> VisitedInstrs;
|
||||
|
||||
bool HaveVectorizedPhiNodes = true;
|
||||
while (HaveVectorizedPhiNodes) {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
|
|
Loading…
Reference in New Issue