Skip to content

Commit

Permalink
Merge pull request #18054 from JuliaLang/tb/builder_clear_ip
Browse files Browse the repository at this point in the history
Clear the IRBuilder's insertion point after emitting a function
  • Loading branch information
JeffBezanson authored Aug 17, 2016
2 parents ee80a0c + a5fdd74 commit c477aab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4718,6 +4718,8 @@ static std::unique_ptr<Module> emit_function(jl_lambda_info_t *lam, jl_llvm_func
}
}

builder.ClearInsertionPoint();

// step 13, Apply LLVM level inlining
for(std::vector<CallInst*>::iterator it = ctx.to_inline.begin(); it != ctx.to_inline.end(); ++it) {
Function *inlinef = (*it)->getCalledFunction();
Expand Down
7 changes: 7 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4469,3 +4469,10 @@ let
k(x) = (k = x; k)
@test k(1) == 1
end

# PR #18054: compilation of cfunction leaves IRBuilder in bad state,
# causing heap-use-after-free when compiling f18054
function f18054()
return Cint(0)
end
cfunction(f18054, Cint, ())

0 comments on commit c477aab

Please sign in to comment.