aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-09-26 22:31:19 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:12 +0100
commitad8e14b740f87d814a00f9f0d44301f71ffd7ec6 (patch)
treece081aa8c2e0aada497ddefb52963089dcd336b7
parentce55d03eef8cefff5ed731c0e1176425d59c600f (diff)
downloadtinycc-ad8e14b740f87d814a00f9f0d44301f71ffd7ec6.tar.gz
tinycc-ad8e14b740f87d814a00f9f0d44301f71ffd7ec6.tar.bz2
opt: Don't emit inline functions from dead code
Inside dead code don't regard inline functions as being referenced.
-rw-r--r--tccgen.c2
-rw-r--r--tests/tcctest.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/tccgen.c b/tccgen.c
index 056ee4e..f9d4a7c 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4594,7 +4594,7 @@ ST_FUNC void unary(void)
effect to generate code for it at the end of the
compilation unit. Inline function as always
generated in the text section. */
- if (!s->c)
+ if (!s->c && !nocode_wanted)
put_extern_sym(s, text_section, 0, 0);
r = VT_SYM | VT_CONST;
} else {
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 0485a74..7bdffff 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -1170,6 +1170,11 @@ void bool_test()
extern int undefined_function(void);
extern int defined_function(void);
+static inline void refer_to_undefined(void)
+{
+ undefined_function();
+}
+
void optimize_out(void)
{
int i = 0 ? undefined_function() : defined_function();
@@ -1264,6 +1269,9 @@ void optimize_out(void)
else
undefined_function();
+ if (defined_function() && 0)
+ refer_to_undefined();
+
if (1)
return;
printf ("oor:%d\n", undefined_function());