re PR tree-optimization/89730 (-flive-patching=inline-only-static should grant always...
authorQing Zhao <qing.zhao@oracle.com>
Wed, 3 Apr 2019 19:00:25 +0000 (19:00 +0000)
committerQing Zhao <qinzhao@gcc.gnu.org>
Wed, 3 Apr 2019 19:00:25 +0000 (19:00 +0000)
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

gcc/ChangeLog
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/live-patching-4.c [new file with mode: 0644]

index 0d7c206..4099ce6 100644 (file)
@@ -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
index 360c3de..f37cd9d 100644 (file)
@@ -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.  */
index eaee0a3..fd16b92 100644 (file)
@@ -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 (file)
index 0000000..ffea8f4
--- /dev/null
@@ -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" } } */