forked from OSchip/llvm-project
[llvm] Use set_is_subset (NFC)
This commit is contained in:
parent
ca5247bb17
commit
d639120983
|
@ -71,7 +71,7 @@ template <class S1Ty, class S2Ty>
|
|||
bool set_is_subset(const S1Ty &S1, const S2Ty &S2) {
|
||||
if (S1.size() > S2.size())
|
||||
return false;
|
||||
for (auto &It : S1)
|
||||
for (const auto &It : S1)
|
||||
if (!S2.count(It))
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "llvm/ADT/DepthFirstIterator.h"
|
||||
#include "llvm/ADT/PostOrderIterator.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
|
||||
|
@ -676,10 +677,7 @@ static void compareLoops(const LoopT *L, const LoopT *OtherL,
|
|||
const SmallPtrSetImpl<const BlockT *> &OtherBlocksSet =
|
||||
OtherL->getBlocksSet();
|
||||
assert(BlocksSet.size() == OtherBlocksSet.size() &&
|
||||
llvm::all_of(BlocksSet,
|
||||
[&OtherBlocksSet](const BlockT *BB) {
|
||||
return OtherBlocksSet.count(BB);
|
||||
}) &&
|
||||
llvm::set_is_subset(BlocksSet, OtherBlocksSet) &&
|
||||
"Mismatched basic blocks in BlocksSets!");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Analysis/ScopedNoAliasAA.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Analysis/MemoryLocation.h"
|
||||
#include "llvm/IR/InstrTypes.h"
|
||||
|
@ -138,14 +139,7 @@ bool ScopedNoAliasAAResult::mayAliasInScopes(const MDNode *Scopes,
|
|||
collectMDInDomain(NoAlias, Domain, NANodes);
|
||||
|
||||
// To not alias, all of the nodes in ScopeNodes must be in NANodes.
|
||||
bool FoundAll = true;
|
||||
for (const MDNode *SMD : ScopeNodes)
|
||||
if (!NANodes.count(SMD)) {
|
||||
FoundAll = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (FoundAll)
|
||||
if (llvm::set_is_subset(ScopeNodes, NANodes))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/PriorityQueue.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
|
@ -1600,14 +1601,6 @@ static bool computePath(SUnit *Cur, SetVector<SUnit *> &Path,
|
|||
return FoundPath;
|
||||
}
|
||||
|
||||
/// Return true if Set1 is a subset of Set2.
|
||||
template <class S1Ty, class S2Ty> static bool isSubset(S1Ty &Set1, S2Ty &Set2) {
|
||||
for (typename S1Ty::iterator I = Set1.begin(), E = Set1.end(); I != E; ++I)
|
||||
if (Set2.count(*I) == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Compute the live-out registers for the instructions in a node-set.
|
||||
/// The live-out registers are those that are defined in the node-set,
|
||||
/// but not used. Except for use operands of Phis.
|
||||
|
@ -1711,7 +1704,7 @@ void SwingSchedulerDAG::colocateNodeSets(NodeSetType &NodeSets) {
|
|||
SmallSetVector<SUnit *, 8> S2;
|
||||
if (N2.empty() || !succ_L(N2, S2))
|
||||
continue;
|
||||
if (isSubset(S1, S2) && S1.size() == S2.size()) {
|
||||
if (llvm::set_is_subset(S1, S2) && S1.size() == S2.size()) {
|
||||
N1.setColocate(++Colocate);
|
||||
N2.setColocate(Colocate);
|
||||
break;
|
||||
|
@ -1883,11 +1876,11 @@ void SwingSchedulerDAG::computeNodeOrder(NodeSetType &NodeSets) {
|
|||
LLVM_DEBUG(dbgs() << "NodeSet size " << Nodes.size() << "\n");
|
||||
OrderKind Order;
|
||||
SmallSetVector<SUnit *, 8> N;
|
||||
if (pred_L(NodeOrder, N) && isSubset(N, Nodes)) {
|
||||
if (pred_L(NodeOrder, N) && llvm::set_is_subset(N, Nodes)) {
|
||||
R.insert(N.begin(), N.end());
|
||||
Order = BottomUp;
|
||||
LLVM_DEBUG(dbgs() << " Bottom up (preds) ");
|
||||
} else if (succ_L(NodeOrder, N) && isSubset(N, Nodes)) {
|
||||
} else if (succ_L(NodeOrder, N) && llvm::set_is_subset(N, Nodes)) {
|
||||
R.insert(N.begin(), N.end());
|
||||
Order = TopDown;
|
||||
LLVM_DEBUG(dbgs() << " Top down (succs) ");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/CodeGen/LivePhysRegs.h"
|
||||
#include "llvm/CodeGen/ReachingDefAnalysis.h"
|
||||
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
||||
|
@ -660,10 +661,7 @@ void ReachingDefAnalysis::collectKilledOperands(MachineInstr *MI,
|
|||
|
||||
SmallPtrSet<MachineInstr*, 4> Uses;
|
||||
getGlobalUses(Def, PhysReg, Uses);
|
||||
for (auto *Use : Uses)
|
||||
if (!Dead.count(Use))
|
||||
return false;
|
||||
return true;
|
||||
return llvm::set_is_subset(Uses, Dead);
|
||||
};
|
||||
|
||||
for (auto &MO : MI->operands()) {
|
||||
|
@ -688,9 +686,8 @@ bool ReachingDefAnalysis::isSafeToDefRegAt(MachineInstr *MI, MCRegister PhysReg,
|
|||
if (auto *Def = getReachingLocalMIDef(MI, PhysReg)) {
|
||||
SmallPtrSet<MachineInstr*, 2> Uses;
|
||||
getGlobalUses(Def, PhysReg, Uses);
|
||||
for (auto *Use : Uses)
|
||||
if (!Ignore.count(Use))
|
||||
return false;
|
||||
if (!llvm::set_is_subset(Uses, Ignore))
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Transforms/Scalar/LoopSink.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/AliasSetTracker.h"
|
||||
|
@ -212,11 +213,9 @@ static bool sinkInstruction(
|
|||
return false;
|
||||
|
||||
// Return if any of the candidate blocks to sink into is non-cold.
|
||||
if (BBsToSinkInto.size() > 1) {
|
||||
for (auto *BB : BBsToSinkInto)
|
||||
if (!LoopBlockNumber.count(BB))
|
||||
return false;
|
||||
}
|
||||
if (BBsToSinkInto.size() > 1 &&
|
||||
!llvm::set_is_subset(BBsToSinkInto, LoopBlockNumber))
|
||||
return false;
|
||||
|
||||
// Copy the final BBs into a vector and sort them using the total ordering
|
||||
// of the loop block numbers as iterating the set doesn't give a useful
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "llvm/ADT/Hashing.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/PostOrderIterator.h"
|
||||
#include "llvm/ADT/SetOperations.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/SparseBitVector.h"
|
||||
|
@ -389,8 +390,7 @@ public:
|
|||
if (Members.size() != Other->Members.size())
|
||||
return false;
|
||||
|
||||
return all_of(Members,
|
||||
[&](const Value *V) { return Other->Members.count(V); });
|
||||
return llvm::set_is_subset(Members, Other->Members);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue