[llvm-dev] MLIR for clang

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 20 19:19:07 PST 2020



> On Feb 16, 2020, at 1:16 AM, Prashanth N R via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
>   Starting from May-June, we at "Compiler Tree" would  start porting clang compiler to use MLIR as middle end target. If someone has already started a similar effort we would love to collaborate with them. If someone would like to work with us, we are ready to form a group and collaborate. If there are sharing opportunities from Fortran side, we would like to consider the same.
> 
>    We are in the early phase of design for "C" part of the work. From our experience with (FC+MLIR) compiler, we are estimating that we would have an early cut of the compiler working with non-trivial workload within a quarter of starting of work.

Hi Prashanth,

I’d love to see this.

In terms of staging this in over time, have you considered starting by tackling the Clang “CFG” representation first?  It is used for source level analysis (-Wunreachable, clang static analyzer) and would be much better as a “CIL” implemented in MLIR.  From there, you could port Clang’s CodeGen/IRGen to be based on that IR instead of the AST.  From there, you could factor other parts of IRGen out into their own independent MLIR lowering phases (e.g. ABI lowering etc).

The advantage of starting with the CFG representation is that the bar to getting it accepted into the tree is lower (Clang CFG isn’t complete) and swapping out one IR with another should not create a compile time regression - adding another phase could.

-Chris



More information about the llvm-dev mailing list