Print native code emitted by the JIT

Hi everybody,

I'm toying with the Kaleidoscope example from the documentation (with
llvm 2.5) and I want to print out on stderr, the native code (X86)
emitted with the JIT.
I have found the "createMachineFunctionPrinterPass" function.
But when I add it to the FunctionPassManager (
OurFPM.add(createMachineFunctionPrinterPass(cerr, "")); ). I get an
error at runtime : "MachineFunction.cpp:378: static
llvm::MachineFunction& llvm::MachineFunction::get(const
llvm::Function*): Assertion `mc && "Call construct() method first to
allocate the object"' failed."

I have probably miss an initialization or something like this, but I
can't figure out. Do you have any ideas ?

Thanks.

Olivier.

Olivier Meurant <meurant.olivier@gmail.com> writes:

[snip]

I have probably miss an initialization or something like this, but I
can't figure out. Do you have any ideas ?

Set this global variable:

       llvm::PrintMachineCode = 1;

This seems to print the native assembly machine code after each pass or
optimization. It's quite verbose.