title: how to use llvm intrinsics @llvm.read_register?
body: <p>I noticed that <code>llvm.read_register()</code> could read the value of stack pointer, as well as <code>llvm.write_register()</code> could set the value of stack pointer. I add main function to the <code>stackpointer.ll</code> which could be found in the llvm src:</p>
  
  <pre><code>;stackpointer.ll  
   define i32 @get_stack() nounwind {  
   　%sp = call i32 @llvm.read_register.i32(metadata !0)  
   　ret i32 %sp  
  }
  
  declare i32 @llvm.read_register.i32(metadata) nounwind  
  !0 = metadata !{metadata !"sp\00"}
  
  define i32 @main() {  
  　%1 = call i32 @get_stack()  
  　ret i32 %1  
  }
  </code></pre>
  
  <p>I tested on an armv7 board running ubuntu 11.04:</p>
  
  <pre><code>lli stackpointer.ll
  </code></pre>
  
  <p>then, I get a stack dump:</p>
  
  <pre><code>ARMCodeEmitter::emitPseudoInstruction  
  UNREACHABLE executed at ARMCodeEmitter.cpp:847! 
  Stack dump:  
  0.　　Program arguments: lli stackpointer.ll  
  1.　　Running pass 'ARM Machine Code Emitter' on function '@main'  
  Aborted
  </code></pre>
  
  <p>I also tried llc:</p>
  
  <pre><code>llc stackpointer.ll -o stackpointer.s
  </code></pre>
  
  <p>The error messege:</p>
  
  <pre><code>Can't get register for value!  
  UNREACHABLE executed at ARMCodeEmitter.cpp:1183!   
  Stack dump:  
  0.　　Program arguments: llc stackpointer.ll -o stackpointer.s  
  1.　　Running pass 'Function Pass Manager' on moulude 'stackpointer.ll'  
  2.　　Running pass 'ARM Instruction Selection' on function '@get_stack'  
  Aborted  
  </code></pre>
  
  <p>I also tried on x86-64 platform, it didn't work. What is the correct way to use these intrinsics?</p>