opt: Don't emit inline functions from dead code

Inside dead code don't regard inline functions as being
referenced.
This commit is contained in:
Michael Matz 2016-09-26 22:31:19 +02:00
parent ce55d03eef
commit ad8e14b740
2 changed files with 9 additions and 1 deletions

View file

@ -4594,7 +4594,7 @@ ST_FUNC void unary(void)
effect to generate code for it at the end of the effect to generate code for it at the end of the
compilation unit. Inline function as always compilation unit. Inline function as always
generated in the text section. */ generated in the text section. */
if (!s->c) if (!s->c && !nocode_wanted)
put_extern_sym(s, text_section, 0, 0); put_extern_sym(s, text_section, 0, 0);
r = VT_SYM | VT_CONST; r = VT_SYM | VT_CONST;
} else { } else {

View file

@ -1170,6 +1170,11 @@ void bool_test()
extern int undefined_function(void); extern int undefined_function(void);
extern int defined_function(void); extern int defined_function(void);
static inline void refer_to_undefined(void)
{
undefined_function();
}
void optimize_out(void) void optimize_out(void)
{ {
int i = 0 ? undefined_function() : defined_function(); int i = 0 ? undefined_function() : defined_function();
@ -1264,6 +1269,9 @@ void optimize_out(void)
else else
undefined_function(); undefined_function();
if (defined_function() && 0)
refer_to_undefined();
if (1) if (1)
return; return;
printf ("oor:%d\n", undefined_function()); printf ("oor:%d\n", undefined_function());