How to pass an option to a user-defined pass

Hi, I used the following code to define an option passed by user in a user-defined pass:

static cl::opt<bool> InstrumentdFile("InstrumentdFile",
                                     cl::desc("Is an instrumented file?"),
                                     cl::init(false), cl::Hidden);

Then I compiled the pass into a lib, I use the command to execute the pass

opt -load-pass-plugin=**.so -passes="**" -InstrumentdFile=1 ...

But I got the following error:

opt: Unknown command line argument '-InstrumentdFile=1'.  Try: 'opt --help'
opt: Did you mean '--instrorderfile'?

My opt version is 14.0.6

If I delete the -InstrumentdFile=1, the pass executes successfully. How Can I fix this?

All options get parsed before any actions are taken, including loading the plugin, so I think you cannot use cl::opt in a plugin. I don’t do a lot of work with passes so I am not sure how to solve this.