On 19 January 2014 20:55, Alexander Graf <ag...@suse.de> wrote: > On 19.01.2014, at 21:52, Peter Maydell <peter.mayd...@linaro.org> wrote: >> Longer term I was wondering if we should define the concept >> of a 'scope object' for TCG temporaries, so you create a scope >> object and then we have versions of tcg_temp_new_*() that >> take a scope object to effectively define the lifetime of that >> temp. Destroying the scope object frees every TCG temp in it. >> Then we could just have the target frontends create a scope >> for each instruction, and they wouldn't need to worry about >> manually freeing TCG temporaries within it at all. That seems >> better than the current approach where every frontend rolls >> its own auto-free mechanism, and would render this sort of >> "check for bugs in manual temp freeing" unnecessary too. >> >> (We could also make the tcg_gen_brcond* functions do a >> "free all temps in all scope objects" and then we'd catch >> use-of-temp-after-branch bugs, especially if we also got >> TCG to assert on use of a dead temporary rather than only >> later when it was doing regalloc on it...) > > I agree - that would be awesome :). We could even go as far > as defining a "fallback scope" that's instruction wide
I was thinking the fallback scope would have to be 'whole basic block' (both because that makes more sense as a TCG API and to avoid having to fix every frontend at once), though you're right that this sits a bit awkwardly with the fact that in practice the scope you want 99% of the time is going to be "single guest insn". thanks -- PMM