[GHC] #9308: nofib fannkuch-redux runs perpetually with -fllvm
#9308: nofib fannkuch-redux runs perpetually with -fllvm ------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Running the nofib benchmarks with make -k EXTRA_HC_OPTS=-fllvm on a HEAD build of ghc configured with perf-llvm (3.4.2) results in fannkuch-redux running in an infinite loop. The benchmark runs in about 3.5s without the -fllvm {{{ HC = /Users/xx/Projects/ghc/inplace/bin/ghc-stage2 HC_OPTS = -O2 -Rghc-timing -H32m -hisuf hi -fllvm -rtsopts -XBangPatterns -O2 RUNTEST_OPTS = -ghc-timing ==nofib== fannkuch-redux: time to compile Main follows... /Users/jrp/Projects/ghc/inplace/bin/ghc-stage2 -O2 -Rghc-timing -H32m -hisuf hi -fllvm -rtsopts -XBangPatterns -O2 -c Main.hs -o Main.o <<ghc: 358716248 bytes, 313 GCs, 10827462/27497216 avg/max bytes residency (6 samples), 57M in use, 0.00 INIT (0.00 elapsed), 0.20 MUT (0.53 elapsed), 0.21 GC (0.23 elapsed) :ghc>> ==nofib== fannkuch-redux: size of Main.o follows... __TEXT __DATA __OBJC others dec hex 10333 497 0 0 10830 2a4e ==nofib== fannkuch-redux: time to link fannkuch-redux follows... <<ghc: 19914544 bytes, 16 GCs, 1005021/2239600 avg/max bytes residency (3 samples), 25M in use, 0.00 INIT (0.00 elapsed), 0.01 MUT (0.53 elapsed), 0.02 GC (0.02 elapsed) :ghc>> ==nofib== fannkuch-redux: size of fannkuch-redux follows... __TEXT __DATA __OBJC others dec hex 4075520 446464 0 4295945496 4300467480 10053ed18 ==nofib== fannkuch-redux: time to run fannkuch-redux follows... ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm --------------------------------------------+------------------------------ Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: NoFib benchmark suite | Version: 7.8.3 Resolution: | Keywords: fannkuch- Operating System: MacOS X | redux Type of failure: Runtime performance bug | Architecture: x86_64 Test Case: fannkuch-redux | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Changes (by jrp): * component: Compiler => NoFib benchmark suite * testcase: => fannkuch-redux * failure: None/Unknown => Runtime performance bug * version: 7.8.2 => 7.8.3 * architecture: Unknown/Multiple => x86_64 (amd64) * keywords: => fannkuch-redux * os: Unknown/Multiple => MacOS X -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (LLVM) | Keywords: fannkuch-redux Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Incorrect | Related Tickets: #5567 result at runtime | Test Case: fannkuch- | redux | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * failure: Runtime performance bug => Incorrect result at runtime * component: NoFib benchmark suite => Compiler (LLVM) * os: MacOS X => Unknown/Multiple * related: => #5567 Comment: I can reproduce this with LLVM 3.3 on Linux x86_64. This one is a TBAA issue. The infinite loop goes away with `-fno-llvm-tbaa` or with this patch applied (from #9125): {{{ diff --git a/compiler/llvmGen/LlvmCodeGen/Regs.hs b/compiler/llvmGen/LlvmCodeGen/Regs.hs index 0048659..d837d13 100644 --- a/compiler/llvmGen/LlvmCodeGen/Regs.hs +++ b/compiler/llvmGen/LlvmCodeGen/Regs.hs @@ -101,11 +101,6 @@ stgTBAA , (heapN, fsLit "heap", Just topN) , (rxN, fsLit "rx", Just heapN) , (baseN, fsLit "base", Just topN) - -- FIX: Not 100% sure about 'others' place. Might need to be under 'heap'. - -- OR I think the big thing is Sp is never aliased, so might want - -- to change the hieracy to have Sp on its own branch that is never - -- aliased (e.g never use top as a TBAA node). - , (otherN, fsLit "other", Just topN) ] -- | Id values @@ -115,7 +110,7 @@ stackN = getUnique (fsLit "LlvmCodeGen.Regs.stackN") heapN = getUnique (fsLit "LlvmCodeGen.Regs.heapN") rxN = getUnique (fsLit "LlvmCodeGen.Regs.rxN") baseN = getUnique (fsLit "LlvmCodeGen.Regs.baseN") -otherN = getUnique (fsLit "LlvmCodeGen.Regs.otherN") +otherN = topN -- | The TBAA metadata identifier tbaa :: LMString }}} The issue is Cmm code that looks like this: {{{ /* let go !acc = do k <- peekElemOff xs 0 if k == 0 then f acc else flop (fromIntegral k) xs >> go (acc+1) */ c7b3: _s6xW::I64 = I64[Sp + 8]; _s6yp::I64 = %MO_UU_Conv_W8_W64(I8[_s6xW::I64]); // read from xs via _s6xW: TBAA "other" if (_s6yp::I64 != 0) goto c7ca; else goto c7cb; c7ca: I64[Sp - 8] = block_c7bd_info; R3 = _s6xW::I64 + _s6yp::I64; R2 = _s6xW::I64; Sp = Sp - 8; call $wa1_r6tm_info(R3, R2) args: 8, res: 8, upd: 8; ... /* flop k xs = flopp xs (xs `advancePtr` k) where flopp i j = when (i < j) $ swap i j >> flopp (incPtr i) (decPtr j) swap i j = do a <- peek i b <- peek j poke j a poke i b */ $wa1_r6tm_entry() // [R3, R2] ... {offset c6Wl: if (R2 < R3) goto c6Ws; else goto c6Wt; c6Ws: _s6uQ::I64 = %MO_UU_Conv_W8_W64(I8[R3]); I8[R3] = I8[R2]; // read from xs via R2: TBAA "rx" I8[R2] = %MO_UU_Conv_W64_W8(_s6uQ::I64); R3 = R3 - 1; R2 = R2 + 1; call $wa1_r6tm_info(R3, R2) args: 8, res: 0, upd: 8; }}} "rx" and "other" are incomparable in our TBAA tree. Apparently LLVM treats this as undefined behavior and, in this case, emits an infinite loop. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (LLVM) | Keywords: fannkuch-redux Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: 9504 Type of failure: Incorrect | Related Tickets: #5567 result at runtime | Test Case: fannkuch- | redux | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * blockedby: => 9504 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.8.3 Resolution: | Keywords: fannkuch- Operating System: Unknown/Multiple | redux Type of failure: Incorrect result | Architecture: x86_64 at runtime | (amd64) Blocked By: 9504 | Test Case: fannkuch- Related Tickets: #5567 | redux | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by erikd): * cc: erikd (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.8.3 Resolution: | Keywords: fannkuch- | redux Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Incorrect result | Test Case: fannkuch- at runtime | redux Blocked By: 9504 | Blocking: Related Tickets: #5567 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by bgamari): * cc: bgamari (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.8.3 Resolution: | Keywords: fannkuch- | redux Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Incorrect result | Test Case: fannkuch- at runtime | redux Blocked By: 9504 | Blocking: Related Tickets: #5567 | Differential Revisions: -------------------------------------+------------------------------------- Description changed by bgamari: Old description:
Running the nofib benchmarks with make -k EXTRA_HC_OPTS=-fllvm on a HEAD build of ghc configured with perf-llvm (3.4.2) results in fannkuch-redux running in an infinite loop. The benchmark runs in about 3.5s without the -fllvm
{{{ HC = /Users/xx/Projects/ghc/inplace/bin/ghc-stage2 HC_OPTS = -O2 -Rghc-timing -H32m -hisuf hi -fllvm -rtsopts -XBangPatterns -O2 RUNTEST_OPTS = -ghc-timing ==nofib== fannkuch-redux: time to compile Main follows... /Users/jrp/Projects/ghc/inplace/bin/ghc-stage2 -O2 -Rghc-timing -H32m -hisuf hi -fllvm -rtsopts -XBangPatterns -O2 -c Main.hs -o Main.o <<ghc: 358716248 bytes, 313 GCs, 10827462/27497216 avg/max bytes residency (6 samples), 57M in use, 0.00 INIT (0.00 elapsed), 0.20 MUT (0.53 elapsed), 0.21 GC (0.23 elapsed) :ghc>> ==nofib== fannkuch-redux: size of Main.o follows... __TEXT __DATA __OBJC others dec hex 10333 497 0 0 10830 2a4e ==nofib== fannkuch-redux: time to link fannkuch-redux follows... <<ghc: 19914544 bytes, 16 GCs, 1005021/2239600 avg/max bytes residency (3 samples), 25M in use, 0.00 INIT (0.00 elapsed), 0.01 MUT (0.53 elapsed), 0.02 GC (0.02 elapsed) :ghc>> ==nofib== fannkuch-redux: size of fannkuch-redux follows... __TEXT __DATA __OBJC others dec hex 4075520 446464 0 4295945496 4300467480 10053ed18 ==nofib== fannkuch-redux: time to run fannkuch-redux follows... ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; }}}
New description: Running the nofib benchmarks with `make -k EXTRA_HC_OPTS=-fllvm` on a HEAD build of ghc configured with perf-llvm (3.4.2) results in fannkuch-redux running in an infinite loop. The benchmark runs in about 3.5s without the -fllvm {{{ HC = /Users/xx/Projects/ghc/inplace/bin/ghc-stage2 HC_OPTS = -O2 -Rghc-timing -H32m -hisuf hi -fllvm -rtsopts -XBangPatterns -O2 RUNTEST_OPTS = -ghc-timing ==nofib== fannkuch-redux: time to compile Main follows... /Users/jrp/Projects/ghc/inplace/bin/ghc-stage2 -O2 -Rghc-timing -H32m -hisuf hi -fllvm -rtsopts -XBangPatterns -O2 -c Main.hs -o Main.o <<ghc: 358716248 bytes, 313 GCs, 10827462/27497216 avg/max bytes residency (6 samples), 57M in use, 0.00 INIT (0.00 elapsed), 0.20 MUT (0.53 elapsed), 0.21 GC (0.23 elapsed) :ghc>> ==nofib== fannkuch-redux: size of Main.o follows... __TEXT __DATA __OBJC others dec hex 10333 497 0 0 10830 2a4e ==nofib== fannkuch-redux: time to link fannkuch-redux follows... <<ghc: 19914544 bytes, 16 GCs, 1005021/2239600 avg/max bytes residency (3 samples), 25M in use, 0.00 INIT (0.00 elapsed), 0.01 MUT (0.53 elapsed), 0.02 GC (0.02 elapsed) :ghc>> ==nofib== fannkuch-redux: size of fannkuch-redux follows... __TEXT __DATA __OBJC others dec hex 4075520 446464 0 4295945496 4300467480 10053ed18 ==nofib== fannkuch-redux: time to run fannkuch-redux follows... ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; ../../runstdtest/runstdtest ./fannkuch-redux -o1 fannkuch-redux.stdout -o1 fannkuch-redux.stdout -ghc-timing 11; }}} -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.8.3 Resolution: | Keywords: fannkuch- | redux Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Incorrect result | Test Case: fannkuch- at runtime | redux Blocked By: 9504 | Blocking: Related Tickets: #5567 | Differential Rev(s): Phab:D2758 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dobenour): * status: new => patch * differential: => Phab:D2758 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.8.3 Resolution: | Keywords: fannkuch- | redux Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Incorrect result | Test Case: fannkuch- at runtime | redux Blocked By: 9504 | Blocking: Related Tickets: #5567 | Differential Rev(s): Phab:D2758 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"90fae01c326bf8b0802b4e8968f84886be4e1380/ghc" 90fae01c/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="90fae01c326bf8b0802b4e8968f84886be4e1380" Fix LLVM TBAA metadata Accesses through a Cmm local are currently reported as having the "other" type, which can only alias other "other" accesses. However, this assumption is incorrect, which can result in silent bad LLVM codegen. Fixes #9308. Fixes #9504. Test Plan: GHC CI Reviewers: rwbarton, austin, bgamari Reviewed By: bgamari Subscribers: michalt, thomie Differential Revision: https://phabricator.haskell.org/D2758 GHC Trac Issues: #9125, #9308, #9504 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9308: nofib fannkuch-redux runs perpetually with -fllvm -------------------------------------+------------------------------------- Reporter: jrp | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (LLVM) | Version: 7.8.3 Resolution: fixed | Keywords: fannkuch- | redux Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Incorrect result | Test Case: fannkuch- at runtime | redux Blocked By: 9504 | Blocking: Related Tickets: #5567 | Differential Rev(s): Phab:D2758 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9308#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC