[llvm-bugs] [Bug 50095] New: Compilation issue when passing args on stack instead of registers

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 23 06:09:14 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50095

            Bug ID: 50095
           Summary: Compilation issue when passing args on stack instead
                    of registers
           Product: clang
           Version: trunk
          Hardware: PC
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ian.denny at miniclip.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following code, when compiled for armv8a, looks like it corrupting the
stack at sp+16 when it's writing a zero value parameter over the register x29
temp storage. If it helps I have also reproduced the issue online using
godbolt.

--------------------------------------------------------------------------

extern __attribute__ ((noreturn)) void func_Error();

extern void func_9 (void * p1, void* p2, void* p3, void* p4, void* p5, void*
p6, void* p7, void* p8,  void* p9);

void NullCheck(void * p)
{
    if (p == 0) func_Error();
}

void testfunc2 (void * p1, void* p2, void* p3, void* p4, void* p5, void* p6,
void* p7, void* p8, void* p9)
{
    NullCheck((void *)p1);
    func_9(p1, p2, p3, p4, p5, p6, p7, p8, 0);
}

--------------------------------------------------------------------------

NullCheck(void*):
        cbz     x0, .LBB0_2
        ret
.LBB0_2:
        stp     x29, x30, [sp, #-16]!
        mov     x29, sp
        bl      func_Error()

testfunc2(void*, void*, void*, void*, void*, void*, void*, void*, void*):
        stp     x29, x30, [sp, #-16]!
        mov     x29, sp
        cbz     x0, .LBB1_2
>>>     str     xzr, [x29, #16]
>>>     ldp     x29, x30, [sp], #16
        b       func_9(void*, void*, void*, void*, void*, void*, void*, void*,
void*)

.LBB1_2:
        bl      func_Error()

--------------------------------------------------------------------------

https://godbolt.org/z/oePr3eTWh

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210423/f028f35e/attachment.html>


More information about the llvm-bugs mailing list