Kyriakos
Kyriakos

Reputation: 757

Emit the llvm-ir bytecode from my llvm pass

Is there anyway to emit the llvm-ir bytecode from inside my pass, into a file? I want the same format that I am getting by using the opt tool, so I can pass this file to the opt later.

Upvotes: 4

Views: 1227

Answers (1)

Oak
Oak

Reputation: 26898

To print a module in the textual representation (which opt can parse just file) to stdout, use Module::dump(). To save it to a file, use Module::print (and just pass null as the 2nd argument). To dump it to a bitcode file, use llvm::WriteBitcodeToFile.

Upvotes: 3

Related Questions