Warnings when using opt for read-only (preserving) passes

Hi,

I've written a FunctionPass that happens to be read-only (preserving): It doesn't modify the code in any way; it just does some analysis and dumps out the results for each function by overriding FunctionPass::print. I now need to make some changes to the pass, and these changes will mean that the results cannot be known until all functions have been visited. So there's no longer anything to do in FunctionPass::print. Instead I only need to call printf in FunctionPass::doFinalization to dump the final results.

This presents a minor problem. Taking out FunctionPass::print causes "opt -analyze ..." to give warnings: "Pass::print not implemented for pass!" Okay, makes sense, but when I take out the -analyze parameter, I get another warning: "WARNING: You're attempting to print out a bitcode file ..." This also makes sense, because opt assumes my pass has modified the code in some way, so it's trying to output the modifications.

But how can I get rid of these warnings? I can suppress the second one by adding "2> /dev/null" to the opt command, but that suppresses the entire error stream, which isn't good. I also tried converting my FunctionPass into a ModulePass, and iterating over the functions manually, but I ran into problems because I can't seem to require a function pass, such as UnifyFunctionExitNodes, to run on a function if I'm within a ModulePass.

Any other suggestions? Thanks,

Trevor

Trevor Harmon wrote:

Hi,

I've written a FunctionPass that happens to be read-only (preserving):
It doesn't modify the code in any way; it just does some analysis and
dumps out the results for each function by overriding
FunctionPass::print. I now need to make some changes to the pass, and
these changes will mean that the results cannot be known until all
functions have been visited. So there's no longer anything to do in
FunctionPass::print. Instead I only need to call printf in
FunctionPass::doFinalization to dump the final results.

This presents a minor problem. Taking out FunctionPass::print causes
"opt -analyze ..." to give warnings: "Pass::print not implemented for
pass!" Okay, makes sense, but when I take out the -analyze parameter,
I get another warning: "WARNING: You're attempting to print out a
bitcode file ..." This also makes sense, because opt assumes my pass
has modified the code in some way, so it's trying to output the
modifications.

But how can I get rid of these warnings?

opt -disable-output ...

  I can suppress the second one

Thanks, that works nicely.

Any thoughts on why this parameter isn't mentioned in the docs (http://llvm.org/cmds/opt.html) or in the "opt --help" output? Was it just an oversight?

Trevor