[PATCH] D25324: [ELF] - Check that section alignment is a power of 2.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 12:40:53 PDT 2016
On Thu, Oct 6, 2016 at 12:34 PM, Rui Ueyama via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> We used to represent alignments both in 2^n and log2, and I streamlined it
> by using 2^n consistently because it was confusing. So I'm inclined not to
> go back to that state unless you show saving a few bits is worth doing.
>
> As to the division, I think alignTo in MathExtras.h is too powerful that it
> can handle alignment of non-power-of-2. It can take any number as an
> alignment. Do we really need it? I'm wondering if we can replace the
> implementation with this
>
> inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew = 0)
> {
> assert(Align != 0 && "Align can't be 0.");
> assert(!isPowerOf2_64(Align) && "Align must be a power of 2.");
> // return (Value + Align - 1 - Skew) / Align * Align + Skew;
> return ((Value - Skew + Align - 1) & -Align) + Skew;
> }
>
Interesting. I think this is a good idea if can be shown that it
matters. Otherwise I'm under the impression that it's not entirely
worth the complexity of adding a new API.
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list