In this assignment you will implement a pass to build a program’s CFG from its linear code. This assignment is due on Sunday March 6th at 11:59pm.
For this assignment, you can choose to use either the URCC compiler or LLVM.
Instructions for URCC
- Checkout and install the URCC compiler (follow the instructions in the README file). Make sure you are using a version of clang between 3.3 and 3.6 or URCC may fail. If you decide to use the CSUG machines, you can use clang 3.6 that is installed in /u/cs255/build-llvm-36/bin.
- Follow the algorithm in section 5.3.4 of the Cooper & Torczon book (page 241) to write a pass that builds the CFG of the program and visualizes it using graphViz (instructions on how to write a URCC pass are included in the README file).
- Test your compiler pass on test cases included in the test directory.
- Explain your implementation in a Readme file. Report all test case failures.
- Archive your code and the Readme file and submit on Blackboard.
Note: A CFG pass is already implemented in the URCC compiler. You shall not look at that implementation.
Instructions for LLVM
- Following the same instructions as in assignment 2, create an LLVM project in your CSUG account.
- Implement a pass that builds the CFG of the program and visualizes it using graphviz. If you need to iterate over instructions in a function, you must use the following code:
#include "llvm/IR/InstIterator.h" // F is a pointer to a Function instance for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) errs() << *I << "\n";
- You can use BGL (Boost Graph Library), which is already installed on CSUG filesystem. Graphviz is included in this library.
- Test your compiler pass on test cases included in URCC’s repository (https://github.com/dcompiler/urcc/tree/master/tests).
- Explain your implementation in a Readme file. Report all test case failures.
- Archive your code and the Readme file and submit on Blackboard.
Note: A CFG pass is already implemented in LLVM. You shall not look at that implementation.
[…] CFG pass in URCC […]