title: Why are there some intrinsics in LLVM language?
body: <p>I find that there are some intrinsic functions in <a href="http://llvm.org/docs/LangRef.html#intrinsic-functions" rel="noreferrer">LLVM</a> such as <code>llvm.memcpy</code>, <code>llvm.va_start</code>. </p>
  
  <p>However I haven't got any idea why they exist and why others don't. For example, as <code>memcpy</code>'s prototype is inside <code>string.h</code>, why other functions, like <code>strcpy</code>, are not treated as intrinsic?</p>
  
  <p>I noticed that the frontend may generate special intrinsic function call in some cases. For a simple case:</p>
  
  <pre><code>#include&lt;string.h&gt;
  
  int foo(void){
      char str[10] = "str";
      return 0;
  }
  </code></pre>
  
  <p>The llvm IR for <code>foo</code> generated by clang is:</p>
  
  <pre><code>define i32 @foo() #0 {
  entry:
    %str = alloca [10 x i8], align 1
    %0 = bitcast [10 x i8]* %str to i8*
    call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* getelementptr inbounds ([10 x i8]* @foo.str, i32 0, i32 0), i64 10, i32 1, i1 false)
    ret i32 0
  }
  </code></pre>
  
  <p><code>llvm.memcpy</code> is called in IR but is not in source code. But can the frontend generate LLVM IR without this intrinsic?</p>
  
  <p>I also came across a document about <a href="http://llvm.org/releases/1.1/docs/LangRef.html#i_malloc" rel="noreferrer">a much earlier version of llvm language reference</a> and found that some special functions like <code>malloc</code>, <code>free</code> were included in LLVM instructions(obviously they no longer exist).</p>
  
  <p>So what's the insight that the llvm instruction is designed so?</p>