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
45944594 effect to generate code for it at the end of the
45954595 compilation unit. Inline function as always
45964596 generated in the text section. */
4597− if (!s->c)
4597+ if (!s->c && !nocode_wanted)
45984598 put_extern_sym(s, text_section, 0, 0);
45994599 r = VT_SYM | VT_CONST;
46004600 } else {
tests/tcctest.c+8−0
@@ -1170,6 +1170,11 @@ void bool_test() · 1169 unmodified lines
11701170 extern int undefined_function(void);
11711171 extern int defined_function(void);
11721172
1173+static inline void refer_to_undefined(void)
1174+{
1175+ undefined_function();
1176+}
1177+
11731178 void optimize_out(void)
11741179 {
11751180 int i = 0 ? undefined_function() : defined_function();
@@ -1264,6 +1269,9 @@ void optimize_out(void) · 88 unmodified lines
12641269 else
12651270 undefined_function();
12661271
1272+ if (defined_function() && 0)
1273+ refer_to_undefined();
1274+
12671275 if (1)
12681276 return;
12691277 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