#1512: NCG to handle cyclic fixups for rematching register assignment for jump
blocks
-------------------------------+--------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version:
Severity: normal | Keywords:
Difficulty: Moderate (1 day) | Os: Unknown
Testcase: | Architecture: Unknown
-------------------------------+--------------------------------------------
joinToTargets in
[http://darcs.haskell.org/ghc/compiler/nativeGen/RegisterAlloc.hs
RegisterAlloc.hs]
generates a jump to a particular target. On the first jump to a target,
the virtual register assignment is associated with this target. All
following jumps to the target must ensure that the current virtual
register assignment matches that one of the target. If that's not the
case, fixup code is generated before the branch instruction.
In rare cases, that occur when compiling the RTS on i386 in -fPIC -dynamic
mode we have to generate cyclic fixup code. Here is one issue that comes
from compiling PrimOps.cmm:
Assignment of target:
* virtual register A in real register A
* virtual register B in real register B.
Current assignment:
* virtual register A in real register B
* virtual register B in real register A.
Basically, we have to move A to B, and B to A. There is no move sequence
that allows this without using a scratch register.
[http://darcs.haskell.org/ghc/compiler/nativeGen/RegisterAlloc.hs
RegisterAlloc.hs] detects this by using stronglyConnCompR in joinToTargets
(Line 869). At the moment, it does not provide a solution for this, it
just fails.
My trivial approach would be:
{{{
handleComponent (CyclicSCC ((vreg,src,dsts):rest))
= let sccs = stronglyConnCompR rest
in [makeMove vreg src (InMem empty_spill)] ++
concatMap handleComponent sccs ++
map (makeMove vreg (InMem empty_spill)) dsts
}}}
I'm only having trouble to find empty_spill, namely an empty spill slot on
the stack.
I have no clear idea what the (simulated) stack pointer is pointing at and
whether it is save to assume that below (above?) is scratch space I can
abuse for such a task.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1512>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs