diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td --- a/flang/include/flang/Optimizer/Transforms/Passes.td +++ b/flang/include/flang/Optimizer/Transforms/Passes.td @@ -172,7 +172,7 @@ }]; let constructor = "::fir::createExternalNameConversionPass()"; let options = [ - Option<"appendUnderscore", "append-underscore", + Option<"appendUnderscoreOpt", "append-underscore", "bool", /*default=*/"true", "Append trailing underscore to external names."> ]; diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp --- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp +++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp @@ -143,13 +143,14 @@ ExternalNameConversionPass(bool appendUnderscoring) : appendUnderscores(appendUnderscoring) {} - ExternalNameConversionPass() { appendUnderscores = appendUnderscore; } + ExternalNameConversionPass() { usePassOpt = true; } mlir::ModuleOp getModule() { return getOperation(); } void runOnOperation() override; private: bool appendUnderscores; + bool usePassOpt; }; } // namespace @@ -157,9 +158,11 @@ auto op = getOperation(); auto *context = &getContext(); + appendUnderscores = (usePassOpt) ? appendUnderscoreOpt : appendUnderscores; + mlir::RewritePatternSet patterns(context); patterns.insert(context, appendUnderscore); + MangleNameOnAddrOfOp>(context, appendUnderscores); ConversionTarget target(*context); target.addLegalDialect