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

GHC ghc-devs at haskell.org
Mon Sep 1 22:14:42 UTC 2014


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

Comment (by Fanael):

 Replying to [comment:12 awson]:
 > 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?

 Yes, there is. Use `trunc`, for example:

 {{{
 %foo = type <{i32, i32}>
 @aaa = global i32 5
 @bbb = global i32 5
 @foo = constant %foo<{i32 trunc(i64 sub(i64 ptrtoint (i32* @aaa to i64),
 i64 ptrtoint (i32* @bbb to i64)) to i32), i32 0}>

 }}}

 LLVM will generate
 {{{
 foo:
         .long   aaa-bbb
         .long   0                       # 0x0
 }}}

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


More information about the ghc-tickets mailing list