This is an archive of the discontinued LLVM Phabricator instance.

AArch64: use a constpool for blockaddress(...) on MachO
ClosedPublic

Authored by t.p.northover on Aug 3 2020, 5:37 AM.

Details

Reviewers
ab
Summary

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.

Diff Detail

Event Timeline

t.p.northover created this revision.Aug 3 2020, 5:37 AM
t.p.northover requested review of this revision.Aug 3 2020, 5:37 AM

Ahmed pointed out that getAddr already results in a MOVaddrBA eventually so the ISelLowering change was pointless.

ab accepted this revision.Jan 26 2021, 9:57 AM
This revision is now accepted and ready to land.Jan 26 2021, 9:57 AM
t.p.northover closed this revision.Feb 8 2021, 7:13 AM

Thanks Ahmed, committed as c93d50dd7168.