Another string optimisation problem in gcc-2.95.2

Graham Stoney greyham@research.canon.com.au
Tue Apr 25 20:08:00 GMT 2000


Hi gang,

Continuing my quest for the elimination of unused strings, I've noticed that
when the out-of-line copy of an inlined function is optimised away, the strings
that it references are not. As a result, unused static inline functions (such
as those you might encounter in a .h file) still generate gumpf in .rodata.

Here's a simple example:

    static inline int call(char *str)
    {
	printf("this is a string");
    }

    int main()
    {
	return 0;
    }

Notice that the string remains:

	.file	"inline2.c"
	.version	"01.01"
gcc2_compiled.:
.section	.rodata
.LC0:
	.string	"this is a string"
.text
	.align 4
.globl main
	.type	 main,@function
main:
	pushl %ebp
	movl %esp,%ebp
	xorl %eax,%eax
	movl %ebp,%esp
	popl %ebp
	ret
.Lfe1:
	.size	 main,.Lfe1-main
	.ident	"GCC: (GNU) 2.95.2 19991024 (release)"

This may be related to my last mail about strings not obeying -fdata-sections,
but I think the case for fixing this one is even more compelling.

Regards,
Graham
-- 
Graham Stoney
Principal Hardware/Software Engineer
Canon Information Systems Research Australia
Ph: +61 2 9805 2909  Fax: +61 2 9805 2929


More information about the Gcc-bugs mailing list