I have a number of C source code files, on which I would like to perform some type of static analysis. First, I need to get rid of any loop in the control flow graph, for which I use the following one-liners:
~$ clang -emit-llvm -c file.c -o file.bc
~$ opt -Oz -mem2reg -simplifycfg -loops -lcssa -loop-rotate -loop-unroll \
-unroll-threshold=1000000000 -unroll-count=3000 file.bc -o target.bc
I would like to know whether the resulting bytecode in target.bc
still contains some loop, e.g. because it was not possible to unroll it with the given parameters.
One option would be to use llvm-dis
, parse the result into a control flow graph and then check whether any loop exists.
However, I would like to avoid reinventing the wheel and resort on existing command-line tools.
Q: Would you be able to point me one of such tools, and how to use it?