<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85209>85209</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[GlobalISel] Hash collisions / hitting EmptyKey or TombstoneKey on map key in RegisterBankInfo
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
marcauberer
</td>
</tr>
</table>
<pre>
We experience sporadic failures in [RegisterBankInfo::getOperandsMapping](https://github.com/llvm/llvm-project/blob/203757776826cfd164c537048ec90f5ada50cae2/llvm/lib/CodeGen/RegisterBankInfo.cpp#L334). These failures seem to be triggered by
`hash_code Hash = hash_combine_range(Begin, End);`
hitting the value of EmptyKey or TombstoneKey in the DenseMap member [MapOfOperandsMappings](https://github.com/llvm/llvm-project/blob/203757776826cfd164c537048ec90f5ada50cae2/llvm/include/llvm/CodeGen/RegisterBankInfo.h#L413). We still use LLVM 13, but the coding seems to have remained the same until to date.
We also see failures in [RegisterBankInfo::ValueMapping::verify](https://github.com/llvm/llvm-project/blob/203757776826cfd164c537048ec90f5ada50cae2/llvm/lib/CodeGen/RegisterBankInfo.cpp#L555) that seem to be triggered by hash collisions from
`hash_code Hash = hash_combine_range(Begin, End);`
To us it seems that this coding is not protected against these problems and therefore failures can happen randomly.
Already posted the problem in the Forum, but got no answer there:
https://discourse.llvm.org/t/registerbankinfo-getoperandsmapping-not-protected-against-hash-collisions-emptykey-tombstonekey/77659
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlU-P2zYTxj8NfRnYkEn9Peiwu47yBu8uArSL7DEYiSOJNUUKJLWpv31B2c46C6RoDy16kaAhOeLM73lI9F4Nhqhm2T3LDhtcwmhdPaHrcGnJkdu0Vp7qFwL6fSanyHQEfrYOpeqgR6UXRx6UAZbd_0KD8oHcPZrjJ9NbJu6YuBsofJ7JoZH-CedZmYFlB8bLMY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