Converting LLVM bitcode back to LLVM assembly

In this recipe, you will convert LLVM bitcode back to LLVM IR. Well, this is actually possible using the LLVM disassembler tool called llvm-dis.

Getting ready

To do this, you need the llvm-dis tool installed.

How to do it...

To see how the bitcode file is getting converted to IR, use the test.bc file generated in the recipe Converting IR to LLVM Bitcode. The test.bc file is provided as the input to the llvm-dis tool. Now proceed with the following steps:

  1. Using the following command shows how to convert a bitcode file to an the one we had created in the IR file:
    $ llvm-dis test.bc –o test.ll
    
  2. Have a look at the generated LLVM IR by the following:
    | $ cat test.ll
    ; ModuleID = 'test.bc'
    
    define i32 @mult(i32 ...

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.