I’m trying to get the instruction counts of each function in a single llvm IR.
I try the command below:
opt -enable-new-pm=0 -instcount -stats source_IR.ll
and I get the result like:
I’m trying to get the instruction counts of each function in a single llvm IR.
I try the command below:
opt -enable-new-pm=0 -instcount -stats source_IR.ll
and I get the result like:
Not sure if there’s a better solution, anyway we can achieve it by script like:
$ cat t.sh
#!/bin/bash
for f in $(grep -r define $1 | cut -d @ -f 2 | cut -d ‘(’ -f 1)
do
echo “Function: $f”
llvm-extract -S $1 --func=$f | opt -S -enable-new-pm=0 -instcount -stats > /dev/null
done
$ source t.sh llvm/test/CodeGen/X86/add.ll