Allow top-level string literals in Core (#8472)
authorTakano Akio <tak@anoak.io>
Wed, 18 Jan 2017 23:26:47 +0000 (18:26 -0500)
committerBen Gamari <ben@smart-cactus.org>
Fri, 20 Jan 2017 19:36:29 +0000 (14:36 -0500)
commitd49b2bb21691892ca6ac8f2403e31f2a5e53feb3
treecc8488acf59467899e4d3279a340577eec95310f
parenta2a67b77c3048713541d1ed96ec0b95fb2542f9a
Allow top-level string literals in Core (#8472)

This commits relaxes the invariants of the Core syntax so that a
top-level variable can be bound to a primitive string literal of type
Addr#.

This commit:

* Relaxes the invatiants of the Core, and allows top-level bindings whose
  type is Addr# as long as their RHS is either a primitive string literal or
  another variable.

* Allows the simplifier and the full-laziness transformer to float out
  primitive string literals to the top leve.

* Introduces the new StgGenTopBinding type to accomodate top-level Addr#
  bindings.

* Introduces a new type of labels in the object code, with the suffix "_bytes",
  for exported top-level Addr# bindings.

* Makes some built-in rules more robust. This was necessary to keep them
  functional after the above changes.

This is a continuation of D2554.

Rebasing notes:
This had two slightly suspicious performance regressions:

* T12425: bytes allocated regressed by roughly 5%
* T4029: bytes allocated regressed by a bit over 1%
* T13035: bytes allocated regressed by a bit over 5%

These deserve additional investigation.

Rebased by: bgamari.

Test Plan: ./validate --slow

Reviewers: goldfire, trofi, simonmar, simonpj, austin, hvr, bgamari

Reviewed By: trofi, simonpj, bgamari

Subscribers: trofi, simonpj, gridaphobe, thomie

Differential Revision: https://phabricator.haskell.org/D2605

GHC Trac Issues: #8472
53 files changed:
compiler/cmm/CLabel.hs
compiler/cmm/CmmInfo.hs
compiler/cmm/CmmUtils.hs
compiler/codeGen/StgCmm.hs
compiler/codeGen/StgCmmClosure.hs
compiler/codeGen/StgCmmEnv.hs
compiler/codeGen/StgCmmUtils.hs
compiler/coreSyn/CoreLint.hs
compiler/coreSyn/CorePrep.hs
compiler/coreSyn/CoreSubst.hs
compiler/coreSyn/CoreSyn.hs
compiler/coreSyn/CoreUtils.hs
compiler/ghci/ByteCodeAsm.hs
compiler/ghci/ByteCodeGen.hs
compiler/main/HscMain.hs
compiler/prelude/PrelRules.hs
compiler/profiling/SCCfinal.hs
compiler/simplCore/CSE.hs
compiler/simplCore/SetLevels.hs
compiler/simplCore/SimplEnv.hs
compiler/simplCore/Simplify.hs
compiler/simplStg/SimplStg.hs
compiler/simplStg/StgCse.hs
compiler/simplStg/StgStats.hs
compiler/simplStg/UnariseStg.hs
compiler/stgSyn/CoreToStg.hs
compiler/stgSyn/StgLint.hs
compiler/stgSyn/StgSyn.hs
docs/core-spec/core-spec.mng
testsuite/tests/deSugar/should_compile/T2431.stderr
testsuite/tests/numeric/should_compile/T7116.stdout
testsuite/tests/perf/compiler/all.T
testsuite/tests/perf/should_run/T8472.hs [new file with mode: 0644]
testsuite/tests/perf/should_run/T8472.stdout [new file with mode: 0644]
testsuite/tests/perf/should_run/all.T
testsuite/tests/perf/space_leaks/all.T
testsuite/tests/roles/should_compile/Roles13.stderr
testsuite/tests/simplCore/should_compile/Makefile
testsuite/tests/simplCore/should_compile/T3234.stderr
testsuite/tests/simplCore/should_compile/T3717.stderr
testsuite/tests/simplCore/should_compile/T3772.stdout
testsuite/tests/simplCore/should_compile/T4908.stderr
testsuite/tests/simplCore/should_compile/T4930.stderr
testsuite/tests/simplCore/should_compile/T7360.stderr
testsuite/tests/simplCore/should_compile/T8274.stdout
testsuite/tests/simplCore/should_compile/T9400.stderr
testsuite/tests/simplCore/should_compile/all.T
testsuite/tests/simplCore/should_compile/noinline01.stderr
testsuite/tests/simplCore/should_compile/par01.stderr
testsuite/tests/simplCore/should_compile/rule2.stderr
testsuite/tests/simplCore/should_compile/spec-inline.stderr
testsuite/tests/simplCore/should_compile/str-rules.hs [new file with mode: 0644]
testsuite/tests/simplCore/should_compile/str-rules.stdout [new file with mode: 0644]