diff options
author | Jason Merrill <jason@casey.cygnus.com> | 1999-12-16 00:09:35 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1999-12-15 19:09:35 -0500 |
commit | 5afb79e7f856b5a9b4414ee34940b568aa77abe8 (patch) | |
tree | 8f73132ac5140a32542ad1c3a7a0a0ab4b8f62b4 /gcc | |
parent | 6150df627a7fb825a10280e54c35c8250e69bae0 (diff) | |
download | gcc-5afb79e7f856b5a9b4414ee34940b568aa77abe8.zip gcc-5afb79e7f856b5a9b4414ee34940b568aa77abe8.tar.gz gcc-5afb79e7f856b5a9b4414ee34940b568aa77abe8.tar.bz2 |
function.c (retrofit_block): Abort if we don't find a suitable insn.
* function.c (retrofit_block): Abort if we don't find a suitable insn.
(insert_block_after_note): Abort if we don't have a previous block.
Remove FN parameter.
* function.h: Adjust.
* tree.c (walk_tree): Walk operand subtrees in forward order.
* optimize.c (expand_call_inline): Likewise.
(optimize_function): Initialize id->scope_stmt to something useful.
(remap_block): Assume id->scope_stmt has a useful value.
From-SVN: r30965
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 24 | ||||
-rw-r--r-- | gcc/cp/tree.c | 16 | ||||
-rw-r--r-- | gcc/function.c | 24 | ||||
-rw-r--r-- | gcc/function.h | 7 |
6 files changed, 50 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0462e45..190810b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +1999-12-15 Jason Merrill <jason@casey.cygnus.com> + + * function.c (retrofit_block): Abort if we don't find a suitable insn. + (insert_block_after_note): Abort if we don't have a previous block. + Remove FN parameter. + * function.h: Adjust. + 1999-12-15 Mark Mitchell <mark@codesourcery.com> * builtins.c (expand_builtin_mathfn): Make sure not to expand the diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ac432dc..6069bf0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1999-12-15 Jason Merrill <jason@casey.cygnus.com> + + * tree.c (walk_tree): Walk operand subtrees in forward order. + * optimize.c (expand_call_inline): Likewise. + (optimize_function): Initialize id->scope_stmt to something useful. + (remap_block): Assume id->scope_stmt has a useful value. + 1999-12-15 Nathan Sidwell <nathan@acm.org> * typeck.c (build_c_cast): Expand warning message. Move pointer @@ -67,7 +74,6 @@ (reinit_parse_for_expr): Use. (check_newline): Use. ->>>>>>> 1.1463 1999-12-13 Mark Mitchell <mark@codesourcery.com> * optimize.c (initialize_inlined_parameters): Take FN to which the diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 2177e4a..7eae09d 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -176,13 +176,9 @@ remap_block (scope_stmt, decls, id) /* We put the BLOCK_VARS in reverse order; fix that now. */ BLOCK_VARS (new_block) = nreverse (BLOCK_VARS (new_block)); /* Graft the new block into the tree. */ - insert_block_after_note (new_block, - (id->scope_stmt - ? SCOPE_STMT_BLOCK (id->scope_stmt) - : NULL_TREE), - (id->scope_stmt - ? SCOPE_BEGIN_P (id->scope_stmt) : 1), - VARRAY_TREE (id->fns, 0)); + insert_block_after_note (new_block, + SCOPE_STMT_BLOCK (id->scope_stmt), + SCOPE_BEGIN_P (id->scope_stmt)); /* Remember that this is now the last scope statement with an associated block. */ id->scope_stmt = scope_stmt; @@ -536,7 +532,7 @@ expand_call_inline (tp, walk_subtrees, data) inside the body of a TARGET_EXPR. */ if (TREE_CODE (*tp) == TARGET_EXPR) { - int i; + int i, len = first_rtl_op (TARGET_EXPR); /* We're walking our own subtrees. */ *walk_subtrees = 0; @@ -544,7 +540,7 @@ expand_call_inline (tp, walk_subtrees, data) /* Actually walk over them. This loop is the body of walk_trees, omitting the case where the TARGET_EXPR itself is handled. */ - for (i = first_rtl_op (TARGET_EXPR) - 1; i >= 0; --i) + for (i = 0; i < len; ++i) { if (i == 2) ++id->in_target_cleanup_p; @@ -615,7 +611,8 @@ expand_call_inline (tp, walk_subtrees, data) id->scope_stmt = scope_stmt; /* Tell the debugging backends that this block represents the - outermost scope of the inlined function. */ + outermost scope of the inlined function. FIXME what to do for + inlines in cleanups? */ if (SCOPE_STMT_BLOCK (scope_stmt)) BLOCK_ABSTRACT_ORIGIN (SCOPE_STMT_BLOCK (scope_stmt)) = DECL_ORIGIN (fn); @@ -725,6 +722,13 @@ optimize_function (fn) VARRAY_PUSH_TREE (id.fns, s->function_decl); prev_fn = s->function_decl; } + + /* Initialize id->scope_stmt with a fake SCOPE_STMT for the outermost + block of the function (i.e. the BLOCK with __FUNCTION__ et al). */ + id.scope_stmt = build_min_nt (SCOPE_STMT, + BLOCK_SUBBLOCKS (DECL_INITIAL (fn))); + SCOPE_BEGIN_P (id.scope_stmt) = 1; + /* Replace all calls to inline functions with the bodies of those functions. */ expand_calls_inline (&DECL_SAVED_TREE (fn), &id); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 37c947d..f730b21 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1623,21 +1623,19 @@ walk_tree (tp, func, data) || TREE_CODE_CLASS (code) == 'r' || TREE_CODE_CLASS (code) == 's') { - int i; + int i, len; /* Walk over all the sub-trees of this operand. */ - i = first_rtl_op (code) - 1; + len = first_rtl_op (code); /* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same. But, we only want to walk once. */ if (code == TARGET_EXPR && TREE_OPERAND (*tp, 3) == TREE_OPERAND (*tp, 1)) - --i; - /* Go through the subtrees. */ - while (i >= 0) - { - WALK_SUBTREE (TREE_OPERAND (*tp, i)); - --i; - } + --len; + /* Go through the subtrees. We need to do this in forward order so + that the scope of a FOR_EXPR is handled properly. */ + for (i = 0; i < len; ++i) + WALK_SUBTREE (TREE_OPERAND (*tp, i)); /* For statements, we also walk the chain so that we cover the entire statement tree. */ diff --git a/gcc/function.c b/gcc/function.c index 2392f32..3211204 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -5495,22 +5495,22 @@ round_trampoline_addr (tramp) /* Insert the BLOCK in the block-tree, knowing that the previous block-note is for OLD_BLOCK. BEGIN_P is non-zero if the previous - block-note was the for the beginning of a BLOCK. FN is the - FUNCTION_DECL into which the BLOCK is being inserted. */ + block-note was the for the beginning of a BLOCK. */ void -insert_block_after_note (block, old_block, begin_p, fn) +insert_block_after_note (block, old_block, begin_p) tree block; tree old_block; int begin_p; - tree fn; { if (begin_p) { - /* If there was no previous block, use the top-level block for - the function. */ + /* If there was no previous block, something's gone terribly + wrong. We used to try to use DECL_INITIAL for the current + function, but that will never be correct, and completely + hoses the block structure. */ if (!old_block) - old_block = DECL_INITIAL (fn); + abort (); BLOCK_SUPERCONTEXT (block) = old_block; BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (old_block); @@ -5545,12 +5545,12 @@ retrofit_block (block, last_insn) || NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END)) break; + if (insn == NULL_RTX) + abort (); + insert_block_after_note (block, - insn ? NOTE_BLOCK (insn) : NULL_TREE, - insn - ? (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG) - : 1, - current_function_decl); + NOTE_BLOCK (insn), + NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG); } /* The functions identify_blocks and reorder_blocks provide a way to diff --git a/gcc/function.h b/gcc/function.h index 059d8e1..0e2b7b8 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -1,5 +1,5 @@ /* Structure for saving state for a nested function. - Copyright (C) 1989, 92-97, 1998 Free Software Foundation, Inc. + Copyright (C) 1989, 92-97, 1998, 1999 Free Software Foundation, Inc. This file is part of GNU CC. @@ -545,9 +545,8 @@ extern struct function *outer_function_chain; extern void identify_blocks PROTO((tree, rtx)); /* Insert the BLOCK in the block-tree, knowing that the previous block-note is for OLD_BLOCK. BEGIN_P is non-zero if the previous - block-note was the for the beginning of a BLOCK. FN is the - FUNCTION_DECL into which the BLOCK is being inserted. */ -extern void insert_block_after_note PROTO((tree, tree, int, tree)); + block-note was the for the beginning of a BLOCK. */ +extern void insert_block_after_note PROTO((tree, tree, int)); /* Insert a new BLOCK at an appropriate place in the block tree. */ extern void retrofit_block PROTO((tree, rtx)); |