Cilk+ builds INDIRECT_REFs when expanding builtins (oops) and thus
those can leak into MEM_EXRs which will lead to ICEs later.
The following patch properly builds a MEM_REF instead.  Grepping
for INDIRECT_REF I found another suspicious use (just removed,
it cannot have triggered and it looks bogus) and the use of
a langhook instead of proper GIMPLE interfaces (function also
used during expansion).

Bootstrap / testing in progress together with some other stuff.

Ok?

Thanks,
Richard.

2014-02-13  Richard Biener  <rguent...@suse.de>

        * cilk-common.c: Include gimple-expr.h.
        (cilk_arrow): Build a MEM_REF, not an INDIRECT_REF.
        (get_frame_arg): Use middel-end types_compatible_p.  Do not
        strip INDIRECT_REFs.

Index: gcc/cilk-common.c
===================================================================
--- gcc/cilk-common.c   (revision 207725)
+++ gcc/cilk-common.c   (working copy)
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.
 #include "recog.h"
 #include "tree-iterator.h"
 #include "gimplify.h"
+#include "gimple-expr.h"
 #include "cilk.h"
 
 /* This structure holds all the important fields of the internal structures,
@@ -66,8 +67,7 @@ cilk_dot (tree frame, int field_number,
 tree
 cilk_arrow (tree frame_ptr, int field_number, bool volatil)
 {
-  return cilk_dot (fold_build1 (INDIRECT_REF, 
-                               TREE_TYPE (TREE_TYPE (frame_ptr)), frame_ptr), 
+  return cilk_dot (build_simple_mem_ref (frame_ptr), 
                   field_number, volatil);
 }
 
@@ -287,12 +287,11 @@ get_frame_arg (tree call)
 
   argtype = TREE_TYPE (argtype);
   
-  gcc_assert (!lang_hooks.types_compatible_p
-             || lang_hooks.types_compatible_p (argtype, cilk_frame_type_decl));
+  gcc_assert (types_compatible_p (argtype, cilk_frame_type_decl));
 
   /* If it is passed in as an address, then just use the value directly 
      since the function is inlined.  */
-  if (TREE_CODE (arg) == INDIRECT_REF || TREE_CODE (arg) == ADDR_EXPR)
+  if (TREE_CODE (arg) == ADDR_EXPR)
     return TREE_OPERAND (arg, 0);
   return arg;
 }

Reply via email to