Closed
Description
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
by this function
I gusee there are caused by two reasons:
__asm
lead tomyfunc
function prototype changed fromvoid myfunc(alignedint) ;
tovoid myfunc();
, soIC
opt it.- I'm not sure there is a regular way to generate this IR? https://godbolt.org/z/1efKn1bje If have, maybe we should reject
naked
function inInstCombinerImpl::transformConstExprCastCall