<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96614>96614</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SPIR-V] Backend crashes on a collision between explicit integer constant and added automatically by IR Translator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
VyacheslavLevytskyy
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
VyacheslavLevytskyy
</td>
</tr>
</table>
<pre>
There are cases when the same integer constant is added both via Backend constant tracking path and automatically by IR Translator. Automatically added constant has an integer type with a bit width equal to the target machine word. When we have the same value of the integer constant but the type differs (for example, i64 when translating for i32 target), there is a collision between explicit integer constant and added automatically by IR Translator that breaks internal Backend agreements about constants tracking and leads to a crash on later translation stages due to existence of the constant in code but absence the same constant in a dependency graph.
A simple reproducer is the following:
```
@a_var = addrspace(1) global [2 x i8] [i8 1, i8 1]
@p_var = addrspace(1) global ptr addrspace(1) getelementptr (i8, ptr addrspace(1) @a_var, i64 2)
define spir_func void @foo() {
entry:
ret void
}
```
A collision will happen between `2` in the `@a_var` definition and `i64 2` added by IR Translator when translating the gep of the `@p_var` definition.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE1v4zYQ_TX0ZRBDpixZOuiQ1DCwQA_FdrE9LkbkSGJDkyo5sqN_X1D-SpugPS1gWJD4-DjvzeNgjKZ3RI0oXoSU32dUA0WLp1_pNHN8nWchpSj2K5x48KH5BLBqvZ6bbwMFAgwECiNFOA_kgAeCiEcC45h6CqC8i4yOwURArUlD63mAk0F4QfVKTj8gHFC9GtfDiDwAOg04sT8iG4XWztDO8OUrfAvookX2YQ3P_1i_8N_pBoyA7l4JzyPB2SRmaA3D2WgegP6a0AL7pXLG0BPDEdVgHMHZB72GP5KuM8GAJ3roO6GdCHy3fPkgtp34QpjO1KbrKEQQsup8AHrD42hJyF_AlNurbVdNSXzCmFxeixGyTkhezE4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