Outsourcing the constexpr evaluation to the LLVM IR interpreter?

Using Clang CodeGen to generate IR for constexpr evaluation seems like a non-starter, due to complications with cross-compilation, and differing semantics between compile-time and runtime (particularly related to diagnostics). I think trying to share the code like this actually ends up increasing the complexity overall.

You could theoretically add an optional JIT to ConstantInterpreter. But there’s probably room to optimize without going that route, and I doubt the evaluation is actually a bottleneck in most cases.

If you want to simplify reasoning over clang ASTs, what you really want is something like [RFC] An MLIR based Clang IR (CIR) , I think.

1 Like