Skip to content

[Driver] Do not add gno-column-info when using sampling PGO #117954

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
merged 3 commits into from
Dec 1, 2024

Conversation

HaohaiWen
Copy link
Contributor

Column info is important for sampling PGO to generate/load profile file.
On windows, it will be automatically added when using -gdwarf to generate
profile file. It should also be generated when fprofile-sample-use= is used.

Column info is important for sampling PGO to generate/load profile file.
On windows, it will be automatically added when using -gdwarf to generate
profile file. It should also be generated when fprofile-sample-use= is
used.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Nov 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 28, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Haohai Wen (HaohaiWen)

Changes

Column info is important for sampling PGO to generate/load profile file.
On windows, it will be automatically added when using -gdwarf to generate
profile file. It should also be generated when fprofile-sample-use= is used.


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

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+6-6)
  • (modified) clang/test/Driver/codeview-column-info.c (+1)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 217c1a845f0a47..b6d39a5186b794 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4690,15 +4690,15 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
   // Column info is included by default for everything except SCE and
-  // CodeView. Clang doesn't track end columns, just starting columns, which,
-  // in theory, is fine for CodeView (and PDB).  In practice, however, the
-  // Microsoft debuggers don't handle missing end columns well, and the AIX
-  // debugger DBX also doesn't handle the columns well, so it's better not to
-  // include any column info.
+  // CodeView if not use sampling PGO. Clang doesn't track end columns, just
+  // starting columns, which, in theory, is fine for CodeView (and PDB).  In
+  // practice, however, the Microsoft debuggers don't handle missing end columns
+  // well, and the AIX debugger DBX also doesn't handle the columns well, so
+  // it's better not to include any column info.
   if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
     (void)checkDebugInfoOption(A, Args, D, TC);
   if (!Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
-                    !EmitCodeView &&
+                    !(EmitCodeView && !getLastProfileSampleUseArg(Args)) &&
                         (DebuggerTuning != llvm::DebuggerKind::SCE &&
                          DebuggerTuning != llvm::DebuggerKind::DBX)))
     CmdArgs.push_back("-gno-column-info");
diff --git a/clang/test/Driver/codeview-column-info.c b/clang/test/Driver/codeview-column-info.c
index 4cabefac06e648..99b1d1d9f94689 100644
--- a/clang/test/Driver/codeview-column-info.c
+++ b/clang/test/Driver/codeview-column-info.c
@@ -14,5 +14,6 @@
 // CHECK: "-gno-column-info"
 
 // RUN: %clang_cl -### /Z7 -gcolumn-info -- %s 2>&1 | FileCheck --check-prefix=COLUMN %s
+// RUN: %clang_cl -### --target=x86_64-windows-msvc /Z7 /fprofile-sample-use=%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=COLUMN %s
 
 // COLUMN-NOT: "-gno-column-info"

@HaohaiWen HaohaiWen merged commit 22417ec into llvm:main Dec 1, 2024
8 checks passed
@HaohaiWen HaohaiWen deleted the column-info branch December 1, 2024 12:54
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants