[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 24 14:04:07 PDT 2021
craig.topper added a comment.
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.
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