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

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
Testcase is alongside

int a;
static void __attribute__((noinline)) foo () { a = 1; }
static void __attribute__((noinline)) foo2 () { a = 2; }

struct X
{
  virtual void bar (int i) { if (!i) { foo (); __builtin_abort (); } }
};

void baz (int i)
{
  if (!i)
     { foo2 (); __builtin_abort (); }
}

X xx;

which should make both foo and foo2 .text.unlikely and ipa-comdat should
move foo into bars comdat group.

On x86_64-linux it happens that we can have both .text.unlikely and comdat
membership:

        .section       
.text.unlikely._ZL3foov,"axG",@progbits,_ZN1X3barEi,comdat
        .type   _ZL3foov, @function
_ZL3foov:
.LFB0:
        .cfi_startproc
        movl    $1, a(%rip)
        ret

and it doesn't conflict with:

        .section        .text.unlikely,"ax",@progbits
        .type   _ZL4foo2v, @function
_ZL4foo2v:
.LFB1:
        .cfi_startproc
        movl    $2, a(%rip)
        ret
        .cfi_endproc


With the cross to AIX I get

./../trunk-g/gcc/t.C: In function ‘void foo2()’:
../../trunk-g/gcc/t.C:3:39: error: void foo2() causes a section type conflict
with void foo()
 static void __attribute__((noinline)) foo2 () { a = 2; }
                                       ^~~~
../../trunk-g/gcc/t.C:2:39: note: ‘void foo()’ was declared here
 static void __attribute__((noinline)) foo () { a = 1; }
                                       ^~~

Reply via email to