Ticket #5681 (closed bug: duplicate)
par# and spark# call newSpark differently, confuses LLVM backend
| Reported by: | scpmw | Owned by: | dterei |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Compiler (LLVM) | Version: | 7.2.1 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | GHC rejects valid program | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: | #5486 |
Description
If par# and spark# are being used in the same compilation unit, say like
case spark# (work 2) realWorld# of
(# _, _ #) -> case par# (work 1) of
_ -> return ()
The LLVM backend generates code like follows:
call ccc void (i8*,i8*)* @newSpark( i8* %lnnX, i8* %lnnZ ) nounwind
[...]
%lno7 = call ccc void (i8*,i8*)* @newSpark( i8* %lno4, i8* %lno6 ) nounwind
So both call newSpark under the hood - but inconsistently. The first call expects no returned value, while the second does. As the first seen call doesn't have a returned value, the backend concludes that the function's type must be void (i8*,i8*) *, which make opt choke on the second usage:
opt: /tmp/ghc23150_0/ghc23150_0.ll:845:1: error: instructions returning void cannot have a name %lno7 = call ccc void (i8*,i8*)* @newSpark( i8* %lno4, i8* %lno6 ) nounwind ^
The underlying reason is in code generation: It doesn't always ask for the return value of newSpark. So one way to fix this is to just always get the return value - but simply discard it if it's not needed. Patch attached.

