summaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2009-02-23 13:10:53 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2009-02-23 13:10:53 +0000
commit362676499c08b5b814947261088c1a614984efb1 (patch)
treed5fc8eef4ee0352c6b6283866a64b8d5d9ec3bde /gcc/tree.c
parent47863d1acad7e104874b244272cb69ba0ac7b839 (diff)
downloadgcc-362676499c08b5b814947261088c1a614984efb1.tar.gz
PR tree-optimization/37709
* tree.c (block_ultimate_origin): Move here from dwarf2out. * tree.h (block_ultimate_origin): Declare. * dwarf2out.c (block_ultimate_origin): Move to tree.c * tree-ssa-live.c (remove_unused_scope_block_p): Eliminate blocks containig no instructions nor live variables nor nested blocks. (dump_scope_block): New function. (remove_unused_locals): Enable removal of dead blocks by default; enable dumping at TDF_DETAILS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144381 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 03c54cc1cb1..423c8681cf2 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -9199,4 +9199,49 @@ build_target_option_node (void)
return t;
}
+/* Determine the "ultimate origin" of a block. The block may be an inlined
+ instance of an inlined instance of a block which is local to an inline
+ function, so we have to trace all of the way back through the origin chain
+ to find out what sort of node actually served as the original seed for the
+ given block. */
+
+tree
+block_ultimate_origin (const_tree block)
+{
+ tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
+
+ /* output_inline_function sets BLOCK_ABSTRACT_ORIGIN for all the
+ nodes in the function to point to themselves; ignore that if
+ we're trying to output the abstract instance of this function. */
+ if (BLOCK_ABSTRACT (block) && immediate_origin == block)
+ return NULL_TREE;
+
+ if (immediate_origin == NULL_TREE)
+ return NULL_TREE;
+ else
+ {
+ tree ret_val;
+ tree lookahead = immediate_origin;
+
+ do
+ {
+ ret_val = lookahead;
+ lookahead = (TREE_CODE (ret_val) == BLOCK
+ ? BLOCK_ABSTRACT_ORIGIN (ret_val) : NULL);
+ }
+ while (lookahead != NULL && lookahead != ret_val);
+
+ /* The block's abstract origin chain may not be the *ultimate* origin of
+ the block. It could lead to a DECL that has an abstract origin set.
+ If so, we want that DECL's abstract origin (which is what DECL_ORIGIN
+ will give us if it has one). Note that DECL's abstract origins are
+ supposed to be the most distant ancestor (or so decl_ultimate_origin
+ claims), so we don't need to loop following the DECL origins. */
+ if (DECL_P (ret_val))
+ return DECL_ORIGIN (ret_val);
+
+ return ret_val;
+ }
+}
+
#include "gt-tree.h"