[llvm-bugs] [Bug 46180] New: The memclr call generated by the compiler optimization cannot be disabled.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 3 01:15:38 PDT 2020


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

            Bug ID: 46180
           Summary: The memclr call generated by the compiler optimization
                    cannot be disabled.
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 2077213809 at qq.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

I have some code that the compiler generates calls to the libc library by
default and cannot be disabled, even if I use -ffreestanding or -fno-builtin.

My program runs in a bare-metal environment without any libc libraries, and
compiler optimizations like this cause my program to linker fail.

clang -ffreestanding -fno-builtin --target=arm-none-eabi -Oz  -S test.c -o -

typedef struct {
  int a;
  int b;
  int c;
  int d;
  int e;
  int *p;
} A;

void __attribute__((noinline)) test(A *a){
  a->e = 1;
}
int main()
{
  A a = {0};
  test(&a);
}

main:
        .fnstart
        .save   {r4, r10, r11, lr}
        push    {r4, r10, r11, lr}
        .setfp  r11, sp, #8
        add     r11, sp, #8
        .pad    #24
        sub     sp, sp, #24
        mov     r4, sp
        mov     r1, #24
        mov     r0, r4
        bl      __aeabi_memclr4 // linker failed
        mov     r0, r4
        bl      test
        sub     sp, r11, #8
        pop     {r4, r10, r11, lr}
        bx      lr

-- 
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/20200603/831fd2f5/attachment-0001.html>


More information about the llvm-bugs mailing list