[PATCH] PR tree-optimization/16808: verify_ssa failed: Missing definition for SSA_NAME

Jie Zhang zhangjie@magima.com.cn
Tue Aug 3 00:26:00 GMT 2004


Hi,

How about this patch? Are there other variables that need be renamed? 
The testcase is diffed with /dev/null, so it looks a little weird.



regards
--
Jie


2004-08-03  Jie Zhang  <zhangjie@magima.com.cn>

    PR tree-optimization/16808
    * tree-ssa-ccp.c (execute_fold_all_builtins): Rename the affected vars
    in V_MAY_DEFS after folding builtins.
    (struct tree_opt_pass pass_fold_builtins): Add TODO_rename_vars in
    todo_flags_finish.

    * testsuite/gcc.c-torture/compile/20040803-1.c: New testcase.


Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/tree-ssa-ccp.c,v
retrieving revision 2.29
diff -u -p -r2.29 tree-ssa-ccp.c
--- tree-ssa-ccp.c    30 Jul 2004 22:55:25 -0000    2.29
+++ tree-ssa-ccp.c    3 Aug 2004 00:08:19 -0000
@@ -2653,11 +2653,11 @@ execute_fold_all_builtins (void)
   basic_block bb;
   FOR_EACH_BB (bb)
     {
-      block_stmt_iterator i;
-      for (i = bsi_start (bb); !bsi_end_p (i); bsi_next (&i))
+      block_stmt_iterator bsi;
+      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
     {
-      tree *stmtp = bsi_stmt_ptr (i);
-      tree call = get_rhs (*stmtp);
+      tree stmt = bsi_stmt (bsi);
+      tree call = get_rhs (stmt);
       tree callee, result;
 
       if (!call || TREE_CODE (call) != CALL_EXPR)
@@ -2666,7 +2666,7 @@ execute_fold_all_builtins (void)
       if (!callee || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL)
         continue;
 
-      result = ccp_fold_builtin (*stmtp, call);
+      result = ccp_fold_builtin (stmt, call);
       if (!result)
         switch (DECL_FUNCTION_CODE (callee))
           {
@@ -2684,16 +2684,31 @@ execute_fold_all_builtins (void)
       if (dump_file && (dump_flags & TDF_DETAILS))
         {
           fprintf (dump_file, "Simplified\n  ");
-          print_generic_stmt (dump_file, *stmtp, dump_flags);
+          print_generic_stmt (dump_file, stmt, dump_flags);
         }
 
-      if (set_rhs (stmtp, result))
-        modify_stmt (*stmtp);
+      if (set_rhs (&stmt, result))
+        {
+          size_t i;
+          stmt_ann_t ann;
+          v_may_def_optype v_may_defs;
+
+          ann = stmt_ann (stmt);
+          v_may_defs = V_MAY_DEF_OPS (ann);
+          for (i = 0; i < NUM_V_MAY_DEFS (v_may_defs); i++)
+        {
+          tree op = V_MAY_DEF_RESULT (v_may_defs, i);
+          tree var = SSA_NAME_VAR (op);
+          bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
+        }
+
+          modify_stmt (stmt);
+        }
 
       if (dump_file && (dump_flags & TDF_DETAILS))
         {
           fprintf (dump_file, "to\n  ");
-          print_generic_stmt (dump_file, *stmtp, dump_flags);
+          print_generic_stmt (dump_file, stmt, dump_flags);
           fprintf (dump_file, "\n");
         }
     }
@@ -2714,6 +2729,7 @@ struct tree_opt_pass pass_fold_builtins
   0,                    /* properties_destroyed */
   0,                    /* todo_flags_start */
   TODO_dump_func | TODO_verify_ssa    /* todo_flags_finish */
+    | TODO_rename_vars
 };
 

--- /dev/null    2004-07-29 21:31:29.000000000 +0800
+++ testsuite/gcc.c-torture/compile/20040803-1.c    2004-08-03 
07:21:20.000000000 +0800
@@ -0,0 +1,44 @@
+/* PR tree-optimization 16808
+   This test case used to cause ICE when folding exp (0.0) to 1.0 in 
fab.  */
+
+double exp(double);
+void f0(void);
+void f(double);
+
+typedef struct Parser {
+    int x;
+    char *s;
+} Parser;
+
+static double pop(Parser *p) {
+    if (p->s[0] <= 0) {
+    f0();
+    return 0;
+    }
+
+    --p->x;
+    return 0;
+}
+
+static void evalFactor(Parser *p) {
+    while (p->x)
+    f(exp(pop(p)));
+}
+
+static void evalTerm(Parser *p) {
+    while (p->s[0])
+    evalFactor(p);
+}
+
+static void evalExpression(Parser *p) {
+    evalTerm(p);
+    while (p->s[0])
+    evalTerm(p);
+}
+
+void evalPrimary(Parser *p) {
+    if (p->s)
+    return;
+    evalExpression(p);
+}
+
 





More information about the Gcc-patches mailing list