[LLVMdev] Getting dump of native assembly?

Óscar Fuentes ofv at wanadoo.es
Tue Oct 2 19:28:57 PDT 2012


"Paul J. Lucas" <paul at lucasmail.org> writes:

> I'm using the IRBuilder C++ API to generate LLVM IR code and execute
> it on-the-fly.  I know about Module::dump() to print the IR code, but
> is there any way to print out the native assembly code (x86 in my
> case)?

Not the native assembly, but a representation of the native
instructions, just create your ExecutionEngine thus:

  EngineBuilder builder(MyModule);
  ...
  TargetMachine *tm = builder.selectTarget();
  tm->Options.PrintMachineCode = 1;
  ExecutionEngine *EE = builder.create(tm);

It is quite verbose too.




More information about the llvm-dev mailing list