llvmllvm-clangllvm-3.0

Number of load instruction in a program


How to count total number of load instruction on a simple "hello world" program through LLVM ??


Solution

  • Write a pass which iterates over all the instructions in the module, then count the number of instructions that fulfil isa<LoadInst>(I).

    See the programmer's manual for how to iterate over all the instructions.

    If you're not sure how to write a pass, take a look at this handy guide.