Procházet zdrojové kódy

gcc: Convert constant arguments to the corresponding formal parameter type.

* gcc-plugin/src/starpu.c (build_task_submission)[local_vars]: Use the
  TASK_DECL's formal parameter types, not the actual argument types.
  Convert the new variables initial value to the formal parameter's
  type.
Ludovic Courtès před 14 roky
rodič
revize
63c90aed8e
1 změnil soubory, kde provedl 14 přidání a 4 odebrání
  1. 14 4
      gcc-plugin/src/starpu.c

+ 14 - 4
gcc-plugin/src/starpu.c

@@ -948,23 +948,33 @@ build_task_submission (tree task_decl, gimple call)
   {
     size_t n;
     tree vars = NULL_TREE;
+    tree arg_types = TYPE_ARG_TYPES (TREE_TYPE (task_decl));
 
-    for (n = 0; n < gimple_call_num_args (call); n++)
+    for (n = 0;
+	 n < gimple_call_num_args (call);
+	 n++, arg_types = TREE_CHAIN (arg_types))
       {
-	tree arg;
+	tree arg, type;
+
+	/* Initially ARG_TYPES should be a list of N type nodes.  */
+	gcc_assert (TREE_CODE (arg_types) == TREE_LIST);
+	type = TREE_VALUE (arg_types);
+	gcc_assert (type != NULL_TREE);
 
 	arg = gimple_call_arg (call, n);
+
 	if (!POINTER_TYPE_P (TREE_TYPE (arg))
 	    && TREE_CONSTANT (arg)
 	    && TREE_CODE (arg) != VAR_DECL
 	    && TREE_CODE (arg) != ADDR_EXPR)
 	  {
 	    /* ARG is a scalar constant.  Introduce a variable to hold it.  */
-	    tree var = create_tmp_var (TREE_TYPE (arg), ".literal-arg");
+	    tree var = create_tmp_var (type, ".literal-arg");
+	    tree init_value = fold_convert (type, arg);
 
 	    /* Initialize VAR.  */
 	    gimple_seq init = NULL;
-	    tree modify = build2 (MODIFY_EXPR, TREE_TYPE (arg), var, arg);
+	    tree modify = build2 (MODIFY_EXPR, type, var, init_value);
 	    force_gimple_operand (modify, &init, true, var);
 
 	    gimple_seq_add_seq (body, init);