<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - The memclr call generated by the compiler optimization cannot be disabled."
   href="https://bugs.llvm.org/show_bug.cgi?id=46180">46180</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The memclr call generated by the compiler optimization cannot be disabled.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>2077213809@qq.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>