From: Alexandre Oliva <aoliva@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [vtab (and trunk?)] fix fallout from SSA-coalescing user variables
Date: Mon, 01 Oct 2007 19:12:00 -0000 [thread overview]
Message-ID: <or641qbqe2.fsf@free.oliva.athome.lsd.ic.unicamp.br> (raw)
[-- Attachment #1: Type: text/plain, Size: 711 bytes --]
After installing the patch that enables SSA coalescing of all
variables, I've experienced some compilation errors in Ada, having to
do with EH tables.
As it turns out, the compiler was not ready for such coalescing of
gimple registers. It created situations in which, because of the
abnormal setjmp/longjmp edges used for EH in the (stage1?) Ada
compiler, we'd get variables that were gimple registers and that had
multiple live versions simultaneously renamed at the time of
inlining. This should never happen.
This patch arranges for us to note the correct variable version to use
at the new edges for such gimple registers, instead of incorrectly
relying on renaming to do that.
:ADDPATCH vtab/inline:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gcc-debug-coalesce-inline-fallout.patch --]
[-- Type: text/x-patch, Size: 6982 bytes --]
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* tree-cfg.c (verify_stmts): Check for missing PHI defs.
* tree-inline.c (update_ssa_across_eh_edges): Renamed to...
(update_ssa_across_abnormal_edges): ... this. Set slots in the
return PHI node.
(copy_edges_for_bb): Handle nonlocal label edges.
(make_nonlocal_label_edges): Deleted.
(optimize_inline_calls): Don't call it.
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c.orig 2007-09-28 00:03:12.000000000 -0300
+++ gcc/tree-inline.c 2007-09-28 00:03:16.000000000 -0300
@@ -1018,7 +1018,8 @@ copy_bb (copy_body_data *id, basic_block
we might want to change way build CFG pre-inlining to include
all the possible edges then. */
static void
-update_ssa_across_eh_edges (basic_block bb)
+update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
+ bool can_throw, bool nonlocal_goto)
{
edge e;
edge_iterator ei;
@@ -1029,13 +1030,35 @@ update_ssa_across_eh_edges (basic_block
{
tree phi;
- gcc_assert (e->flags & EDGE_EH);
+ gcc_assert (e->flags & EDGE_ABNORMAL);
+ if (!nonlocal_goto)
+ gcc_assert (e->flags & EDGE_EH);
+ if (!can_throw)
+ gcc_assert (!(e->flags & EDGE_EH));
for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
{
+ edge re;
+
+ /* There shouldn't be any PHI nodes in the ENTRY_BLOCK. */
+ gcc_assert (!e->dest->aux);
+
gcc_assert (SSA_NAME_OCCURS_IN_ABNORMAL_PHI
(PHI_RESULT (phi)));
- mark_sym_for_renaming
- (SSA_NAME_VAR (PHI_RESULT (phi)));
+
+ if (!is_gimple_reg (PHI_RESULT (phi)))
+ {
+ mark_sym_for_renaming
+ (SSA_NAME_VAR (PHI_RESULT (phi)));
+ continue;
+ }
+
+ re = find_edge (ret_bb, e->dest);
+ gcc_assert (re);
+ gcc_assert ((re->flags & (EDGE_EH | EDGE_ABNORMAL))
+ == (e->flags & (EDGE_EH | EDGE_ABNORMAL)));
+
+ SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, e),
+ USE_FROM_PTR (PHI_ARG_DEF_PTR_FROM_EDGE (phi, re)));
}
}
}
@@ -1044,7 +1067,7 @@ update_ssa_across_eh_edges (basic_block
accordingly. Edges will be taken care of later. Assume aux
pointers to point to the copies of each BB. */
static void
-copy_edges_for_bb (basic_block bb, int count_scale)
+copy_edges_for_bb (basic_block bb, int count_scale, basic_block ret_bb)
{
basic_block new_bb = (basic_block) bb->aux;
edge_iterator ei;
@@ -1076,6 +1099,7 @@ copy_edges_for_bb (basic_block bb, int c
for (bsi = bsi_start (new_bb); !bsi_end_p (bsi);)
{
tree copy_stmt;
+ bool can_throw, nonlocal_goto;
copy_stmt = bsi_stmt (bsi);
update_stmt (copy_stmt);
@@ -1096,7 +1120,10 @@ copy_edges_for_bb (basic_block bb, int c
into a COMPONENT_REF which doesn't. If the copy
can throw, the original could also throw. */
- if (tree_can_throw_internal (copy_stmt))
+ can_throw = tree_can_throw_internal (copy_stmt);
+ nonlocal_goto = tree_can_make_abnormal_goto (copy_stmt);
+
+ if (can_throw || nonlocal_goto)
{
if (!bsi_end_p (bsi))
/* Note that bb's predecessor edges aren't necessarily
@@ -1108,12 +1135,18 @@ copy_edges_for_bb (basic_block bb, int c
new_bb->aux = e->src->aux;
bsi = bsi_start (new_bb);
}
+ }
- make_eh_edges (copy_stmt);
+ if (can_throw)
+ make_eh_edges (copy_stmt);
- if (gimple_in_ssa_p (cfun))
- update_ssa_across_eh_edges (bb_for_stmt (copy_stmt));
- }
+ if (nonlocal_goto)
+ make_abnormal_goto_edges (bb_for_stmt (copy_stmt), true);
+
+ if ((can_throw || nonlocal_goto)
+ && gimple_in_ssa_p (cfun))
+ update_ssa_across_abnormal_edges (bb_for_stmt (copy_stmt), ret_bb,
+ can_throw, nonlocal_goto);
}
}
@@ -1285,7 +1318,7 @@ copy_cfg_body (copy_body_data * id, gcov
last = last_basic_block;
/* Now that we've duplicated the blocks, duplicate their edges. */
FOR_ALL_BB_FN (bb, cfun_to_copy)
- copy_edges_for_bb (bb, count_scale);
+ copy_edges_for_bb (bb, count_scale, exit_block_map);
if (gimple_in_ssa_p (cfun))
FOR_ALL_BB_FN (bb, cfun_to_copy)
copy_phis_for_bb (bb, id);
@@ -2803,60 +2836,6 @@ has_abnormal_outgoing_edge_p (basic_bloc
return false;
}
-/* When a block from the inlined function contains a call with side-effects
- in the middle gets inlined in a function with non-locals labels, the call
- becomes a potential non-local goto so we need to add appropriate edge. */
-
-static void
-make_nonlocal_label_edges (void)
-{
- block_stmt_iterator bsi;
- basic_block bb;
-
- FOR_EACH_BB (bb)
- {
- for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
- {
- tree stmt = bsi_stmt (bsi);
- if (tree_can_make_abnormal_goto (stmt))
- {
- if (stmt == bsi_stmt (bsi_last (bb)))
- {
- if (!has_abnormal_outgoing_edge_p (bb))
- make_abnormal_goto_edges (bb, true);
- }
- else
- {
- edge e = split_block (bb, stmt);
- bb = e->src;
- make_abnormal_goto_edges (bb, true);
- }
- break;
- }
-
- /* Update PHIs on nonlocal goto receivers we (possibly)
- just created new edges into. */
- if (TREE_CODE (stmt) == LABEL_EXPR
- && gimple_in_ssa_p (cfun))
- {
- tree target = LABEL_EXPR_LABEL (stmt);
- if (DECL_NONLOCAL (target))
- {
- tree phi;
-
- for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
- {
- gcc_assert (SSA_NAME_OCCURS_IN_ABNORMAL_PHI
- (PHI_RESULT (phi)));
- mark_sym_for_renaming
- (SSA_NAME_VAR (PHI_RESULT (phi)));
- }
- }
- }
- }
- }
-}
-
/* Expand calls to inline functions in the body of FN. */
unsigned int
@@ -2935,8 +2914,6 @@ optimize_inline_calls (tree fn)
cgraph_node_remove_callees (id.dst_node);
fold_cond_expr_cond ();
- if (current_function_has_nonlocal_label)
- make_nonlocal_label_edges ();
/* It would be nice to check SSA/CFG/statement consistency here, but it is
not possible yet - the IPA passes might make various functions to not
throw and they don't care to proactively update local EH info. This is
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c.orig 2007-09-28 00:03:12.000000000 -0300
+++ gcc/tree-cfg.c 2007-09-28 00:03:16.000000000 -0300
@@ -4258,11 +4258,18 @@ verify_stmts (void)
tree t = PHI_ARG_DEF (phi, i);
tree addr;
+ if (!t)
+ {
+ error ("missing PHI def");
+ debug_generic_stmt (phi);
+ err |= true;
+ continue;
+ }
/* Addressable variables do have SSA_NAMEs but they
are not considered gimple values. */
- if (TREE_CODE (t) != SSA_NAME
- && TREE_CODE (t) != FUNCTION_DECL
- && !is_gimple_val (t))
+ else if (TREE_CODE (t) != SSA_NAME
+ && TREE_CODE (t) != FUNCTION_DECL
+ && !is_gimple_val (t))
{
error ("PHI def is not a GIMPLE value");
debug_generic_stmt (phi);
[-- Attachment #3: Type: text/plain, Size: 249 bytes --]
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
next reply other threads:[~2007-10-01 19:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-01 19:12 Alexandre Oliva [this message]
2007-10-01 19:20 ` Andrew Pinski
2007-10-01 19:28 ` Eric Botcazou
2007-10-03 16:56 ` Alexandre Oliva
2007-10-03 17:39 ` Eric Botcazou
2007-10-02 9:19 ` Richard Guenther
2007-10-03 16:54 ` Alexandre Oliva
2007-10-03 18:22 ` Richard Guenther
2007-10-06 11:45 ` Alexandre Oliva
2007-10-06 19:41 ` Regression with "Re: [vtab (and trunk?)] fix fallout from SSA-coalescing user variables" Hans-Peter Nilsson
2007-10-08 20:16 ` Alexandre Oliva
2007-10-09 4:46 ` Alexandre Oliva
2007-10-08 20:41 ` [vtab (and trunk?)] fix fallout from SSA-coalescing user variables Alexandre Oliva
2007-10-08 23:57 ` Alexandre Oliva
2007-10-11 10:13 ` Richard Guenther
2007-10-12 8:55 ` Alexandre Oliva
2007-10-13 18:37 ` Alexandre Oliva
2007-10-14 1:40 ` Alexandre Oliva
2007-10-15 9:05 ` Richard Guenther
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=or641qbqe2.fsf@free.oliva.athome.lsd.ic.unicamp.br \
--to=aoliva@redhat.com \
--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).