[flang-commits] [llvm] [clang-tools-extra] [flang] [clang] [flang] Pass to add frame pointer attribute (PR #74598)
Andrzej WarzyĆski via flang-commits
flang-commits at lists.llvm.org
Wed Dec 20 00:59:32 PST 2023
================
@@ -245,6 +245,24 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
opts.AliasAnalysis = opts.OptimizationLevel > 0;
+ if (const llvm::opt::Arg *a =
+ args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+ llvm::StringRef s = a->getValue();
+
+ if (!(s == "none" || s == "non-leaf" || s == "all")) {
+ const auto debugWarningId = diags.getCustomDiagID(
+ clang::DiagnosticsEngine::Error, "Frame pointer: %0");
+ diags.Report(debugWarningId).AddString(a->getValue());
+ }
+
+ if (s == "none")
+ opts.setFramePointer(llvm::FramePointerKind::None);
+ else if (s == "non-leaf")
+ opts.setFramePointer(llvm::FramePointerKind::NonLeaf);
+ else
+ opts.setFramePointer(llvm::FramePointerKind::All);
----------------
banach-space wrote:
1. You don't need `else` in this block.
2. You could use `llvm::StringSwitch` and use the default value to mark a failure (as opposed to `if (!(s == "none" || s == "non-leaf" || s == "all"))` above)
https://github.com/llvm/llvm-project/pull/74598
More information about the flang-commits
mailing list