[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-15 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #16 from Martin Liška  ---
Author: marxin
Date: Fri Sep 15 12:13:04 2017
New Revision: 252808

URL: https://gcc.gnu.org/viewcvs?rev=252808=gcc=rev
Log:
Backport r249735

2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* ipa-visibility.c (non_local_p): Handle visibility.
2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias
to a function declaration.
2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* gcc.target/i386/pr81128.c: New test.

Added:
branches/gcc-5-branch/gcc/testsuite/gcc.target/i386/pr81128.c
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/c-family/ChangeLog
branches/gcc-5-branch/gcc/c-family/c-common.c
branches/gcc-5-branch/gcc/ipa-visibility.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-15 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

Martin Liška  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #15 from Martin Liška  ---
Fixed.

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-15 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #14 from Martin Liška  ---
Author: marxin
Date: Fri Sep 15 09:13:29 2017
New Revision: 252792

URL: https://gcc.gnu.org/viewcvs?rev=252792=gcc=rev
Log:
Backport r249735

2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* ipa-visibility.c (non_local_p): Handle visibility.
2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias
to a function declaration.
2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* gcc.target/i386/pr81128.c: New test.

Added:
branches/gcc-6-branch/gcc/testsuite/gcc.target/i386/pr81128.c
Modified:
branches/gcc-6-branch/gcc/ChangeLog
branches/gcc-6-branch/gcc/c-family/ChangeLog
branches/gcc-6-branch/gcc/c-family/c-common.c
branches/gcc-6-branch/gcc/ipa-visibility.c
branches/gcc-6-branch/gcc/testsuite/ChangeLog

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-15 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #13 from Martin Liška  ---
Author: marxin
Date: Fri Sep 15 08:12:30 2017
New Revision: 252782

URL: https://gcc.gnu.org/viewcvs?rev=252782=gcc=rev
Log:
Backport r249735

2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* ipa-visibility.c (non_local_p): Handle visibility.
2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias
to a function declaration.
2017-09-15  Martin Liska  

Backport from mainline
2017-06-28  Martin Liska  

PR ipa/81128
* gcc.target/i386/pr81128.c: New test.

Added:
branches/gcc-7-branch/gcc/testsuite/gcc.target/i386/pr81128.c
Modified:
branches/gcc-7-branch/gcc/ChangeLog
branches/gcc-7-branch/gcc/c-family/ChangeLog
branches/gcc-7-branch/gcc/c-family/c-attribs.c
branches/gcc-7-branch/gcc/ipa-visibility.c
branches/gcc-7-branch/gcc/testsuite/ChangeLog

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-01 Thread billy.o.mahony at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #12 from Billy O'Mahony  ---
Thanks, Martin. That's great. Can you update the ticket with the fixed versions
when you get a chance? 

(In reply to Martin Liška from comment #11)
> (In reply to Billy O'Mahony from comment #10)
> > Hi All,
> > 
> > thanks to Martin, Nathan and Richard for working on and fixing this issue.
> > 
> > Can anyone say if the fix will be back ported to future point releases of
> > the 5.x, 6.x, 7.x versions? 
> > 
> > Regards,
> > Billy
> 
> Well, in general I don't tend to backport multiversioning patches as many
> dependent patches were applied in GCC 8 cycle. But this one is quite
> independent. I'm planning to do backports next week.

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-01 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #11 from Martin Liška  ---
(In reply to Billy O'Mahony from comment #10)
> Hi All,
> 
> thanks to Martin, Nathan and Richard for working on and fixing this issue.
> 
> Can anyone say if the fix will be back ported to future point releases of
> the 5.x, 6.x, 7.x versions? 
> 
> Regards,
> Billy

Well, in general I don't tend to backport multiversioning patches as many
dependent patches were applied in GCC 8 cycle. But this one is quite
independent. I'm planning to do backports next week.

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-09-01 Thread billy.o.mahony at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #10 from Billy O'Mahony  ---
Hi All,

thanks to Martin, Nathan and Richard for working on and fixing this issue.

Can anyone say if the fix will be back ported to future point releases of the
5.x, 6.x, 7.x versions? 

Regards,
Billy

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-06-28 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

Martin Liška  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
  Known to work||8.0
  Known to fail|8.0 |

--- Comment #9 from Martin Liška  ---
Fixed on trunk so far.

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-06-28 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #8 from Martin Liška  ---
Author: marxin
Date: Wed Jun 28 12:47:24 2017
New Revision: 249735

URL: https://gcc.gnu.org/viewcvs?rev=249735=gcc=rev
Log:
Do not allow to inline ifunc resolvers (PR ipa/81128).

2017-06-28  Martin Liska  

PR ipa/81128
* ipa-visibility.c (non_local_p): Handle visibility.
2017-06-28  Martin Liska  

PR ipa/81128
* c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias
to a function declaration.
2017-06-28  Martin Liska  

PR ipa/81128
* gcc.target/i386/pr81128.c: New test.

Added:
trunk/gcc/testsuite/gcc.target/i386/pr81128.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-attribs.c
trunk/gcc/ipa-visibility.c
trunk/gcc/testsuite/ChangeLog

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-06-22 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #7 from Martin Liška  ---
Created attachment 41607
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41607=edit
Patch candidate

Idea is to not allow to inline via an ifunc alias and do not allow to
can_replace_by_local_alias ifunc aliases. Thoughts?

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-06-20 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

--- Comment #6 from Nathan Sidwell  ---
the ifunc attribute is essentially slightly different syntactic sugar to the
alias attribute.  It sounds like the optimizer is treating the attribute as-if
it were an alias.

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-06-20 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

Martin Liška  changed:

   What|Removed |Added

 CC||nathan at gcc dot gnu.org

--- Comment #5 from Martin Liška  ---
Well, I'm also not sure how it should behave. What happens currently is that we
have static alias and static resolver. Thus ipa-visibility finds out that call
to do_it_right_at_runtime can be replaced with resolve_do_it_right_at_runtime.
Then inlining happens. I'm adding Nathan who implemented ifunc support in GCC
and should know answer.

I suggest to not evaluate ifunc alias as not interposable. That would prevent
the problem.

[Bug ipa/81128] Function multi-versioning does not work with -O

2017-06-20 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81128

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Keywords||wrong-code
   Last reconfirmed||2017-06-20
  Component|c   |ipa
 CC||marxin at gcc dot gnu.org,
   ||mliska at suse dot cz
 Ever confirmed|0   |1
Summary|Function multi-versioning   |Function multi-versioning
   |does not work with -Ofast   |does not work with -O
  Known to fail||4.8.5, 6.3.1, 7.1.1, 8.0

--- Comment #4 from Richard Biener  ---
Confirmed.  Even -O1 breaks it, I suppose we somehow inline the resolver
improperly which means a bogus cgraph is constructed?

GCC 4.8 gets it right at -O1 but fails at -O2, so I guess this never worked
correctly.

Declaring resolve_do_it_right_at_runtime with __attribute__((noinline,noclone))
doesn't fix this though...

main () ends up calling the resolver directly, no ifunc is emitted.

I'm not 100% sure this is proper use of attribute ifunc, defering to Martin
here.