This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: access to deleted pointer in flow.c


Hi,

I wrote:

> After the call to redirect_edge_succ_nodup
> cbranch_jump_edge/cbranch_fallthru_edge might be removed (in my case it
> was cbranch_fallthru_edge).

I attached the patch I'm currently using.
I bootstrapped/regtested it successful on i686-linux, m68k-linux is
still compiling but it looks good so far and the patch seems to help.

bye, Roman

2001-08-20  Roman Zippel  <zippel@linux-m68k.org>

	* flow.c (redirect_edge_succ_nodup): return new edge
	(try_simplify_condjump): use new edge
	* basic-block.h (redirect_edge_succ_nodup): update prototype
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.465
diff -u -r1.465 flow.c
--- flow.c	2001/08/19 03:04:17	1.465
+++ flow.c	2001/08/20 15:31:52
@@ -3335,8 +3335,10 @@
   /* Success.  Update the CFG to match.  Note that after this point
      the edge variable names appear backwards; the redirection is done
      this way to preserve edge profile data.  */
-  redirect_edge_succ_nodup (cbranch_jump_edge, cbranch_dest_block);
-  redirect_edge_succ_nodup (cbranch_fallthru_edge, jump_dest_block);
+  cbranch_jump_edge = redirect_edge_succ_nodup (cbranch_jump_edge,
+						cbranch_dest_block);
+  cbranch_fallthru_edge = redirect_edge_succ_nodup (cbranch_fallthru_edge,
+						    jump_dest_block);
   cbranch_jump_edge->flags |= EDGE_FALLTHRU;
   cbranch_fallthru_edge->flags &= ~EDGE_FALLTHRU;
 
@@ -9024,7 +9019,7 @@
 
 /* Like previous but avoid possible dupplicate edge.  */
 
-void
+edge
 redirect_edge_succ_nodup (e, new_succ)
      edge e;
      basic_block new_succ;
@@ -9040,9 +9035,11 @@
       s->probability += e->probability;
       s->count += e->count;
       remove_edge (e);
+      e = s;
     }
   else
     redirect_edge_succ (e, new_succ);
+  return e;
 }
 
 /* Redirect an edge's predecessor from one block to another.  */
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/basic-block.h,v
retrieving revision 1.111
diff -u -r1.111 basic-block.h
--- basic-block.h	2001/08/06 06:39:20	1.111
+++ basic-block.h	2001/08/20 15:32:02
@@ -297,7 +297,7 @@
 						 basic_block, int));
 extern void remove_edge			PARAMS ((edge));
 extern void redirect_edge_succ		PARAMS ((edge, basic_block));
-extern void redirect_edge_succ_nodup	PARAMS ((edge, basic_block));
+extern edge redirect_edge_succ_nodup	PARAMS ((edge, basic_block));
 extern void redirect_edge_pred		PARAMS ((edge, basic_block));
 extern void create_basic_block		PARAMS ((int, rtx, rtx, rtx));
 extern int flow_delete_block		PARAMS ((basic_block));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]