diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-18 10:23:22 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-18 10:23:22 +0000 |
commit | 0680da650a36b1b2245bc8d92876dbd243bd311c (patch) | |
tree | 82a1fb5a01a533049b83b6416d9b5e4eef768913 /gcc/dse.c | |
parent | 028d5ac7ffe7bae46aedabc679074b4c80f45df8 (diff) | |
download | gcc-0680da650a36b1b2245bc8d92876dbd243bd311c.tar.gz |
2012-10-18 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 192552 using svnmerge.py
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@192557 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dse.c')
-rw-r--r-- | gcc/dse.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/gcc/dse.c b/gcc/dse.c index eff4a3909c8..631a1f20ac7 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -989,7 +989,32 @@ delete_dead_store_insn (insn_info_t insn_info) insn_info->wild_read = false; } -/* Check if EXPR can possibly escape the current function scope. */ +/* Return whether DECL, a local variable, can possibly escape the current + function scope. */ + +static bool +local_variable_can_escape (tree decl) +{ + if (TREE_ADDRESSABLE (decl)) + return true; + + /* If this is a partitioned variable, we need to consider all the variables + in the partition. This is necessary because a store into one of them can + be replaced with a store into another and this may not change the outcome + of the escape analysis. */ + if (cfun->gimple_df->decls_to_pointers != NULL) + { + void *namep + = pointer_map_contains (cfun->gimple_df->decls_to_pointers, decl); + if (namep) + return TREE_ADDRESSABLE (*(tree *)namep); + } + + return false; +} + +/* Return whether EXPR can possibly escape the current function scope. */ + static bool can_escape (tree expr) { @@ -998,7 +1023,11 @@ can_escape (tree expr) return true; base = get_base_address (expr); if (DECL_P (base) - && !may_be_aliased (base)) + && !may_be_aliased (base) + && !(TREE_CODE (base) == VAR_DECL + && !DECL_EXTERNAL (base) + && !TREE_STATIC (base) + && local_variable_can_escape (base))) return false; return true; } @@ -2518,14 +2547,8 @@ scan_insn (bb_info_t bb_info, rtx insn) const_call = RTL_CONST_CALL_P (insn); if (!const_call) { - rtx call = PATTERN (insn); - if (GET_CODE (call) == PARALLEL) - call = XVECEXP (call, 0, 0); - if (GET_CODE (call) == SET) - call = SET_SRC (call); - if (GET_CODE (call) == CALL - && MEM_P (XEXP (call, 0)) - && GET_CODE (XEXP (XEXP (call, 0), 0)) == SYMBOL_REF) + rtx call = get_call_rtx_from (insn); + if (call && GET_CODE (XEXP (XEXP (call, 0), 0)) == SYMBOL_REF) { rtx symbol = XEXP (XEXP (call, 0), 0); if (SYMBOL_REF_DECL (symbol) |