PR jit/63854: Fix memory leak within gcc_options
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Nov 2014 19:08:29 +0000 (19:08 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Nov 2014 19:08:29 +0000 (19:08 +0000)
gcc/ChangeLog:
PR jit/63854
* opts.c (finalize_options_struct): New.
* opts.h (finalize_options_struct): New.
* toplev.c (toplev::finalize): Call finalize_options_struct
on global_options and global_options_set.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217791 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/opts.c
gcc/opts.h
gcc/toplev.c

index 15010a0..90e86f6 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-19  David Malcolm  <dmalcolm@redhat.com>
+
+       PR jit/63854
+       * opts.c (finalize_options_struct): New.
+       * opts.h (finalize_options_struct): New.
+       * toplev.c (toplev::finalize): Call finalize_options_struct
+       on global_options and global_options_set.
+
 2014-11-19  Manuel López-Ibáñez  <manu@gcc.gnu.org>
            Jakub Jelinek  <jakub@redhat.com>
 
index a83345b..f3deb40 100644 (file)
@@ -307,6 +307,14 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
   targetm_common.option_init_struct (opts);
 }
 
+/* Release any allocations owned by OPTS.  */
+
+void
+finalize_options_struct (struct gcc_options *opts)
+{
+  XDELETEVEC (opts->x_param_values);
+}
+
 /* If indicated by the optimization level LEVEL (-Os if SIZE is set,
    -Ofast if FAST is set, -Og if DEBUG is set), apply the option DEFAULT_OPT
    to OPTS and OPTS_SET, diagnostic context DC, location LOC, with language
index f694082..c3ec942 100644 (file)
@@ -325,6 +325,7 @@ extern void decode_cmdline_options_to_array (unsigned int argc,
 extern void init_options_once (void);
 extern void init_options_struct (struct gcc_options *opts,
                                 struct gcc_options *opts_set);
+extern void finalize_options_struct (struct gcc_options *opts);
 extern void decode_cmdline_options_to_array_default_mask (unsigned int argc,
                                                          const char **argv, 
                                                          struct cl_decoded_option **decoded_options,
index 86c4b81..6021807 100644 (file)
@@ -2170,4 +2170,7 @@ toplev::finalize (void)
   ipa_cp_c_finalize ();
   ipa_reference_c_finalize ();
   params_c_finalize ();
+
+  finalize_options_struct (&global_options);
+  finalize_options_struct (&global_options_set);
 }