[PATCH] D125278: [GlobalOpt] Relax the check for ctor priorities

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 01:18:20 PDT 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:2062
+  // Skip external functions.
+  if (F->empty())
+    return false;
----------------
`F->isDeclaration()` would be more idiomatic?


================
Comment at: llvm/lib/Transforms/Utils/CtorUtils.cpp:80
 /// Find the llvm.global_ctors list, verifying that all initializers have an
 /// init priority of 65535.
 static GlobalVariable *findGlobalCtors(Module &M) {
----------------
Outdated comment.


================
Comment at: llvm/lib/Transforms/Utils/CtorUtils.cpp:129
+  std::vector<size_t> CtorsByPriority(Ctors.size());
+  std::iota(CtorsByPriority.begin(), CtorsByPriority.end(), 0);
+  stable_sort(CtorsByPriority, [&](size_t LHS, size_t RHS) {
----------------
Why does this sort CtorsByPriority rather than sorting Ctors directly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125278



More information about the llvm-commits mailing list