Bug 89730 - -flive-patching=inline-only-static should grant always_inline attribute for extern function
Summary: -flive-patching=inline-only-static should grant always_inline attribute for e...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: qinzhao
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 18:23 UTC by qinzhao
Modified: 2021-05-04 12:31 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-03-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description qinzhao 2019-03-15 18:23:48 UTC
for the following small testing case:

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;
}

with the latest upstream gcc9:

/home/qinzhao/Install/latest/bin/gcc -O3 -flive-patching=inline-only-static -fdump-tree-einline -fdump-ipa-inline -fopt-info-inline-all=inline.txt t.c
t.c: In function ‘main’:
t.c:7:43: error: inlining failed in call to always_inline ‘foo’: function has external linkage when the user requests only inlining static for live patching
    7 | inline __attribute__((always_inline)) int foo (int a)
      |                                           ^~~
t.c:20:9: note: called from here
   20 |   sum = foo (m) + bar (n);
      |         ^~~~~~~
t.c:7:43: error: inlining failed in call to always_inline ‘foo’: function has external linkage when the user requests only inlining static for live patching
    7 | inline __attribute__((always_inline)) int foo (int a)
      |                                           ^~~
t.c:20:9: note: called from here
   20 |   sum = foo (m) + bar (n);
      |         ^~~~~~~

We should grant extern alway_inline routine to be inlined even with -flive-patching=inline-only-static.
Comment 1 Richard Biener 2019-03-18 09:26:27 UTC
always_inline should simply be always inlined.
Comment 2 qinzhao 2019-04-03 19:00:57 UTC
Author: qinzhao
Date: Wed Apr  3 19:00:25 2019
New Revision: 270134

URL: https://gcc.gnu.org/viewcvs?rev=270134&root=gcc&view=rev
Log:
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.

Added:
    trunk/gcc/testsuite/gcc.dg/live-patching-4.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-inline.c
    trunk/gcc/testsuite/ChangeLog