summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-18 12:24:33 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-18 12:24:33 +0200
commit315e73730a0d1e3e00d8c567866465be8914ab03 (patch)
tree0ccf219c6f2d378e95fd43be1b3bc6b528a15a1c
parent32829f79774e90b4345b0bc8d7614b96893ff6f3 (diff)
LLVM compiler — IF: For the return value, use alloca instead of phi.
-rw-r--r--MLKLLVMCompiler.mm13
1 files changed, 4 insertions, 9 deletions
diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm
index e7dc660..c5e463c 100644
--- a/MLKLLVMCompiler.mm
+++ b/MLKLLVMCompiler.mm
@@ -710,29 +710,24 @@ static Constant
BasicBlock *elseBlock = BasicBlock::Create ("if_else");
BasicBlock *joinBlock = BasicBlock::Create ("if_join");
- Value *thenValue, *elseValue;
-
Value *test = builder.CreateICmpNE ([_conditionForm processForLLVM],
ConstantPointerNull::get (PointerTy));
+ Value *value = builder.CreateAlloca (PointerTy, NULL, "if_result");
builder.CreateCondBr (test, thenBlock, elseBlock);
builder.SetInsertPoint (thenBlock);
- thenValue = [_consequentForm processForLLVM];
+ builder.CreateStore ([_consequentForm processForLLVM], value);
builder.CreateBr (joinBlock);
builder.SetInsertPoint (elseBlock);
function->getBasicBlockList().push_back (elseBlock);
- elseValue = [_alternativeForm processForLLVM];
+ builder.CreateStore ([_alternativeForm processForLLVM], value);
builder.CreateBr (joinBlock);
builder.SetInsertPoint (joinBlock);
function->getBasicBlockList().push_back (joinBlock);
- PHINode *value = builder.CreatePHI (PointerTy, "if_result");
- value->addIncoming (thenValue, thenBlock);
- value->addIncoming (elseValue, elseBlock);
-
- return value;
+ return builder.CreateLoad (value);
}
@end