------- Additional Comments From hubicka at ucw dot cz 2004-12-02 16:05 ------- Subject: Re: [4.0 Regression] gcc.dg/debug/dwarf2/dwarf-die7.c fails
> > ------- Additional Comments From bje at gcc dot gnu dot org 2004-12-02 05:43 > ------- > Trivial test case: > > static int f () { return 3; } > int main() { return f (); } > > Here, cgraph_optimize() decides to inline f() into main() and then eliminates > the node for f() from the call graph. cgraph_expand_function() never emits > assembly for f(), so no DIE is emitted either. The cgraph dump file > summarises > the situation: > > Optimized callgraph: > > main/1: 13 insns (5 after inlining) needed tree inlinable > called by: > calls: f/0 (inlined) > f/0: (inline copy in main/1) 2 insns reachable tree local inlinable > called by: main/1 (inlined) > calls: > > Final callgraph: > > main/1: 13 insns (5 after inlining) needed inlinable asm_written > called by: > calls: > > The dilemma here is that we really don't want to emit the real f(), since it > is > never called in the translation unit and we don't want to waste text doing > so. > All we want is debugging information for f(). I thing the scheme this was supposed to work was to keep the BLOCK node from the inlined version of f() in the DECL_INITIAL of main() so the debug info dumper notice that function f() has been inlined and produce the abstract insteance of it himself. Since the BLOCK nodes are gone and we now attach debug info into statements and we apparently succeeds to remove body of f() entirely even without optimization we no longer do this. I am not sure how to deal with this properly either (I am not debug info expert). The crude version of patch is not correct as the main point is to be able to breakpoint inside f() and get program stopped correctly that apparently won't work as everything about f() in main() is dead. We even might declare this proper behaviour and simply make the function nonempty in the testcase or we might add dummy empty statements and maintain it around till end of compilation but that sounds involved for such a minnor nit in dedbug info. Honza > > The following crude patch makes things work, but it's wrong: > > Index: cgraphunit.c > =================================================================== > RCS file: /home/bje/gcc-cvs/gcc/gcc/cgraphunit.c,v > retrieving revision 1.90 > diff -u -p -r1.90 cgraphunit.c > --- cgraphunit.c 18 Nov 2004 00:18:43 -0000 1.90 > +++ cgraphunit.c 2 Dec 2004 05:41:16 -0000 > @@ -786,6 +786,14 @@ cgraph_mark_functions_to_output (void) > && !TREE_ASM_WRITTEN (decl) > && !DECL_EXTERNAL (decl)) > node->output = 1; > + else if (DECL_SAVED_TREE (decl) > + && node->global.inlined_to > + && !node->needed > + && node->reachable > + && node->local.local > + && !TREE_ASM_WRITTEN (decl) > + && !DECL_EXTERNAL (decl)) > + node->output = 1; > else > { > /* We should've reclaimed all functions that are not needed. */ > @@ -811,9 +819,6 @@ static void > cgraph_expand_function (struct cgraph_node *node) > { > tree decl = node->decl; > - > - /* We ought to not compile any inline clones. */ > - gcc_assert (!node->global.inlined_to); > > if (flag_unit_at_a_time) > announce_function (decl); > > Any ideas on how to proceed? > > -- > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17924 > > ------- You are receiving this mail because: ------- > You are on the CC list for the bug, or are watching someone who is. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17924