diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-12-13 21:03:47 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-12-13 21:03:47 +0000 |
commit | 78a289a921a5787579715c5d70fcd75c6f072a1b (patch) | |
tree | acff1e0e903850d88412936e41046a30e559dc43 /gcc/tree-inline.c | |
parent | 60e0f43541113052e3af80df52359ec3de4f94f8 (diff) | |
download | gcc-78a289a921a5787579715c5d70fcd75c6f072a1b.tar.gz |
gcc/ChangeLog:
PR tree-opt/16951
* tree-inline.c (setup_one_parameter): Don't directly map a
parameter to the address of another variable of the same
function.
gcc/testsuite/ChangeLog:
PR tree-opt/16951
* gcc.c-torture/compile/20041211-1.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92106 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 29740df72b0..db2b2361874 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -655,6 +655,22 @@ copy_body (inline_data *id) return body; } +/* Return true if VALUE is an ADDR_EXPR of an automatic variable + defined in function FN, or of a data member thereof. */ + +static bool +self_inlining_addr_expr (tree value, tree fn) +{ + tree var; + + if (TREE_CODE (value) != ADDR_EXPR) + return false; + + var = get_base_address (TREE_OPERAND (value, 0)); + + return var && lang_hooks.tree_inlining.auto_var_in_fn_p (var, fn); +} + static void setup_one_parameter (inline_data *id, tree p, tree value, tree fn, tree *init_stmts, tree *vars, bool *gimplify_init_stmts_p) @@ -679,7 +695,13 @@ setup_one_parameter (inline_data *id, tree p, tree value, tree fn, It is not big deal to prohibit constant propagation here as we will constant propagate in DOM1 pass anyway. */ if (is_gimple_min_invariant (value) - && lang_hooks.types_compatible_p (TREE_TYPE (value), TREE_TYPE (p))) + && lang_hooks.types_compatible_p (TREE_TYPE (value), TREE_TYPE (p)) + /* We have to be very careful about ADDR_EXPR. Make sure + the base variable isn't a local variable of the inlined + function, e.g., when doing recursive inlining, direct or + mutually-recursive or whatever, which is why we don't + just test whether fn == current_function_decl. */ + && ! self_inlining_addr_expr (value, fn)) { insert_decl_map (id, p, value); return; |