This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [mark@markmitchell.com: Re: More Dwarf2 issues]
- To: wilson at cygnus dot com
- Subject: Re: [mark@markmitchell.com: Re: More Dwarf2 issues]
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Sat, 5 Sep 1998 19:26:32 -0700
- CC: law at cygnus dot com, egcs-patches at cygnus dot com
- References: <199808311842.LAA08123@rtl.cygnus.com>
- Reply-to: mark at markmitchell dot com
>>>>> "Jim" == Jim Wilson <wilson@cygnus.com> writes:
>> * integrate.c (integrate_decl_tree): Make the
>> DECL_ABSTRACT_ORIGIN the most distant ancestor, not the
>> immediate parent.
Jim> I approve of the patch.
Jim> However, I think it is incomplete, because there are other
Jim> places that set DECL_ABSTRACT_ORIGIN. I think we should
Jim> change all of them at the same time rather than just one of
Jim> them.
I have attached what I believe to be a complete patch. I tested this
patch by bootstrapping with -gdwarf-2 on x86, and running the C++
test-suite with -gdwarf-2 for all tests. I inspected the Fortran/C++
front-ends and made sure that these changes should be safe. The Chill
front-end does use DECL_ABSTRACT_ORIGIN, but I couldn't quite make
sense of how, so I ignored it.
Jim, may I check this in?
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
Fri Sep 4 16:47:36 1998 Mark Mitchell <mark@markmitchell.com>
* tree.h (DECL_ORIGIN): New macro.
* integrate.c (copy_and_set_decl_abstract_origin): New function.
(copy_decl_list): Use it.
(integrate_parm_decls): Likewise.
(integrate_decl_tree): Likewise.
* dwarf2out.c (decl_ultimate_origin): Simplify.
* dwarfout.c (decl_ultimate_origin): Likewise.
* c-decl.c (duplicate_decls): Use DECL_ORIGIN.
(pushdecl): Likewise.
Index: tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tree.h,v
retrieving revision 1.51
diff -c -p -r1.51 tree.h
*** tree.h 1998/08/21 19:32:16 1.51
--- tree.h 1998/09/04 23:19:10
*************** struct tree_type
*** 1101,1106 ****
--- 1101,1111 ----
definition. */
#define DECL_ABSTRACT_ORIGIN(NODE) (DECL_CHECK (NODE)->decl.abstract_origin)
+ /* Like DECL_ABSTRACT_ORIGIN, but returns NODE if there's no abstract
+ origin. This is useful when setting the DECL_ABSTRACT_ORIGIN. */
+ #define DECL_ORIGIN(NODE) \
+ (DECL_ABSTRACT_ORIGIN (NODE) ? DECL_ABSTRACT_ORIGIN (NODE) : NODE)
+
/* Nonzero for any sort of ..._DECL node means this decl node represents
an inline instance of some original (abstract) decl from an inline function;
suppress any warnings about shadowing some other variable. */
Index: integrate.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/integrate.c,v
retrieving revision 1.34
diff -c -p -r1.34 integrate.c
*** integrate.c 1998/06/25 15:14:38 1.34
--- integrate.c 1998/09/04 23:19:01
*************** static void set_decl_origin_self PROTO((
*** 78,83 ****
--- 78,84 ----
static void set_block_abstract_flags PROTO((tree, int));
void set_decl_abstract_flags PROTO((tree, int));
+ static tree copy_and_set_decl_abstract_origin PROTO((tree));
/* Returns the Ith entry in the label_map contained in MAP. If the
Ith entry has not yet been set, return a fresh label. This function
*************** save_for_inline_copying (fndecl)
*** 752,762 ****
free (label_map);
}
/* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
For example, this can copy a list made of TREE_LIST nodes. While copying,
! for each node copied which doesn't already have is DECL_ABSTRACT_ORIGIN
! set to some non-zero value, set the DECL_ABSTRACT_ORIGIN of the copy to
! point to the corresponding (abstract) original node. */
static tree
copy_decl_list (list)
--- 753,782 ----
free (label_map);
}
+ /* Copy NODE (as with copy_node). NODE must be a DECL. Set the
+ DECL_ABSTRACT_ORIGIN for the new accordinly. */
+
+ static tree
+ copy_and_set_decl_abstract_origin (node)
+ tree node;
+ {
+ tree copy = copy_node (node);
+ if (DECL_ABSTRACT_ORIGIN (copy) != NULL_TREE)
+ /* That means that NODE already had a DECL_ABSTRACT_ORIGIN. (This
+ situation occurs if we inline a function which itself made
+ calls to inline functions.) Since DECL_ABSTRACT_ORIGIN is the
+ most distant ancestor, we don't have to do anything here. */
+ ;
+ else
+ /* The most distant ancestor must be NODE. */
+ DECL_ABSTRACT_ORIGIN (copy) = node;
+
+ return copy;
+ }
+
/* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
For example, this can copy a list made of TREE_LIST nodes. While copying,
! set DECL_ABSTRACT_ORIGIN appropriately. */
static tree
copy_decl_list (list)
*************** copy_decl_list (list)
*** 768,784 ****
if (list == 0)
return 0;
! head = prev = copy_node (list);
! if (DECL_ABSTRACT_ORIGIN (head) == NULL_TREE)
! DECL_ABSTRACT_ORIGIN (head) = list;
next = TREE_CHAIN (list);
while (next)
{
register tree copy;
! copy = copy_node (next);
! if (DECL_ABSTRACT_ORIGIN (copy) == NULL_TREE)
! DECL_ABSTRACT_ORIGIN (copy) = next;
TREE_CHAIN (prev) = copy;
prev = copy;
next = TREE_CHAIN (next);
--- 788,800 ----
if (list == 0)
return 0;
! head = prev = copy_and_set_decl_abstract_origin (head);
next = TREE_CHAIN (list);
while (next)
{
register tree copy;
! copy = copy_and_set_decl_abstract_origin (next);
TREE_CHAIN (prev) = copy;
prev = copy;
next = TREE_CHAIN (next);
*************** integrate_parm_decls (args, map, arg_vec
*** 2192,2198 ****
/* These args would always appear unused, if not for this. */
TREE_USED (decl) = 1;
/* Prevent warning for shadowing with these. */
! DECL_ABSTRACT_ORIGIN (decl) = tail;
pushdecl (decl);
/* Fully instantiate the address with the equivalent form so that the
debugging information contains the actual register, instead of the
--- 2208,2214 ----
/* These args would always appear unused, if not for this. */
TREE_USED (decl) = 1;
/* Prevent warning for shadowing with these. */
! DECL_ABSTRACT_ORIGIN (decl) = DECL_ORIGIN (tail);
pushdecl (decl);
/* Fully instantiate the address with the equivalent form so that the
debugging information contains the actual register, instead of the
*************** integrate_decl_tree (let, level, map)
*** 2231,2237 ****
push_obstacks_nochange ();
saveable_allocation ();
! d = copy_node (t);
pop_obstacks ();
if (DECL_RTL (t) != 0)
--- 2247,2253 ----
push_obstacks_nochange ();
saveable_allocation ();
! d = copy_and_set_decl_abstract_origin (t);
pop_obstacks ();
if (DECL_RTL (t) != 0)
*************** integrate_decl_tree (let, level, map)
*** 2246,2253 ****
}
/* These args would always appear unused, if not for this. */
TREE_USED (d) = 1;
- /* Prevent warning for shadowing with these. */
- DECL_ABSTRACT_ORIGIN (d) = t;
if (DECL_LANG_SPECIFIC (d))
copy_lang_decl (d);
--- 2262,2267 ----
Index: dwarf2out.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/dwarf2out.c,v
retrieving revision 1.66
diff -c -p -r1.66 dwarf2out.c
*** dwarf2out.c 1998/08/11 13:23:44 1.66
--- dwarf2out.c 1998/09/04 23:18:33
*************** static tree
*** 3527,3550 ****
decl_ultimate_origin (decl)
register tree decl;
{
! register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
!
! if (immediate_origin == NULL_TREE)
! return NULL_TREE;
! else
! {
! register tree ret_val;
! register tree lookahead = immediate_origin;
!
! do
! {
! ret_val = lookahead;
! lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
! }
! while (lookahead != NULL && lookahead != ret_val);
! return ret_val;
! }
}
/* Determine the "ultimate origin" of a block. The block may be an inlined
--- 3527,3540 ----
decl_ultimate_origin (decl)
register tree decl;
{
! #ifdef ENABLE_CHECKING
! if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
! /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
! most distant ancestor, this should never happen. */
! abort ();
! #endif
! return DECL_ABSTRACT_ORIGIN (decl);
}
/* Determine the "ultimate origin" of a block. The block may be an inlined
*************** dwarf2out_decl (decl)
*** 9420,9426 ****
if (DECL_IGNORED_P (decl))
{
if (TREE_CODE (decl) == FUNCTION_DECL
! && DECL_INITIAL (decl) != NULL)
abort ();
return;
--- 9410,9416 ----
if (DECL_IGNORED_P (decl))
{
if (TREE_CODE (decl) == FUNCTION_DECL
! && DECL_INITIAL (decl) != NULL)
abort ();
return;
Index: dwarfout.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/dwarfout.c,v
retrieving revision 1.26
diff -c -p -r1.26 dwarfout.c
*** dwarfout.c 1998/09/02 13:54:33 1.26
--- dwarfout.c 1998/09/04 23:18:49
*************** static tree
*** 1150,1172 ****
decl_ultimate_origin (decl)
register tree decl;
{
! register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
! if (immediate_origin == NULL)
! return NULL;
! else
! {
! register tree ret_val;
! register tree lookahead = immediate_origin;
!
! do
! {
! ret_val = lookahead;
! lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
! }
! while (lookahead != NULL && lookahead != ret_val);
! return ret_val;
! }
}
/* Determine the "ultimate origin" of a block. The block may be an
--- 1150,1163 ----
decl_ultimate_origin (decl)
register tree decl;
{
! #ifdef ENABLE_CHECKING
! if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
! /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
! most distant ancestor, this should never happen. */
! abort ();
! #endif
! return DECL_ABSTRACT_ORIGIN (decl);
}
/* Determine the "ultimate origin" of a block. The block may be an
Index: c-decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-decl.c,v
retrieving revision 1.43
diff -c -p -r1.43 c-decl.c
*** c-decl.c 1998/08/24 02:08:34 1.43
--- c-decl.c 1998/09/04 23:18:07
*************** duplicate_decls (newdecl, olddecl, diffe
*** 2020,2026 ****
DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
if (DECL_INLINE (newdecl))
! DECL_ABSTRACT_ORIGIN (newdecl) = olddecl;
}
}
if (different_binding_level)
--- 2020,2026 ----
DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
if (DECL_INLINE (newdecl))
! DECL_ABSTRACT_ORIGIN (newdecl) = DECL_ORIGIN (olddecl);
}
}
if (different_binding_level)
*************** pushdecl (x)
*** 2384,2390 ****
DECL_ARGUMENTS (x) = DECL_ARGUMENTS (oldglobal);
DECL_RESULT (x) = DECL_RESULT (oldglobal);
TREE_ASM_WRITTEN (x) = TREE_ASM_WRITTEN (oldglobal);
! DECL_ABSTRACT_ORIGIN (x) = oldglobal;
}
/* Inner extern decl is built-in if global one is. */
if (DECL_BUILT_IN (oldglobal))
--- 2384,2390 ----
DECL_ARGUMENTS (x) = DECL_ARGUMENTS (oldglobal);
DECL_RESULT (x) = DECL_RESULT (oldglobal);
TREE_ASM_WRITTEN (x) = TREE_ASM_WRITTEN (oldglobal);
! DECL_ABSTRACT_ORIGIN (x) = DECL_ORIGIN (oldglobal);
}
/* Inner extern decl is built-in if global one is. */
if (DECL_BUILT_IN (oldglobal))