[PATCH] D45199: AArch64: Allow offsets to be folded into addresses with ELF.

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 13:35:49 PDT 2018


t.p.northover accepted this revision.
t.p.northover added a comment.

Thanks for updating the patch. LGTM!



================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:10644-10645
+
+  // Check whether folding this offset is legal. It must not go out of bounds of
+  // the referenced object to avoid violating the code model, and must be
+  // smaller than 2^21 because this is the largest offset expressible in all
----------------
pcc wrote:
> t.p.northover wrote:
> > Is this some object format constraint? Because in straight LLVM IR I don't think there's any rule against going out of bounds.
> It is a code model constraint. Imagine that you have an executable with virtual size of exactly 2GB (which just fits into the small code model), a function at the very start and a variable at the very end. If the function takes the address of the variable and adds a large out-of-bounds offset, folding the offset would push the address outside of the range allowed by the code model, and the linker would be unable to relocate the ADRP instruction. We would still be able to compute the address of the start of the variable and add the offset in code.
OK, that makes sense.


https://reviews.llvm.org/D45199





More information about the llvm-commits mailing list