Browse Source

gcc: Have `validate_task_implementation' skip external task implementations.

* gcc-plugin/src/starpu.c (validate_task_implementation): Check for
  CGRAPH != NULL.

* gcc-plugin/tests/Makefile.am (gcc_tests): Add `external-task-impl.c'.

* gcc-plugin/tests/external-task-impl.c: New file.
Ludovic Courtès 13 years ago
parent
commit
69b940943a
3 changed files with 50 additions and 13 deletions
  1. 16 13
      gcc-plugin/src/starpu.c
  2. 1 0
      gcc-plugin/tests/Makefile.am
  3. 33 0
      gcc-plugin/tests/external-task-impl.c

+ 16 - 13
gcc-plugin/src/starpu.c

@@ -2080,20 +2080,23 @@ validate_task_implementation (tree impl)
   const struct cgraph_edge *callee;
 
   cgraph = cgraph_get_node (impl);
-  for (callee = cgraph->callees;
-       callee != NULL;
-       callee = callee->next_callee)
-    {
-      if (task_p (callee->callee->decl))
-	{
-	  location_t loc;
 
-	  loc = gimple_location (callee->call_stmt);
-	  error_at (loc, "task %qE cannot be invoked from task implementation %qE",
-		    DECL_NAME (callee->callee->decl),
-		    DECL_NAME (impl));
-	}
-    }
+  /* When a definition of IMPL is available, check its callees.  */
+  if (cgraph != NULL)
+    for (callee = cgraph->callees;
+	 callee != NULL;
+	 callee = callee->next_callee)
+      {
+	if (task_p (callee->callee->decl))
+	  {
+	    location_t loc;
+
+	    loc = gimple_location (callee->call_stmt);
+	    error_at (loc, "task %qE cannot be invoked from task implementation %qE",
+		      DECL_NAME (callee->callee->decl),
+		      DECL_NAME (impl));
+	  }
+      }
 }
 
 static unsigned int

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

@@ -28,6 +28,7 @@ gcc_tests =					\
   task-errors.c					\
   scalar-tasks.c				\
   pointer-tasks.c				\
+  external-task-impl.c				\
   no-initialize.c				\
   lib-user.c					\
   wait-errors.c					\

+ 33 - 0
gcc-plugin/tests/external-task-impl.c

@@ -0,0 +1,33 @@
+/* GCC-StarPU
+   Copyright (C) 2012 Institut National de Recherche en Informatique et Automatique
+
+   GCC-StarPU is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   GCC-StarPU is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC-StarPU.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* (instructions compile) */
+
+void the_task (int foo, float bar[foo])
+  __attribute__ ((task));
+
+static void the_task_cpu (int foo, float bar[foo])
+  __attribute__ ((task_implementation ("cpu", the_task)));
+
+/* Make sure GCC doesn't barf on this one.  */
+extern void the_task_cuda (int foo, float bar[foo])
+  __attribute__ ((task_implementation ("cuda", the_task)));
+
+static void
+the_task_cpu (int foo, float bar[foo])
+{
+  /* Nothingness.  */
+}