On Mon, 8 Dec 2014, Joseph Myers wrote: > On Mon, 8 Dec 2014, Richard Biener wrote: > > > The alternative is to decide "used" in the middle-end at one point, > > for example at the end of all_lowering_passes where hopefully > > we have constant folded and removed dead code enough. We can also > > compute an overall "uses libm" flag to fix the testcase I reported > > (of course we'd like to re-compute that at LTO time). > > If you do that, of course any optimizations before deciding "used" need to > be conservative - assume that any function except the one you're > optimizing a call of is not "used".
Yes. I guess I'm willing to consider a new langhook that for C evaluates C_DECL_USED. We still have to find a suitable point to query it - with the earliest point is after parsing finished (thus when we finalize the TU). At that point all constant expression folding should have happened (up to the point required by the language) - but I suppose C_DECL_USED is still set even if all calls were constant folded away. Note that computing a middle-end "C_DECL_USED" can be done from gimplification (possibly after folding the calls there once). Same for a global "libm function used" flag (where at some point we might need a target hook to allow specifying whether a call is from libm). Richard.