compiler/cmm/PprC.hs: constify labels in .rodata
authorSergei Trofimovich <slyfox@gentoo.org>
Mon, 24 Apr 2017 13:41:35 +0000 (09:41 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 24 Apr 2017 16:53:43 +0000 (12:53 -0400)
commitb68697e579d38ca29c2b84377dc2affa04659a28
tree3d7a9f8c888baad175c81863d5519fb42e817770
parentd5cb4d2b7fab89ea1c3fc74da2317f86e75816ea
compiler/cmm/PprC.hs: constify labels in .rodata

Consider one-line module
    module B (v) where v = "hello"
in -fvia-C mode it generates code like
    static char gibberish_str[] = "hello";

It resides in data section (precious resource on ia64!).
The patch switches genrator to emit:
    static const char gibberish_str[] = "hello";

Other types if symbols that gained 'const' qualifier are:

- info tables (from haskell and CMM)
- static reference tables (from haskell and CMM)

Cleanups along the way:

- fixed info tables defined in .cmm to reside in .rodata
- split out closure declaration into 'IC_' / 'EC_'
- added label declaration (based on label type) right before
  each label definition (based on section type) so that C
  compiler could check if declaration and definition matches
  at definition site.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: ran testsuite on unregisterised x86_64 compiler

Reviewers: simonmar, ezyang, austin, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #8996

Differential Revision: https://phabricator.haskell.org/D3481
compiler/cmm/CLabel.hs
compiler/cmm/Cmm.hs
compiler/cmm/CmmInfo.hs
compiler/cmm/PprC.hs
compiler/llvmGen/LlvmCodeGen/Data.hs
includes/Stg.h
includes/rts/storage/InfoTables.h
includes/stg/MiscClosures.h