MlirOptMain call the function multiple times


I want to call MlirOptMain function(llvm-project/mlir/lib/Support/MlirOptMain.cpp) multiple times for different files. But I can’t call the function more than once because the command line options are created and initialized only once.

  static cl::opt<std::string> inputFilename(
      cl::Positional, cl::desc("<input file>"), cl::init("-"));

  static cl::opt<std::string> outputFilename("o", cl::desc("Output filename"),

How can I run MlirOptMain function multiple times?

The options will be registered once, but the parsing happens on each invocation isn’t it? llvm-project/MlirOptMain.cpp at main · llvm/llvm-project · GitHub