]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
toplev.c: Invoke FINISH_UNIT callbacks before call to finalize().
authorOlatunji Ruwase <tjruwase@google.com>
Mon, 20 Jul 2009 19:28:05 +0000 (19:28 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 20 Jul 2009 19:28:05 +0000 (19:28 +0000)
./: * toplev.c: Invoke FINISH_UNIT callbacks before call to
finalize().
testsuite/:
* gcc.dg/plugin/finish_unit_plugin.c: New test.
* gcc.dg/plugin/finish_unit-test-1.c: New test.
* gcc.dg/plugin/plugin.exp: Added finish_unit_plugin.c test.

From-SVN: r149833

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/finish_unit-test-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/plugin.exp
gcc/toplev.c

index 532c9257ac5ed0199f7cf63c4e23969a6ef04435..43ea2b7a04cec33425d55374ffb108b73fc93ef2 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Olatunji Ruwase  <tjruwase@google.com>
+
+       * toplev.c: Invoke FINISH_UNIT callbacks before call to
+       finalize().
+
 2009-07-20  Shujing Zhao  <pearly.zhao@oracle.com>
 
        * Makefile.in (TREE_INLINE_H, tree-inline.o, cgraph.o): Remove
index b7ba7d4f9747b3521cb644cb65987804d4524e73..5faeb99bf237e8835f62300f2514a41327e12bd5 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-20  Olatunji Ruwase  <tjruwase@google.com>
+
+       * gcc.dg/plugin/finish_unit_plugin.c: New test.
+       * gcc.dg/plugin/finish_unit-test-1.c: New test.
+       * gcc.dg/plugin/plugin.exp: Added finish_unit_plugin.c test.
+
 2009-07-20  Adam Nemet  <anemet@caviumnetworks.com>
 
        * gcc.target/mips/ext-3.c: New test.
diff --git a/gcc/testsuite/gcc.dg/plugin/finish_unit-test-1.c b/gcc/testsuite/gcc.dg/plugin/finish_unit-test-1.c
new file mode 100644 (file)
index 0000000..4cd8a40
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+int main (int argc, char **argv) 
+{ 
+  return 0;  
+}
diff --git a/gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c b/gcc/testsuite/gcc.dg/plugin/finish_unit_plugin.c
new file mode 100644 (file)
index 0000000..634daee
--- /dev/null
@@ -0,0 +1,28 @@
+/* This plugin creates a fake function in the FINISH_UNIT callback, in
+ * other words right after compilation of the translation unit. 
+*/
+#include "gcc-plugin.h"
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "toplev.h"
+#include "basic-block.h"
+#include "gimple.h"
+#include "tree.h"
+#include "tree-pass.h"
+#include "intl.h"
+
+int plugin_is_GPL_compatible;
+
+static void finish_unit_callback (void *gcc_data, void *user_data)
+{
+  cgraph_build_static_cdtor ('I', NULL, DEFAULT_INIT_PRIORITY);
+}
+
+int plugin_init (struct plugin_name_args *plugin_info,
+                 struct plugin_gcc_version *version)
+{
+  register_callback ("finish_unit", PLUGIN_FINISH_UNIT, &finish_unit_callback, NULL);
+  return 0;
+}
index 3122fa8dc3eff799eee2725733667530476a0d08..872a0ea8c3c4bc64541b7c5d3311d616ea247c81 100644 (file)
@@ -51,6 +51,7 @@ set plugin_test_list [list \
     { ggcplug.c ggcplug-test-1.c } \
     { one_time_plugin.c one_time-test-1.c } \
     { start_unit_plugin.c start_unit-test-1.c } \
+    { finish_unit_plugin.c finish_unit-test-1.c } \
 ]
 
 foreach plugin_test $plugin_test_list {
index 6fa3f1a44ec79194fcf25da508c7a6d2576b1a72..81d55f3a5b8393c79c3d7b20d4e5aceadfad7be3 100644 (file)
@@ -1091,6 +1091,9 @@ compile_file (void)
     }
 #endif
 
+  /* Invoke registered plugin callbacks.  */
+  invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);
+  
   /* This must be at the end.  Some target ports emit end of file directives
      into the assembly file here, and hence we can not output anything to the
      assembly file after this point.  */
@@ -2348,9 +2351,6 @@ do_compile (void)
        compile_file ();
 
       finalize ();
-
-      /* Invoke registered plugin callbacks.  */
-      invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);
     }
 
   /* Stop timing and print the times.  */