This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFC] tree-cfg.c: Check that a nonlocal label doesn't appear inthe middle of a basic block.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dvorakz at suse dot cz, dnovillo at redhat dot com
- Date: Wed, 19 Jan 2005 00:00:30 -0500 (EST)
- Subject: [RFC] tree-cfg.c: Check that a nonlocal label doesn't appear inthe middle of a basic block.
Hi,
Attached is a patch to check that a nonlocal label doesn't appear in
the middle of a basic block.
Note that we don't consider a nonlocal label to be appearing in the
middle of a basic block if all the statements before the label are
also nonlocal labels.
This patch is based on the thread starting at
http://gcc.gnu.org/ml/gcc/2005-01/msg01036.html
Unfortunately, this patch introduces the following regressions (or
rather catches the following errors that went undetected previously).
+FAIL: gcc.c-torture/compile/20021108-1.c -O0 (test for excess errors)
+FAIL: gcc.c-torture/compile/20021108-1.c -O1 (test for excess errors)
+FAIL: gcc.c-torture/compile/20021108-1.c -O2 (test for excess errors)
+FAIL: gcc.c-torture/compile/20021108-1.c -O3 -fomit-frame-pointer (test for excess errors)
+FAIL: gcc.c-torture/compile/20021108-1.c -O3 -g (test for excess errors)
+FAIL: gcc.c-torture/compile/20021108-1.c -Os (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-1.c -O0 (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-1.c -O1 (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-1.c -O2 (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-1.c -O3 -fomit-frame-pointer (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-1.c -O3 -g (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-1.c -Os (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-2.c -O0 (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-2.c -O1 (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-2.c -O2 (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-2.c -O3 -fomit-frame-pointer (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-2.c -O3 -g (test for excess errors)
+FAIL: gcc.c-torture/compile/labels-2.c -Os (test for excess errors)
+FAIL: gcc.dg/pr16973.c (test for excess errors)
I have not analyzed what's causing these problems.
Kazu Hirata
2005-01-18 Kazu Hirata <kazu@cs.umass.edu>
* tree-cfg.c (tree_verify_flow_info): Check that a nonlocal
label doesn't appear in the middle of a basic block.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.139
diff -c -d -p -r2.139 tree-cfg.c
*** tree-cfg.c 17 Jan 2005 18:44:18 -0000 2.139
--- tree-cfg.c 18 Jan 2005 16:19:56 -0000
*************** tree_verify_flow_info (void)
*** 3595,3619 ****
{
bool found_ctrl_stmt = false;
/* Skip labels on the start of basic block. */
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
{
! if (TREE_CODE (bsi_stmt (bsi)) != LABEL_EXPR)
break;
! if (label_to_block (LABEL_EXPR_LABEL (bsi_stmt (bsi))) != bb)
{
- tree stmt = bsi_stmt (bsi);
error ("Label %s to block does not match in bb %d\n",
IDENTIFIER_POINTER (DECL_NAME (LABEL_EXPR_LABEL (stmt))),
bb->index);
err = 1;
}
! if (decl_function_context (LABEL_EXPR_LABEL (bsi_stmt (bsi)))
!= current_function_decl)
{
- tree stmt = bsi_stmt (bsi);
error ("Label %s has incorrect context in bb %d\n",
IDENTIFIER_POINTER (DECL_NAME (LABEL_EXPR_LABEL (stmt))),
bb->index);
--- 3595,3630 ----
{
bool found_ctrl_stmt = false;
+ stmt = NULL_TREE;
+
/* Skip labels on the start of basic block. */
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
{
! tree prev_stmt = stmt;
!
! stmt = bsi_stmt (bsi);
!
! if (TREE_CODE (stmt) != LABEL_EXPR)
break;
! if (prev_stmt && stmt_starts_bb_p (stmt, prev_stmt))
! {
! error ("Nonlocal and/or computed GOTO targets "
! "in the middle of basic block bb %d", bb->index);
! err = 1;
! }
!
! if (label_to_block (LABEL_EXPR_LABEL (stmt)) != bb)
{
error ("Label %s to block does not match in bb %d\n",
IDENTIFIER_POINTER (DECL_NAME (LABEL_EXPR_LABEL (stmt))),
bb->index);
err = 1;
}
! if (decl_function_context (LABEL_EXPR_LABEL (stmt))
!= current_function_decl)
{
error ("Label %s has incorrect context in bb %d\n",
IDENTIFIER_POINTER (DECL_NAME (LABEL_EXPR_LABEL (stmt))),
bb->index);