Commit c8d19a69 by David Malcolm Committed by David Malcolm

PR jit/63854: Fix leak within jit-builtins.c

gcc/jit/ChangeLog:
	PR jit/63854
	* jit-builtins.c
	(gcc::jit::recording::builtins_manager::make_fn_type): Call the
	context's new_function_type method, rather than directly creating
	a function_type instance.
	* jit-recording.c
	(gcc::jit::recording::context::new_function_type): New method,
	adapted from part of...
	(gcc::jit::recording::context::new_function_ptr_type): ...this.
	Update to call new_function_type.
	* jit-recording.h
	(gcc::jit::recording::context::new_function_type): New method.

From-SVN: r218231
parent 9370adeb
2014-12-01 David Malcolm <dmalcolm@redhat.com> 2014-12-01 David Malcolm <dmalcolm@redhat.com>
PR jit/63854
* jit-builtins.c
(gcc::jit::recording::builtins_manager::make_fn_type): Call the
context's new_function_type method, rather than directly creating
a function_type instance.
* jit-recording.c
(gcc::jit::recording::context::new_function_type): New method,
adapted from part of...
(gcc::jit::recording::context::new_function_ptr_type): ...this.
Update to call new_function_type.
* jit-recording.h
(gcc::jit::recording::context::new_function_type): New method.
2014-12-01 David Malcolm <dmalcolm@redhat.com>
PR jit/63969 PR jit/63969
* jit-playback.c: Ensure that ctxt_progname is non-NULL. * jit-playback.c: Ensure that ctxt_progname is non-NULL.
......
...@@ -398,11 +398,10 @@ builtins_manager::make_fn_type (enum jit_builtin_type, ...@@ -398,11 +398,10 @@ builtins_manager::make_fn_type (enum jit_builtin_type,
if (!return_type) if (!return_type)
goto error; goto error;
result = new function_type (m_ctxt, result = m_ctxt->new_function_type (return_type,
return_type, num_args,
num_args, param_types,
param_types, is_variadic);
is_variadic);
error: error:
delete[] param_types; delete[] param_types;
......
...@@ -492,6 +492,27 @@ recording::context::new_union_type (recording::location *loc, ...@@ -492,6 +492,27 @@ recording::context::new_union_type (recording::location *loc,
return result; return result;
} }
/* Create a recording::function_type instance and add it to this context's
list of mementos.
Used by new_function_ptr_type and by builtins_manager::make_fn_type. */
recording::function_type *
recording::context::new_function_type (recording::type *return_type,
int num_params,
recording::type **param_types,
int is_variadic)
{
recording::function_type *fn_type
= new function_type (this,
return_type,
num_params,
param_types,
is_variadic);
record (fn_type);
return fn_type;
}
/* Create a recording::type instance and add it to this context's list /* Create a recording::type instance and add it to this context's list
of mementos. of mementos.
...@@ -505,13 +526,11 @@ recording::context::new_function_ptr_type (recording::location *, /* unused loc ...@@ -505,13 +526,11 @@ recording::context::new_function_ptr_type (recording::location *, /* unused loc
recording::type **param_types, recording::type **param_types,
int is_variadic) int is_variadic)
{ {
recording::function_type *fn_type = recording::function_type *fn_type
new function_type (this, = new_function_type (return_type,
return_type, num_params,
num_params, param_types,
param_types, is_variadic);
is_variadic);
record (fn_type);
/* Return a pointer-type to the the function type. */ /* Return a pointer-type to the the function type. */
return fn_type->get_pointer (); return fn_type->get_pointer ();
......
...@@ -88,6 +88,12 @@ public: ...@@ -88,6 +88,12 @@ public:
new_union_type (location *loc, new_union_type (location *loc,
const char *name); const char *name);
function_type *
new_function_type (type *return_type,
int num_params,
type **param_types,
int is_variadic);
type * type *
new_function_ptr_type (location *loc, new_function_ptr_type (location *loc,
type *return_type, type *return_type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment