[PATCH] D35640: [lld] [COFF] Align import address chunks to the pointer size

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 14:08:57 PDT 2017


mstorsjo marked an inline comment as done.
mstorsjo added inline comments.


================
Comment at: COFF/Chunks.cpp:186
 static void applyArm64Ldr(uint8_t *Off, uint64_t Imm) {
   int Size = read32le(Off) >> 30;
+  if ((Imm & ((1 << Size) - 1)) != 0)
----------------
ruiu wrote:
> It is better to use uint32_t so that you don't need to think about sign-extended shift.
Sure - do you want that change separately in a different change, or squashed into this one?


================
Comment at: COFF/Chunks.cpp:187
   int Size = read32le(Off) >> 30;
+  if ((Imm & ((1 << Size) - 1)) != 0)
+    fatal("Misaligned ldr/str offset");
----------------
ruiu wrote:
> Use llvm::isPowerOf2_32.
Doesn't that check a different thing? This tests if the lowest `Size` bits of `Imm` are nonzero, while `llvm::isPowerOf2_32` checks if the value is a power of two?


https://reviews.llvm.org/D35640





More information about the llvm-commits mailing list