Skip to content

Commit

Permalink
Remove deprecated preloadDialectInContext flag for MlirOptMain that…
Browse files Browse the repository at this point in the history
  • Loading branch information
joker-eph committed Apr 24, 2023
1 parent ffd6f6b commit 9c8db44
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
2 changes: 1 addition & 1 deletion flang/tools/fir-opt/fir-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ int main(int argc, char **argv) {
DialectRegistry registry;
fir::support::registerDialects(registry);
return failed(MlirOptMain(argc, argv, "FIR modular optimizer driver\n",
registry, /*preloadDialectsInContext=*/false));
registry));
}
18 changes: 1 addition & 17 deletions mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ class MlirOptMainConfig {
return success();
}

// Deprecated.
MlirOptMainConfig &preloadDialectsInContext(bool preload) {
preloadDialectsInContextFlag = preload;
return *this;
}
bool shouldPreloadDialectsInContext() const {
return preloadDialectsInContextFlag;
}

/// Show the registered dialects before trying to load the input file.
MlirOptMainConfig &showDialects(bool show) {
showDialectsFlag = show;
Expand Down Expand Up @@ -180,9 +171,6 @@ class MlirOptMainConfig {
/// The callback to populate the pass manager.
std::function<LogicalResult(PassManager &)> passPipelineCallback;

/// Deprecated.
bool preloadDialectsInContextFlag = false;

/// Show the registered dialects before trying to load the input file.
bool showDialectsFlag = false;

Expand Down Expand Up @@ -219,12 +207,8 @@ LogicalResult MlirOptMain(llvm::raw_ostream &outputStream,
/// Implementation for tools like `mlir-opt`.
/// - toolName is used for the header displayed by `--help`.
/// - registry should contain all the dialects that can be parsed in the source.
/// - preloadDialectsInContext will trigger the upfront loading of all
/// dialects from the global registry in the MLIRContext. This option is
/// deprecated and will be removed soon.
LogicalResult MlirOptMain(int argc, char **argv, llvm::StringRef toolName,
DialectRegistry &registry,
bool preloadDialectsInContext = false);
DialectRegistry &registry);

/// Helper wrapper to return the result of MlirOptMain directly from main.
///
Expand Down
6 changes: 1 addition & 5 deletions mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ static LogicalResult processBuffer(raw_ostream &os,
return failure();

// Parse the input file.
if (config.shouldPreloadDialectsInContext())
context.loadAllAvailableDialects();
context.allowUnregisteredDialects(config.shouldAllowUnregisteredDialects());
if (config.shouldVerifyDiagnostics())
context.printOpOnDiagnostic(false);
Expand Down Expand Up @@ -363,8 +361,7 @@ LogicalResult mlir::MlirOptMain(llvm::raw_ostream &outputStream,
}

LogicalResult mlir::MlirOptMain(int argc, char **argv, llvm::StringRef toolName,
DialectRegistry &registry,
bool preloadDialectsInContext) {
DialectRegistry &registry) {
static cl::opt<std::string> inputFilename(
cl::Positional, cl::desc("<input file>"), cl::init("-"));

Expand Down Expand Up @@ -392,7 +389,6 @@ LogicalResult mlir::MlirOptMain(int argc, char **argv, llvm::StringRef toolName,
// Parse pass names in main to ensure static initialization completed.
cl::ParseCommandLineOptions(argc, argv, helpHeader);
MlirOptMainConfig config = MlirOptMainConfig::createFromCLOptions();
config.preloadDialectsInContext(preloadDialectsInContext);

// When reading from stdin and the input is a tty, it is often a user mistake
// and the process "appears to be stuck". Print a message to let the user know
Expand Down
3 changes: 1 addition & 2 deletions mlir/tools/mlir-opt/mlir-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,5 @@ int main(int argc, char **argv) {
::test::registerTestDynDialect(registry);
#endif
return mlir::asMainReturnCode(
mlir::MlirOptMain(argc, argv, "MLIR modular optimizer driver\n", registry,
/*preloadDialectsInContext=*/false));
mlir::MlirOptMain(argc, argv, "MLIR modular optimizer driver\n", registry));
}

0 comments on commit 9c8db44

Please sign in to comment.