[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:05:11 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
----------------
tblah wrote:

Sorry I didn't spot this before. It will match strings other than `"all"`. We should provide an error on an invalid input instead of silently setting it to all.

For example, imagine if Clang added a new frame pointer kind called "apple". Somebody might try to set the frame pointer to "apple" in flang, and they wouldn't get any error telling them it was not supported, but flang would actually set the frame pointer kind to "all": probably not doing what the user wanted.

https://github.com/llvm/llvm-project/pull/74598


More information about the flang-commits mailing list