How to print machine code of JIT IR

Hi,
  I am using LLVM 3.1, and wants to print the machine code of JIT IR

I try the following method

EngineBuilder builder(&ctx.getModule());
builder.setEngineKind(EngineKind::JIT);

Hi Chia Lun Liu,

   I am using LLVM 3.1, and wants to print the machine code of JIT IR

I try the following method

EngineBuilder builder(&ctx.getModule());
  builder.setEngineKind(EngineKind::JIT);
  *
    TargetMachine * tm = builder.selectTarget();
    tm->Options.PrintMachineCode = true;*
     engine = builder.create();

Try builder.create(tm).

selectTarget() returns a new object, so setting options on that has no effect on the ExecutionEngine which is built by the create() call.
In fact, EngineBuilder.create() just creates passes a newly created TargetMachine:

  ExecutionEngine *create() {
    return create(selectTarget());
  }

Another question is that I am not sure when JIT would dump machine code.

It actually dumps it several times during code emission, after running different passes on it. Code emission happens on the first call to the functions, thus lazily (or just in time).

Cheers,
Clemens

Hi Clemens Hammacher,

  I try your method, and it prints what I want. I am grateful for your info.

Chia Lun Liu