[flang-commits] [flang] d85b94b - [Flang] -funderscoring bug fix
Mark Danial via flang-commits
flang-commits at lists.llvm.org
Thu Jul 13 08:31:00 PDT 2023
Author: Mark Danial
Date: 2023-07-13T11:30:35-04:00
New Revision: d85b94bf0080dcd780656c0f5e6342800720eba9
URL: https://github.com/llvm/llvm-project/commit/d85b94bf0080dcd780656c0f5e6342800720eba9
DIFF: https://github.com/llvm/llvm-project/commit/d85b94bf0080dcd780656c0f5e6342800720eba9.diff
LOG: [Flang] -funderscoring bug fix
There was a bug with the -funderscoring / -fno-underscoring options from (https://reviews.llvm.org/D140795) that prevented the driver option from controlling the underscoring behaviour and instead the behaviour could only be controlled by the pass option instead of the driver option. The driver test case did not catch the bug and also needed to be updated.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D155042
Added:
Modified:
flang/include/flang/Optimizer/Transforms/Passes.td
flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
flang/test/Driver/underscoring.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td
index c04b8382bc4800..e6ecdede294842 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -172,7 +172,7 @@ def ExternalNameConversion : Pass<"external-name-interop", "mlir::ModuleOp"> {
}];
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
index a5f58a833132ca..f128a8a52ddd89 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -158,13 +158,14 @@ class ExternalNameConversionPass
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
@@ -172,9 +173,11 @@ void ExternalNameConversionPass::runOnOperation() {
auto op = getOperation();
auto *context = &getContext();
+ appendUnderscores = (usePassOpt) ? appendUnderscoreOpt : appendUnderscores;
+
mlir::RewritePatternSet patterns(context);
patterns.insert<MangleNameOnFuncOp, MangleNameForCommonBlock,
- MangleNameOnAddrOfOp>(context, appendUnderscore);
+ MangleNameOnAddrOfOp>(context, appendUnderscores);
ConversionTarget target(*context);
target.addLegalDialect<fir::FIROpsDialect, LLVM::LLVMDialect,
diff --git a/flang/test/Driver/underscoring.f90 b/flang/test/Driver/underscoring.f90
index a19b193df39fe4..7c03d040504ea5 100644
--- a/flang/test/Driver/underscoring.f90
+++ b/flang/test/Driver/underscoring.f90
@@ -10,15 +10,15 @@ subroutine test()
end
! UNDERSCORING: test_
+! UNDERSCORING-NOT: {{test:$}}
! UNDERSCORING: ext_sub_
+! UNDERSCORING-NOT: {{ext_sub[^_]*$}}
! UNDERSCORING: comblk_
+! UNDERSCORING-NOT: comblk,
! NO-UNDERSCORING-NOT: test_
-! NO-UNDERSCORING-NOT: _QPtest
-! NO-UNDERSCORING: test
+! NO-UNDERSCORING: test:
! NO-UNDERSCORING-NOT: ext_sub_
-! NO-UNDERSCORING-NOT: _QPext_sub
-! NO-UNDERSCORING: ext_sub
+! NO-UNDERSCORING: {{ext_sub[^_]*$}}
! NO-UNDERSCORING-NOT: comblk_
-! NO-UNDERSCORING-NOT: _QBcomblk
-! NO-UNDERSCORING: comblk
+! NO-UNDERSCORING: comblk,
More information about the flang-commits
mailing list