Skip to content

[Flang] Fix options for FunctionAttr pass #126819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

rscottmanley
Copy link
Contributor

For non-basic types GenericOptionParser::findArgStrForValue will return null, ultimately an llvm_unreachable, when the specific values are not found. Add the enum, much like the debug-level option in AddDebugInfo to resolve this problem. Also change tuneCPU to be std::string or it will also fail.

For non-basic types GenericOptionParser::findArgStrForValue will return
null when the specific values are not found. Add the enum, much like the
debug-level option in AddDebugInfo to resolve this problem. Also change
tuneCPU to be std::string or it will also have the same problem.
@rscottmanley rscottmanley self-assigned this Feb 11, 2025
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Feb 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 11, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Scott Manley (rscottmanley)

Changes

For non-basic types GenericOptionParser::findArgStrForValue will return null, ultimately an llvm_unreachable, when the specific values are not found. Add the enum, much like the debug-level option in AddDebugInfo to resolve this problem. Also change tuneCPU to be std::string or it will also fail.


Full diff: https://github.com/llvm/llvm-project/pull/126819.diff

1 Files Affected:

  • (modified) flang/include/flang/Optimizer/Transforms/Passes.td (+26-23)
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td
index 61f8b0835c958..0b6e0119c16c3 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -383,30 +383,33 @@ def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
      freeing up an additional register in numerous functions. However, this
      approach can make debugging unfeasible on certain machines.
   }];
-  let options = [
-    Option<"framePointerKind", "frame-pointer",
-           "mlir::LLVM::framePointerKind::FramePointerKind", 
-           /*default=*/"mlir::LLVM::framePointerKind::FramePointerKind{}",
-           "frame pointer">,
-    Option<"noInfsFPMath", "no-infs-fp-math",
-           "bool", /*default=*/"false",
-           "Set the no-infs-fp-math attribute on functions in the module.">,
-    Option<"noNaNsFPMath", "no-nans-fp-math",
-           "bool", /*default=*/"false",
-           "Set the no-nans-fp-math attribute on functions in the module.">,
-    Option<"approxFuncFPMath", "approx-func-fp-math",
-           "bool", /*default=*/"false",
+  let options =
+      [Option<"framePointerKind", "frame-pointer",
+              "mlir::LLVM::framePointerKind::FramePointerKind",
+              /*default=*/"mlir::LLVM::framePointerKind::FramePointerKind{}",
+              "frame pointer", [{::llvm::cl::values(
+            clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::None, "None", ""),
+            clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::NonLeaf, "NonLeaf", ""),
+            clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::All, "All", ""),
+            clEnumValN(mlir::LLVM::framePointerKind::FramePointerKind::Reserved, "Reserved", "")
+          )}]>,
+       Option<"noInfsFPMath", "no-infs-fp-math", "bool", /*default=*/"false",
+              "Set the no-infs-fp-math attribute on functions in the module.">,
+       Option<"noNaNsFPMath", "no-nans-fp-math", "bool", /*default=*/"false",
+              "Set the no-nans-fp-math attribute on functions in the module.">,
+       Option<
+           "approxFuncFPMath", "approx-func-fp-math", "bool",
+           /*default=*/"false",
            "Set the approx-func-fp-math attribute on functions in the module.">,
-    Option<"noSignedZerosFPMath", "no-signed-zeros-fp-math",
-           "bool", /*default=*/"false",
-           "Set the no-signed-zeros-fp-math attribute on functions in the module.">,
-    Option<"unsafeFPMath", "unsafe-fp-math",
-           "bool", /*default=*/"false",
-           "Set the unsafe-fp-math attribute on functions in the module.">,
-    Option<"tuneCPU", "tune-cpu",
-           "llvm::StringRef", /*default=*/"llvm::StringRef{}",
-           "Set the tune-cpu attribute on functions in the module.">,
-];
+       Option<"noSignedZerosFPMath", "no-signed-zeros-fp-math", "bool",
+              /*default=*/"false",
+              "Set the no-signed-zeros-fp-math attribute on functions in the "
+              "module.">,
+       Option<"unsafeFPMath", "unsafe-fp-math", "bool", /*default=*/"false",
+              "Set the unsafe-fp-math attribute on functions in the module.">,
+       Option<"tuneCPU", "tune-cpu", "std::string", /*default=*/"",
+              "Set the tune-cpu attribute on functions in the module.">,
+  ];
 }
 
 def AssumedRankOpConversion : Pass<"fir-assumed-rank-op", "mlir::ModuleOp"> {

Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rscottmanley rscottmanley merged commit cbe879d into llvm:main Feb 12, 2025
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building flang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/16448

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
73.474 [176/19/7135] Creating library symlink lib/libbenchmark_main.so.0 lib/libbenchmark_main.so
74.040 [176/18/7136] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/CompilerGeneratedNames.cpp.o
74.549 [176/17/7137] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/LoopVersioning.cpp.o
74.958 [176/16/7138] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/MemoryAllocation.cpp.o
75.612 [176/15/7139] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/MemRefDataFlowOpt.cpp.o
75.676 [176/14/7140] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AddDebugInfo.cpp.o
76.016 [176/13/7141] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AffineDemotion.cpp.o
76.045 [176/12/7142] Linking CXX shared library lib/libFortranEvaluate.so.21.0git
76.051 [175/12/7143] Creating library symlink lib/libFortranEvaluate.so
76.622 [173/13/7144] Building CXX object tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o
FAILED: tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o 
/usr/local/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/flang/lib/Optimizer/Passes -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/lib/Optimizer/Passes -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/../mlir/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/mlir/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/clang/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/../clang/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fPIC  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o -MF tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o.d -o tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o -c /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/lib/Optimizer/Passes/Pipelines.cpp
../llvm-project/flang/lib/Optimizer/Passes/Pipelines.cpp:329:27: error: missing field 'tuneCPU' initializer [-Werror,-Wmissing-field-initializers]
  329 |        config.UnsafeFPMath}));
      |                           ^
