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

    <tr>
        <th>Summary</th>
        <td>
            [NVPTX] Incorrect alignment in call prototype for 'sprintf' function
        </td>
    </tr>

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

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

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

<pre>
    The NVPTX backend currently emits the incorrect alignment when trying to compile the `sprintf` function with LTO. It will emit errors like the following:
```
ptxas a.s, line 1509; error   : Alignment of argument does not match formal parameter '_'
```
Looking at  the IR in https://godbolt.org/z/n9nK6ddxb I noticed that many of these `_` function calls come from the main implementation. If this function is internalized, then these calls get an incorrect alignment of `16` as in the following:
```
prototype_82 : .callprototype (.param .b32 _) _ (.param .align 16 .b8 _[16], .param .b64 _);
```
If I make the indirect call instead have an alignment of `8`, then it works just fine, i.e. This also happens if I manually remove the `internal` keyword from the function and thus make it `.visible`.
```
prototype_82 : .callprototype (.param .b32 _) _ (.param .align 8 .b8 _[16], .param .b64 _);
```

Any clue why this would cause issues? Since this is an indirect call it's not like there's a set prototype we need to adhere to. And I don't see why making the function `.visible` or not makes the alignment correct.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VMFu4zYQ_Rr6MliBoizJOejgNDBgdNEWbVD0ZlDiyGJMkQY5itb79QUpx94EORQFFjBsmeLMvHlv5skQ9NEiNqx8ZOXTSk40ON-8DFOLvlq1Tl2a5wHht7__eP4HWtmd0CroJu_RkrkAjpoC0ICgbee8x45AGn20I1qCeUAL5C_aHoEcdG48a4PpOqt4OHttqWcVh36yHWlnYdY0wNfn3zPYE8zamFQB0HvnAxh9WqJ7Z4ybtT2yYsv4E-NbVvHrJ_090zcZQGaBiV_AaIuQl_yBFY9LKgBgxRa2N6SuB-mPU3pWDgNYRzBK6g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