Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass flags to a LLVM pass?

Tags:

llvm

I'm implementing a LLVM pass, and would like to turn some options on or off via the command line, especially I'd like to have a -v verbose mode for my pass.

I couldn't find a mechanism for passing command line flags mentioned in any of the docs, does one exist?

like image 274
Tzafrir Avatar asked Jan 31 '11 16:01

Tzafrir


2 Answers

The solution I found is to use LLVM's general CommandLine API: http://llvm.org/docs/CommandLine.html

Works as expected in opt when loading the pass dynamically.

like image 92
Tzafrir Avatar answered Sep 19 '22 11:09

Tzafrir


Another useful trick is:

#define DEBUG_TYPE "my-special-name"

...

#include "llvm/Support/Debug.h"

...

Sprinkle a bunch of debug output around:

DEBUG(dbgs() << "Original Frame Size: " << FrameSize << "\n" );

...

DEBUG(Node->dump(CurDAG));

Then, on the command line: ... -debug-only my-special-name ... will get your output.

If your pass is run with the clang front end, you can use:

... -mllvm -debug-only my-special-name ...

like image 22
Richard Pennington Avatar answered Sep 22 '22 11:09

Richard Pennington