diff options
author | David Robillard <d@drobilla.net> | 2010-12-31 20:20:26 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-31 20:20:26 +0000 |
commit | 733e4d61c811dfec32953df51b7e57f853307a9b (patch) | |
tree | 308b4bdc86885af2289c78b9d21d971bf40287c9 /src/llvm.cpp | |
parent | 2d426b8cbc3dfe24615df9cc9fb4e1ddf96de475 (diff) | |
download | resp-733e4d61c811dfec32953df51b7e57f853307a9b.tar.gz resp-733e4d61c811dfec32953df51b7e57f853307a9b.tar.bz2 resp-733e4d61c811dfec32953df51b7e57f853307a9b.zip |
Compile match 'else' case to unreachable instruction.
git-svn-id: http://svn.drobilla.net/resp/resp@395 ad02d1e2-f140-0410-9f75-f8b11f17cedd
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; } |