Blame SOURCES/gcc8-rh1668903-2.patch

f56e54
commit 9939b2f79bd9b75b99080a17f3d6f1214d543477
f56e54
Author: qinzhao <qinzhao@138bc75d-0d04-0410-961f-82ee72b054a4>
f56e54
Date:   Wed Apr 3 19:00:25 2019 +0000
f56e54
f56e54
    2019-04-03  qing zhao  <qing.zhao@oracle.com>
f56e54
    
f56e54
            PR tree-optimization/89730
f56e54
            * ipa-inline.c (can_inline_edge_p): Delete the checking for
f56e54
            -flive-patching=inline-only-static.
f56e54
            (can_inline_edge_by_limits_p): Add the checking for
f56e54
            -flive-patching=inline-only-static and grant always_inline
f56e54
            even when -flive-patching=inline-only-static is specified.
f56e54
    
f56e54
            * gcc.dg/live-patching-4.c: New test.
f56e54
    
f56e54
    
f56e54
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270134 138bc75d-0d04-0410-961f-82ee72b054a4
f56e54
f56e54
--- gcc/ipa-inline.c
f56e54
+++ gcc/ipa-inline.c
f56e54
@@ -385,12 +385,6 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
f56e54
       e->inline_failed = CIF_ATTRIBUTE_MISMATCH;
f56e54
       inlinable = false;
f56e54
     }
f56e54
-  else if (callee->externally_visible
f56e54
-	   && flag_live_patching == LIVE_PATCHING_INLINE_ONLY_STATIC)
f56e54
-    {
f56e54
-      e->inline_failed = CIF_EXTERN_LIVE_ONLY_STATIC;
f56e54
-      inlinable = false;
f56e54
-    }
f56e54
   if (!inlinable && report)
f56e54
     report_inline_failed_reason (e);
f56e54
   return inlinable;
f56e54
@@ -433,6 +427,13 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, bool report,
f56e54
      		 DECL_ATTRIBUTES (caller->decl))
f56e54
       && !caller_growth_limits (e))
f56e54
     inlinable = false;
f56e54
+  else if (callee->externally_visible
f56e54
+	   && !DECL_DISREGARD_INLINE_LIMITS (callee->decl)
f56e54
+	   && flag_live_patching == LIVE_PATCHING_INLINE_ONLY_STATIC)
f56e54
+    {
f56e54
+      e->inline_failed = CIF_EXTERN_LIVE_ONLY_STATIC;
f56e54
+      inlinable = false;
f56e54
+    }
f56e54
   /* Don't inline a function with a higher optimization level than the
f56e54
      caller.  FIXME: this is really just tip of iceberg of handling
f56e54
      optimization attribute.  */
f56e54
--- /dev/null
f56e54
+++ gcc/testsuite/gcc.dg/live-patching-4.c
f56e54
@@ -0,0 +1,23 @@
f56e54
+/* { dg-do compile } */
f56e54
+/* { dg-options "-O2 -flive-patching=inline-only-static -fdump-tree-einline-optimized" } */
f56e54
+
f56e54
+extern int sum, n, m;
f56e54
+
f56e54
+extern inline __attribute__((always_inline)) int foo (int a);
f56e54
+inline __attribute__((always_inline)) int foo (int a)
f56e54
+{
f56e54
+  return a + n;
f56e54
+}
f56e54
+
f56e54
+static int bar (int b)
f56e54
+{
f56e54
+  return b * m;
f56e54
+}
f56e54
+
f56e54
+int main()
f56e54
+{
f56e54
+  sum = foo (m) + bar (n); 
f56e54
+  return 0;
f56e54
+}
f56e54
+
f56e54
+/* { dg-final { scan-tree-dump "Inlining foo into main"  "einline" } } */