Hi, I'm trying to help with the porting of dehydra / treehydra to gcc 4.5.
There are some tests that are failing, and in working through them, I'm finding some issues that might be differences between 4.3 and 4.5. One problem is about walking the instructions associated with a function. The treehydra code is a bit convoluted, so I've converted it into a testsuite case. See attached. Essentially, the problem appears to be that DECL_SAVED_TREE() returns null. If I understand the treehydra code, that used to provide a list of GENERIC instructions. Is there a way to get that in 4.5? Brad
Index: testsuite/g++.dg/plugin/exec_plugin.c =================================================================== --- testsuite/g++.dg/plugin/exec_plugin.c (revision 0) +++ testsuite/g++.dg/plugin/exec_plugin.c (revision 0) @@ -0,0 +1,94 @@ +/* test case for DECL_SAVED_TREE */ + +#include <stdlib.h> +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "tree-pass.h" +#include "intl.h" +#include "gcc-plugin.h" + + +static unsigned int +execute_exec_plugin_example (void) +{ + warning (0, "%p", DECL_SAVED_TREE (current_function_decl)); + return 0; +} + +static struct gimple_opt_pass pass_exec_plugin_example = +{ + { + GIMPLE_PASS, + "exec_plugin", /* name */ + NULL, /* gate */ + execute_exec_plugin_example, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + 0, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func /* todo_flags_finish */ + } +}; + +/* Initialization function that GCC calls. This plugin takes an argument + that specifies the name of the reference pass and an instance number, + both of which determine where the plugin pass should be inserted. */ + +int +plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) +{ + struct plugin_pass pass_info; + const char *plugin_name = plugin_info->base_name; + int argc = plugin_info->argc; + struct plugin_argument *argv = plugin_info->argv; + char *ref_pass_name = NULL; + int ref_instance_number = 0; + int i; + + /* Process the plugin arguments. This plugin takes the following arguments: + ref-pass-name=<PASS_NAME> and ref-pass-instance-num=<NUM>. */ + for (i = 0; i < argc; ++i) + { + if (!strcmp (argv[i].key, "ref-pass-name")) + { + if (argv[i].value) + ref_pass_name = argv[i].value; + else + warning (0, G_("option '-fplugin-arg-%s-ref-pass-name'" + " requires a pass name"), plugin_name); + } + else if (!strcmp (argv[i].key, "ref-pass-instance-num")) + { + if (argv[i].value) + ref_instance_number = strtol (argv[i].value, NULL, 0); + else + warning (0, G_("option '-fplugin-arg-%s-ref-pass-instance-num'" + " requires an integer value"), plugin_name); + } + else + warning (0, G_("plugin %qs: unrecognized argument %qs ignored"), + plugin_name, argv[i].key); + } + + if (!ref_pass_name) + { + error (G_("plugin %qs requires a reference pass name"), plugin_name); + return 1; + } + + pass_info.pass = &pass_exec_plugin_example.pass; + pass_info.reference_pass_name = ref_pass_name; + pass_info.ref_pass_instance_number = ref_instance_number; + pass_info.pos_op = PASS_POS_INSERT_AFTER; + + register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); + + return 0; +} Index: testsuite/g++.dg/plugin/plugin.exp =================================================================== --- testsuite/g++.dg/plugin/plugin.exp (revision 147827) +++ testsuite/g++.dg/plugin/plugin.exp (working copy) @@ -48,6 +48,7 @@ # plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... } set plugin_test_list [list \ { attribute_plugin.c attribute_plugin-test-1.C } \ + { exec_plugin.c exec_plugin-test-1.C } \ { selfassign.c self-assign-test-1.C self-assign-test-2.C self-assign-test-3.C } \ { dumb_plugin.c dumb-plugin-test-1.C } ] Index: testsuite/g++.dg/plugin/exec_plugin-test-1.C =================================================================== --- testsuite/g++.dg/plugin/exec_plugin-test-1.C (revision 0) +++ testsuite/g++.dg/plugin/exec_plugin-test-1.C (revision 0) @@ -0,0 +1,16 @@ +// Test case for the exec plugin. +// { dg-do compile } +// { dg-options "-O -fplugin-arg-exec_plugin-ref-pass-name=cfg -fplugin-arg-exec_plugin-ref-pass-instance-num=1" } + +int func() +{ + int x = x; + static int y = y; + float *f; + char n; + int overflow; + + *f = *f; + y = x; + x = y; +}