This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix Dwarf-2 ICE (was Re: force insert nested functions into parent function's DIE)
On Fri, Jan 04, 2002 at 06:01:42PM +0100, Jakub Jelinek wrote:
> I think we cannot call outlining_inline_function too early when RTL is not
> generated, dwarf2out.c definitely shouldn't be attaching DECL_RTL's to
> things like function parameters etc.
Indeed, that would seem to be the case.
> * gcc.dg/20020104-2.c: New test.
Go ahead and commit the test case.
I'm currently testing the following, which is like yours, except
that I move the outlining_inline_function into rest_of_compilation
instead of having every front end manage this on its own.
r~
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.286
diff -c -p -d -r1.286 c-decl.c
*** c-decl.c 2002/01/02 18:28:41 1.286
--- c-decl.c 2002/01/04 19:11:32
*************** c_expand_body (fndecl, nested_p, can_def
*** 6947,6957 ****
timevar_push (TV_EXPAND);
- if (DECL_INLINE (fndecl))
- /* Do any preparation such as emitting abstract debug info for the
- inline before it gets mangled by optimization. */
- (*debug_hooks->outlining_inline_function) (fndecl);
-
if (nested_p)
{
/* Make sure that we will evaluate variable-sized types involved
--- 6947,6952 ----
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.345
diff -c -p -d -r1.345 dwarf2out.c
*** dwarf2out.c 2002/01/04 02:00:26 1.345
--- dwarf2out.c 2002/01/04 19:11:32
*************** loc_descriptor_from_tree (loc, addressp)
*** 7968,7974 ****
case PARM_DECL:
{
rtx rtl = rtl_for_decl_location (loc);
- enum machine_mode mode = GET_MODE (rtl);
if (rtl == NULL_RTX)
return 0;
--- 7968,7973 ----
*************** loc_descriptor_from_tree (loc, addressp)
*** 7981,7986 ****
--- 7980,7987 ----
}
else
{
+ enum machine_mode mode = GET_MODE (rtl);
+
if (GET_CODE (rtl) == MEM)
{
indirect_p = 1;
*************** rtl_for_decl_location (decl)
*** 8751,8757 ****
/* Use DECL_RTL as the "location" unless we find something better. */
rtl = DECL_RTL_IF_SET (decl);
! if (TREE_CODE (decl) == PARM_DECL)
{
if (rtl == NULL_RTX || is_pseudo_reg (rtl))
{
--- 8752,8769 ----
/* Use DECL_RTL as the "location" unless we find something better. */
rtl = DECL_RTL_IF_SET (decl);
! /* When generating abstract instances, ignore everything except
! constants and symbols living in memory. */
! if (! reload_completed)
! {
! if (rtl
! && (CONSTANT_P (rtl)
! || (GET_CODE (rtl) == MEM
! && CONSTANT_P (XEXP (rtl, 0)))))
! return rtl;
! rtl = NULL_RTX;
! }
! else if (TREE_CODE (decl) == PARM_DECL)
{
if (rtl == NULL_RTX || is_pseudo_reg (rtl))
{
*************** rtl_for_decl_location (decl)
*** 8816,8822 ****
/* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant,
and will have been substituted directly into all expressions that use it.
C does not have such a concept, but C++ and other languages do. */
! else if (DECL_INITIAL (decl))
rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
EXPAND_INITIALIZER);
--- 8828,8834 ----
/* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant,
and will have been substituted directly into all expressions that use it.
C does not have such a concept, but C++ and other languages do. */
! else if (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
EXPAND_INITIALIZER);
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/integrate.c,v
retrieving revision 1.180
diff -c -p -d -r1.180 integrate.c
*** integrate.c 2001/12/30 18:01:05 1.180
--- integrate.c 2002/01/04 19:11:32
*************** output_inline_function (fndecl)
*** 2950,2959 ****
debug_hooks = &do_nothing_debug_hooks;
}
- /* Do any preparation, such as emitting abstract debug info for the inline
- before it gets mangled by optimization. */
- (*debug_hooks->outlining_inline_function) (fndecl);
-
/* Compile this function all the way down to assembly code. As a
side effect this destroys the saved RTL representation, but
that's okay, because we don't need to inline this anymore. */
--- 2950,2955 ----
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.565
diff -c -p -d -r1.565 toplev.c
*** toplev.c 2002/01/04 05:41:24 1.565
--- toplev.c 2002/01/04 19:11:33
*************** rest_of_compilation (decl)
*** 2363,2373 ****
if (!cfun->x_whole_function_mode_p)
identify_blocks ();
- /* Then remove any notes we don't need. That will make iterating
- over the instruction sequence faster, and allow the garbage
- collector to reclaim the memory used by the notes. */
- remove_unnecessary_notes ();
-
/* In function-at-a-time mode, we do not attempt to keep the BLOCK
tree in sensible shape. So, we just recalculate it here. */
if (cfun->x_whole_function_mode_p)
--- 2363,2368 ----
*************** rest_of_compilation (decl)
*** 2504,2509 ****
--- 2499,2516 ----
if (DECL_EXTERNAL (decl))
goto exit_rest_of_compilation;
}
+
+ /* We are now committed to emitting code for this function. Do any
+ preparation, such as emitting abstract debug info for the inline
+ before it gets mangled by optimization. */
+ if (DECL_INLINE (decl))
+ (*debug_hooks->outlining_inline_function) (decl);
+
+ /* Remove any notes we don't need. That will make iterating
+ over the instruction sequence faster, and allow the garbage
+ collector to reclaim the memory used by the notes. */
+ remove_unnecessary_notes ();
+ reorder_blocks ();
ggc_collect ();
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.242
diff -c -p -d -r1.242 semantics.c
*** semantics.c 2002/01/02 18:28:43 1.242
--- semantics.c 2002/01/04 19:11:33
*************** expand_body (fn)
*** 2503,2513 ****
recorded when we finished processing the function. */
lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
- if (DECL_INLINE (fn))
- /* Do any preparation such as emitting abstract debug info for the
- inline before it gets mangled by optimization. */
- (*debug_hooks->outlining_inline_function) (fn);
-
/* Generate code for the function. */
genrtl_finish_function (fn);
--- 2503,2508 ----