[PATCH] D119880: [FuncSpec] Support function specialization across multiple arguments.

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 00:46:45 PST 2022


SjoerdMeijer added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp:339
+      if (!ForceFunctionSpecialization && MinGainThreshold == 0) {
+        // Sort the specializations based on Gain.
+        for (auto &Entry : Specializations) {
----------------
This isn't clear to me, I don't see how we sort things. First, we add things to a map here....


================
Comment at: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp:352
+      auto Iter = Sorted.begin();
+      while ((size_t)std::distance(Iter, Sorted.end()) > Sorted.size()/2) {
+        CallBase *Call = Iter->second;
----------------
... and then we iterate over half the elements in the map here.

Does the sorting rely on the keys of the map? Not sure I find that the cleanest way of doing it, think it could be a one liner and doing a llvm::stable_sort?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119880



More information about the llvm-commits mailing list