Skip to content

[Feature] Pre-built JIT IR: compile C++ kernels to bitcode for JIT inlining #502

Description

@zhangxffff

Feature Category

SQL Function / Operator

Problem / Use Case

Writing JIT code in bolt currently requires using the LLVM IRBuilder API directly, which is verbose (e.g., RowContainerCodeGenerator is ~400 lines for row comparison) and hard to maintain.

Proposed Solution

Introduce a pre-built JIT IR framework that compiles C++ kernel functions to LLVM bitcode at build time and inlines them into JIT-composed modules at runtime.

Key components:

  1. Build pipeline: kernels.cpp → clang -emit-llvm -c -O2 → xxd -i → embedded byte array. Compile flags are extracted from ninja build commands via gen_kernel_flags.sh to support bolt headers (e.g., DecodedVector.h).
  2. Runtime linking: PrebuiltIR::load() parses embedded bitcode, ThrustJITv2::linkPrebuiltModule() links it into JIT modules with internal linkage to avoid symbol conflicts.
  3. IR optimization: AlwaysInlinerLegacyPass + InstCombine/GVN/CFGSimplification in ThrustJITv2's IR transform layer.

References / Prior Art

No response

Importance

High (Needed for production)

Willingness to Contribute

Yes, I can submit a PR

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions