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.

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#

Last modified 6 months ago Last modified on Apr 11, 2017 12:59:45 PM