<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/85202>85202</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Anchored Addresses to reduce global address calculation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sjoerdmeijer
      </td>
    </tr>
</table>

<pre>
    GCC has a feature to anchor addresses, which calculates a base address for global variables and uses offsets to that base address to access globals. This saves instructions to materialise the addresses of globals on some architectures, on AArch64 for example:

https://godbolt.org/z/qbn6rTbf8

The GCC feature is described in a bit more detail here:

https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gccint/Anchored-Addresses.html

This is related to PR #56392, but that might be more focused on a RISC-V, like enabling the GlobalMerge pass. 

About the difference between anchored addresses and GlobalMerge: GlobalMerge is a relative simple pass that tries to merge internal globals, so it is less generic than anchored addresses. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU01v7DYM_DXyhVjDltcb78GHbR72oYcCxWvQuz5oi6kspaKctP31hey4LykK9LJr2CRnODNUzDQHxFH0P4j-S6XW7GIa-TlisgvSM6ZKR_vn-PXxEZxiUDChymtCyBFUMC4mUNYmZEYW8hHeHBkHRnmzepWxdGjFeBTBFBPMPmrl4VUlUtqXmmBhZWSI08SYuQzPTuXPrQXRmPK0D-AanhwxsHpFBgqc02oyxbCVLipjIuWJEbLD7ywhTscAiAE4LggqGUcZTdlsWyMGuN2ScZfzxhj_UMuLR9HdRPNFNO-_LucXLu_kXcj7HK2OPtcxzULe_xLy_rsOl_Skp-Fj05NDKGoeOhKDRTaJNFqgUPSiDEtMCBazIg8O0_8gG1PPYX1HjsFTQBsN759OfS3rZn-mkIW83zbf0J5uhya1y4v_zJK4UEtYXLRF0J-_gZBdf-musiik17x7tNDsMmjcOU_RrIy2CKjg24-_PJ5-LdWefkPAoLSnMG9-fN0s-AnTjPCimGv4iH_TcZuPYGmaMGEwCBrzG2J4zx3aD56WBH2YKLrbJwAqOdx2oVcEpmLmhrqvkBPhHpq9OmRMQfkjJmUBjkC5zPFbADFgIlO6_4tODZUdO3vtrqrCsX1om3Pb9P21cuM0tPoyPEy9ergMrcXBXK76ooarHCQOpq1olI08N117bptGdte6aZWapqab9Fm31g7i3OCiyNfevy7F84qYVxyHXjay8kqj5-2epQz4BttHIWU57zSWnpNeZxbnxhNn_j4lU_Y4HtmAf7JRdEloV4PH4R4HeVw5xVCtyY__SiVlt-raxEXIe0F5_zu9pPiMpgRx41ZiunH_OwAA__916Yjl">