This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[PATCH] lower gimple: Sustain line number info for returns if possible


Hi,

I see several guality tests failing on s390 because the line number
info of the return statement of a function is lost.  The information
is lost when lower gimple tries to merge return statements by adding
gotos.  The line number info is removed in lower_function_body since
the return might now be used for implementing several returns at
different code locations. However the removal isn't necessary if a
merge did not actually occur.

The attached patch moves the removal of the line info from
lower_function_body to lower_gimple_return and only does the removal
if the return statement is actually re-used.

This fixes 91 testsuite fails on s390x. However there are a few new
fails where the line numbers of warnings have changed due to more
return statements having line number information now:

> FAIL: gcc.dg/noreturn-1.c detect return from noreturn (test for warnings, line 38)
> FAIL: gcc.dg/noreturn-1.c (test for excess errors)
> FAIL: gcc.dg/pr39666-2.c  (test for warnings, line 8)
> FAIL: gcc.dg/pr39666-2.c (test for excess errors)
> FAIL: gcc.dg/uninit-pr19430.c  (test for warnings, line 21)
> FAIL: gcc.dg/uninit-pr19430.c (test for excess errors)
> FAIL: c-c++-common/pr20000.c  -Wc++-compat   (test for warnings, line 13)
> FAIL: c-c++-common/pr20000.c  -Wc++-compat   (test for warnings, line 28)
> FAIL: c-c++-common/pr20000.c  -Wc++-compat  (test for excess errors)

I'll post patches moving the expected warnings in the testcases accordingly.

Bootstrapped on s390x.

Ok for mainline?

Bye,

-Andreas-


2011-02-07  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* gimple-low.c (lower_function_body): Don't remove the location of
	the return statement here.
	(lower_gimple_return): Do it here instead but only if the return
	statement is actually used twice.


Index: gcc/gimple-low.c
===================================================================
*** gcc/gimple-low.c.orig
--- gcc/gimple-low.c
*************** lower_function_body (void)
*** 148,158 ****
  
        x = gimple_build_label (t.label);
        gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
- 
-       /* Remove the line number from the representative return statement.
- 	 It now fills in for many such returns.  Failure to remove this
- 	 will result in incorrect results for coverage analysis.  */
-       gimple_set_location (t.stmt, UNKNOWN_LOCATION);
        gsi_insert_after (&i, t.stmt, GSI_CONTINUE_LINKING);
      }
  
--- 148,153 ----
*************** lower_gimple_return (gimple_stmt_iterato
*** 746,752 ****
        tmp_rs = *VEC_index (return_statements_t, data->return_statements, i);
  
        if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt))
! 	goto found;
      }
  
    /* Not found.  Create a new label and record the return statement.  */
--- 741,754 ----
        tmp_rs = *VEC_index (return_statements_t, data->return_statements, i);
  
        if (gimple_return_retval (stmt) == gimple_return_retval (tmp_rs.stmt))
! 	{
! 	  /* Remove the line number from the representative return statement.
! 	     It now fills in for many such returns.  Failure to remove this
! 	     will result in incorrect results for coverage analysis.  */
! 	  gimple_set_location (tmp_rs.stmt, UNKNOWN_LOCATION);
! 
! 	  goto found;
! 	}
      }
  
    /* Not found.  Create a new label and record the return statement.  */


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