Fixed bug caused by trying to do casts directly in advice calls.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Wed, 13 Oct 2010 00:39:20 +0000 (20:39 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Wed, 13 Oct 2010 00:39:20 +0000 (20:39 -0400)
src/aop-weave.c

index 348534c452858a5fa6f7062bd772c4321d60766b..9d5cd985fd8e34302b65f004ae8b805e5dec9af2 100644 (file)
@@ -142,10 +142,29 @@ build_string_ptr (const char *string)
   return ret;
 }
 
+/* Create a temporary variable and assign the given value to that
+   variable with a cast.  Insert the assignment before the join point
+   and return the temporary value. */
+static tree
+insert_cast (tree val, tree cast_type, struct aop_joinpoint *jp)
+{
+  tree tmp;
+  tree cast;
+  gimple cast_assign;
+
+  tmp = create_tmp_var (cast_type, "ia_cast");
+  cast = build1 (CONVERT_EXPR, cast_type, val);
+
+  cast_assign = gimple_build_assign (tmp, cast);
+  jp->pc->insert_before (jp, cast_assign);
+
+  return tmp;
+}
+
 /* Whenver InterAspect matches an "all signed" or "all unsigned"
    value, it needs to cast it up to a long long before passing it. */
 static tree
-cast_to_all_integer (tree val)
+cast_to_all_integer (tree val, struct aop_joinpoint *jp)
 {
   tree gcc_type;
   HOST_WIDE_INT size;
@@ -161,8 +180,7 @@ cast_to_all_integer (tree val)
       tree cast_type = TYPE_UNSIGNED (gcc_type) ? long_long_unsigned_type_node
        : long_long_integer_type_node;
 
-      val = build1 (CONVERT_EXPR, cast_type, val);
-      return val;
+      return insert_cast (val, cast_type, jp);
     }
   else
     {
@@ -171,8 +189,9 @@ cast_to_all_integer (tree val)
     }
 }
 
+/* Similar to cast_to_all_integer, above. */
 static tree
-cast_to_all_fp (tree val)
+cast_to_all_fp (tree val, struct aop_joinpoint *jp)
 {
   tree gcc_type;
   HOST_WIDE_INT size;
@@ -185,8 +204,7 @@ cast_to_all_fp (tree val)
 
   if (size != 8)
     {
-      val = build1 (CONVERT_EXPR, double_type_node, val);
-      return val;
+      return insert_cast (val, double_type_node, jp);
     }
   else
     {
@@ -203,9 +221,9 @@ build_dynval (struct aop_dynval *dv)
   val = dv->get_dynval (dv);
 
   if (is_all_integer_type (dv->type))
-    val = cast_to_all_integer (val);
+    val = cast_to_all_integer (val, dv->jp);
   else if (is_all_fp_type (dv->type))
-    val = cast_to_all_fp (val);
+    val = cast_to_all_fp (val, dv->jp);
 
   return val;
 }