Added aop_finish().
authorJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 7 Sep 2010 22:19:54 +0000 (18:19 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 7 Sep 2010 22:19:54 +0000 (18:19 -0400)
src/aop-main.c

index 49c1f7eed0777fcf8ded8f6aa6286532d48f2d80..35833fa728fa5dbd0e2bf2eb0e43700d67975414 100644 (file)
@@ -154,6 +154,28 @@ aop_join_on_copy (struct aop_pointcut *pc, int copy, join_callback callback,
   }
 }
 
+/**
+ * InterAspect calls this function after all compilation is finished
+ * and before GCC and InterAspect data structures are destroyed.  It
+ * is provided so that InterAspect plug-ins can override it (by
+ * providing their own version), giving them a last chance to clean up
+ * data structures or free up other resources.
+ *
+ * The best place to output an automatic header (using
+ * aop_write_c_header()) is in aop_finish().
+ */
+__attribute__((weak)) __attribute__((noinline)) void
+aop_finish ()
+{
+  /* This function exists only to be overridden. */
+
+  /* Weird bug: if this function is empty, GCC inlines the call to it
+     in aop_cleanup() making it impossible to override (even if we
+     explicitly specify noinline).  We can trick GCC into emitting the
+     calls with this empty assembly block. */
+  __asm__ volatile ("");
+}
+
 /**
  * Find the value for a command-line argument passed to the plug-in.
  * You can pass a key/value argument to your plug-in on the GCC
@@ -258,6 +280,8 @@ cleanup_passes ()
 static void
 aop_cleanup (void *event_date, void *data)
 {
+  aop_finish ();
+
   free_type_table ();
   free_prototype_table ();
   cleanup_passes ();