AArch64: use a constpool for blockaddress(...) on MachO
authorTim Northover <t.p.northover@gmail.com>
Mon, 8 Feb 2021 14:47:14 +0000 (14:47 +0000)
committerTim Northover <t.p.northover@gmail.com>
Mon, 8 Feb 2021 15:13:29 +0000 (15:13 +0000)
commitc93d50dd716879a7edb2c28f4bf9d435651f3766
tree21f878c4584642e28286114a2cac0806ec55fda7
parent4b661b4059b0b5fa8594a0717df208a122ea15da
AArch64: use a constpool for blockaddress(...) on MachO

More MachO madness for everyone. MachO relocations are only 32-bits, which
means the ARM64_RELOC_ADDEND one only actually has 24 (signed) bits for the
actual addend. This is a problem when calculating the address of a basic block;
because it has no symbol of its own, the sequence

adrp x0, Ltmp0@PAGE
add x0, x0, x0 Ltmp0@PAGEOFF

is represented by relocation with an addend that contains the offset from the
function start to Ltmp, and so the largest function where this is guaranteed to
work is 8MB. That's not quite big enough that we can call it user error (IMO).

So this patch puts the any blockaddress into a constant-pool, where the addend
is instead stored in the (x)word being relocated, which is obviously big enough
for any function.
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/test/CodeGen/AArch64/arm64-blockaddress.ll
llvm/test/CodeGen/AArch64/arm64_32.ll