<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115733>115733</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
@llvm.experimental.stackmap intrinsic crashes when the second parameter (numShadowBytes) is a variable instead of a constant
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DigOrDog
</td>
</tr>
</table>
<pre>
# Description
The llvm.experimental.stackmap intrinsic currently crashes when the numShadowBytes parameter is provided as a variable rather than a constant. According to the syntax, llvm.experimental.stackmap is expected to record the location of specified values in the stack map without generating code. However, when attempting to pass a variable as the second argument (numShadowBytes), the compiler fails, leading to a segmentation fault during the X86 DAG->DAG Instruction Selection pass.
Example code that triggers the crash:
```
@G = global i16 0
@G.1 = global i32 2147483647
define void @f(i32 %nelems) {
entry:
%B = sub i32 %nelems, 65536
%mem = alloca i32, i32 %nelems, align 4
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 %B, ptr %mem)
ret void
}
; Function Attrs: nocallback nofree nosync willreturn
declare void @llvm.experimental.stackmap(i64, i32, ...) #0
attributes #0 = { nocallback nofree nosync willreturn }
```
https://godbolt.org/z/eM46jdv7r
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMGSozYQ_Rr50rUUFhg8Bw72ej3JIZXD5pBrIxrQRkiU1NjjfH1KMpPxTDabuFwgV79uvfckPwxBD5aoEbuj2J02uPDofHPSw6_-5IZN67pbI2QBJwrK65m1syI_ifzw20hgzGXK6GUmryeyjCYLjOqPCWfQlr22QStQi_dk2dxAeQwjBbiOZIFHArtMX0fs3PV4Ywowo8eJmDzoALN3F91RBxgA4YJeY2sIPPJIHnhECwjK2cBoOYODUs532g7ALs0ON8v4IuTnH7IMEAuKqYt9nuKQ1G6cwigWXA9hJqV7TR1c0CwUQN_ppzEQ51w1j25hGMiSR440lOsog5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