Merge LLVMBuilder and FoldingBuilder, calling

the result IRBuilder.  Patch by Dominic Hamon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49604 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2008-04-13 06:22:09 +00:00
parent 86941611c9
commit 89f6d88db3
18 changed files with 295 additions and 493 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ unsigned gcd(unsigned x, unsigned y) {
#include <llvm/PassManager.h>
#include <llvm/Analysis/Verifier.h>
#include <llvm/Assembly/PrintModulePass.h>
#include <llvm/Support/LLVMBuilder.h>
#include <llvm/Support/IRBuilder.h>
using namespace llvm;
@@ -110,13 +110,13 @@ Module* makeLLVMModule() {
<div class="doc_code">
<pre>
LLVMBuilder builder(entry);
IRBuilder builder(entry);
Value* xEqualsY = builder.CreateICmpEQ(x, y, &quot;tmp&quot;);
builder.CreateCondBr(xEqualsY, ret, cond_false);
</pre>
</div>
<p>Our next block, <code>ret</code>, is pretty simple: it just returns the value of <code>x</code>. Recall that this block is only reached if <code>x == y</code>, so this is the correct behavior. Notice that instead of creating a new <code>LLVMBuilder</code> for each block, we can use <code>SetInsertPoint</code> to retarget our existing one. This saves on construction and memory allocation costs.</p>
<p>Our next block, <code>ret</code>, is pretty simple: it just returns the value of <code>x</code>. Recall that this block is only reached if <code>x == y</code>, so this is the correct behavior. Notice that instead of creating a new <code>IRBuilder</code> for each block, we can use <code>SetInsertPoint</code> to retarget our existing one. This saves on construction and memory allocation costs.</p>
<div class="doc_code">
<pre>