Improve X86CodeGen's pprASCII.

Authored by sighingnow on Feb 6 2018, 12:31 AM.



The original implementation generates a list of SDoc then concatenates
them using hcat. For memory optimization, we can transform the given
literal string into escaped string the construct SDoc directly.

This optimization will decreate the memory allocation when there's big
literal strings in haskell code, see Trac Trac #14741.

Signed-off-by: HE, Tao <>

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
sighingnow created this revision.Feb 6 2018, 12:31 AM
simonpj accepted this revision.Feb 6 2018, 3:08 AM
simonpj added a subscriber: simonpj.

The perf improvement seems dramatic -- hooray!

In the commit message (and summarised in the Note above) can you say what the perf gain is? We don't want someone to accidentally revert!

Also, is it possible to make a performance regression test that will blow up if this goes wrong again?



There's clearly something important (to perf) happening here. Can you add a Note to explain the idea, and point to the ticket?

This revision is now accepted and ready to land.Feb 6 2018, 3:08 AM
sighingnow updated this revision to Diff 15366.Feb 6 2018, 6:24 AM
  • Add Note [Pretty print ASCII when AsmCodeGen].
sighingnow marked an inline comment as done.Feb 6 2018, 6:25 AM

Great catch; I'll merge but let's be sure to add a test.

This revision was automatically updated to reflect the committed changes.