Giter Site home page Giter Site logo

llvm-dataflow-analysis's Introduction

These programs are demonstrations of how LLVM can be used for (very simple) static dataflow analyses (both inter- and intraprocedural). The presentation is illustrative and does not demonstrate how to implement scalable analyses.

The provided filepolicy analysis identifies simple errors in using fread, fwrite, and fclose where they may potentially be called on files that have already been closed.

The provided constant-propagation analysis identifies simple constant values that can be determined at compile time. It then prints out the computable constant arguments to all function calls in the module.

The provided futurefunctions analysis uses backward dataflow analysis to identify the functions that may be called in the future at all call sites in a program.

Building with CMake

  1. Clone the repository.

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

     mkdir dfbuild
    
  3. Change into the new directory.

     cd dfbuild
    
  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-dataflow-analysis
    
  5. Run make inside the build directory:

     make
    

This produces tools called bin/filepolicy, bin/constant-propagation, and bin/futurefunctions.

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 -O1 -emit-llvm ../llvm-dataflow-analysis/test/filepolicy/c/01straightCorrect.c -o 01.bc

Running the file policy analyzer:

bin/filepolicy 01.bc

The tests in the tests directory can be run using the provided Makefiles

llvm-dataflow-analysis'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.