<div dir="ltr"><div>Hi, </div><div><br></div><div>I have been looking for code examples to create an LLVM module from scratch. <br><br>The LLVM API is certainly well-documented but may still looks daunting for some. I have googled, and the only found document on this subject (of creating an llvm module from scratch): </div><div><br></div><div><a href="http://llvm.org/releases/2.6/docs/tutorial/JITTutorial1.html">http://llvm.org/releases/2.6/docs/tutorial/JITTutorial1.html</a></div><div><br></div><div>should be outdated, given that llvm API evolves at each release.  Are you aware of   a similar, more recent version of the linked ressource? For information, what I need to do is roughly something like this:</div><div><br></div><div>1. create a new module m</div><div>2. create a new function f </div><div>3. clone the body of an existing function g from a file</div><div>4. put some special instructions into f, and call g at the end of f</div><div>5. put both f and g into m</div><div>6. return an llvm IR code derived from m.</div><div><br></div><div>I learned how to handle #4 by writing an LLVM pass (thanks to the ‘hello world’ example at <a href="http://llvm.org/docs/WritingAnLLVMPass.html">http://llvm.org/docs/WritingAnLLVMPass.html</a>), but have always had difficulties in finding template code for doing  #1~#3 and #5.  Any resource? Thanks for your help. <br></div><div><br clear="all"><div><div class="gmail_signature">Zhoulai</div></div>
</div>
</div>