[GHC] #7571: LLVM codegen does not handle integer literals in branch conditionals.

GHC cvs-ghc at haskell.org
Sun Jan 13 00:09:55 CET 2013


#7571: LLVM codegen does not handle integer literals in branch conditionals.
--------------------------------+-------------------------------------------
Reporter:  thoughtpolice        |          Owner:  thoughtpolice   
    Type:  bug                  |         Status:  new             
Priority:  normal               |      Component:  Compiler (LLVM) 
 Version:  7.6.1                |       Keywords:  llvm, codegen   
      Os:  Unknown/Multiple     |   Architecture:  Unknown/Multiple
 Failure:  Building GHC failed  |      Blockedby:                  
Blocking:                       |        Related:                  
--------------------------------+-------------------------------------------
 When compiling GHC HEAD on my ODROID-U2 ARM machine, running Ubuntu 12.10,
 with LLVM 3.3svn, I get this error while building part of the RTS:

 {{{

 linaro at linaro-ubuntu-desktop ~/code/ghc
  % "inplace/bin/ghc-stage1" -static -prof  -H32m -O -Iincludes
 -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-
 ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -package-name
 rts -dcmm-lint      -i -irts -irts/dist/build -irts/dist/build/autogen
 -Irts/dist/build -Irts/dist/build/autogen            -optc-O2 -O2    -c
 rts/StgStdThunks.cmm -o rts/dist/build/StgStdThunks.p_o  You are using a
 new version of LLVM that hasn't been tested yet!
 We will try though...
 ghc-stage1: panic! (the 'impossible' happened)
   (GHC version 7.7.20130111 for arm-unknown-linux):
         LlvmCodeGen.CodeGen.genCondBranch: Cond expr not bool! (i32 1)

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

 linaro at linaro-ubuntu-desktop ~/code/ghc
  %

 }}}

 The reason is that StgStdThunks.cmm does something like:

 {{{

 #ifdef FOO
 #define THING(x) 1
 #else
 #define THING(x) do_something((x))
 #endif

 ...

   if (THING(x)) {
     ...
   }

 }}}

 Depending on if FOO is defined, the conditional could have an expression
 or a literal in the branch head.

 This is directly fed into the backend from the compiler.
 LlvmCodeGen.CodeGen.genLit does not properly narrow the type of the
 literal from i32 to i1 when generating the code, causing a compiler panic.
 We would have likely never seen this outside hand-written Cmm, since the
 code generator would otherwise trivially eliminate such branches in the
 optimizers.

 Coincidentally, I would imagine this failure would mean that the compiler
 has not been able to bootstrap with LLVM for quite some time. I haven't
 bisected this, but I'd speculate it was some time around the switch to the
 NCG.

 I believe I have a fix for this that I am testing on my machine.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7571>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list