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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Missing signext attribute on parameter
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:optimizations
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            rnk,
            uweigand,
            aeubanks
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          JonPsson
      </td>
    </tr>
</table>

<pre>
    `a() { printf("\n"); }`

Instcombine replaces the call to printf with a call to putchar, but forgets to add an extension on the new parameter:

`  %call = call signext i32 (i8*, ...) @printf(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))`

=> After InstCombinePass

`%putchar = call i32 @putchar(i32 10)`

=>

```
        lhi     %r2, 10
        jg      putchar@PLT
```

This particular case seems perhaps harmless, but I suspect that calls to other library functions might not be: on SystemZ all outgoing parameters less than 32 bits in width must have a sign/zero extension attribute at the call site to conform to the ABI.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1VE1vozAQ_TVwGS0iBpJw4JA0W6mrXanS9rQ3AwO4BRvZQ79-_Y6dpEmr3cjBeMZ68974mdq0b1W0TmUktpEoIdrsYbZKUxcCIiputJ9EGWV7zh54b5QeonR3fN5pR42ZaqURLM6jbNABDQiNHEcgcwKDF0UDyEt0oWaQNhI3UC8EnbE9kvMZ2bYgNeAroXbKaODh8TS-wCytnJDQRtnumgRzAohEEdCj7HAs41SvGQZUJji5VSxn5wsmSRKU5umH0JADbRbdYgdMBUecUNNMFpSufdx5jKjYC3gF3l4cPNTn9c5jJo6CLLXOIb16Kf343DtmGmXfYdexIvCNvDk28l4690Ueizu17KIv6GIR51ZufWCV_q_OV8TjCEs4_cZBhZmrWeG5r75seOyP87lmnt7_fPgn5PH5MCjnT41Us4zMvZEOwSFOHEU7yNkBw0wjsuCTFe7ALW7GhvjUJQWlwReGTWBhVLWV9g26RTfE7nAwqX4gPjqCGtkW3i6_3xzh9Ad8k8xCvVG6v3jHgS_n0TVww2rFvlOaDdqyQ6fFEVN6Rvaq908kbt_Rmis7SiKrmCjvoIvRneIAs2yMZi9P_tXndvu75LofcVtlbZmVMiZFI1bsn6tzZxPBL-Wcp3s276Uc1_7QEC92rAai2fmbIG559HzBljrhu8iLcXw-T99max65nbxk6AW50bdFXmQiHqq0SDEvt-t8061X667Nsob_ZV7Ksli1mYxHWePoPE3-BgTQbGdmUpN6l6H94QtxiFUlUiHSTOSrjdikm2TdlEJ0626zWbdF17TsFJykGhMPkvBtj20V2NVL7zg5KkfukuQL4PXjqbLVT-EbxBdOiOUFVS91e4lIXGqpn85k5EKDsdUPo--dMzoOsqug-S_YTIGH">