2

I see from this question there is a way to dump a module to bitcode (.bc), but I would like to dump the IR to a .ll file so that I can view the IR.

I know llvm-dis can convert .bc to .ll but in my case it does not work. I have written some passes that transform the module in a way that llvm-dis fails to convert the bitcode to IR.

Is there an API similar to LLVMWriteBitcodeToFile that lets me dump a module to IR directly?

Increasingly Idiotic
  • 5,700
  • 5
  • 35
  • 73

2 Answers2

0

You can use opt to do that. e.g.,

opt -S test.bc -o test.ll

A. K.
  • 34,395
  • 15
  • 52
  • 89
0

From arnt's comment, just use llvm::Module::print()

Increasingly Idiotic
  • 5,700
  • 5
  • 35
  • 73
  • I use `llvmmodule->print(ostream, nullptr);` but why my llvm::Module only prints `source_filename` but nothing else? – linrongbin Jul 07 '20 at 09:34