GithubHelp home page GithubHelp logo

jonboh / llvm-ir-analysis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cdisselkoen/llvm-ir-analysis

0.0 1.0 0.0 214 KB

License: MIT License

C 3.35% Rust 53.42% Makefile 0.31% LLVM 42.92%

llvm-ir-analysis's Introduction

llvm-ir-analysis: Static analysis of LLVM IR

crates.io License

This crate provides several simple static analyses of LLVM IR. In particular, this crate computes the following on an llvm-ir Module or Function:

The above analyses are provided by the FunctionAnalysis, ModuleAnalysis, and CrossModuleAnalysis objects, which lazily compute each of these structures on demand and cache the results.

Getting started

llvm-ir-analysis is on crates.io, so you can simply add it as a dependency in your Cargo.toml, selecting the feature corresponding to the LLVM version you want:

[dependencies]
llvm-ir-analysis = { version = "0.3.2", features = ["llvm-14"] }

Currently, the supported LLVM versions are llvm-8, llvm-9, llvm-10, llvm-11, llvm-12, llvm-13, and llvm-14. The corresponding LLVM library must be available on your system; see the llvm-sys README for more details and instructions.

You'll also need some LLVM IR to analyze, in the form of an llvm-ir Module or Function. This can be easily generated from an LLVM bitcode file; for more detailed instructions, see llvm-ir's README.

Once you have a Module, you can construct a ModuleAnalysis object:

let module = Module::from_bc_path(...)?;
let analysis = ModuleAnalysis::new(&module);

You can get Module-wide analyses such as analysis.call_graph() directly from the ModuleAnalysis object. You can also get Function-level analyses such as the control-flow graph using analysis.fn_analysis("my_func"); or you can construct a FunctionAnalysis directly with FunctionAnalysis::new().

Finally, you can get multi-module analyses such as a cross-module call graph by starting with a CrossModuleAnalysis instead of just a ModuleAnalysis. The CrossModuleAnalysis also provides a ModuleAnalysis for each of the included modules, again computed lazily on demand.

llvm-ir-analysis's People

Contributors

cdisselkoen avatar matklad 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.