Skip to content

ShangkunLi/llvm-pass-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

llvm-pass-template

Since the method given in documentation need to put your own pass in the directory llvm-project/llvm/lib/Transforms ,which is inconvenient for use.

In this repository, we provide with a complete LLVM pass template, which enables building a pass independently.

It's for LLVM 17.0.

You can put this llvm-pass-template file anywhere you want.

To build this pass:

    $ mkdir build
    $ cd build
    $ cmake ..
    $ make

Then you can find the .so file in llvm-pass-template/build/Hello/libHelloPass.so.

To run this pass:

You need to use clang to generate the .bc file of your source code firstly.

$ clang -c -emit-llvm path/to/main.c -o path/to/main.bc

Then, you can run the pass to get the result.

$ opt -load path/to/llvm-pass-template/build/Hello/libHelloPass.so -hello path/to/main.bc -o /dev/null

About

A llvm-pass template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages