summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOlatunji Ruwase <tjruwase@google.com>2009-06-17 02:18:55 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2009-06-16 22:18:55 -0400
commit8dd1bca076bba00642c88d60d24f63e604f49e23 (patch)
tree47ed037195b7f5fa3dc0189666a546e3a68d44f0 /gcc
parent54c4ebb7a524b52febe148e226bf5bc94d8832ae (diff)
downloadgcc-8dd1bca076bba00642c88d60d24f63e604f49e23.tar.gz
[multiple changes]
2009-06-16 Olatunji Ruwase <tjruwase@google.com> * plugin.c(position_pass): Skip newly inserted pass during list traversal to avoid repeated insertion. 2009-06-05 Olatunji Ruwase <tjruwase@google.com> * gcc.dg/plugin/one_time_plugin.c: New test. * gcc.dg/plugin/one_time-test-1.c: New test. * gcc.dg/plugin/plugin.exp: Added one_time_plugin.c test. From-SVN: r148566
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/plugin.c5
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/plugin/one_time-test-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/plugin/one_time_plugin.c60
-rw-r--r--gcc/testsuite/gcc.dg/plugin/plugin.exp1
6 files changed, 85 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c7d5a934ec5..fff4dd18138 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-16 Olatunji Ruwase <tjruwase@google.com>
+
+ * plugin.c(position_pass): Skip newly inserted pass during list
+ traversal to avoid repeated insertion.
+
2009-06-16 Ian Lance Taylor <iant@google.com>
* vec.h (VEC_stack_alloc): Define different version if
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 0b5515e4907..93151f8a8a7 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -336,6 +336,11 @@ position_pass (struct plugin_pass *plugin_pass_info,
case PASS_POS_INSERT_AFTER:
new_pass->next = pass->next;
pass->next = new_pass;
+
+ /* Skip newly inserted pass to avoid repeated
+ insertions in the case where the new pass and the
+ existing one have the same name. */
+ pass = new_pass;
break;
case PASS_POS_INSERT_BEFORE:
new_pass->next = pass;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 020d8a38189..f84f90cc639 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-05 Olatunji Ruwase <tjruwase@google.com>
+
+ * gcc.dg/plugin/one_time_plugin.c: New test.
+ * gcc.dg/plugin/one_time-test-1.c: New test.
+ * gcc.dg/plugin/plugin.exp: Added one_time_plugin.c test.
+
2009-06-16 Ian Lance Taylor <iant@google.com>
* g++.dg/warn/skip-1.C: New testcase.
diff --git a/gcc/testsuite/gcc.dg/plugin/one_time-test-1.c b/gcc/testsuite/gcc.dg/plugin/one_time-test-1.c
new file mode 100644
index 00000000000..a49ecb4affe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/one_time-test-1.c
@@ -0,0 +1,8 @@
+/* Test that pass is inserted and invoked once. */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+int main (int argc, char **argv)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
new file mode 100644
index 00000000000..8ae327a68f9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c
@@ -0,0 +1,60 @@
+/* Plugin that prints message if it inserted (and invoked) more than once. */
+#include "config.h"
+#include "gcc-plugin.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "toplev.h"
+#include "gimple.h"
+#include "tree-pass.h"
+#include "intl.h"
+
+static bool one_pass_gate (void)
+{
+ return true;
+}
+
+static unsigned int one_pass_exec (void)
+{
+ static int counter = 0;
+
+ if (counter > 0) {
+ printf ("Executed more than once \n");
+ }
+ counter++;
+}
+
+struct gimple_opt_pass one_pass =
+{
+ {
+ GIMPLE_PASS,
+ "useless", /* name */
+ one_pass_gate, /* gate */
+ one_pass_exec, /* execute */
+ NULL, /* sub */
+ NULL, /* next */
+ 0, /* static_pass_number */
+ 0, /* tv_id */
+ PROP_gimple_any, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ TODO_dump_func /* todo_flags_finish */
+ }
+};
+
+
+int plugin_init (struct plugin_name_args *plugin_info,
+ struct plugin_gcc_version *version)
+{
+ struct plugin_pass p;
+
+ p.pass = &one_pass.pass;
+ p.reference_pass_name = "useless";
+ p.ref_pass_instance_number = 1;
+ p.pos_op = PASS_POS_INSERT_AFTER;
+
+ register_callback ("one_pass", PLUGIN_PASS_MANAGER_SETUP, NULL, &p);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp
index 63ee74427f6..be6d7ab1243 100644
--- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
+++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
@@ -49,6 +49,7 @@ load_lib plugin-support.exp
set plugin_test_list [list \
{ selfassign.c self-assign-test-1.c self-assign-test-2.c } \
{ ggcplug.c ggcplug-test-1.c } \
+ { one_time_plugin.c one_time-test-1.c } \
]
foreach plugin_test $plugin_test_list {