[Analysis] Change std::sort to llvm::sort in response to r327219

Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort.
Refer D44363 for a list of all the required patches.

Reviewers: sanjoy, dexonsmith, hfinkel, RKSimon

Reviewed By: dexonsmith

Subscribers: david2050, llvm-commits

Differential Revision: https://reviews.llvm.org/D44944

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mandeep Singh Grang 2018-04-01 01:46:51 +00:00
parent 319a335961
commit ccca812fc3
8 changed files with 21 additions and 21 deletions

View File

@ -155,9 +155,9 @@ static void combineWeight(Weight &W, const Weight &OtherW) {
static void combineWeightsBySorting(WeightList &Weights) {
// Sort so edges to the same node are adjacent.
std::sort(Weights.begin(), Weights.end(),
[](const Weight &L,
const Weight &R) { return L.TargetNode < R.TargetNode; });
llvm::sort(Weights.begin(), Weights.end(),
[](const Weight &L,
const Weight &R) { return L.TargetNode < R.TargetNode; });
// Combine adjacent edges.
WeightList::iterator O = Weights.begin();
@ -702,7 +702,7 @@ static void findIrreducibleHeaders(
"Expected irreducible CFG; -loop-info is likely invalid");
if (Headers.size() == InSCC.size()) {
// Every block is a header.
std::sort(Headers.begin(), Headers.end());
llvm::sort(Headers.begin(), Headers.end());
return;
}
@ -736,8 +736,8 @@ static void findIrreducibleHeaders(
Others.push_back(Irr.Node);
DEBUG(dbgs() << " => other = " << BFI.getBlockName(Irr.Node) << "\n");
}
std::sort(Headers.begin(), Headers.end());
std::sort(Others.begin(), Others.end());
llvm::sort(Headers.begin(), Headers.end());
llvm::sort(Others.begin(), Others.end());
}
static void createIrreducibleLoop(

View File

@ -395,7 +395,7 @@ populateAliasMap(DenseMap<const Value *, std::vector<OffsetValue>> &AliasMap,
}
// Sort AliasList for faster lookup
std::sort(AliasList.begin(), AliasList.end());
llvm::sort(AliasList.begin(), AliasList.end());
}
}
@ -479,7 +479,7 @@ static void populateExternalRelations(
}
// Remove duplicates in ExtRelations
std::sort(ExtRelations.begin(), ExtRelations.end());
llvm::sort(ExtRelations.begin(), ExtRelations.end());
ExtRelations.erase(std::unique(ExtRelations.begin(), ExtRelations.end()),
ExtRelations.end());
}

View File

@ -96,8 +96,8 @@ void CallGraph::print(raw_ostream &OS) const {
for (const auto &I : *this)
Nodes.push_back(I.second.get());
std::sort(Nodes.begin(), Nodes.end(),
[](CallGraphNode *LHS, CallGraphNode *RHS) {
llvm::sort(Nodes.begin(), Nodes.end(),
[](CallGraphNode *LHS, CallGraphNode *RHS) {
if (Function *LF = LHS->getFunction())
if (Function *RF = RHS->getFunction())
return LF->getName() < RF->getName();

View File

@ -805,7 +805,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallSite QueryCS) {
DirtyBlocks.push_back(Entry.getBB());
// Sort the cache so that we can do fast binary search lookups below.
std::sort(Cache.begin(), Cache.end());
llvm::sort(Cache.begin(), Cache.end());
++NumCacheDirtyNonLocal;
// cerr << "CACHED CASE: " << DirtyBlocks.size() << " dirty: "
@ -1068,7 +1068,7 @@ SortNonLocalDepInfoCache(MemoryDependenceResults::NonLocalDepInfo &Cache,
break;
default:
// Added many values, do a full scale sort.
std::sort(Cache.begin(), Cache.end());
llvm::sort(Cache.begin(), Cache.end());
break;
}
}
@ -1638,7 +1638,7 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
// Re-sort the NonLocalDepInfo. Changing the dirty entry to its
// subsequent value may invalidate the sortedness.
std::sort(NLPDI.begin(), NLPDI.end());
llvm::sort(NLPDI.begin(), NLPDI.end());
}
ReverseNonLocalPtrDeps.erase(ReversePtrDepIt);

View File

@ -1338,10 +1338,10 @@ void MemorySSA::placePHINodes(
SmallVector<BasicBlock *, 32> IDFBlocks;
IDFs.calculate(IDFBlocks);
std::sort(IDFBlocks.begin(), IDFBlocks.end(),
[&BBNumbers](const BasicBlock *A, const BasicBlock *B) {
return BBNumbers.lookup(A) < BBNumbers.lookup(B);
});
llvm::sort(IDFBlocks.begin(), IDFBlocks.end(),
[&BBNumbers](const BasicBlock *A, const BasicBlock *B) {
return BBNumbers.lookup(A) < BBNumbers.lookup(B);
});
// Now place MemoryPhi nodes.
for (auto &BB : IDFBlocks)

View File

@ -10645,7 +10645,7 @@ void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
Terms.erase(std::unique(Terms.begin(), Terms.end()), Terms.end());
// Put larger terms first.
std::sort(Terms.begin(), Terms.end(), [](const SCEV *LHS, const SCEV *RHS) {
llvm::sort(Terms.begin(), Terms.end(), [](const SCEV *LHS, const SCEV *RHS) {
return numberOfTerms(LHS) > numberOfTerms(RHS);
});

View File

@ -1862,7 +1862,7 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
Phis.push_back(&PN);
if (TTI)
std::sort(Phis.begin(), Phis.end(), [](Value *LHS, Value *RHS) {
llvm::sort(Phis.begin(), Phis.end(), [](Value *LHS, Value *RHS) {
// Put pointers at the back and make sure pointer < pointer = false.
if (!LHS->getType()->isIntegerTy() || !RHS->getType()->isIntegerTy())
return RHS->getType()->isIntegerTy() && !LHS->getType()->isIntegerTy();

View File

@ -1329,10 +1329,10 @@ static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) {
void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end());
std::sort(VectorDescs.begin(), VectorDescs.end(), compareByScalarFnName);
llvm::sort(VectorDescs.begin(), VectorDescs.end(), compareByScalarFnName);
ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end());
std::sort(ScalarDescs.begin(), ScalarDescs.end(), compareByVectorFnName);
llvm::sort(ScalarDescs.begin(), ScalarDescs.end(), compareByVectorFnName);
}
void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(