Skip to content

aryan828/llvm-static-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLVM IR ANALYSIS

LLVM provides passes to perform analysis or tansformation on LLVM IR. These passes can be used to improve the performance of the code or to analyze the code for bottlenecks.

There are three types of passes in LLVM:

  • Analysis Passes
  • Transformation Passes
  • Utility Passes

This repository contains 2 examples of analysis passes:

  • ListFunction: Lists all the functions along with their argument size, basic block count and instruction count.
  • StaticCallCounter: Counts the number of static calls to a function.

These passes are out-of-tree. Because adding any pass into LLVM requires building it again and again, which was not feasible for our case.

Requirements

  • LLVM 15.x.x
  • clang

Installation

  1. Change the path of your LLVM installation directory in root CMakeLists.txt.
  2. mkdir build
  3. cd build
  4. cmake ../
  5. cmake --build .



Usage

List Function

opt -load-pass-plugin ./lib/libListFunction.so -passes=list-function -disable-output <input ll file>

Static Call Counter

opt -load-pass-plugin ./lib/libStaticCallCounter.so -passes=static-call-counter -disable-output <input ll file>

Screenshots

List Function

Static Call Counter

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published