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

    <tr>
        <th>Summary</th>
        <td>
            AMDGPU/TeraScale: Mesa Clover OpenCL crashes on llvm::TargetInstrInfo::ReplaceTailWithBranchTo()
        </td>
    </tr>

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

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

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

<pre>
    Originally posted here: https://github.com/void-linux/void-packages/issues/43921

Running some models causes Mesa's OpenCL implementation for TeraScale (Clover) to call `llvm::TargetInstrInfo::ReplaceTailWithBranchTo()` from `/usr/lib/libLLVM-15.so`, which itself is provided by `libllvm` version 15. This call causes a segmentation fault (verified via `gdb`).

To reproduce the bug:
 - Use a TeraScale 3 GPU.
 - Ensure Mesa uses Clover as an OpenCL implementation with llvm 15.
 - Download an affected TensorFlow Lite model ([squeezenet](https://tfhub.dev/tensorflow/lite-model/squeezenet/1/default/1) for example).
 - Compile TensorFlow Lite's benchmark with GPU support.
 - Run it with the --use_gpu=true --gpu_backend="cl" options.
 - Observe the segmentation fault

In my particular case I'm using an old Radeon 8670D, a Terascale 3 iGPU with the radeon kernel driver.
Since segmentation faults are typically caused by null-pointer dereferencing in CPU code I tried to solve the problem in the linked issue by patching llvm with a backport of https://github.com/llvm/llvm-project/commit/17069608940d22cd6266afb948443b11793f0a57, but the segmentation fault still occurred.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVctu4zYXfhp6c2BDomTZXHiRiX8HARIkyDh_lwOKPJJYU6TKiz3p0xek3CS9TIGiG1kSqePvpk_ce9UbxB1ZfyHr_YLHMFi3e8RTWZSL1sq33ZNTvTJc6zeYrA8oYUCHpLqBIYTJk-qG0AOhh16FIbYrYUdCD2er5FIrE7__fjFxceI9ekIPyvuYT-qK0ZI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