Skip to content
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

[flang] Default -g to full debug info. #89418

Merged
merged 1 commit into from
Apr 22, 2024
Merged

[flang] Default -g to full debug info. #89418

merged 1 commit into from
Apr 22, 2024

Conversation

abidh
Copy link
Contributor

@abidh abidh commented Apr 19, 2024

Currently, -g defaults to line tables only. This PR changes that to full debug information. This will allow us to test/use the upcoming debug info changes.

Currently, -g defaults to line tables only. This PR changes that to
full debug information. This will allow us to test/use the upcoming
debug info changes.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' flang:driver flang Flang issues not falling into any other category labels Apr 19, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 19, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-flang-driver

Author: None (abidh)

Changes

Currently, -g defaults to line tables only. This PR changes that to full debug information. This will allow us to test/use the upcoming debug info changes.


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

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1-1)
  • (modified) flang/lib/Frontend/CompilerInvocation.cpp (+1)
  • (added) flang/test/Driver/debug-level.f90 (+7)
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index b46bac24503ce1..abe0b931676005 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -118,7 +118,7 @@ void Flang::addOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
     Arg *gNArg = Args.getLastArg(options::OPT_gN_Group);
     DebugInfoKind = debugLevelToInfoKind(*gNArg);
   } else if (Args.hasArg(options::OPT_g_Flag)) {
-    DebugInfoKind = llvm::codegenoptions::DebugLineTablesOnly;
+    DebugInfoKind = llvm::codegenoptions::FullDebugInfo;
   } else {
     DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
   }
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e432c5a302754c..f1b7b53975398e 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -145,6 +145,7 @@ static bool parseDebugArgs(Fortran::frontend::CodeGenOptions &opts,
     }
     opts.setDebugInfo(val.value());
     if (val != llvm::codegenoptions::DebugLineTablesOnly &&
+        val != llvm::codegenoptions::FullDebugInfo &&
         val != llvm::codegenoptions::NoDebugInfo) {
       const auto debugWarning = diags.getCustomDiagID(
           clang::DiagnosticsEngine::Warning, "Unsupported debug option: %0");
diff --git a/flang/test/Driver/debug-level.f90 b/flang/test/Driver/debug-level.f90
new file mode 100644
index 00000000000000..bc0aee166e6a37
--- /dev/null
+++ b/flang/test/Driver/debug-level.f90
@@ -0,0 +1,7 @@
+! RUN: %flang %s -g -c -### 2>&1 | FileCheck %s --check-prefix=FULL
+! RUN: %flang %s -g1 -c -### 2>&1 | FileCheck %s --check-prefix=LINE
+! RUN: %flang %s -gline-tables-only -c -### 2>&1 | FileCheck %s --check-prefix=LINE
+
+! LINE: -debug-info-kind=line-tables-only
+! FULL: -debug-info-kind=standalone
+

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 19, 2024

@llvm/pr-subscribers-clang-driver

Author: None (abidh)

Changes

Currently, -g defaults to line tables only. This PR changes that to full debug information. This will allow us to test/use the upcoming debug info changes.


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

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1-1)
  • (modified) flang/lib/Frontend/CompilerInvocation.cpp (+1)
  • (added) flang/test/Driver/debug-level.f90 (+7)
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index b46bac24503ce1..abe0b931676005 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -118,7 +118,7 @@ void Flang::addOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
     Arg *gNArg = Args.getLastArg(options::OPT_gN_Group);
     DebugInfoKind = debugLevelToInfoKind(*gNArg);
   } else if (Args.hasArg(options::OPT_g_Flag)) {
-    DebugInfoKind = llvm::codegenoptions::DebugLineTablesOnly;
+    DebugInfoKind = llvm::codegenoptions::FullDebugInfo;
   } else {
     DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
   }
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e432c5a302754c..f1b7b53975398e 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -145,6 +145,7 @@ static bool parseDebugArgs(Fortran::frontend::CodeGenOptions &opts,
     }
     opts.setDebugInfo(val.value());
     if (val != llvm::codegenoptions::DebugLineTablesOnly &&
+        val != llvm::codegenoptions::FullDebugInfo &&
         val != llvm::codegenoptions::NoDebugInfo) {
       const auto debugWarning = diags.getCustomDiagID(
           clang::DiagnosticsEngine::Warning, "Unsupported debug option: %0");
diff --git a/flang/test/Driver/debug-level.f90 b/flang/test/Driver/debug-level.f90
new file mode 100644
index 00000000000000..bc0aee166e6a37
--- /dev/null
+++ b/flang/test/Driver/debug-level.f90
@@ -0,0 +1,7 @@
+! RUN: %flang %s -g -c -### 2>&1 | FileCheck %s --check-prefix=FULL
+! RUN: %flang %s -g1 -c -### 2>&1 | FileCheck %s --check-prefix=LINE
+! RUN: %flang %s -gline-tables-only -c -### 2>&1 | FileCheck %s --check-prefix=LINE
+
+! LINE: -debug-info-kind=line-tables-only
+! FULL: -debug-info-kind=standalone
+

Copy link
Contributor

@tblah tblah 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 for splitting all of this into small very easy to review patches.

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.

LGTM

@abidh
Copy link
Contributor Author

abidh commented Apr 22, 2024

I am going to merge this. There is bot failure (trailing whitespace in clang/lib/Serialization/ASTWriter.cpp) which seems unrelated to this PR.

@abidh abidh merged commit 087b33b into llvm:main Apr 22, 2024
8 of 9 checks passed
@abidh abidh deleted the baseline2 branch April 22, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants