<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144301>144301</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
PDB shows wrong calling convention when compiling static functions on Windows x86
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
momo5502
</td>
</tr>
</table>
<pre>
Compiling the following sample for Windows x86 with -O3 shows that `static_func` will have `fastcc` applied to it:
```C++
static __declspec(noinline) int static_func(int arg1){
return arg1 * 2;
}
int main(int argc, char* argv[]) {
return static_func(argc);
}
```
https://godbolt.org/z/Pcroj66c4
The PDB however shows `NearC`, so cdecl, instead of `FastCall`.
The reason this happens is because GlobalOpt updates the CC, but not the debug info:
https://github.com/llvm/llvm-project/blob/aa8a1fa6f515f45db55365b9c1f8453ded24ed32/llvm/lib/Transforms/IPO/GlobalOpt.cpp#L2022
I feel like the `DISubroutineType` should be updated to `DW_CC_BORLAND_msfastcall` for Windows x86. So that the PDB depicts the correct CC.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVEtv2zgQ_jX0ZVCDoiTaPuiQyNAiQNEE2wA9GnyMJHYpUiApe7u_fkHJTdLeChB6zAy_mfnmIWI0g0NsSP1I6vNOLGn0oZn85Ouasp30-kfT-mk21rgB0ojQe2v9Lf9FMc02CwJ8M077W4R_jxxuJo3w6bmEOGZRGkUCwmlMIhl16RenCKdwM9bCKK6Ydb2ISa1iMc_WoIbkwSRSPhC6Hk630xL2mA992ODgctGobJxREXZ03jhrHBJ2AuMSfHTJjlkiwlAQdiKHxxX4tD0DpiW4VQmEPQAj5ao_nDf3-eYkjHsHUYS1oEYRsrkIw3XjLzt-w76j_hrEdvf0i4OfyW3OxpTmmDNnHWHd4LX0Nu19GAjr_iOse1HBf-dcVZv564jwcn6E0d_wiuFOOuH0C4rQZlTWQvSgMk_527iYUGjwfbbqREytsJZwun8HDCiid5BGE2EU84wugokgUYklIvxlvRT2eU6wzFokjGtjtG2Gl0sC59Mq0SiXAYzr_Vslf8vOpHGRe-Unwjprrz9fn-bgv6NKhHXSeklYJ8RRFL3gfV3UfVVrWdclr-VJFf2xqkuNmlWoS_YBx-R7r0G42PswRcK6p5dnwrq36PdqngkrPzPK2BbdE_SIFqz5B9cECKfnp6-LDH5JxuHrjxlzk8bRL1aDxHv-a7tm22-Xtr08Pv_9-eHL-TLFta03cn-fkj189dtopHsBNc5GpY1K5UNAlaBt9zvdlPpUnsQOm-JQU1rXtCh2Y1NUpUKqdalrcSgLTsVB1pxTXmFVSSV2pmGU1ZQXnHJWlsVeVFT1lehlJQ5H7A-kojgJY_eZsdxhOxPjgk1RVSUtdlZItHHdDIw5vMGqJYzlRRGatU5yGSKpqDUxxXeYZJLFJie1deMteDdAZiKvDeXdFV0y3sFtRAfqbb3cZzqPSlZH8O4jZ7sl2OaPG2iNOlf_nta1Yf8HAAD__01Akv8">