Course Project

For this project you will write a pass for the LLVM compiler.
  1. Download the LLVM compiler source from, configure, compile and install it.
  2. Study the documentation on and familiarize yourselves with the compiler, its phases, and APIs.
  3. Study the Tutorial on writing an example LLVM pass.
  4. Write an additional pass for LLVM to change the program. Your pass should discover all direct calls to printf and add an additional call to fprintf with the same arguments right after each printf call, so that the program writes (in addition to stdout) a file named log.txt containing everything printf-ed on stdout. The file log.txt should be fopen-ed at the start of main() and closed before main() ends.


For the project you have to deliver
  1. A report of at most 3 pages, describing the process that you took to rewrite the program.
  2. The source code in a tarball, along with a README file describing how to compile and run LLVM including your pass (e.g., where to place your files in the LLVM source tree, what to change in Makefiles if needed, configure flags). Include one or two example input programs along with directions of how to transform them using LLVM plus your pass.

Due Date

Email the above deliverables to the instructor by the last day of the exams.