Code Generator

This page describes code generator ("codegen") in GHC. It is meant to reflect current state of the implementation. If you notice any inaccuracies please update the page (if you know how) or complain on ghc-devs.

A brief history of code generator

You might occasionally hear about "old" and "new" code generator. GHC 7.6 and earlier used the old code generator. New code generator was being developed since 2007 and it was enabled by default on 31 August 2012 after the release of GHC 7.6.1. The first stable GHC to use the new code generator is 7.8.1 released in early 2014.

Various historical pages, with still-useful info:


Use Keyword = CodeGen to ensure that a ticket ends up on these lists.

Open Tickets:

Remove Hack in compiler/nativeGen/X86/CodeGen.hs
Avoid unnecessary evaluation when unpacking constructors
Refactor the plumbing of CafInfo to make it more robust
No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm
Double double assignment in optimized Cmm on SPARC
Add dead store elimination
Function arguments are always spilled/reloaded if scrutinee is already in WHNF
Avoid TidyPgm predicting what CorePrep will do
Cheap-to-compute values aren't pushed into case branches inducing unnecessary register pressure
Implement the 'Improved LLVM Backend' proposal
LLVM does not need to trash caller-saved registers.
Improve cmm/assembly for pattern matches with two constants.

Closed Tickets:

LLVM codegen does not handle integer literals in branch conditionals.
Register allocator chokes on certain branches with literals
LLVM backend does not properly widen certain literal types in call expressions
Loopification should omit stack check
cmm common block not eliminated
cmm case, binary search instead of jump table
Loopification does not trigger for IO even if it could
GHC and LLVM don't agree on what to do with byteSwap16#
Improve assembly for dense jump tables.

Last modified 7 weeks ago Last modified on Nov 29, 2017 10:10:28 AM