https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89730

            Bug ID: 89730
           Summary: -flive-patching=inline-only-static should grant
                    always_inline attribute for extern function
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qinzhao at gcc dot gnu.org
  Target Milestone: ---

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.

Reply via email to