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

    <tr>
        <th>Summary</th>
        <td>
            [CUDA][HIP] incorrect linkage of shadow variable for inline device variable 
        </td>
    </tr>

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

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

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

<pre>
    C++17 inline variables have weak linkage in ELF files, which means multiple copies in different translation units are merged into one copy by the linker.

nvcc emits it as weak in both device and host:

https://godbolt.org/z/n8EjvWKxe

currently clang only emits it as weak in device but not host. This causes multiple shadow variables registered for the same device variable.

https://godbolt.org/z/Maz7aMhcP

This caused issue in HIP:

https://github.com/ROCm/HIP/issues/3463
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU19vozgQ_zTmZVRkDJTwwEOTFN3prrrqtKt9NvYA0xo7sk3S9NOvoOk2qlaV9sWWLP9mfn9mZAg0WMSGlVsmxPklyMnQzIRg5T6Rcxydb95fk87pc7NjYsvENquArCGLcJSeZGcwwCiPCCeUz2DIPssBgSzc_9tCTwYDEzs4jaRGmFDaANNsIh0MgnIHwrD81dT36NFGiF7aYGQkZ2G2FANIjzChH1AD2ejA2RV5hu4MccS1JfqU8T3jd2-nPSoFOC1oiiDDGzey0Lk4gsYjKQRpNYwuRJbfXWPHGA9heRMtE-3gdOdMTJ0fmGhfmWjt5v7p-OOfF7wGqdkv7M0ZlJF2AGfN-bcELr27OYJ1ce2fwreRAig5B7wyJ4xSu9OVyR4HChE9auidX6UHOeF7yfeP6Z-IeZCvlXwY1eM16IOOBgphXtP86-_Hr42iOM5dqtzERPv_f7vlWjCiXUsEJtq8uM0T3eS6zmuZYJNVWVFu8kyIZGxUzXuuq6qopJC96ku1Kfgmq-uq7ive9Qk1gouClzzLKl4KkZa3t1xjL_SmrvK-7ljBcZJkUmOO06IxWTs3Na-KOjGyQxMu427x9KbsMu--WTA33TwEVnBDIYaPKpGiWfdk931_x8o9K7eLsHIPZJXzHlX8Nfau_5zbmtVlYT4lBcnsTfOFjQuFy3Vz8O4JVbz2cxX2MwAA___a-jy-">