[llvm] [BOLT] [NFC] Eliminate uses of throwing std::map::at (PR #92950)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 12:38:55 PDT 2024


================
@@ -1557,15 +1557,28 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
       llvm::stable_sort(Functions,
                         [Ascending, &Stats](const BinaryFunction *A,
                                             const BinaryFunction *B) {
-                          return Ascending ? Stats.at(A) < Stats.at(B)
-                                           : Stats.at(B) < Stats.at(A);
+                          auto StatsItr = Stats.find(A);
----------------
aaupov wrote:

Can you please try to factor out the common code into a functor/lambda that would accept a comparison operator to be used? (i.e. operator< in one case and lessThan in another). 

https://github.com/llvm/llvm-project/pull/92950


More information about the llvm-commits mailing list