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;
#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"
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
//===----------------------------------------------------------------------===//
#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"
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;
}
#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"
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.
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;
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) ");
//===----------------------------------------------------------------------===//
#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"
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()) {
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;
}
//===----------------------------------------------------------------------===//
#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"
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
#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"
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: