Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > On Fri, Apr 16, 2021 at 12:02 PM Richard Sandiford via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> >> This patch fixes a regression introduced by the rtl-ssa patches. >> It was seen on HPPA but it might be latent elsewhere. >> >> The problem is that the traditional way of expanding an untyped_call >> is to emit sequences like: >> >> (call (mem (symbol_ref "foo"))) >> (set (reg pseudo1) (reg result1)) >> ... >> (set (reg pseudon) (reg resultn)) >> >> The ABI specifies that result1..resultn are clobbered by the call but >> nothing in the RTL indicates that result1..resultn are the results >> of the call. Normally, using a clobbered value gives undefined results, >> but in this case the results are well-defined and matter for correctness. >> >> This seems like a niche case, so I think it would be better to mark >> it explicitly rather than try to detect it heuristically. >> >> Note that in expand_builtin_apply we already have an rtx_insn *, >> so it doesn't matter whether we call emit_call_insn or emit_insn. >> Calling emit_insn seems more natural now that the gen_* call >> has been split out. It also matches later code in the function. >> >> Tested on aarch64-linux-gnu, arm-linux-gnueabihf, armeb-eabi and >> x86_64-linux-gnu. OK to install? > > OK. Does DF handle this correctly?
Kind-of. DF creates explicit clobbers for all call-clobbered registers and later uses use the results of these clobbers. I guess consumers handle that leniently in practice and don't treat the result as undefined. But yeah, it would probably be better to add a proper set in DF too. > I wonder why we cannot simply do sth like > > (call_insn (set (parallel [ (reg:...) (reg:...) ] ) (mem (symbol_ref...))) > > or so? But I guess we'd have to alter all targets for this... Yeah, that would be better. Targets don't need to define untyped_call if they just have one return value register, and in that case the builtins.c code will use a normal call_value that describes the operation properly. But the other targets would need special code to handle this. Thanks, Richard