logo       

Re: GHC on IA-64: msg#00136

lang.haskell.glasgow.bugs

Subject: Re: GHC on IA-64

Hi Simon,

On Mon, 2006-03-27 at 10:29 +0100, Simon Marlow wrote:
> Thanks for the analysis Duncan. Would you mind submitting a ticket for
> this?
>
> What does the crash look like in gdb? Does it look like it has jumped
> into the middle of nowhere, or is it a crash in some actual code that
> you can disassemble? To find out what was happening just before the
> crash, the recipe is usually:

Matthew Chapman explained why it happened. Let me quote:


> > > The reason this regex is so specific is that it acts as a sanity check.
> > > The way GHC works on IA64 is that every STG function runs in the same
> > > register stack window (this allows tailcalls to work). This register
> > > stack window has 32 locals allocated, so a function must not use any
> > > more than this.
> >
> > So that explains why it didn't work when I merely relaxed the regexp in
> > the mangler.
>
> Yep, the "Illegal instruction" you get is exactly because it's
> accessing past the end of the allocated register window, and that
> particular fault is mapped by Linux to "Illegal instruction".


So it's not a surprise. The solution is not to relax the mangler as I
tried but to make sure gcc never uses more than 32 locals but spills to
the stack instead in the case that register pressure is very high.

With gcc 3.3 the problem only happened on an example of extreme
unrolling in darcs. With gcc 4.1 on ia64 the problem happened when
rebuilding ghc itself. For one function in one ghc module, gcc was
allocating 33 locals, which is one more than allowed. This problem is
only going to get worse as gcc gets smarter on ia64. (Other than that,
gcc 4.1 seems to work on wit ghc on ia64. Darcs compiled fine when using
gcc 4.1. Interestingly when darcs was compiled with ghc+gcc4.1 rather
than ghc+gcc3.3, the darcs binary stopped causing unaligned access
warnings from the kernel.)

Matthew suggested using -mfixed-range=loc32-loc79 or
-mfixed-range=loc16-loc79 or even -mfixed-range=in0-in7,loc16-loc79.

This does appear to work in reducing the number of locals that gcc
allocates, but then the mangler chokes on the bit of code immediately
after (that appears to be spilling registers to the stack instead).

We haven't figured that latter bit out yet.

If you're interested, Simon, I have a registerised build of ghc-6.4.1
for ia64 with GHCi available. It's currently sitting on the Gentoo
mirrors as distfiles/ghc-bin-6.4.1-ia64.tbz2. Of course it installs
into /usr and would need some "sed -i" work to relocate. In fact if you
want these things (linked or hosted) for your download page, we've got
x86, amd64, alpha, hppa, sparc, ppc, ppc64 and ia64. We're having
trouble with mips.

If you ever feel like getting it to work on mips linux I can probably
get you access to a 16 way SMP mips @ 250Mhz with 8GB ram :-).

Duncan


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise