diff options
author | Stephen Hines <srhines@google.com> | 2014-04-23 16:57:46 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-04-24 15:53:16 -0700 |
commit | 36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch) | |
tree | e6cfb69fbbd937f450eeb83bfb83b9da3b01275a /lib/Bitcode/Writer/ValueEnumerator.cpp | |
parent | 69a8640022b04415ae9fac62f8ab090601d8f889 (diff) | |
download | external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2 |
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index a164104..8531e76 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -159,12 +159,11 @@ void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map, V->dump(); OS << " Uses(" << std::distance(V->use_begin(),V->use_end()) << "):"; - for (Value::const_use_iterator UI = V->use_begin(), UE = V->use_end(); - UI != UE; ++UI) { - if (UI != V->use_begin()) + for (const Use &U : V->uses()) { + if (&U != &*V->use_begin()) OS << ","; - if((*UI)->hasName()) - OS << " " << (*UI)->getName(); + if(U->hasName()) + OS << " " << U->getName(); else OS << " [null]"; @@ -173,29 +172,19 @@ void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map, } } -// Optimize constant ordering. -namespace { - struct CstSortPredicate { - ValueEnumerator &VE; - explicit CstSortPredicate(ValueEnumerator &ve) : VE(ve) {} - bool operator()(const std::pair<const Value*, unsigned> &LHS, - const std::pair<const Value*, unsigned> &RHS) { - // Sort by plane. - if (LHS.first->getType() != RHS.first->getType()) - return VE.getTypeID(LHS.first->getType()) < - VE.getTypeID(RHS.first->getType()); - // Then by frequency. - return LHS.second > RHS.second; - } - }; -} - /// OptimizeConstants - Reorder constant pool for denser encoding. void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) { if (CstStart == CstEnd || CstStart+1 == CstEnd) return; - CstSortPredicate P(*this); - std::stable_sort(Values.begin()+CstStart, Values.begin()+CstEnd, P); + std::stable_sort(Values.begin() + CstStart, Values.begin() + CstEnd, + [this](const std::pair<const Value *, unsigned> &LHS, + const std::pair<const Value *, unsigned> &RHS) { + // Sort by plane. + if (LHS.first->getType() != RHS.first->getType()) + return getTypeID(LHS.first->getType()) < getTypeID(RHS.first->getType()); + // Then by frequency. + return LHS.second > RHS.second; + }); // Ensure that integer and vector of integer constants are at the start of the // constant pool. This is important so that GEP structure indices come before |