- The offset should be treated as a signed one.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This patch only handles the case where that offset is representable in a 32-bit signed integer. For a generic 64-bit offset out of range of 32-bit integer, we need to revise the relocation spec to enhance REL32_HI from the orginal
(S +A - P) >> 32
to
(S + (A << 32) - P) >> 32
where A is that 32-bit sword addend. In fact, we split a 64-bit offset into low 32-bit addend used in REL32_LO and high 32-bit addend used in REL32_HI. However, that needs changes in more than components. As that's the rate case, I want to address the current critical issue first and will start the discussion on relocation changes.
BTW, in the real example, that negative offset is created by LSR pass to reduce the code strength in a loop.
GlobalISel doesn't have this issue yet as it won't fold G_GLOBAL_VALUE and PTR_ADD together. So, it only observe positive offsets. But, we'd better change that interface as well.
If you could merge this with an existing test for this, that would be slightly preferable