Skip to content

LLVM as a back-end for RyuJIT #313

@EgorBo

Description

@EgorBo

Since dotnet/corert#8230 thread was archived recently, I'm creating a new one here to continue the discussion.

I'm trying to build a minimal dynamically-loaded extension for RyuJIT to generate LLVM IR (and compile it for tier1 (JIT) or use in AOT scenarios) from GenTrees (HIR/LIR) in order to benefit from RyuJIT's .net specific optimizations and SSA transformation for locals. Something like this:

image

(my local version is a bit more complicated but it's still just a very high-level prototype and is a mess)

Some of the challenges (too early to make a deep analysis):

  • Setup LLVM dependency (currently, I just use a locally built one)
  • Make RyuJIT's headers portable, basically, provide an external API, stabilize layout (e.g. a lot of fields here and there depend on different condition symbols)
  • Implement all operators, GC/EH, etc - How to draw an owl

Since there are LLILC and #247 efforts I wonder what can be shared/merged. Maybe it makes sense to bind all RyuJIT's structures/API to C# (e.g. via CppAst.NET) and continue IR -> LLVM IR transformation there using LLVMSharp (C# bindings for LLVM C-api). Maybe it's better to join #247 and just port RyuJIT's optimizations one-by-one there.

Initially, I just wanted to make an extension for RyuJIT to replace tier1 with LLVM-JIT for HPC# code (a GC-free subset of C# in Unity's Burst for high-performance stuff) to generate vectorized loops, etc where RyuJIT currently doesn't perform well. But I see that there is a quite a demand for AOT. So maybe you have some thoughts regarding the direction it is better to move to to make it at least theoretically useful?

/cc @jkotas @MichalStrehovsky @yowl @AndyAyersMS

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-LLVMLLVM generation for Native AOT compilation (including Web Assembly)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions