public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PRs middle-end/15014 and middle-end/16973, removing labels with their address taken
@ 2004-10-04 15:06 Andrew Pinski
  2004-10-05 22:40 ` Jeffrey A Law
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Pinski @ 2004-10-04 15:06 UTC (permalink / raw)
  To: GCC Patches

The problem here is that we were getting rid of some bb as they were 
being marked as unreachable (which is true in the code flow sense) but 
should not
be removed.  I fixed this by adding an edge from the first bb to the 
label's
bb which has its address taken.  I think this is most correct solution 
as
this does not happen much we should not have to worry about losing some
optimization possibility from doing it this way.

OK? Bootstrapped and tested on powerpc-apple-darwin.

Thanks,
Andrew Pinski


Testcase:
void
f (void)
{
   static __SIZE_TYPE__ u = &&a-&&b;
   a : b :  return;
}


ChangeLog:
	* tre-cfg.c (make_edges): After making the edges but before
	cleaning up the cfg, make an edge from the first BB to ever
	BB which we take the address of the label.

Patch:
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.64
diff -u -p -r2.64 tree-cfg.c
--- tree-cfg.c	2 Oct 2004 12:47:10 -0000	2.64
+++ tree-cfg.c	4 Oct 2004 14:44:19 -0000
@@ -417,6 +417,7 @@ static void
  make_edges (void)
  {
    basic_block bb;
+  basic_block target_bb;

    /* Create an edge from entry to the first block with executable
       statements in it.  */
@@ -448,6 +449,30 @@ make_edges (void)
    /* We do not care about fake edges, so remove any that the CFG
       builder inserted for completeness.  */
    remove_fake_exit_edges ();
+
+  /* Look for the block starting with the destination label.  In the
+     case of a computed label, make an edge from the entry block to the
+     computed lablel.  */
+  FOR_EACH_BB (target_bb)
+    {
+      block_stmt_iterator bsi;
+
+      for (bsi = bsi_start (target_bb); !bsi_end_p (bsi); bsi_next 
(&bsi))
+	{
+	  tree target = bsi_stmt (bsi);
+
+	  if (TREE_CODE (target) != LABEL_EXPR)
+	    break;
+
+	  if (FORCED_LABEL (LABEL_EXPR_LABEL (target))
+	      || DECL_NONLOCAL (LABEL_EXPR_LABEL (target)))
+	    {
+	      make_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest,
+	                 target_bb, EDGE_ABNORMAL);
+	      break;
+	    }
+	}
+    }

    /* Clean up the graph and warn for unreachable code.  */
    cleanup_tree_cfg ();


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH] Fix PRs middle-end/15014 and middle-end/16973, removing labels with their address taken
@ 2004-10-18 21:37 Ulrich Weigand
  0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Weigand @ 2004-10-18 21:37 UTC (permalink / raw)
  To: pinskia; +Cc: gcc-patches

Andrew Pinski wrote:

>I also applied the following testcase for PR 16973.

This one fails with:
/home/weigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr16973.c: In function 'f':
/home/weigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr16973.c:8: error: taking the address of a label is non-standard
/home/weigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr16973.c:8: error: taking the address of a label is non-standard
/home/weigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr16973.c:8: error: pointer of type 'void *' used in subtraction

I guess you should reset dg-options to remove the "-ansi -pedantic-errors".

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-10-18 21:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-04 15:06 [PATCH] Fix PRs middle-end/15014 and middle-end/16973, removing labels with their address taken Andrew Pinski
2004-10-05 22:40 ` Jeffrey A Law
2004-10-05 23:12   ` Joseph S. Myers
2004-10-06  2:35   ` Andrew Pinski
2004-10-06 17:03     ` Jeffrey A Law
2004-10-10 18:01   ` Andrew Pinski
2004-10-18 19:27     ` Jeffrey A Law
2004-10-18 20:19       ` Andrew Pinski
2004-10-18 21:37 Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).