From: Qing Zhao Date: Wed, 3 Apr 2019 19:00:25 +0000 (+0000) Subject: re PR tree-optimization/89730 (-flive-patching=inline-only-static should grant always... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bc53dee0baa3f3e06c89081ef01f506037acd1ff;p=gcc.git re PR tree-optimization/89730 (-flive-patching=inline-only-static should grant always_inline attribute for extern function) 2019-04-03 qing zhao PR tree-optimization/89730 * ipa-inline.c (can_inline_edge_p): Delete the checking for -flive-patching=inline-only-static. (can_inline_edge_by_limits_p): Add the checking for -flive-patching=inline-only-static and grant always_inline even when -flive-patching=inline-only-static is specified. * gcc.dg/live-patching-4.c: New test. From-SVN: r270134 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d7c206de90..4099ce66307 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-04-03 qing zhao + + PR tree-optimization/89730 + * ipa-inline.c (can_inline_edge_p): Delete the checking for + -flive-patching=inline-only-static. + (can_inline_edge_by_limits_p): Add the checking for + -flive-patching=inline-only-static and grant always_inline + even when -flive-patching=inline-only-static is specified. + 2019-04-03 Jeff Law PR rtl-optimization/81025 diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 360c3de3289..f37cd9da26d 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -385,12 +385,6 @@ can_inline_edge_p (struct cgraph_edge *e, bool report, e->inline_failed = CIF_ATTRIBUTE_MISMATCH; inlinable = false; } - else if (callee->externally_visible - && flag_live_patching == LIVE_PATCHING_INLINE_ONLY_STATIC) - { - e->inline_failed = CIF_EXTERN_LIVE_ONLY_STATIC; - inlinable = false; - } if (!inlinable && report) report_inline_failed_reason (e); return inlinable; @@ -433,6 +427,13 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, bool report, DECL_ATTRIBUTES (caller->decl)) && !caller_growth_limits (e)) inlinable = false; + else if (callee->externally_visible + && !DECL_DISREGARD_INLINE_LIMITS (callee->decl) + && flag_live_patching == LIVE_PATCHING_INLINE_ONLY_STATIC) + { + e->inline_failed = CIF_EXTERN_LIVE_ONLY_STATIC; + inlinable = false; + } /* Don't inline a function with a higher optimization level than the caller. FIXME: this is really just tip of iceberg of handling optimization attribute. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eaee0a304a3..fd16b9204eb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-03 qing zhao + + PR tree-optimization/89730 + * gcc.dg/live-patching-4.c: New test. + 2019-04-03 Clément Chigot * lib/go-torture.exp: Only add lto to TORTURE_OPTIONS if it is diff --git a/gcc/testsuite/gcc.dg/live-patching-4.c b/gcc/testsuite/gcc.dg/live-patching-4.c new file mode 100644 index 00000000000..ffea8f4cc1c --- /dev/null +++ b/gcc/testsuite/gcc.dg/live-patching-4.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -flive-patching=inline-only-static -fdump-tree-einline-optimized" } */ + +extern int sum, n, m; + +extern inline __attribute__((always_inline)) int foo (int a); +inline __attribute__((always_inline)) int foo (int a) +{ + return a + n; +} + +static int bar (int b) +{ + return b * m; +} + +int main() +{ + sum = foo (m) + bar (n); + return 0; +} + +/* { dg-final { scan-tree-dump "Inlining foo/0 into main/2" "einline" } } */