diff options
author | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-04 01:54:26 +0000 |
---|---|---|
committer | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-04 01:54:26 +0000 |
commit | 9e45f419716a86e6892c802abdc45ea2a2aa65a9 (patch) | |
tree | 416968ea26b7983325a0c2ff0b9e690796ea0157 /gcc/gimple-low.c | |
parent | 61cf5777cb1c34f07eaf9fe1f8fa166f5d6d6437 (diff) | |
download | ppe42-gcc-9e45f419716a86e6892c802abdc45ea2a2aa65a9.tar.gz ppe42-gcc-9e45f419716a86e6892c802abdc45ea2a2aa65a9.zip |
2005-01-03 Daniel Berlin <dberlin@dberlin.org>
Fix PR debug/17924
Fix PR debug/19191
* dwarf2out.c (block_ultimate_origin): Follow decl origin if origin
is a decl.
* gimple-low.c (mark_blocks_with_used_vars): New function.
(mark_blocks_with_used_subblocks): Ditto.
(mark_used_blocks): Ditto.
(pass_mark_used_blocks): New pass.
* tree-inline.c: Include debug.h.
(expand_call_inline): Call outlining_inline_function here.
* tree-optimize.c (init_tree_optimization_passes): Add
pass_mark_used_blocks.
* tree-pass.h (pass_mark_used_blocks): New.
* Makefile.in (tree-inline.o): Add debug.h dependency.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92882 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-low.c')
-rw-r--r-- | gcc/gimple-low.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index c6f6f7611e2..ee57d9beda0 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -540,3 +540,87 @@ struct tree_opt_pass pass_remove_useless_vars = TODO_dump_func, /* todo_flags_finish */ 0 /* letter */ }; + +/* Mark BLOCK used if it has a used variable in it, then recurse over it's + subblocks. */ + +static void +mark_blocks_with_used_vars (tree block) +{ + tree var; + tree subblock; + + if (!TREE_USED (block)) + { + for (var = BLOCK_VARS (block); + var; + var = TREE_CHAIN (var)) + { + if (TREE_USED (var)) + { + TREE_USED (block) = true; + break; + } + } + } + for (subblock = BLOCK_SUBBLOCKS (block); + subblock; + subblock = BLOCK_CHAIN (subblock)) + mark_blocks_with_used_vars (subblock); +} + +/* Mark BLOCK used if any of it's subblocks have the USED bit set, or it's + abstract origin is used. */ + +static bool +mark_blocks_with_used_subblocks (tree block) +{ + tree subblock; + + /* The block may have no variables, but still be used, if it's abstract + origin is used. This occurs when we inline functions with no parameters + that call functions with no parameters or local vars (such as + dwarf2/dwarf-die7.c). You end up with a block that has an abstract + origin, no variables, and nothing in the subblocks is used. However, the + block is really used, because it's abstract origin was used. */ + + if (BLOCK_ABSTRACT_ORIGIN (block)) + { + if (TREE_USED (BLOCK_ABSTRACT_ORIGIN (block))) + TREE_USED (block) = true; + } + + for (subblock = BLOCK_SUBBLOCKS (block); + subblock; + subblock = BLOCK_CHAIN (subblock)) + TREE_USED (block) |= mark_blocks_with_used_subblocks (subblock); + return TREE_USED (block); +} + +/* Mark the used attribute on blocks correctly. */ + +static void +mark_used_blocks (void) +{ + + mark_blocks_with_used_vars (DECL_INITIAL (current_function_decl)); + mark_blocks_with_used_subblocks (DECL_INITIAL (current_function_decl)); +} + + +struct tree_opt_pass pass_mark_used_blocks = +{ + "blocks", /* name */ + NULL, /* gate */ + mark_used_blocks, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + 0, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func, /* todo_flags_finish */ + 0 /* letter */ +}; |