Skip to content

Commit

Permalink
irgen: Fix IR generation of if-else statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
mewmew committed Jun 15, 2016
1 parent 181d595 commit 724220e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions irgen/lower.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ func (m *Module) ifStmt(f *Function, stmt *ast.IfStmt) {
f.curBlock = trueBranch

m.stmt(f, stmt.Body)
trueBranch.emitJmp(falseBranch)
end := falseBranch
f.curBlock = falseBranch

if stmt.Else != nil {
m.stmt(f, stmt.Else)
end := f.NewBasicBlock("")
end = f.NewBasicBlock("")
falseBranch.emitJmp(end)
f.curBlock = end
}

trueBranch.emitJmp(end)
}

// returnStmt lowers the given return statement to LLVM IR, emitting code to f.
Expand Down

0 comments on commit 724220e

Please sign in to comment.