[PATCH] Implement ADRP CSE for global symbols

Quentin Colombet qcolombet at apple.com
Fri Apr 25 10:59:23 PDT 2014

Hi Jiangning,

On a second though, I do not think approach #2 is reasonable.
In your example:
adrp r0, MergedGlobal at PAGE
load [r0, var1_offset_within_PAGE]
load [r0, var2_offset_within_PAGE]
load [r0, var3_offset_within_PAGE]

Is in fact, syntax A
adrp r0, MergedGlobal at PAGE
load [r0, MergedGlobal at PAGEOFF+var1_offset]
load [r0, MergedGlobal at PAGEOFF+var2_offset]
load [r0, MergedGlobal at PAGEOFF+var3_offset]

Or put another way, syntax B
adrp r0, MergedGlobal at PAGE
load [r0, MergedGlobal_var1 at PAGEOFF]
load [r0, MergedGlobal_var2 at PAGEOFF]
load [r0, MergedGlobal_var3 at PAGEOFF]

For syntax A to be valid, you need to be sure that MergedGlobal at PAGEOFF+varX_offset fits the encoding space.
For syntax B to be valid, you need to be sure that MergedGlobal at PAGE == MergedGlobal_varX at PAGE.

Thus, in both cases, this is not generally correct.

To increase the likelihood of this being correct, you’ll need to align the thing on a PAGE, and make sure that the reachable fields are within the encoding space (this should be fine, because of the get max offset thing). I’d say that is not desirable.

Therefore, I think we need to go for approach #1.
That said, if we can set an alignment that makes sense, that sounds good. In fact, for external globals, we may have to produce an accurate alignment for external users to get what they expect based on the original alignment of each field.

What do you think?



More information about the llvm-commits mailing list