On Sat, Apr 14, 2018 at 11:53:51AM +0200, Martin Liška wrote:
> > > 2018-04-12 Martin Liska <[email protected]>
> > >
> > > PR ipa/85329
> > > * g++.dg/ext/pr85329.C: New test.
> > > * gcc.target/i386/mvc12.c: New test.
> > > @@ -413,7 +426,11 @@ expand_target_clones (struct cgraph_node *node, bool
> > > definition)
> > > tree attributes = make_attribute ("target", "default",
> > > DECL_ATTRIBUTES (node->decl));
> > > DECL_ATTRIBUTES (node->decl) = attributes;
> > > + DECL_COMDAT (node->decl) = 0;
> > > + DECL_WEAK (node->decl) = 0;
> > > + DECL_ARTIFICIAL (node->decl) = 1;
> > > node->local.local = false;
> > > + node->set_comdat_group (NULL);
> >
> > If you make C++ inline and get the idea to use target cloning attribute on
> > this,
> > this will likely lead to link error if you compile multiple files because
> > you
> > turn comdat to non-comdat.
>
> Can you please explain this in more detail? Ideally showing a test-case that
> would fail?
I'd guess something along the lines of
typedef void (*F) ();
__attribute__((target ("default"))) inline void foo () {}
__attribute__((target ("avx"))) inline void foo () {}
__attribute__((target_clones ("default", "avx"))) inline void bar () {}
#ifdef SRC_A
F pa = foo;
F qa = bar;
#else
F pb = foo;
F qb = bar;
extern F pa, qa;
int
main ()
{
asm volatile ("" : "+g" (pa), "+g" (pb), "+g" (qa), "+g" (qb));
pa ();
pb ();
qa ();
qb ();
}
#endif
and
g++ -O2 -c -DSRC_A test.C -o testa.o
g++ -O2 -o test{,a.o,.C}
This doesn't actually fail, because the bar symbol, even when it doesn't
have STB_WEAK (which it should), is in the comdat group and so only one is
picked up.
Jakub