From 315e73730a0d1e3e00d8c567866465be8914ab03 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 18 Aug 2008 12:24:33 +0200 Subject: =?UTF-8?q?LLVM=20compiler=20=E2=80=94=20IF:=20For=20the=20return?= =?UTF-8?q?=20value,=20use=20alloca=20instead=20of=20phi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MLKLLVMCompiler.mm | 13 ++++--------- 1 file 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 -- cgit v1.2.3