[flang-commits] [flang] [flang] Pass to add frame pointer attribute (PR #74598)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Mon Dec 11 03:21:05 PST 2023
================
@@ -248,13 +248,21 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
if (const llvm::opt::Arg *a =
args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
llvm::StringRef s = a->getValue();
- assert(s == "none" || s == "non-leaf" || s == "all");
- if (s == "none")
+
+ if (!(s=="none" || s=="no-leaf" || s=="all")) {
+ const auto debugWarningId = diags.getCustomDiagID(
+ clang::DiagnosticsEngine::Warning, "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);
+ } else {
+ if (s == "non-leaf")
+ opts.setFramePointer(llvm::FramePointerKind::NonLeaf);
+ else
+ opts.setFramePointer(llvm::FramePointerKind::All);
----------------
tblah wrote:
Ahh I missread the old side of the diff. What I liked would be something more like
```
if (s == "option1")
...
else if (s == "option2")
...
else if (s == "option3")
...
else
error!
```
There is no need for braces on any of these because there will only be a single line in the body of the if statements.
Kiran was right that in this case
```
if (cond)
something
else
if (cond2)
foo
else
bar
```
It is a good idea to put braces around the outer if because otherwise it is harder to see to which `if` the final `else` belongs.
https://github.com/llvm/llvm-project/pull/74598
More information about the flang-commits
mailing list