Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#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.

Attachments (3)

newspark-llvm-fix.patch (1.6 KB) - added by scpmw 2 years ago.
newSpark_bug.hs (208 bytes) - added by scpmw 2 years ago.
0001-Code-generation-Always-ask-for-result-of-newSpark.patch (1.7 KB) - added by scpmw 2 years ago.
output of git format-patch

Download all attachments as: .zip

Change History (8)

Changed 2 years ago by scpmw

Changed 2 years ago by scpmw

comment:1 Changed 2 years ago by dterei

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

thanks, this is a duplicate of #5486. I'll probably use the patch attached but a more general fix is needed to handle the underlying issue.

comment:2 Changed 2 years ago by dterei

In future can you apply correct git patches please?

http://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git

Not sure how you created the attached patch but I can't apply with 'git am'.

comment:3 Changed 2 years ago by scpmw

That's simply git show output. I just assumed that was a useful format - it should certainly apply cleanly using patch -p 1 < newspark-llvm-fix.patch.

I'll attach the git format-patch output later.

comment:4 Changed 2 years ago by dterei

Its useful and applies cleanly but if you use format-patch then its easier for me to apply in a way that gives you credit for the patch.

comment:5 Changed 2 years ago by dterei

Changed 2 years ago by scpmw

output of git format-patch

Note: See TracTickets for help on using tickets.