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

    <tr>
        <th>Summary</th>
        <td>
            [BOLT] Support PIC fixed branch
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            BOLT
      </td>
    </tr>

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

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

<pre>
    [bolt-x86_64-ubuntu-clang](https://lab.llvm.org/buildbot/#/builders/252) started to fail with jump table heuristic failure (https://lab.llvm.org/buildbot/#/builders/252/builds/9615).

The crash is caused by the following function in GCC-built Clang:
_ZN5clang15ModuleMapParser23parseOptionalAttributesERNS_9ModuleMap10AttributesE.localalias

Unsupported code pattern is the following:
```
81a3a0f: 48 63 05 16 b4 03 fa movslq  -0x5fc4bea(%rip), %rax  # 0x21dee2c <CSWTCH.677+0x3dc>
81a3a16: 48 8d 15 03 b4 03 fa          leaq  -0x5fc4bfd(%rip), %rdx  # 0x21dee20 <CSWTCH.677+0x3d0>
81a3a1d: 48 01 d0                      addq  %rdx, %rax
81a3a20: 3e ff e0                      jmpq  *%rax
```

The compiler could have avoided using PIC jump table access pattern and instead jump to the target directly. But since it has not, we need to gracefully handle that.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE1v4zYQ_TX0ZWCDIvV58MFRNm2B7geaFAV6CUbkyGJAi1p-OM6_L6R4vU6QnpYwTJBDvjcaznsYgtmPRFtW3LDidoUpDs5vEdPkjqvO6Zc50jkb16e6fCzzderSGNNaWRz3rLhloh5inAKTOybumLiz2G2sPR42zu-ZuOuSsbpzcQnKHxvkAxN3ohBMNBAi-kgaooMejYVnEwd4SocJInaWYKDkTYhGLeHkCX6Z9HVjXjZlVjDRbBi_ZXz3-v8wECiPYQATQGEKpKF7gTgQ9M5a92zGPfRpVNG4EcwIv7XtekaM0C5lkWegx3-_FEuhsuKz08nSZ5y-oQ_khZzm-es0Q6DdxehNlyKFT399uX9sLqczfhXaWKfQojUYrtP9ewxpmtxSQ-U0wYQxkh_n7N_kfMmLlfz8W5Z1hhJ5z-QO8hpKCbyArIQuBy6hRzi4Y7DfAdb8VPQq7wiZqJkovJmYaJhoYV7gCYAJCfwkMk0kFDDZtvf_PLS_b8qqYuKGn6RWTH66Ys3KM2utIStmvgvrZVjCK_Jef0Su35HzD8n5O3J9JucZaA4fDtT6O5wpfn7pFYjgM4gk6Hug_wF5OkwLyO769rtHuGo9d5iMJQ_KJathwCMBHp3RpCGFufe-_dFeCwSVohAuz46jBjOGSKjPp9zSBxH9niJo40lF-7KBmxQhmFERmAgDBhhnybTwTDDSqyD3HhX1ydoXGHDUliAOGDcrvZW6kQ2uaJtVWSFqWeXVathWFecodF7xGsuqq8q6o6ropNRUCJ33K7MVXOS84E3W5EJUm4oTbyTJqutLlFXJck4HNPai55UJIdG2ycq8XlnsyIbFrYS4-frnAxNi9i2_nY-vu7QPLOfWhBh-AkQT7eJwy4XiFu5f9bLUsTenWd4eRzWskrfbt86yN3FI3Ua5w2wz9vhjWk_ePZGaLWbJb_GSOcX_AgAA__9iGJt8">