Giter Club home page Giter Club logo

llvm-demo's Introduction

These programs are demonstrations of how LLVM can be used for (very simple) static and dynamic analyses. However, they use many of the initial building blocks necessary for solving more complex problems.

The provided analyses count the number of direct invocations of a particular function are present within a program or within and execution depending on whether static or dynamic analysis is used.

Building with CMake

  1. Clone the demo repository.

     git clone https://github.com/nsumner/llvm-demo.git
    
  2. Create a new directory for building.

     mkdir demobuild
    
  3. Change into the new directory.

     cd demobuild
    
  4. Run CMake with the path to the LLVM source.

     cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=True \
         -DLLVM_DIR=</path/to/LLVM/build>/lib/cmake/llvm/ ../llvm-demo
    
  5. Run make inside the build directory:

     make
    

This produces a callcounter tool called bin/callcounter and supporting libraries in lib/.

Note, building with a tool like ninja can be done by adding -G Ninja to the cmake invocation and running ninja instead of make.

Running

First suppose that you have a program compiled to bitcode:

clang -g -c -emit-llvm ../llvm-demo/test/simpletest.c -o calls.bc

Running the dynamic call printer:

bin/callcounter -dynamic calls.bc -o calls
./calls

Running the static call printer:

bin/callcounter -static calls.bc

or by loading the pass as a plugin for opt:

opt -analyze -load lib/libcallcounter-lib.so -callcounter calls.bc

llvm-demo's People

Contributors

nsumner 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.