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

    <tr>
        <th>Summary</th>
        <td>
            Not passing a type to attribute byval when declaring a function is inconsistent
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          Vasil-Kirov
      </td>
    </tr>
</table>

<pre>
    If you set the attribute byval to a function parameter but forget to pass the parameter type it only raises an error around 20% of the time, otherwise it seems to work which shouldn't be the case.

`
func->addAttributeAtIndex(arg_index, Attribute::get(context, Attribute::AttrKind::ByVal));
`

Running the same program causes verifyModule to raise an error around 20% of the time, the program to straight up crash (on verifyModule -> ... -> isSized check) 5% of the time and for it to compile successfully the rest of the times.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNU01vnDAQ_TVwGQWBWdjlwGGTNFIUtYdWyrUyMIAbr73y2Luhv75jNl-NeiiyzJiZ53nzZujssLT3Iyw2AKEHPyNI753qgkfolpPU4C1IGIPpvbIGjtLJA3p0wCEwWjdFmOXvRCv8PcAvRwTlwRq9gJOKkEAaQOesA-lsMAOIPBEV2HGFenXARNyA5YM7c3xEE-KBYoazdU9wnlU_A8026MEkYuuhwxXbS8IsyW-TfP-y1_nFiNSvkvKLHIb9a2l7f28GfE7ETrrpp7rYN_DmT8o9Ly6NI3prPD77f_jj8YHBl9P18ih1Ipq4yutPJC7792CMMtNKmFglODo7sVzMPkR1TujUuHy1Q9AYS15F-z_NVulfbmMkecZOs4dwhN5JmoEr4fb9lSGqAlmWXQxFP9RvHKCfsX_iIqD6lIaJDLHjsSucoreHo-JbKPQ9Eo1Bc5tjrEPyH3H00pcU26Ku66IR_KRDWw5N2cjUK6-x_Wb9OkNRHnkZnTh4n2bxPKOBAXst3SXwbS4VgTLcKlLk0fg0ON3O3h8pNkfc8ZqUn0OXMW0-aH16fV2xbL-w5wbfKaKAxEa122yLdG4rUeVVLut63BabaidxU-7Katvs-maoiyFPtexQU5tU14kQBs-wXsF2Ut2mqhW5EEVeNEVV5KLIig7LptvIOt9VY5OPySbHg1Q6izwy_pdS166UujAROzUXQ-_OKM9kENd0fL8MfraufZSk9NWDcvaUrunblf4f0wpH2Q">