1 error generated.
76.785 [173/12/7145] Linking CXX shared library lib/libFIRBuilder.so.21.0git
76.902 [173/11/7146] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/ArrayValueCopy.cpp.o
77.046 [173/10/7147] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AbstractResult.cpp.o
77.541 [173/9/7148] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/SimplifyIntrinsics.cpp.o
78.385 [173/8/7149] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/StackArrays.cpp.o
81.736 [173/7/7150] Linking CXX shared library lib/libFortranSemantics.so.21.0git
96.115 [173/6/7151] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/PolymorphicOpConversion.cpp.o
124.963 [173/5/7152] Building CXX object tools/flang/tools/tco/CMakeFiles/tco.dir/tco.cpp.o
126.499 [173/4/7153] Building CXX object tools/flang/tools/fir-opt/CMakeFiles/fir-opt.dir/fir-opt.cpp.o
175.255 [173/3/7154] Building CXX object tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o
191.832 [173/2/7155] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Bridge.cpp.o
279.175 [173/1/7156] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 12, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building flang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/19806

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
53.426 [107/24/6577] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AddAliasTags.cpp.o
54.122 [107/23/6578] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AffinePromotion.cpp.o
54.143 [107/22/6579] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/ControlFlowConverter.cpp.o
54.319 [107/21/6580] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AffineDemotion.cpp.o
57.672 [107/20/6581] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AbstractResult.cpp.o
64.311 [107/19/6582] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/SimplifyRegionLite.cpp.o
66.731 [107/18/6583] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/VScaleAttr.cpp.o
68.623 [107/17/6584] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AlgebraicSimplification.cpp.o
70.802 [107/16/6585] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/FunctionAttr.cpp.o
71.512 [107/15/6586] Building CXX object tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o
FAILED: tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/lib/Optimizer/Passes -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Optimizer/Passes -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/../mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o -MF tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o.d -o tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Optimizer/Passes/Pipelines.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Optimizer/Passes/Pipelines.cpp:329:27: error: missing field 'tuneCPU' initializer [-Werror,-Wmissing-field-initializers]
  329 |        config.UnsafeFPMath}));
      |                           ^
1 error generated.
73.439 [107/14/6587] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/MemoryAllocation.cpp.o
76.563 [107/13/6588] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/ExternalNameConversion.cpp.o
76.812 [107/12/6589] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/StackReclaim.cpp.o
77.620 [107/11/6590] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/LoopVersioning.cpp.o
77.949 [107/10/6591] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AddDebugInfo.cpp.o
78.413 [107/9/6592] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/StackArrays.cpp.o
79.390 [107/8/6593] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/SimplifyIntrinsics.cpp.o
81.210 [107/7/6594] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/ArrayValueCopy.cpp.o
84.505 [107/6/6595] Building CXX object tools/flang/tools/fir-opt/CMakeFiles/fir-opt.dir/fir-opt.cpp.o
85.226 [107/5/6596] Building CXX object tools/flang/tools/tco/CMakeFiles/tco.dir/tco.cpp.o
87.691 [107/4/6597] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/PolymorphicOpConversion.cpp.o
131.809 [107/3/6598] Building CXX object tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o
227.324 [107/2/6599] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Bridge.cpp.o
520.695 [107/1/6600] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o
ninja: build stopped: subcommand failed.

flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
For non-basic types GenericOptionParser::findArgStrForValue will return
null, ultimately an llvm_unreachable, when the specific values are not
found. Add the enum, much like the debug-level option in AddDebugInfo to
resolve this problem. Also change tuneCPU to be std::string or it will
also fail.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
For non-basic types GenericOptionParser::findArgStrForValue will return
null, ultimately an llvm_unreachable, when the specific values are not
found. Add the enum, much like the debug-level option in AddDebugInfo to
resolve this problem. Also change tuneCPU to be std::string or it will
also fail.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
For non-basic types GenericOptionParser::findArgStrForValue will return
null, ultimately an llvm_unreachable, when the specific values are not
found. Add the enum, much like the debug-level option in AddDebugInfo to
resolve this problem. Also change tuneCPU to be std::string or it will
also fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants