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

    <tr>
        <th>Summary</th>
        <td>
            BOLT fails to instrument AArch64 trunk Clang linked with mold
        </td>
    </tr>

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

    <tr>
      <th>Assignees</th>
      <td>
            yota9,
            ElvinaYakubova
      </td>
    </tr>

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

<pre>
    AArch64 buildbot https://lab.llvm.org/buildbot/#/builders/276 is applying BOLT to Clang with Clang-BOLT CMake automation using trunk versions of both.

It has been failing with the following assertion when instrumenting mold-linked Clang:
```
BOLT-ERROR: JITLink failed: In graph in-memory object file, section .text: relocation target "_ZN5clang19RecursiveASTVisitorINS_5arcmt5trans13BodyTransformIN12_GLOBAL__N_118UnusedInitRewriterEEEE12TraverseTypeENS_8QualTypeE/1" at address 0x571bce8 is out of range of Branch26PCRel fixup at 0xeab9b88 (__hot_start, 0x7c00000 + 0x6eb9b88)
```

To repro: 
```
cmake ../llvm-project/llvm -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_APPEND_VC_REV=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DLLVM_USE_LINKER=mold '-DLLVM_ENABLE_PROJECTS=bolt;llvm;clang' -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON '-DLLVM_LIT_ARGS=-v -vv' -GNinja -C../llvm-project/clang/cmake/caches/BOLT.cmake
```

Note that it passes if Clang is linked with lld.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VFGTojgQ_jXxJaUFQUUfeADEOXYZ9JCZ2r0XKkAr2QnESoKj__4qyMzs1XqWFZLupPvrr5OPKsVOHYCHFgEi5CY0XSNCEAkRIRG_sI7-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