Giter VIP home page Giter VIP logo

llvm-bytecode-to-dot's Introduction

LLVM - Bytecode to DOT

A LLVM pass that prints bytecode programs into the dot format.

This is a DCC888 class project assignment.

Description

You must write your own pass, and it must have a few requirements:

  • Each instruction must be printed with an opcode;
  • All the arguments of an instruction must be printed next to this instruction;
  • Arguments that do not have names, such as getelementptr in function calls, should not be printed;
  • Type information should not be printed.

Build

To build this project, you need to run the following shell commands:

Assuming you have ninja-build installed...

$ mkdir -p build
$ cd build
$ cmake -G Ninja -DLLVM_INSTALL_DIR=/path/to/llvm-project/build ..
$ cmake --build .

File Generation

Once you build the project, all source files are generated as follows:

  • All tests' sources are compiled into LLVM IR code, using the following command:
$ clang -S -emit-llvm -o "Filename.c.ll" "Filename.c" -Xclang -disable-O0-optnone
  • Since the pass is built out-of-tree, the libBytecodeToDot.so file is compiled and loaded dynamically as plugin using opt by the following command:
$ opt -load-pass-plugin "build/libBytecodeToDot.so" -passes=mem2reg,lcssa,BytecodeToDotPass -S "FileName.c.ll" -o "FileName.c.ll" 2>&1

Note: both commands were added as custom commands in the CMakeLists.txt file.

Also, every DOT file is generated in the same directory as its relative .ll file.

PDF

To generate the PDF files from the DOT files, go to the root of the repo again and run the following commands:

$ chmod +x pdf_gen.sh
$ ./pdf_gen.sh

The PDF files for each CFG can be found in the tests/Stanford/TestName.ll_Files/FunctionName.dot.pdf folder.

If python's img2pdf package is installed, pdf files get merged into a single file called tests/Stanford/TestName.ll_merged.pdf.

llvm-bytecode-to-dot's People

Contributors

casperento avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.