User Tools

Site Tools


This procedure works in the LegUp 3.0 Virtual Box. It runs the LLVM profiler to determine the total number of times each basic block is executed during a program's execution. It does so by directly executing the LLVM IR using the LLVM interpreter.

We'll use the CHStone/mips benchmark as an example. Just follow these simple steps.

  • Go to the mips directory and type make. You should now have the mips.ll file in the directory.
  • Type: opt -q -f mips.ll -o mips_profile.ll
  • Type: lli -load ../../../llvm/Release+Asserts/lib/ mips_profile.ll
  • Type: llvm-prof -annotated-llvm mips_profile.ll llvmprof.out

The “opt” command instruments the original IR and produces a new IR called mips_profile.ll. The new IR keeps track of run-time data as it executes.

The “lli” command executes the instrumented IR using the LLVM interpreter. The “-load” on the command-line is needed because the instrumentation code inserted by the “opt” command needs access to special functions in the “” library. The profiling results are printed to a special file called “llvmprof.out”.

The “llvm-prof” command reads the instrumented IR and the profiling results and it prints out the IR with the profiling data.

So, you will see some output like this, which indicates the number of times each basic block is executed. It also indicates the number of times each edge in the control-flow graph is traversed.

; <label>:1 ; preds = %4, %0

;;; Basic block executed 2 times.
%s.i.0 = phi i32* [ %tmp, %0 ], [ %6, %4 ]
%2 = phi i32 [ 64, %0 ], [ %5, %4 ]
%3 = icmp eq i32 %2, 0
br i1 %3, label %.legup_memset_4.exit_crit_edge, label %4
;;; Out-edge counts: [1.000000e+00 -> .legup_memset_4.exit_crit_edge] [6.400000e+01 -> ]
how_to_run_the_llvm_profiler_--_works_with_legup_3.0.txt · Last modified: 2013/07/25 16:53 by yvonne.z1229