This is the mail archive of the 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]

eliminating debug info for symbols/types in unexpanded inlines

At Cisco, it was noticed that when you use an extern variable inside an
inline function that is optimized away, you still get debug info for
that variable and its type.

Consider this testcase
extern struct foo { int i; } bar;
static inline int sub (int j) { bar.i = j; return bar.i; }
int main (void) { int really_long_name = 0; return really_long_name; }

Using gcc-4.4 to compile it, I get
khazaddum$ gcc -O -S -g tmp.c
khazaddum$ grep sub tmp.s
khazaddum$ grep bar tmp.s
	.string	"bar"
khazaddum$ grep foo tmp.s
	.string	"foo"

And we see that even though the function sub was optimized away, we have
debug info for bar and foo.

The problem here is that we emit debug info if TREE_USED is set, but
TREE_USED is set at parse time, before we have identified unused inline
functions.  I have a simple patch to fix this that adds a
TREE_USED_EXPAND bit that is set at RTL generation time.

In an environment with a lot of header files, that define a lot of
inline functions, that use a lot of structure types, you can get
significant reductions in the size of the dwarf2 debug output with this
patch.  At Cisco, we see very large binaries with debug info reducing in
size by about 1/3.

Of course, if we had duplicate header file elimination for debug info,
like we already had for stabs, then this is probably not needed, and may
be harmful.  Meanwhile, I think this is useful, and consider it a useful
extension of the existing support for optimizing away unused types.  I
noticed that Cary Coutant was working on a new scheme for this, but it
isn't usable yet.

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