[PATCH] D36351: [lld][ELF] Add profile guided section layout

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 17:56:16 PDT 2018


espindola added inline comments.


================
Comment at: ELF/CallGraphSort.cpp:57
+using ClusterIndex = std::ptrdiff_t;
+using SectionIndex = std::ptrdiff_t;
+using EdgeIndex = std::ptrdiff_t;
----------------
Bigcheese wrote:
> espindola wrote:
> > Why do you need a 64 bit index. Why does it need a typedef?
> While ELF limits the number of sections/symbols a single ELF file can hold, there's no limit on the number of input sections that go into the final link.  If we have multiple ELF files with 4bn sections, then this could overflow.  The chances of this are rare, but there's almost no cost in supporting it.  The correct default type for array indexing is std::ptrdiff_t, you need a good reason to use something else.
> 
> As for the typedef, it makes it clearer what the purpose of the index is. Otherwise they would all have the same type.  If C++ had a good way to do strong typedefs I would be using that here to add compile time enforcement.
The reason is that nothing in lld does this.

Just use int/unsigned as appropriate. We do not design for an abstract pie in the sky.

Change this.



https://reviews.llvm.org/D36351





More information about the llvm-commits mailing list