From 22417ec6cca0ed8ccecb0c2b77011e591378fd2a Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Sun, 1 Dec 2024 20:54:38 +0800 Subject: [PATCH] [Driver] Do not add gno-column-info when using sampling PGO (#117954) 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. --- clang/lib/Driver/ToolChains/Clang.cpp | 12 ++++++------ clang/test/Driver/codeview-column-info.c | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) 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..0f1671a73acd57 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"