<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72843>72843</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Use __asm__ attribute to specify symbol name lead the function prototype change? Is legal?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hstk30-hw
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/hr4z7Wbv3
Has follow code, fail with compile command `-O1 ` in arm32le.
```
typedef __attribute__((aligned (8))) int alignedint;
alignedint a = 11;
extern void abort (void);
extern int memcmp (const void *s1, const void *s2, unsigned int n);
__attribute__((naked)) void dumpregs () __asm__("myfunc");
__attribute__((naked)) void dumpregs ()
{
asm(
"mov ip, sp\n\t"
"stmfd sp!, {r0-r3}\n\t"
"mov r0, sp\n\t"
"stmfd sp!, {ip, r14}\n\t"
"bl testfunc\n\t"
"ldmfd sp!, {r0, r14}\n\t"
"mov sp, r0\n\t"
"bx lr");
}
void testfunc(char* stack)
{
alignedint __x = a;
if (memcmp(&__x, stack+0, sizeof(alignedint)) != 0)
abort();
return;
}
void myfunc(alignedint) ;
int main()
{
myfunc(a);
return 0;
}
```
I see the arguments are removed in the pass `InstCombine` ,
https://github.com/llvm/llvm-project/blob/27c98958c067c341dd3f65b7218c376d333fbed5/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp#L3778C1-L3781C68
I gusee there are caused by two reasons:
1. `__asm` lead to `myfunc` function prototype changed from `void myfunc(alignedint) ;` to `void myfunc();` , so `IC` opt it.
2. I'm not sure there is a regular way to generate this IR? https://godbolt.org/z/1efKn1bje
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVl2P6yYT_jXkZrQRBsd2LnKxmyh6o_dIlapWvYywPY45B4MFeLM5v74CO1kn2rNbVY0iY2B4ZuaZDyyckyeNuCGrF7LaLcTgW2M3rfM_OH1qz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