Opened 9 years ago

Closed 4 years ago

Last modified 2 months ago

#2840 closed bug (duplicate)

Top level string literals

Reported by: simonpj Owned by:
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.10.1
Keywords: strings Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by bgamari)

At the moment GHC's internal language does not allow any top-level definitions of unlifted type, and for the most part rightly so. But consider this:

f :: Int -> String
f n = let a::Addr# = "foo"
      in let g y = ...a...g...
      in g n

Here we'd like to float the definitions out thus:

a::Addr# = "foo"
g y = ...a...g...
f n = g n

This is much better. Usually this happens, but not here, because we don't allow a top-level binding for an Addr#. But really perhaps we should allow an exception for literals, which can safely be bound at top level.

For literals other than strings, this doesn't make any difference, because we inline them freely. But for literal strings we don't want to make lots of copies of them; on the contrary we'd like to CSE identical strings. So it'd help to be able to bind them at top level.

Simon

Change History (10)

comment:1 Changed 8 years ago by simonmar

Type of failure: Runtime performance bug

comment:2 Changed 7 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:3 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:4 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:5 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:6 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:7 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:8 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:9 Changed 4 years ago by simonpj

Resolution: duplicate
Status: newclosed

Closing this in favour of #8472.

Simon

comment:10 Changed 2 months ago by bgamari

Description: modified (diff)
Keywords: strings added
Note: See TracTickets for help on using tickets.