Search code examples
llvmcompiler-optimizationllvm-clangllc

how to get LLVM opt to output MIR to be passed to llc?


I need to pass an MIR file to LLC so that I can use the -run-pass option, but I can't find anything about outputing as MIR from opt. How can I do that?


Solution

  • I stumbled upon this through Google. I found that I can do the following to get MIR from a .ll file. Hopefully this helps someone else who ends up here.

    llc -o bleh.mir <other options> -stop-after=machine-cp -simplify-mir bleh.ll
    

    You can control what ends up in the output file by changing the argument to "-stop-after". A list of passes is found in "llvm/include/llvm/Passes/MachinePassRegistry.def". If you do not include that option, you'll get an assembly listing.