[PATCH] D143019: [BOLT][NFC] Use llvm::make_second_range

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 15:36:56 PST 2023


Amir added inline comments.


================
Comment at: bolt/lib/Core/BinaryContext.cpp:1521
   AllFunctions.reserve(BinaryFunctions.size() + InjectedBinaryFunctions.size());
-  llvm::transform(BinaryFunctions, std::back_inserter(AllFunctions),
-                  [](std::pair<const uint64_t, BinaryFunction> &BFI) {
-                    return &BFI.second;
-                  });
+  llvm::transform(llvm::make_second_range(BinaryFunctions),
+                  std::back_inserter(AllFunctions),
----------------
rafauler wrote:
> Shouldn't this be
>   llvm::copy(llvm::make_second_range(BinaryFunctions), std::back_inserter(AllFunctions));
> like you did in IndirectCallPromotion.cpp? Similarly for other changes.
It can't be a copy. We take a pointer here (`&BF`), hence transform is needed (that applies a lambda to each element before storing the result).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143019/new/

https://reviews.llvm.org/D143019



More information about the llvm-commits mailing list