[PATCH] D152833: A new code layout algorithm for function reordering [1/3]

Sergey Pupyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 15:39:05 PDT 2023


spupyrev added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/CodeLayout.cpp:161
+/// together with the corresponding merge 'type' and 'offset'.
+struct MergeGainT {
+  explicit MergeGainT() = default;
----------------
hoy wrote:
> spupyrev wrote:
> > hoy wrote:
> > > nit: by convention the `T` in the struct name is not needed. I'm seeing `JumpT` and a few other types getting `T`. Is there a particular reason?
> > I too don't like this T suffix but I found myself writing
> > ```
> >     for (Chain *Chain : SortedChains)
> > ```
> > all over the place. It compiles but looks confusing. I strongly prefer `ChainT *Chain` over this instead.
> > 
> > Any other suggestions?
> I usually do 
> 
> 
> ```
>  for (auto *Chain : SortedChains)
> ```
> 
> or
> 
> ```
>  for (Chain *C : SortedChains)
> ```
I've been using the former for a while but Some LLVM folks advised me against over-using `auto` for non-complex types. I've even seen constructs `auto *Chain` refactored to `class Chain *Chain` in some cases, which is worse than introducing `ChainT`, in my opinion.
I feel like providing full variable names, such as `Chain` in instead of `C`, yields more readable code, no?


================
Comment at: llvm/lib/Transforms/Utils/CodeLayout.cpp:991
+std::vector<uint64_t>
+llvm::applyExtTspLayout(const std::vector<uint64_t> &NodeSizes,
+                        const std::vector<uint64_t> &NodeCounts,
----------------
hoy wrote:
> spupyrev wrote:
> > hoy wrote:
> > > I guess CDS is only for function layout, but do you think the name here should be adjusted in order to not be Exstsp-specific?
> > Can you clarify what "name" you refer to? (happy to rename or add a comment if there is a confusion)
> I mean `applyExtTspLayout`. Do you think it makes sense to rename it like `applyCDSLayout`?
These are different algorithms, one is for basic block layout, another one is for functions. Follow-up diff introduces `applyCDSLayout` in addition to `applyExtTspLayout`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152833



More information about the llvm-commits mailing list