This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C identifier lookup speedups, 2/2


Hi Zack,

Here is a testcase, simplified from compile/920625-1.c

/* h8300-hms-gcc -O0 -g compile/920625-1.c */

inline
foo ()
{
  {
    bar ();
  }
}

bar ()
{
}

Here is what seems to be happening:

Somehow the inner scope of foo() is associated with a FUNCTION_DECL of
bar() even though the actual body of bar() is outside foo().

While writing out assembly code for foo() during the final phase,
scope_to_insns_finalize() puts NOTE_INSN_BLOCK_BEG right before the
call to bar().  This causes sdbout_block() to output

	.def	_bar
	.val	_bar
	.scl	2
	.type	044
	.endef

which I think basically means the assembly code for the function bar()
follows immediately despite the fact that we are still in the middle
of writing out foo().  This ".def" later causes gas to say

  "Fatal error: C_EFCN symbol out of scope".

So the point is why the inner scope of foo() is associated with a
FUNCTION_DECL of bar(). (If I am not mistaken, a FUNCTION_DECL is
associated with a function body, not a function call.)

By the way, if you remove "inline", try to be explicit with a
prototype, or put bar() before foo(), then the error goes away.

Is there any way you could look into this?

Thanks,

Kazu Hirata


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]