[GHC] #8974: 64 bit windows executable built with ghc-7.9.20140405+LLVM segfaults

GHC ghc-devs at haskell.org
Tue Apr 22 07:51:24 UTC 2014


#8974: 64 bit windows executable built with ghc-7.9.20140405+LLVM segfaults
------------------------------------+----------------------------------
        Reporter:  awson            |            Owner:
            Type:  bug              |           Status:  new
        Priority:  high             |        Milestone:  7.8.3
       Component:  Compiler (LLVM)  |          Version:  7.9
      Resolution:                   |         Keywords:
Operating System:  Windows          |     Architecture:  x86_64 (amd64)
 Type of failure:  Runtime crash    |       Difficulty:  Unknown
       Test Case:                   |       Blocked By:
        Blocking:                   |  Related Tickets:
------------------------------------+----------------------------------

Comment (by awson):

 I've decided that intervening at
 [http://git.haskell.org/ghc.git/blob/HEAD:/compiler/llvmGen/LlvmCodeGen/Data.hs#l116
 `genStaticLit (CmmLabelDiffOff l1 l2 off)`] is safe and have rewritten the
 code to generate 32-bit arithmetic and pointer conversion, but it turned
 out LLVM generates unsuitable code for `ptrtoint ... to i32` applied to
 64-bit pointer.

 For example, if
 {{{
 @T8947_t1_info_itable = constant %T8947_t1_entry_struct<{i64 add (i64 sub
 (i64 ptrtoint (i8* @S1fL_srt$alias to i64),i64 ptrtoint (void (i64*, i64*,
 i64*, i64, i64, i64, i64, i64, i64, i64)* @T8947_t1_info to i64)),i64 0),
 i64 4294967299, i64 0, i64 64424509455}>, section "X98A__STRIP,__me3",
 align 8
 }}}
 gets rewritten to
 {{{
 @T8947_t1_info_itable = constant %T8947_t1_entry_struct<{i32 add (i32 sub
 (i32 ptrtoint (i8* @S1i6_srt$alias to i32),i32 ptrtoint (void (i64*, i64*,
 i64*, i64, i64, i64, i64, i64, i64, i64)* @T8947_t1_info to i32)),i32 0),
 i32 0, i64 4294967299, i64 0, i64 64424509455}>, section
 "X98A__STRIP,__me3", align 8
 }}}

 LLVM instead of
 {{{
 T8947_t1_info_itable:
         .quad   S1i6_srt-T8947_t1_info
 }}}
 generates (assembler spits {{{Error: invalid operands (.rdata and *ABS*
 sections) for `&'}}})
 {{{
 T8947_t1_info_itable:
         .long   (S1i6_srt&-1)-(T8947_t1_info&-1)
         .long   0                       # 0x0
 }}}
 while we want it to be
 {{{
 T8947_t1_info_itable:
         .long   S1i6_srt-T8947_t1_info
         .long   0                       # 0x0
 }}}

 I'm in no way an LLVM expert and know very little about it. Is there a way
 to make LLVM generate the code we want or are we use the mangler here? Any
 thoughts?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8974#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list