aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2019-11-07 18:06:43 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2019-11-07 17:06:43 +0000
commitc6145f2ac6f946ae2613ffbd85ba072cf05d4a3f (patch)
tree9c4e29310f176f5355cb165b1abc2ecfac45974f
parent4629ea55608ee2f1e04186dce2c7f55af0537ccb (diff)
downloadgcc-c6145f2ac6f946ae2613ffbd85ba072cf05d4a3f.zip
gcc-c6145f2ac6f946ae2613ffbd85ba072cf05d4a3f.tar.gz
gcc-c6145f2ac6f946ae2613ffbd85ba072cf05d4a3f.tar.bz2
optc-save-gen.awk: Generate cl_target_option_free and cl_optimization_option_free.
* optc-save-gen.awk: Generate cl_target_option_free and cl_optimization_option_free. * opth-en.awk: Declare cl_target_option_free and cl_optimization_option_free. * tree.c (free_node): Use it. From-SVN: r277926
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/optc-save-gen.awk25
-rw-r--r--gcc/opth-gen.awk6
-rw-r--r--gcc/tree.c4
4 files changed, 43 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6fb0fac..bfe0ebc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2019-11-07 Jan Hubicka <jh@suse.cz>
+
+ * optc-save-gen.awk: Generate cl_target_option_free
+ and cl_optimization_option_free.
+ * opth-en.awk: Declare cl_target_option_free
+ and cl_optimization_option_free.
+ * tree.c (free_node): Use it.
+
2019-11-06 Jan Hubicka <jh@suse.cz>
* lto-streamer-in.c: Include alloc-pool.h.
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index cf1c368..1c23836 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -802,6 +802,17 @@ for (i = 0; i < n_target_val; i++) {
print "}";
+print "/* free heap memory used by target options */";
+print "void";
+print "cl_target_option_free (struct cl_target_option *ptr ATTRIBUTE_UNUSED)";
+print "{";
+for (i = 0; i < n_target_str; i++) {
+ name = var_target_str[i]
+ print " if (ptr->" name")";
+ print " free (const_cast <char *>(ptr->" name"));";
+}
+print "}";
+
n_opt_val = 4;
var_opt_val[0] = "x_optimize"
var_opt_val_type[0] = "char "
@@ -921,4 +932,18 @@ for (i = 0; i < n_opt_val; i++) {
print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_value (bp, 64);";
}
print "}";
+print "/* Free heap memory used by optimization options */";
+print "void";
+print "cl_optimization_option_free (struct cl_optimization *ptr ATTRIBUTE_UNUSED)";
+print "{";
+for (i = 0; i < n_opt_val; i++) {
+ name = var_opt_val[i]
+ otype = var_opt_val_type[i];
+ if (otype ~ "^const char \\**$")
+ {
+ print " if (ptr->" name")";
+ print " free (const_cast <char *>(ptr->" name"));";
+ }
+}
+print "}";
}
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index e19626a..218e772 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -303,6 +303,9 @@ print "";
print "/* Compare two target option variables from a structure. */";
print "extern bool cl_target_option_eq (const struct cl_target_option *, const struct cl_target_option *);";
print "";
+print "/* Free heap memory used by target option variables. */";
+print "extern void cl_target_option_free (struct cl_target_option *);";
+print "";
print "/* Hash option variables from a structure. */";
print "extern hashval_t cl_target_option_hash (const struct cl_target_option *);";
print "";
@@ -312,6 +315,9 @@ print "";
print "/* Compare two optimization options. */";
print "extern bool cl_optimization_option_eq (cl_optimization const *ptr1, cl_optimization const *ptr2);"
print "";
+print "/* Free heap memory used by optimization options. */";
+print "extern void cl_optimization_option_free (cl_optimization *ptr1);"
+print "";
print "/* Generator files may not have access to location_t, and don't need these. */"
print "#if defined(UNKNOWN_LOCATION)"
print "bool "
diff --git a/gcc/tree.c b/gcc/tree.c
index d08141b..d2c9fe3 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1170,6 +1170,10 @@ free_node (tree node)
vec_free (BLOCK_NONLOCALIZED_VARS (node));
else if (code == TREE_BINFO)
vec_free (BINFO_BASE_ACCESSES (node));
+ else if (code == OPTIMIZATION_NODE)
+ cl_optimization_option_free (TREE_OPTIMIZATION (node));
+ else if (code == TARGET_OPTION_NODE)
+ cl_target_option_free (TREE_TARGET_OPTION (node));
ggc_free (node);
}