imageworks/OpenShadingLanguage — pull request #332 by lgritz (2014-01-20 22:26:48+00:00)
Title: Support for LLVM MCJIT

All along, we've been using LLVM's "old" JIT subsystem. It's not really being maintained well these days, and may some day be phased out completely in favor of its replacement "MCJIT."

This patch allows a build-time switch to use either MCJIT or old JIT. Primarily this is to pave the road for future exclusive use of MCJIT if old JIT is removed from LLVM, or if we wish to use some feature of MCJIT that is not backported to old JIT.

Note that this pull request implicitly includes #331 as well; you can review them separately if you wish.

In this patch, we:

* Link against MCJIT libraries from LLVM

* Amend LLVM_Util to have a debug mode.

* Some incidental movement of BackendLLVM methods from llvm_instance.cpp to backendllvm.cpp.

* Some minor changes to LLVM_Util to support MCJIT.

* Moved some non-essential (and unlikely to inline) functions from llvm_opt.cpp to other cpp files. This helps reduce the dependencies for llvm_ops.cpp, reduce the amount of bitcode to process, and was intended to fix some MCJIT issues (but turned out that they were not relevant in the end).

Currently, this code uses ParseBitcodeFile rather than getLazyBitcodeModule when MCJIT is enabled, since MCJIT appears to have a bug that causes it to not correctly find the symbols in the module when using lazy deserialization. I'm inquiring after this on llvm-dev and hope to get it cleared up at some point, but that doesn't need to hold up this review.