PavlosMak / LLVM-Fence-Insertion

An automatic fence insertion pass for LLVM based on ILP constraints.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fence Insertion for LLVM

A modification of the LLVM compiler infrastructure for automatically inserting fences in weak memory model concurrent programs.

Building and Running Instructions

First clone this repository. Optionally you can set the --depth to 1 to get only the most recent version.

$ git clone git@github.com:PavlosMak/LLVM-Fence-Insertion.git

Then you need to compile the project. The first thing to do is make a build directory inside the repository. Then go inside build and run

$ cmake ../ -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=lld -DLLVM_PARALLEL_LINK_JOBS=1

The above command will generate the build files. Note that it assumes you have lld installed, if not you can remove that argument (at the cost of slower linking) or use your favorite linker. Additionally note that in the above command we set the threshold for parallel linking jobs to 1 (so no parallelism). This is because typically linking takes a lot of memory. Feel free to change the value based on how much memory your system have.

Now that we have the build files it is time to compile. The first time of compiling LLVM will take a lot of time so be prepared to wait for a few hours. Still inside build do:

$ cmake --build .

Once the process has completed go back to the main directory of the repository. Now we can test that our pass works. Run:

$ ./build/bin/opt -load ./build/lib/FenceInsertion.so -FenceInsertion < ./testPrograms/dummy.bc > /dev/null

The above will run the FenceInsertion pass on a simple input. You should see the following on the console:

Fence Insertion: main
Fence Insertion: dummy

Adding test programs

To add a test program first go inside the testPrograms directory. In there you can add your c file. Then you need to generate the LLVM bitcode. Since we are using LLVM-10 you need to use clang-10, so make sure you have that installed. After that simply run:

$ clang-10 -emit-llvm -c myFile.c

About

An automatic fence insertion pass for LLVM based on ILP constraints.

License:Other


Languages

Language:LLVM 49.3%Language:C++ 30.6%Language:Assembly 19.1%Language:Python 0.4%Language:C 0.3%Language:CMake 0.2%Language:OCaml 0.1%Language:Go 0.1%Language:Shell 0.0%Language:HTML 0.0%Language:Perl 0.0%Language:Vim Script 0.0%Language:CSS 0.0%Language:Emacs Lisp 0.0%Language:Objective-C 0.0%Language:Batchfile 0.0%Language:Dockerfile 0.0%Language:Starlark 0.0%Language:Swift 0.0%Language:Roff 0.0%