summaryrefslogtreecommitdiff
path: root/gcc/tree-nrv.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-03-11 05:01:30 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-03-11 05:01:30 +0000
commit93ef915404bbfdce27f48aa2019259cde2b5fe60 (patch)
tree04676e346137008a23915b8a6560a1db577b4ccd /gcc/tree-nrv.c
parent4878f58780f07ee1d9508d6287454b12c86d6d3f (diff)
downloadgcc-93ef915404bbfdce27f48aa2019259cde2b5fe60.tar.gz
PR debug/39086
* tree-nrv.c (tree_nrv): Don't do this optimization if the front end already did. Notice GIMPLE_CALL modifications of the result. Don't copy debug information from an ignored decl or a decl from another function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144772 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-nrv.c')
-rw-r--r--gcc/tree-nrv.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index 40e7508f613..7e811cf8c9d 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -121,6 +121,10 @@ tree_nrv (void)
if (is_gimple_reg_type (result_type))
return 0;
+ /* If the front end already did something like this, don't do it here. */
+ if (DECL_NAME (result))
+ return 0;
+
/* Look through each block for assignments to the RESULT_DECL. */
FOR_EACH_BB (bb)
{
@@ -138,8 +142,8 @@ tree_nrv (void)
if (ret_val)
gcc_assert (ret_val == result);
}
- else if (is_gimple_assign (stmt)
- && gimple_assign_lhs (stmt) == result)
+ else if (gimple_has_lhs (stmt)
+ && gimple_get_lhs (stmt) == result)
{
tree rhs;
@@ -173,9 +177,9 @@ tree_nrv (void)
TREE_TYPE (found)))
return 0;
}
- else if (is_gimple_assign (stmt))
+ else if (gimple_has_lhs (stmt))
{
- tree addr = get_base_address (gimple_assign_lhs (stmt));
+ tree addr = get_base_address (gimple_get_lhs (stmt));
/* If there's any MODIFY of component of RESULT,
then bail out. */
if (addr && addr == result)
@@ -199,10 +203,17 @@ tree_nrv (void)
/* At this point we know that all the return statements return the
same local which has suitable attributes for NRV. Copy debugging
- information from FOUND to RESULT. */
- DECL_NAME (result) = DECL_NAME (found);
- DECL_SOURCE_LOCATION (result) = DECL_SOURCE_LOCATION (found);
- DECL_ABSTRACT_ORIGIN (result) = DECL_ABSTRACT_ORIGIN (found);
+ information from FOUND to RESULT if it will be useful. But don't set
+ DECL_ABSTRACT_ORIGIN to point at another function. */
+ if (!DECL_IGNORED_P (found)
+ && !(DECL_ABSTRACT_ORIGIN (found)
+ && DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (found)) != current_function_decl))
+ {
+ DECL_NAME (result) = DECL_NAME (found);
+ DECL_SOURCE_LOCATION (result) = DECL_SOURCE_LOCATION (found);
+ DECL_ABSTRACT_ORIGIN (result) = DECL_ABSTRACT_ORIGIN (found);
+ }
+
TREE_ADDRESSABLE (result) = TREE_ADDRESSABLE (found);
/* Now walk through the function changing all references to VAR to be