title: llvm optimizes with library functions
body: <p>Starting with code like this</p>
  
  <pre><code>void lib_memset( unsigned char *dest, unsigned char c, unsigned int n)
  {
      while(n--)
      {
          *dest=c;
          dest++;
      }
  }
  </code></pre>
  
  <p>using llvm as a cross compiler</p>
  
  <pre><code>clang -Wall -m32 -emit-llvm -fno-builtin --target=arm-none-eabi  -c lib_memset.c -o lib_memset.bc
  opt -std-compile-opts -strip-debug -march=arm -mcpu=mpcore -mtriple=arm-none-eabi lib_memset.bc -o lib_memset.opt.bc
  llc -march=arm -mcpu=mpcore -disable-simplify-libcalls  lib_memset.opt.bc -o lib_memset.opt.s
  llc -march=arm -mcpu=mpcore -disable-simplify-libcalls  lib_memset.bc -o lib_memset.s
  </code></pre>
  
  <p>and it detects and replaces it with a real memset when the optimizer is used</p>
  
  <pre><code>lib_memset:
      push    {r11, lr}
      mov r3, r1
      mov r11, sp
      cmp r2, #0
      beq .LBB0_2
      mov r1, r2
      mov r2, r3
      bl  __aeabi_memset
  .LBB0_2:                                @ %while.end
      pop {r11, pc}
  </code></pre>
  
  <p>but implements it without.</p>
  
  <p>I don't want that I want it to compile the code I gave it for the target I gave it rather than use library calls. I thought the -disable-simplify-libcalls would do it but it doesn't.</p>
  
  <p>I thought I had figured this out before, but cant find out how to do it. I need the optimizer, I don't want this circular dependency problem of implementing the library and it needing the library, etc. Could do it in asm to take the compiler out of the loop, but shouldn't have to.</p>