Opened 8 years ago

Closed 8 years ago

#5433 closed bug (fixed)

Compiler generates invalid assembly with "bad register name"

Reported by: bos Owned by: simonpj
Priority: high Milestone: 7.4.1
Component: Compiler Version: 7.2.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: x86
Type of failure: Compile-time crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

While working on the statistics package last night, my automated build found a regression in GHC 7.2.1's code generator:

[17 of 23] Compiling Statistics.Distribution.Poisson ( Statistics/Distribution/Poisson.hs, dist/build/Statistics/Distribution/Poisson.o )
/tmp/ghc22105_0/ghc22105_0.s: Assembler messages:

/tmp/ghc22105_0/ghc22105_0.s:5520:0:
     Error: bad register name `%st(-16)'

As you can see from the build output, this code compiles fine with 6.12 and 7.0. These are all 32-bit versions of GHC on a 32-bit Fedora 15 system. This code compiles without a problem on my 64-bit Mac running a 64-bit 7.2.1 release.

I bisected my changes in the statistics tree, and found that it's at this exact change that 7.2.1 transitions from generating good code to bad.

Change History (9)

comment:1 Changed 8 years ago by bos

It's conceivable to me that this could be a dup of ticket #3132.

comment:2 Changed 8 years ago by simonmar

Milestone: 7.4.1
Priority: normalhighest

comment:3 Changed 8 years ago by simonmar

Owner: set to simonmar

I'll look.

comment:4 Changed 8 years ago by marlowsd@…

commit 3572c11958bf77e0797a190efab68cf80895f2ac

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Thu Oct 6 11:57:52 2011 +0100

    Use a custom dead-code analyser instead of calling the occurrence analyser.
    
    In CorePrep we used to call the occurrence analyser to drop dead code
    (see Note [Dead code in CorePrep]), but the occurrence analyser
    sometimes introduces new let bindings for case binders.  This was
    leading to the bug in #5433: the let binding introduced was for an
    unlifted value, and the code generator is not expecting to see let
    bindings of unlifted values (CorePrep is supposed to eliminate them).
    We don't want this let binding anyway, so instead of using the
    occurrence analyser here we have a simple custom dead-code analyser.

 compiler/coreSyn/CorePrep.lhs |   90 +++++++++++++++++++++++++++++++++-------
 1 files changed, 74 insertions(+), 16 deletions(-)

comment:5 Changed 8 years ago by simonmar

Owner: changed from simonmar to simonpj

The bug is fixed, but we currently don't know how to make a test case. simonpj is looking into it.

comment:6 Changed 8 years ago by simonpj

Owner: changed from simonpj to simonmar

Simon M is going to look for a test case; the issue is that we had a case expression whose case-binder was dead, but whose scrutinee was used in the RHS. That doesn't usually happen, because of the binder-swap stuff, and we were curious why not.

comment:7 Changed 8 years ago by simonmar

Owner: changed from simonmar to simonpj

Simon: in ~simonmar/scratch/statistics is a checkout of the statistics package at the point that exhibits the failure (9cd9058379bf91ffd3ccd54163f963cd4d1e8f34). There are some dependencies, so you want to do cabal install --with-ghc=ghc-7.2.1 to install the dependencies and build the package. It fails with 7.2.1.

comment:8 Changed 8 years ago by simonpj

difficulty: Unknown
Priority: highesthigh

comment:9 Changed 8 years ago by simonpj

Resolution: fixed
Status: newclosed

Closing; life is too short.

Note: See TracTickets for help on using tickets.