public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@physics.uc.edu>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix PRs middle-end/15014 and middle-end/16973, removing labels with their address taken
Date: Mon, 04 Oct 2004 15:06:00 -0000	[thread overview]
Message-ID: <2852718A-1614-11D9-81C0-000A95D692F4@physics.uc.edu> (raw)

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 ();


             reply	other threads:[~2004-10-04 14:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-04 15:06 Andrew Pinski [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2852718A-1614-11D9-81C0-000A95D692F4@physics.uc.edu \
    --to=pinskia@physics.uc.edu \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).