This Project involves modifying or enhancing programs compiled with LLVM (Low-Level Virtual Machine) to introduce checkpoints for saving the program's state at specific intervals. This concept is crucial for fault-tolerant computing, debugging, or long-running applications where progress needs to be saved periodically.
MIT License
Course Name - Compiler Design Lab CS 320/321 Course Instructor - Dr. Manojit Ghose
Certainly! Below is a revised README formatted for GitHub (Markdown) for our LLVM Pass project. This version includes slight modifications for better readability and navigation on GitHub.
This project focuses on creating an LLVM pass that inserts checkpoints after every function call in a given C++ application. This enhancement aims to make the system persistent, enabling recovery and continuation from the last checkpoint in case of a failure. This document outlines the necessary steps to set up the environment, compile the required components, and execute the program.
llvm-config
utility should be accessible from the command line.Install LLVM and Clang:
sudo apt-get install llvm clang
brew install llvm
Verify Installation: Ensure both LLVM and Clang are correctly installed by checking their versions:
llvm-config --version
clang --version
Compile the LLVM Pass: Navigate to your project directory and compile the LLVM pass to a shared object file:
clang++ -fPIC -shared -o insert-checkpoint.so insert-checkpoint.cpp $(llvm-config --cxxflags --ldflags --libs core)
Note: The output file will be insert-checkpoint.dylib
for Mac and insert-checkpoint.so
for Linux/Windows.
Compile the C++ Application to LLVM IR:
Compile the C++ application (many_fun.cpp
) to LLVM IR (many_fun.ll
):
clang -S -emit-llvm many_fun.cpp -o many_fun.ll
Run the LLVM Pass on the LLVM IR File: Apply the LLVM pass to the LLVM IR file. If the first command doesn't work due to issues with the legacy pass manager, try alternative commands:
opt -S -enable-new-pm=0 -load=./insert-checkpoint.so -insert-checkpoint many_fun.ll -o output.ll
Compile the Perform Checkpoint Function:
Compile perform_checkpoint.cpp
to an object file:
clang++ -c perform_checkpoint.cpp -o perform_checkpoint.o
Link and Execute the Program:
Link the output.ll
file with the perform_checkpoint.o
object file, and compile to an executable:
clang++ output.ll perform_checkpoint.o -o output
./output
Upon successful execution, the program will insert checkpoints after every function call, as indicated by messages printed to the terminal and entries in the program_state.txt
file. This file logs the function names and battery levels at each checkpoint.
College Name - Indian Institute of Information Technology Guwahati B.Tech CSE 3rd Year
The team has contributed to various aspects of this project, including the design of the LLVM pass, implementation of the checkpoint mechanism, and ensuring the robustness of the system's persistence feature.
"# LLVM-program-persistence-using-checkpoint-insertion"