[GHC] #8131: T7571 with WAY=llvm fails, but not WAY=optllvm

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Test case (#7571 just will not die, it seems) {{{ $ make TEST=T7571 WAY=llvm ... ====> Scanning ./all.T =====> T7571(llvm) 6 of 7 [0, 0, 0] cd . && '/home/a/ghc/ghc-pristine/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -fllvm -no-hs-main >T7571.comp.stderr 2>&1 Actual stderr output differs from expected: --- /dev/null 2013-08-07 22:18:14.132934017 -0500 +++ ./T7571.comp.stderr 2013-08-14 01:26:33.942103723 -0500 @@ -0,0 +1 @@ +WARNING: Non constant alignment value given for memcpy! Please report to GHC developers *** unexpected failure for T7571(llvm) }}} However, this test case does not fail under WAY=optllvm, which I think is worth investigating probably: {{{ $ make TEST=T7571 WAY=optllvm ... ====> Scanning ./all.T =====> T7571(optllvm) 6 of 7 [0, 0, 0] cd . && '/home/a/ghc/ghc-pristine/inplace/bin/ghc-stage2' -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7571.cmm -O -fllvm -no-hs-main >T7571.comp.stderr 2>&1 OVERALL SUMMARY for test run started at Wed Aug 14 01:25:42 CDT 2013 7 total tests, which gave rise to 28 test cases, of which 27 were skipped 0 had missing libraries 1 expected passes 0 expected failures 0 caused framework failures 0 unexpected passes 0 unexpected failures }}} However, there is another way to trigger this bug in *both* cases: {{{ #include "Cmm.h" testMemcpy (W_ dst, W_ src, W_ l, W_ sz) { prim %memcpy(dst, src, l, sz); return (); } }}} will fail both ways. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by thoughtpolice): * testcase: => llvm/should_compile/T8131 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by rwbarton): Can also trigger this from Haskell. {{{ {-# LANGUAGE MagicHash, UnboxedTuples #-} import GHC.Prim import GHC.IO main = IO $ \s -> let (# s1, p0 #) = newByteArray# 10# s (# s2, p #) = unsafeFreezeByteArray# p0 s1 (# s3, q #) = newByteArray# 10# s2 in (# copyByteArray# p 0# q 0# 10# s, () #) }}} {{{ rwbarton@adjunction:/tmp$ ~/ghc-head/bin/ghc m -fllvm -fforce-recomp [1 of 1] Compiling Main ( m.hs, m.o ) WARNING: Non constant alignment value given for memcpy! Please report to GHC developers Linking m ... }}} The `llvm.memcpy` intrinsic requires that its `align` argument be a literal. With `-fllvm` but not `-O`, somewhere along the way the alignment argument to the `MO_Memcpy` gets stored in a Cmm register and the register gets used for the `llvm.memcpy` call, which isn't good enough. With (`-fllvm` and) `-O`, the store to a register gets eliminated and the `llvm.memcpy` call does use a literal alignment argument. That's why T7571 and the Haskell program above work with `-O` but not without. (It doesn't have anything to do with the `if (1)` in T7571.) Fragile. Your T8131 is expected to not compile, I think, because there the alignment argument really is nonconstant. Given that the alignment for `MO_Memcpy` is only used in the LLVM backend, and there it is required to be constant, I would be inclined to move it from a MachOp argument to a parameter of the MachOp constructor, like {{{ data CallishMachOp = ... | MO_Memcpy Alignment -- or would another type be more appropriate? }}} I have a half-finished patch that implements this. Besides eliminating the requirement of ensuring the alignment argument is a literal, it also removes some special cases in the other backends that have to throw away the alignment argument before generating a `memcpy` function call. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by rwbarton): * owner: => rwbarton Comment: As Austin reminds me, the same story applies to MO_Memmove and MO_Memset. I'll finish this patch and update the tests. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by rwbarton): This patch is basically done. I preserved the four-argument syntax for `prim %memcpy` etc. in `.cmm` files. This was trickier than I expected due to the tying-the-knot technique used to resolve Cmm names during parsing: we can't pattern-match on the alignment `CmmExpr` argument (to check whether it is a `CmmLit`) while producing the `MO_MemCpy` call. My workaround was to fail in a "pure" way, with `pprPgmError`, producing a rather ugly error message. A better solution here is welcome. But, this only affects compilation of `.cmm` files so it's not so bad if the edges are a bit rough IMO. Here is the patch for review, particularly of that parsing bit but also generally. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by rwbarton): I have also updated the tests, but the `T8131` `should_fail` test isn't working for me: `make TEST=T8131 WAY=llvm` is skipping the test, for some reason. It works (and the test fails, of course) if I change `compile_fail` to `compile`. Any idea what is going on? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by thoughtpolice): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: llvm/should_compile/T8131 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by monoidal): This happens because the driver runs `compile` in all ways, and `compile_fail` only for `[normal]`. Source: `test_common_work` in `driver/testlib.py` [https://github.com/ghc/testsuite/blob/7d29fbf373befbc0ee60dff01f6a9cabee0478... link]. Possible fix: {{{ def f( name, opts ): opts.only_ways = ['optllvm', 'llvm', 'debugllvm'] opts.extra_ways = ['optllvm', 'llvm', 'debugllvm'] setTestOpts(f) test('T8131', cmm_src, compile_fail, ['']) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm ----------------------------------------------+---------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: Priority: high | infoneeded Component: Compiler | Milestone: Resolution: | Version: 7.7 Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Test Case: llvm/should_compile/T8131 | Unknown/Multiple Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by thoughtpolice): * status: patch => infoneeded -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: infoneeded Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | llvm/should_compile/T8131 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by bgamari): I've rebased and cleaned up these patches and opened D624 to propose them for merge. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: infoneeded Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | llvm/should_compile/T8131 | Blocking: | Differential Revisions: Phab:D624 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * differential: => Phab:D624 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: patch Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | llvm/should_compile/T8131 | Blocking: | Differential Revisions: Phab:D624 -------------------------------------+------------------------------------- Changes (by bgamari): * status: infoneeded => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm
-------------------------------------+-------------------------------------
Reporter: thoughtpolice | Owner: rwbarton
Type: bug | Status: patch
Priority: high | Milestone: 7.12.1
Component: Compiler | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | llvm/should_compile/T8131
| Blocking:
| Differential Revisions: Phab:D624
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm
-------------------------------------+-------------------------------------
Reporter: thoughtpolice | Owner: rwbarton
Type: bug | Status: patch
Priority: high | Milestone: 7.12.1
Component: Compiler | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | llvm/should_compile/T8131
| Blocking:
| Differential Revisions: Phab:D624
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: rwbarton Type: bug | Status: closed Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | llvm/should_compile/T8131 | Blocking: | Differential Revisions: Phab:D624 -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Windows | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | llvm/should_compile/T8131 | Blocking: | Differential Revisions: Phab:D624 -------------------------------------+------------------------------------- Changes (by thomie): * owner: rwbarton => * resolution: fixed => * status: closed => new * os: Unknown/Multiple => Windows Comment: This test is failing hard on Windows. {{{ +ghc: panic! (the 'impossible' happened) + (GHC version 7.11.20150713 for x86_64-unknown-mingw32): + <<loop>> + +Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug \ No newline at end of file *** unexpected failure for T8131(normal) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: closed Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: Operating System: Windows | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | llvm/should_compile/T8131 | Blocking: | Differential Revisions: Phab:D624 -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: thomie, this looks like a much different failure mode than what this bug described (which was due to our inability to guarantee that alignments that were passed to LLVM were constant). Could you open a new bug describing this new failure? I'm going to close this. Feel free to add a reference to the new bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8131: T7571 with WAY=llvm fails, but not WAY=optllvm -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: closed Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | llvm/should_compile/T8131 Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D624 -------------------------------------+------------------------------------- Comment (by rwbarton): This panic is quite interesting though, since there is in fact some new loopy stuff in the Cmm parser. Too bad it is only on Windows... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8131#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC