diff options
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r-- | src/llvm.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp index e445650..1a944dd 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -433,20 +433,22 @@ LLVMEngine::compileIf(CEnv& cenv, const AST* cond, const AST* then, const AST* a appendBlock(engine, parent, nextBB); Value* elseV = NULL; - if (aelse) + if (aelse) { elseV = llVal(resp_compile(cenv, aelse)); - else - elseV = Constant::getNullValue(llType(type)); + engine->builder.CreateBr(mergeBB); + } else { + engine->builder.CreateUnreachable(); + } // Emit end of final else block - engine->builder.CreateBr(mergeBB); BasicBlock* elseBB = engine->builder.GetInsertBlock(); // Emit merge block (Phi node) appendBlock(engine, parent, mergeBB); PHINode* pn = engine->builder.CreatePHI(llType(type), "ifval"); pn->addIncoming(thenV, thenBB); - pn->addIncoming(elseV, elseBB); + if (elseV) + pn->addIncoming(elseV, elseBB); return pn; } |