Opened 3 years ago

Closed 2 years ago

#5054 closed bug (fixed)

LLVM Errors with test cases

Reported by: arsenm Owned by: dterei
Priority: normal Milestone: 7.4.1
Component: Compiler (LLVM) Version: 7.0.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I encountered a build error when using the LLVM backend on my homework. I attempted to get a reduced test case, but ended up running into a different problem. I don't really have the time to reduce these to simpler cases right now, and I figured it would be better to report this rather than doing nothing.

In the original problem, the build fails with:

$ ghc -fllvm -O2 TestCase.hs
[1 of 1] Compiling Main             ( TestCase.hs, TestCase.o )
LLVM ERROR: Cannot yet select: 0x2793a60: f64 = sint_to_fp 0x2795aa0 [ORD=2066] [ID=74]
  0x2795aa0: i64 = add 0x27b9e30, 0x2791990 [ORD=2065] [ID=72]
    0x27b9e30: i64,ch = load 0x2761e08, 0x2796db0, 0x27927a0<LD8[%ln79D]> [ORD=2064] [ID=70]
      0x2761e08: ch = EntryToken [ORD=2061] [ID=0]
      0x2796db0: i64 = add 0x27977b0, 0x27967a0 [ORD=2062] [ID=64]
        0x27977b0: i64,ch = CopyFromReg 0x2761e08, 0x27a76b0 [ORD=2062] [ID=45]
          0x2761e08: ch = EntryToken [ORD=2061] [ID=0]
          0x27a76b0: i64 = Register %reg16387 [ORD=2062] [ID=2]
        0x27967a0: i64 = Constant<7> [ORD=2062] [ID=3]
      0x27927a0: i64 = undef [ORD=2064] [ID=4]
    0x2791990: i64 = Constant<-1> [ORD=2065] [ID=5]

The second error I encountered was:

TestCase2.hs:

ghc -fforce-recomp -fllvm -O2 TestCase2.hs
[1 of 1] Compiling Main             ( TestCase2.hs, TestCase2.o )
LLVM ERROR: Cannot yet select: 0x13834e0: f64 = ConstantFP<0.000000e+00> [ORD=1600] [ID=7]

Replacing the peek/poke with undefined seems to make the errors go away. The programs build and work correctly with the default NCG, and with -O0. The errors happen with -O1 and -O2. Both were using LLVM 2.8 on Linux x86_64.

Attachments (2)

TestCase.hs (4.8 KB) - added by arsenm 3 years ago.
First test case
TestCase2.hs (1.4 KB) - added by arsenm 3 years ago.
Second test case

Download all attachments as: .zip

Change History (10)

Changed 3 years ago by arsenm

First test case

Changed 3 years ago by arsenm

Second test case

comment:1 Changed 3 years ago by dterei

Sorry but I can't reproduce this bug. Can you confirm which OS you are using, which llvm version (and where you got it from) and which ghc version.

comment:2 Changed 3 years ago by simonmar

  • Status changed from new to infoneeded

comment:3 Changed 3 years ago by arsenm

  • Status changed from infoneeded to new

This is with Arch Linux x86_64, ghc 7.0.2 and llvm 2.8, both installed from the Arch repositories (ghc 7.0.2-1, llvm 2.8-5). Also note that it only happens with optimizations, -O2 which I'm not sure I made clear before.

comment:4 Changed 3 years ago by igloo

  • Milestone set to 7.2.1

comment:5 Changed 3 years ago by dterei

  • Owner changed from davidterei@… to dterei

comment:6 Changed 3 years ago by dterei

There is more evidence of this bug, or something like this:

http://lennartkolmodin.blogspot.com/2011/02/binary-by-numbers.html

Will have to replicate setup exactly to find the problem.

comment:7 Changed 3 years ago by igloo

  • Milestone changed from 7.2.1 to 7.4.1

comment:8 Changed 2 years ago by dterei

  • Resolution set to fixed
  • Status changed from new to closed

Closing as I've never been able to reproduce and it was a bug in LLVM itself and in version 2.8 when we are up to 3.0 now. Feel free to reopen if you come across this issue again and can reproduce.

Note: See TracTickets for help on using tickets.