Ticket #5131 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

linux-powerpc : panic in stage1 compiler

Reported by: erikd Owned by: dterei
Priority: normal Milestone:
Component: Compiler Version: 7.1
Keywords: Cc:
Operating System: Linux Architecture: powerpc
Type of failure: Compile-time crash Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I was chasing a segfault that was occuring in the stage2 compiler (bug #5111) and Simon Marlowe suggested I try and find something that fails in the stage1 compiler instead as that would be easier to debug.

I ran the test suite with the stage1 compiler on both x86_64 and powerpc and found that the test testsuite/tests/ghc-regress/rts/2783.hs failed for powerpc but not on x86_64.

The testsuite/tests/ghc-regress/rts/2783.run.stderr file contains the following:

[1 of 1] Compiling Main             ( 2783.hs, 2783.o )
ghc-stage1: panic! (the 'impossible' happened)
  (GHC version 7.1.20110412 for powerpc-unknown-linux):
	LlvmCodeGen.Reg: GlobalReg (VanillaReg 7 VGcPtr) not supported!

I'm willing to invest some time on this, but will probably need some guidance.

Change History

Changed 2 years ago by erikd

Currently trying the following patch.

--- a/compiler/llvmGen/LlvmCodeGen/Regs.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Regs.hs
@@ -38,6 +38,7 @@ lmGlobalReg suf reg
         VanillaReg 4 _ -> wordGlobal $ "R4" ++ suf
         VanillaReg 5 _ -> wordGlobal $ "R5" ++ suf
         VanillaReg 6 _ -> wordGlobal $ "R6" ++ suf
+        VanillaReg 7 _ -> wordGlobal $ "R7" ++ suf
         SpLim          -> wordGlobal $ "SpLim" ++ suf
         FloatReg 1     -> floatGlobal $"F1" ++ suf
         FloatReg 2     -> floatGlobal $"F2" ++ suf

Changed 2 years ago by erikd

And with that patch I get:

[1 of 1] Compiling Main             ( 2783.hs, 2783.o )
ghc-stage1: panic! (the 'impossible' happened)
  (GHC version 7.1.20110412 for powerpc-unknown-linux):
	LlvmCodeGen.Reg: GlobalReg ( -> VanillaReg 8 VGcPtr) not supported!

Obviously no simple solution there.

Changed 2 years ago by simonpj

  • owner set to dterei

David, might you be able look at this? Thanks! Simon

Changed 2 years ago by dterei

Sure. What is the background? I read the Erik is working on restoring PPC support but I assume that is being done using the NCG? This is a bug in the LLVM code generator. Erik are you working on the NCG for PPC or trying to get LLVM to support PPC? If the former this bug probably isn't relevant to you.

If working on LLVM I would get an unregisterised build working first which shouldn't trigger this bug since no registers will be in use. A registered build will require modification to LLVM itself.

Changed 2 years ago by erikd

Yes, I'd like to get LLVM working for powerpc. Unfortunately un-registered builds seem broken at the moment (see bug #5134), but I do have a working 7.0.3 ghc.

I'm willing to do the required modification to LLVM and push it upstream.

Changed 2 years ago by dterei

Hmm OK. I'm heading to bed now but will look into this bug and 5134 tomorrow. Getting unregistered working is defiantly the first step so I wouldn't worry about patching LLVM for now.

Changed 2 years ago by simonmar

While this is something worth fixing, it is almost certainly *not* related to #5111, which was your original problem, because we don't build the stage 2 compiler with LLVM.

Changed 2 years ago by dterei

  • status changed from new to closed
  • resolution set to fixed

OK I've 'fixed' this bug. However don't expect LLVM to work with a registered build of PowerPC. If you want, create a new top level trac bug to track LLVM for PowerPC. Once Ian has 5134 fixed though start working on unregistered. Once that is done start working on registered without TABLES_NEXT_TO_CODE enabled. Once that is working, get TNTC working.

Note: See TracTickets for help on using tickets.