On Mon, Feb 13, 2023 at 12:41:48PM +0000, Richard Biener wrote: > > Could we e.g. prevent turning such indirect calls into direct calls? > > We do exactly have gimple_call_fntype and gimple_call_ctrl_altering_p > to not require special-casing indirect to direct call promotion here.
Ah, so if we make returns_twice apply to function types, then we could just compare if gimple_call_fntype has also returns_twice and if not, not consider it actually returns_twice. > > Anyway, notice_special_calls is called in various spots, not just DCE, > > wouldn't it be better to simply not set calls_setjmp flag in there if > > the current function already has cfg and the call isn't ctrl altering? > > I thought about changing gimple_call_flags instead, filtering out > ECF_RETURNS_TWICE. I just didn't make up my mind on what > property to key at (and to require 'cfun' to be set to query it). > But sure, changing notice_special_calls also works - the only > other relevant caller is the inliner I think, and that could be > replaced by caller |= callee of the two flags tracked instead of > re-scanning each inlined stmt. > > Would you be happy with changing notice_special_calls, dropping the > DCE hunk but keeping the cfgexpand/calls.cc hunks? I think so. Jakub