[LLVMdev] Being able to know the jitted code-size before emitting

Jonathan S. Shapiro shap at eros-os.com
Fri Apr 4 11:58:08 PDT 2008


In general, it is not possible to know jitted code size without
emitting. You can suppress the actual write of the instructions
themselves, but you have to do all of the work prior to that point.

The reason is that on many architectures there are span-dependent
branches. The final instruction size depends on the branch span. The
span depends on the code size, and the code size depends on the
representation of the span. It really is a cyclical dependency, and it
is usually solved by doing the best you can and then breaking cycles in
the span dependency graph by picking one of the offending spans
arbitrarily and fixing it to the max representation length (after which
the rest of the dependency loop can be resolved).

But the point is that you have to actually generate the code (at least
in memory) to do this analysis.

You can get a conservative upper bound on those architectures by
assuming that all spans will use the maximal sized representation, but
you cannot get a precise size without emitting the code.


shap




More information about the llvm-dev mailing list