Ticket #5681 (closed bug: duplicate)

Opened 18 months ago

Last modified 18 months ago

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

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

Change History

Changed 18 months ago by scpmw

Changed 18 months ago by scpmw

Changed 18 months ago by dterei

  • status changed from new to closed
  • resolution set to duplicate

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.

Changed 18 months 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'.

Changed 18 months 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.

Changed 18 months 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.

Changed 18 months ago by dterei

  • related set to #5486

Changed 18 months ago by scpmw

output of git format-patch

Note: See TracTickets for help on using tickets.