Skip to content

Commit

Permalink
cleanup temporary Function after llvmcall pass. should fix #10394
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Apr 16, 2015
1 parent ffa298a commit c7fb764
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ static Value *emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
std::string ir_name;
while(true) {
std::stringstream name;
name << (ctx->f->getName().str()) << i++;
name << (ctx->f->getName().str()) << "u" << i++;
ir_name = name.str();
if (jl_Module->getFunction(ir_name) == NULL)
break;
Expand Down Expand Up @@ -755,7 +755,8 @@ static Value *emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
f->setLinkage(GlobalValue::LinkOnceODRLinkage);

// the actual call
CallInst *inst = builder.CreateCall(prepare_call(f),ArrayRef<Value*>(&argvals[0],nargt));
assert(f->getParent() == jl_Module); // no prepare_call(f) is needed below, since this was just emitted into the same module
CallInst *inst = builder.CreateCall(f,ArrayRef<Value*>(&argvals[0],nargt));
ctx->to_inline.push_back(inst);

JL_GC_POP();
Expand Down
2 changes: 2 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4765,9 +4765,11 @@ static Function *emit_function(jl_lambda_info_t *lam)

// step 17, Apply LLVM level inlining
for(std::vector<CallInst*>::iterator it = ctx.to_inline.begin(); it != ctx.to_inline.end(); ++it) {
Function *inlinef = (*it)->getCalledFunction();
InlineFunctionInfo info;
if (!InlineFunction(*it,info))
jl_error("Inlining Pass failed");
inlinef->eraseFromParent();
}

// step 18. Perform any delayed instantiations
Expand Down

0 comments on commit c7fb764

Please sign in to comment.