Reputation: 1
I used to be able to do:
$ opt -analyze -loops app2/app2.ll
Printing analysis 'Natural Loop Information' for function 'rotf':
Loop at depth 1 containing: %4<header><exiting>,%7,%10,%27,%31<latch>,%14,%24
Loop at depth 2 containing: %10<header><exiting>,%14,%24<latch>
Printing analysis 'Natural Loop Information' for function 'rotf2':
Loop at depth 1 containing: %4<header><exiting>,%7,%10,%27,%31<latch>,%14,%24
Loop at depth 2 containing: %10<header><exiting>,%14,%24<latch>
Printing analysis 'Natural Loop Information' for function 'main':
Loop at depth 1 containing: %4<header><exiting>,%7,%15,%11,%19,%24,%28,%29<latch>
How do I get this information with the new pass manager? The docs are failing me.
$ opt -p print-loops app2/app2.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
opt: unknown pass name 'print-loops'
$ opt -p print-analyze-loops app2/app2.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
opt: unknown pass name 'print-analyze-loops'
Upvotes: 0
Views: 227
Reputation: 1
It turns out, the opt
program has a bug, as pointed out here: https://discourse.llvm.org/t/need-usage-help-w-new-pass-manager-for-opt-analysis-natural-loop-information/75874.
The LoopPrinterPass
fails to define isRequired()
so the output is dropped.
A work-around is to generate the LLVM IR code (via clang) with the -O1
flag, which has other side effects; but then allows opt
to generate the Natural Loop Information with the following syntax:
clang -S -emit-llvm app2.c -O1 -o app2.ll
opt app2.ll -passes="print<loops>" -disable-output
Upvotes: 0