[PATCH] D152840: [ELF] A new code layout algorithm for function reordering [3a/3]

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 12:52:04 PDT 2023


MaskRay added a comment.

Thanks for the update.



================
Comment at: lld/ELF/CallGraphSort.cpp:278
+DenseMap<const InputSectionBase *, int> elf::computeCacheDirectedSortOrder() {
+  // Creating a call graph and necessary data.
+  SmallVector<uint64_t, 0> funcSizes;
----------------
Nit: delete this comment.

"// Create the graph." below is clear enough.


================
Comment at: lld/ELF/CallGraphSort.cpp:283
+  SmallVector<uint64_t, 0> callOffsets;
+  std::vector<const InputSectionBase *> sections;
+  DenseMap<const InputSectionBase *, size_t> secToTargetId;
----------------
`sections` can use `SmallVector` as well.

We can use one type for multiple variables
```
SmallVector<uint64_t, 0> funcSizes, funcCounts, callOffsets;`
```


================
Comment at: lld/ELF/Config.h:62
 
 // For --call-graph-profile-sort={none,hfsort}.
+enum class CGProfileSortKind { None, Hfsort, Cdsort };
----------------
update this comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152840



More information about the llvm-commits mailing list