History

opt: Don't emit inline functions from dead code

Inside dead code don't regard inline functions as being referenced.

Michael Matz committed 10 years ago

Commit ad8e14b1 parent ce55d032 files · +9 −1Browse files

Unified · Split

2 files
  1. tccgen.c +1 −1
  2. tests/tcctest.c +8 −0
tccgen.c+1−1
@@ -4594,7 +4594,7 @@ ST_FUNC void unary(void) · 4593 unmodified lines
4594 effect to generate code for it at the end of the4594 effect to generate code for it at the end of the
4595 compilation unit. Inline function as always4595 compilation unit. Inline function as always
4596 generated in the text section. */4596 generated in the text section. */
4597 if (!s->c)4597 if (!s->c && !nocode_wanted)
4598 put_extern_sym(s, text_section, 0, 0);4598 put_extern_sym(s, text_section, 0, 0);
4599 r = VT_SYM | VT_CONST;4599 r = VT_SYM | VT_CONST;
4600 } else {4600 } else {
tests/tcctest.c+8−0
@@ -1170,6 +1170,11 @@ void bool_test() · 1169 unmodified lines
1170extern int undefined_function(void);1170extern int undefined_function(void);
1171extern int defined_function(void);1171extern int defined_function(void);
1172 1172
1173static inline void refer_to_undefined(void)
1174{
1175 undefined_function();
1176}
1177
1173void optimize_out(void)1178void optimize_out(void)
1174{1179{
1175 int i = 0 ? undefined_function() : defined_function();1180 int i = 0 ? undefined_function() : defined_function();
@@ -1264,6 +1269,9 @@ void optimize_out(void) · 88 unmodified lines
1264 else1269 else
1265 undefined_function();1270 undefined_function();
1266 1271
1272 if (defined_function() && 0)
1273 refer_to_undefined();
1274
1267 if (1)1275 if (1)
1268 return;1276 return;
1269 printf ("oor:%d\n", undefined_function());1277 printf ("oor:%d\n", undefined_function());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t