aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorQing Zhao <qing.zhao@oracle.com>2019-04-03 19:00:25 +0000
committerQing Zhao <qinzhao@gcc.gnu.org>2019-04-03 19:00:25 +0000
commitbc53dee0baa3f3e06c89081ef01f506037acd1ff (patch)
tree1359705dd1bd4a15b210b350955d780748b788f8 /gcc
parentc1d9a8f5904a22f2e1e8ec8f52a9dde30c560809 (diff)
downloadgcc-bc53dee0baa3f3e06c89081ef01f506037acd1ff.zip
gcc-bc53dee0baa3f3e06c89081ef01f506037acd1ff.tar.gz
gcc-bc53dee0baa3f3e06c89081ef01f506037acd1ff.tar.bz2
re PR tree-optimization/89730 (-flive-patching=inline-only-static should grant always_inline attribute for extern function)
2019-04-03 qing zhao <qing.zhao@oracle.com> 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/ipa-inline.c13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/live-patching-4.c23
4 files changed, 44 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0d7c206..4099ce6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2019-04-03 qing zhao <qing.zhao@oracle.com>
+
+ 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 <law@redhat.com>
PR rtl-optimization/81025
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 360c3de..f37cd9d 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 eaee0a3..fd16b92 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-04-03 qing zhao <qing.zhao@oracle.com>
+
+ PR tree-optimization/89730
+ * gcc.dg/live-patching-4.c: New test.
+
2019-04-03 Clément Chigot <clement.chigot@atos.net>
* 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 0000000..ffea8f4
--- /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" } } */