From: David Malcolm Date: Mon, 1 Dec 2014 17:22:19 +0000 (+0000) Subject: PR jit/63854: Fix leak within jit-builtins.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8d19a69348ddcf0e539022fe89b1dcea3835a59;p=gcc.git 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 --- diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 9555e729dd7..c103eb2045c 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,18 @@ +2014-12-01 David Malcolm + + 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 PR jit/63969 diff --git a/gcc/jit/jit-builtins.c b/gcc/jit/jit-builtins.c index 07902e86e76..49d37d8f73a 100644 --- a/gcc/jit/jit-builtins.c +++ b/gcc/jit/jit-builtins.c @@ -398,11 +398,10 @@ builtins_manager::make_fn_type (enum jit_builtin_type, if (!return_type) goto error; - result = new function_type (m_ctxt, - return_type, - num_args, - param_types, - is_variadic); + result = m_ctxt->new_function_type (return_type, + num_args, + param_types, + is_variadic); error: delete[] param_types; diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index 8069afc7558..32bf0345529 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -492,6 +492,27 @@ recording::context::new_union_type (recording::location *loc, 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 of mementos. @@ -505,13 +526,11 @@ recording::context::new_function_ptr_type (recording::location *, /* unused loc 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); + recording::function_type *fn_type + = new_function_type (return_type, + num_params, + param_types, + is_variadic); /* Return a pointer-type to the the function type. */ return fn_type->get_pointer (); diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 4ea8ef12712..9b2cfc67f3c 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -88,6 +88,12 @@ public: new_union_type (location *loc, const char *name); + function_type * + new_function_type (type *return_type, + int num_params, + type **param_types, + int is_variadic); + type * new_function_ptr_type (location *loc, type *return_type,