Skip to content

Compiling and linking files for instTrace pass

Sam Coulter edited this page Jun 28, 2013 · 1 revision

This guide assumes you have the following files

  1. main.ll <- this is the entire c program to be tested, compiled and linked into one llvm IR bytecode file with llvm-gcc

  2. instTraceLib.c <- The instTrace library file, as distributed by LLFI

To Run LLFI instTrace

  1. Compile instTraceLib.c into an LLVM IR file with the following command "llvm-gcc instTraceLib.c -S -emit-llvm -o iTLib.ll"

  2. Run the LLFI indexing pass on main.ll with "opt -load {Path to LLVM Lib}/LLFI.so -genllfiindexpass -S < main.ll > main.indexed.ll

  3. Run the LLFI instTrace pass with "opt -load {Path to LLVM Lib}/LLFI.so -instTrace -S -tout goldenTrace < main.indexed.ll > main.traced.ll

  4. Link main.traced.ll and the instTrace library with "llvm-link main.traced.ll iTLib.ll -S > main.linked.ll

  5. Run the final program "lli main.linked.ll"

  6. Examine instruction traces "cat goldenTrace"