[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 25 14:44:14 PDT 2021


lebedev.ri added a comment.

@arsenm are you happy with the test coverage here?

In D108661#2963519 <https://reviews.llvm.org/D108661#2963519>, @craig.topper wrote:

> Wild speculation. This may be a historical artifact of LoadInst and StoreInst having their getAlignment() function written like this when this limit was created
>
>   unsigned getAlignment() const {
>     return (1 << (getSubclassDataFromInstruction() >> 1)) >> 1;
>   }
>
> Because "1" is signed int the left shift produced a signed int. The final right shift would be an arithmetic shift. So if the alignment was 1 << 30, the subclass data would be 31, the shift would produce INT_MIN, and the arithmetic right shift would produce 0xc0000000 which would be incorrect.
>
> AllocaInst used 1U instead of 1 so would have been immune.

That does seem plausible :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661



More information about the cfe-commits mailing list