diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-03-07 21:35:39 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-03-07 21:35:39 +0000 |
commit | b0f74b24faa4bbbe5f07facb1e414c94e03ab428 (patch) | |
tree | 578efba0d33d0d0f768902a3ecfcdb6ca21a17ac /llvm/lib/Transforms/Scalar | |
parent | 526847fe2041b2e3018a20dc2fb4d12bfc0242cf (diff) | |
download | bcm5719-llvm-b0f74b24faa4bbbe5f07facb1e414c94e03ab428.tar.gz bcm5719-llvm-b0f74b24faa4bbbe5f07facb1e414c94e03ab428.zip |
[C++11] Convert sort predicates into lambdas.
No functionality change.
llvm-svn: 203288
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ConstantHoisting.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp index 4940424c123..b4419313b06 100644 --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -191,18 +191,6 @@ void ConstantHoisting::CollectConstants(Function &F) { CollectConstants(I); } -/// \brief Compare function for sorting integer constants by type and by value -/// within a type in ConstantMaps. -static bool -ConstantMapLessThan(const std::pair<ConstantInt *, ConstantCandidate> &LHS, - const std::pair<ConstantInt *, ConstantCandidate> &RHS) { - if (LHS.first->getType() == RHS.first->getType()) - return LHS.first->getValue().ult(RHS.first->getValue()); - else - return LHS.first->getType()->getBitWidth() < - RHS.first->getType()->getBitWidth(); -} - /// \brief Find the base constant within the given range and rebase all other /// constants with respect to the base constant. void ConstantHoisting::FindAndMakeBaseConstant(ConstantMapType::iterator S, @@ -239,7 +227,14 @@ void ConstantHoisting::FindAndMakeBaseConstant(ConstantMapType::iterator S, /// an add from a common base constant. void ConstantHoisting::FindBaseConstants() { // Sort the constants by value and type. This invalidates the mapping. - std::sort(ConstantMap.begin(), ConstantMap.end(), ConstantMapLessThan); + std::sort(ConstantMap.begin(), ConstantMap.end(), + [](const std::pair<ConstantInt *, ConstantCandidate> &LHS, + const std::pair<ConstantInt *, ConstantCandidate> &RHS) { + if (LHS.first->getType() != RHS.first->getType()) + return LHS.first->getType()->getBitWidth() < + RHS.first->getType()->getBitWidth(); + return LHS.first->getValue().ult(RHS.first->getValue()); + }); // Simple linear scan through the sorted constant map for viable merge // candidates. |