This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to avoid constant propagation into functions?

On Wed, 7 Dec 2016, Richard Biener wrote:
> >Agreed, that's what I've been using in the past for glibc test cases.
> >
> >If that doesn't work, we'll need something else.  Separate compilation
> >of test cases just to thwart compiler optimizations is a significant
> >burden, and will stop working once we have LTO anyway.
> >
> >What about making the function definitions weak?  Would that be more
> >reliable?
> Adding attribute((used)) should do the trick.  It introduces unknown callers and thus without cloning disables IPA.

Hm, depending on the case I think this may be not enough: it thwarts IPA on the
callee side, but still allows the compiler to optimize the caller: for example,
deduce that callee is pure/const (in which case optimizations in the caller may
cause it to be called fewer times than intended or never at all), apply IPA-RA, or
(perhaps in future) deduce that the callee always returns non-NULL and optimize
the caller accordingly.  I think attribute-weak works to suppress IPA on the
caller side, but that is not a good solution because it also has an effect on
linking semantics, may be not available on non-ELF platforms, etc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]