Mercurial > hg > octave-lojdl
changeset 14968:7f60cdfcc0e5
Do not smash stack when passing structures in JIT
* src/pt-jit.cc (jit_convert::convert_llvm::convert_llvm):
Store the prelude block.
(jit_convert::convert_llvm::create_call): Create alloca in prelude.
* src/pt-jit.h (jit_convert::convert_llvm): Added prelude block member.
author | Max Brister <max@2bass.com> |
---|---|
date | Fri, 22 Jun 2012 17:17:48 -0500 |
parents | 0cfe0cf55a02 |
children | bbeef7b8ea2e |
files | src/pt-jit.cc src/pt-jit.h |
diffstat | 2 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pt-jit.cc +++ b/src/pt-jit.cc @@ -2588,8 +2588,7 @@ try { - llvm::BasicBlock *prelude = llvm::BasicBlock::Create (context, "prelude", - function); + prelude = llvm::BasicBlock::Create (context, "prelude", function); builder.SetInsertPoint (prelude); llvm::Value *arg = function->arg_begin (); @@ -2804,6 +2803,8 @@ jit_convert::convert_llvm::create_call (const jit_function::overload& ol, const std::vector<jit_value *>& jargs) { + llvm::IRBuilder<> alloca_inserter (prelude, prelude->begin ()); + llvm::Function *fun = ol.function; if (! fun) fail ("Missing overload"); @@ -2822,7 +2823,7 @@ llvm::Function::arg_iterator llvm_arg = fun->arg_begin (); if (sret) { - args[0] = builder.CreateAlloca (ol.result->to_llvm ()); + args[0] = alloca_inserter.CreateAlloca (ol.result->to_llvm ()); ++llvm_arg; } @@ -2838,7 +2839,7 @@ { // pass structure by pointer assert (arg_type->getPointerTo () == llvm_arg_type); - llvm::Value *new_arg = builder.CreateAlloca (arg_type); + llvm::Value *new_arg = alloca_inserter.CreateAlloca (arg_type); builder.CreateStore (arg, new_arg); args[i + sret] = new_arg; }