<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58583>58583</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[IR Verifier] didn't check if switch case is constant
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
DataCorrupted
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DataCorrupted
</td>
</tr>
</table>
<pre>
```
define void @foo(i16 %0, i16 %1) {
entry:
switch i16 %0, label %default [
i16 %1, label %on_one
i16 2, label %on_two
]
default: ; preds = %entry
br label %exit
on_one: ; preds = %entry
br label %exit
on_two: ; preds = %entry
br label %exit
exit: ; preds = %on_one, %on_two, %default
ret void
}
```
The program is illegal but can pass `IR Verifier`. (`LLParser' will still report error)
However, if the programmer incorrectly `setOperand` of a switch in memory, `IR Verifier` won't report error.
Will update a patch to align tests in `IR Verifier` and `LLParser` for switch testing.
P.S> Should we add sanitization when `Switch->setOperand(...)` ? Currently, it only tests out of bound, should we also test for type consistency?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VFFvmzAQ_jXwcioCUwh54KFNVm1SpU3rtD1OBl-CN8dGtmnW_fqdgTSk28OqSUMI-_Ddfd99Z7sx4qmOynR-022U3gjcSY3waKSA6DrdGROxSmYlRKxII7aBeZ5FbA3R6naKQu3tU5TfTBaAO0rfdrCMU7xBFSxC4IPyEBW3J3dYZF14Gv3VaLx0Yi89_NGcPKJiO02fSwlARAv--onyW-gtCkezbUCYKpsBGnuGxh_SL9Fmsq8B-ze0UPh_QhvtV2H9AW0WiNp3btxknBo1M7Hox_03M1idmnq5Uafvpw4JxewtP4B0IJXCPVfQDB5arqHnjvDL9N1H-IxW7iRashICrWi8v__AraNfbAVHCgXnw9dib6wHtNbQ0noJ99Yc8TEE0DnYgT-DH9CC1K2xFluvngKmQ_--R8u1IAPMDvjzsdBwwIMh7UP9L9nB0Whi5C94JEsWXwLLoRfcIyXtecjpDXAl9xo8Ou8CxO-JiQosy6ZfO2NPrEKg1PsLpA_JQ5S_gYfODErAkeCEAMe19PIn99JoOHY4Qj2MSa7Ie1E3q5IkCRISUpTfwWYgfTTpMwrowWiSaiJsqGOkUWOGELcBd4ZUzoxOI1n_1CO0RjvpPOqWLp27GOusDA-ryjIWdS7W-ZrHXnqFNd0ySxWKLQgpJn3bDtvvoY-zAC13GDZRyO659vFgVd1537tws7E7evfSd0OTtOZAhlKPp-GKtsE36jyZ0rkBHU2KqqjyuKurVgjBWbZqq6oos7LNVkVeVm3esGYnijQej50LTCPGpqSMiMayZiljWUoXaFZcszJZs2ZdrXPOsWjLjGd0P-OBS5WEoMTYfWzrkU0z7B0tKtLInRfpLNAGQZyRttzzDW3YofcoZkg--M7Y-mIpHiuqx3J-ASj2ygo">