On 15/05/11 22:17, Edward Z. Yang wrote:
Yep. I just committed a fix for this. I'm not terribly happy
about the need to check for this invariant, but at least it's relatively
straightforward to watch out for.
In response to this comment:
-- EZY: This code is very dodgy, because callerSaves only ever
-- returns true in the current universe for registers NOT in
-- system_regs (just do a grep for CALLER_SAVES in
-- includes/stg/MachRegs.h). Thus, this is all one giant no-op.
This is as it should be. The reason there are no CALLER_SAVES_Hp or
similar is because we deliberately avoid using caller-saves registers
for Hp due to the cost. It would work fine (due to the code here), but
it would be expensive.
-- What we are
-- actually interested in is saving are the non-system registers, which
-- we is what the old code generator actually does at this point.
-- Unfortunately, we can't do that here either, because we don't
-- liveness information, and thus there's not an easy way to tell which
-- specific global registers need to be saved (the 'vols' argument in
-- the old code generator.) One possible hack is to save all of them
-- unconditionally, but unless we have very clever dead /memory/
-- elimination (unlikely), this will still leave a dead, unnecessary
-- memory assignment. And really, we shouldn't be doing the workaround
-- at this point in the pipeline, see Note [Register parameter passing].
-- Right now the workaround is to avoid inlining across unsafe foreign
-- calls in rewriteAssignments.
So the right solution here is to annotate non-local jumps with the
global registers that are live (see the ToDo comment on CmmCall in
CmmNode.hs). Then, we can arrange that CmmUnsafeForeignCall has the
intended semantics (it preserves all registers), because the native code
generator will be able to save and restore caller-saves registers itself.
The interrim solution, that we have now, is to arrange that caller-save
global registers are never live across an unsafe foreign call. That's
the change you just made. It would be good to have a comment somewhere
to the effect that this is just a temporary solution.
We really don't want to be inferring the "vols" in the way the old code
generator did it, that was much worse. The new way will be better, once
we have non-local jumps annotated with the liveness of global registers,
because then we will have full liveness information. Also, we'll be
able to re-use the R registers in the body of a function, because the
register allocator will have enough liveness information to do so - this
could be quite a big win.
Cheers,
Simon
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc