The callback can be used to provide a default pass pipeline.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Support/MlirOptMain.h | ||
---|---|---|
39 | ||
54–56 | ||
57 | I suspect we can keep a forwarding API from the old one to the new one, it can just be implemented as: LogicalResult MlirOptMain(llvm::raw_ostream &outputStream, std::unique_ptr<llvm::MemoryBuffer> buffer, const PassPipelineCLParser &passPipeline, DialectRegistry ®istry, bool splitInputFile, bool verifyDiagnostics, bool verifyPasses, bool allowUnregisteredDialects, bool preloadDialectsInContext) { auto passManagerSetupFn = [&](PassManager &pm) { auto errorHandler = [&](const Twine &msg) { emitError(UnknownLoc::get(pm.getContext())) << msg; return failure(); }; return passPipeline.addToPipeline(pm, errorHandler); }; return MlirOptMain(outputStream, buffer, passManagerSetupFn, registry, splitInputfile, verifyDiagnostics, verifyPasses, allowUnregisteredDialects, preloadDialectsInContext); } | |
mlir/lib/Support/MlirOptMain.cpp | ||
274 | I wouldn't pass the errorHandler in the callback, that's hard to justify document: it seems like leaking the passPipeline.addToPipeline API to me. Instead you should be able to write it above here and capture it: [&](PassManager &pm) { auto errorHandler = [&](const Twine &msg) { emitError(UnknownLoc::get(pm.getContext())) << msg; return failure(); }; return passPipeline.addToPipeline(pm, errorHandler); }, `` But I would add this in the header (see the other comment) |
mlir/include/mlir/Support/MlirOptMain.h | ||
---|---|---|
57 | Forwarding it is a good idea. Should we do it in the header? |
mlir/include/mlir/Support/MlirOptMain.h | ||
---|---|---|
57 | If it does not need to include more header, then sure, but I'm not sure it'd work right now. |
LG,
I was about to push this (building and running the tests), but I saw River's comment so I'll do as soon as they are addressed
Please document this.