Browse Source

gcc: Build the warn-unregistered pass only for GCC >= 4.6.

* gcc-plugin/src/Makefile.am (starpu_la_SOURCES): Add
  `warn-unregistered.c' only when HAVE_PTR_DEREFS_MAY_ALIAS_P.
* gcc-plugin/tests/Makefile.am (gcc_tests): Likewise.

* gcc-plugin/src/starpu-gcc-config.h.in (HAVE_DECL_PTR_DEREFS_MAY_ALIAS_P):
  New macro.

* gcc-plugin/src/starpu.c (plugin_init): Register
  PASS_WARN_STARPU_UNREGISTERED only when
  HAVE_DECL_PTR_DEREFS_MAY_ALIAS_P.

* m4/gcc.m4 (STARPU_GCC_PLUGIN_SUPPORT): Check for the declaration of
  `ptr_derefs_may_alias_p'.  Add the `HAVE_PTR_DEREFS_MAY_ALIAS_P'
  Automake conditional.
Ludovic Courtès 13 years ago
parent
commit
70a2068c0f

+ 8 - 2
gcc-plugin/src/Makefile.am

@@ -20,8 +20,14 @@ gccplugin_LTLIBRARIES = starpu.la
 starpu_la_SOURCES =				\
   c-expr.y					\
   starpu.c					\
-  utils.c					\
-  warn-unregistered.c
+  utils.c
+
+if HAVE_PTR_DEREFS_MAY_ALIAS_P
+
+# Only for GCC >= 4.6.
+starpu_la_SOURCES += warn-unregistered.c
+
+endif
 
 noinst_HEADERS =				\
   utils.h					\

+ 2 - 0
gcc-plugin/src/starpu-gcc-config.h.in

@@ -37,3 +37,5 @@
 #undef HAVE_C_PRAGMA_H
 
 #undef STARPU_INCLUDE_DIR
+
+#undef HAVE_DECL_PTR_DEREFS_MAY_ALIAS_P

+ 5 - 0
gcc-plugin/src/starpu.c

@@ -3431,6 +3431,10 @@ plugin_init (struct plugin_name_args *plugin_info,
   register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP,
 		     NULL, &pass_info);
 
+#ifdef HAVE_DECL_PTR_DEREFS_MAY_ALIAS_P
+  /* This warning pass is only available when `ptr_derefs_may_alias_p' is
+     available, with GCC >= 4.6.  */
+
   struct register_pass_info pass_info2 =
     {
       designated_field_init (pass, &pass_warn_starpu_unregistered),
@@ -3448,6 +3452,7 @@ plugin_init (struct plugin_name_args *plugin_info,
 
   register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP,
 		     NULL, &pass_info2);
+#endif
 
   include_dir = getenv ("STARPU_GCC_INCLUDE_DIR");
   opencl_include_dirs = tree_cons (NULL_TREE, build_string (1, "."),

+ 10 - 1
gcc-plugin/tests/Makefile.am

@@ -29,7 +29,6 @@ gcc_tests =					\
   release-errors.c				\
   unregister.c					\
   unregister-errors.c				\
-  warn-unregistered.c				\
   task-errors.c					\
   scalar-tasks.c				\
   pointer-tasks.c				\
@@ -47,6 +46,16 @@ gcc_tests =					\
 
 EXTRA_DIST =
 
+if HAVE_PTR_DEREFS_MAY_ALIAS_P
+
+gcc_tests += warn-unregistered.c
+
+else !HAVE_PTR_DEREFS_MAY_ALIAS_P
+
+EXTRA_DIST += warn-unregistered.c
+
+endif !HAVE_PTR_DEREFS_MAY_ALIAS_P
+
 if !STARPU_USE_OPENCL
 
 # XXX: This test simulates a buggy OpenCL implementation, and thus

+ 8 - 3
m4/gcc.m4

@@ -159,13 +159,19 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
     dnl   build_array_ref           -- present but undeclared in 4.6.1
     dnl   build_zero_cst            -- not in GCC 4.5.x; appears in 4.6
     dnl   builtin_decl_explicit     -- new in 4.7, replaces `built_in_decls'
+    dnl   ptr_derefs_may_alias_p    -- new in 4.6, nothing equivalent in 4.5
     dnl   .affects_type_identity    -- new field in 4.7
     _STARPU_WITH_GCC_PLUGIN_API([
       AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
                       build_array_ref, build_zero_cst,
-		      builtin_decl_explicit],
+		      builtin_decl_explicit,
+		      ptr_derefs_may_alias_p],
         [], [], [#include <gcc-plugin.h>
-	         #include <tree.h>])
+	         #include <tree.h>
+		 #include <tree-ssa-alias.h>])
+
+      AM_CONDITIONAL([HAVE_PTR_DEREFS_MAY_ALIAS_P],
+        [test "x$ac_cv_have_decl_ptr_derefs_may_alias_p" = "xyes"])
 
       dnl Work around header naming issues introduced upstream and in Debian
       dnl (see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631082>).
@@ -179,7 +185,6 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
 	[],
 	[#include <gcc-plugin.h>
 	 #include <tree.h>])
-
     ])