According to the documentation in StackMap section for the statepoint we should have:
The first Location in each pair describes the base pointer for the object. The second is the derived pointer actually being relocated.
But actually in the code we emit them in reverse order - derived pointer first, base pointer second.
This change fixes this problem and updates test cases to check ordering.
I would prefer to see this loop structured analogously to the other one you changed. As this change illustrates, the modulo trick here is unnecessarily complex and subject to mistakes.