Hi, On Wed, 14 Nov 2018, Alexander Monakov wrote:
> On Wed, 14 Nov 2018, Segher Boessenkool wrote: > > Yeah, using local register vars to access global registers only works > > by accident. It does work currently though, and people apparently use > > it, so we shouldn't break it :-/ > > In the proposed approach (copying from/to pseudos just before/after the > asm) we can emulate historic behavior by making uninitialized pseudos > take values of the corresponding hardregs. If we decide that doing that > just for must-uninit pseudos is enough, it's a simple extension to the > existing init-regs pass. Does this sound reasonable? Or we can just decide that nothing needs fixing. In particular about this from Jakub and Segher: > > What doesn't work as the reporter expect is assumption that local hard > > register variables that live across function calls must have their > > values preserved; they can be modified by the callees. > > It would be really nice if we could fix that :-) I disagree that there's something to fix. My mental model for local reg vars has always been that such vars are actually an alias for that register, not comparable to normal automatic variables (so, much like global reg vars, except that they don't reserve away the register from regalloc). I.e. like volatile they can arbitrarily change their value. I don't know if other peoples mind model is similar, but it certainly is the model that is implemented in the GIMPLE pipeline (and if memory serves well of the RTL pipeline as well). Copying outof/into pseudos around asms serves no purpose with that model, it rather makes regvars somewhat "safer" to use, without actually making them safer (there _is_ nothing safe about them). Ciao, Michael.