[clang] [llvm] Update documentation and release notes for llvm-profgen COFF support (PR #84864)
https://github.com/HaohaiWen approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/84864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Update documentation and release notes for llvm-profgen COFF support (PR #84864)
@@ -2434,6 +2449,15 @@ usual build cycle when using sample profilers for optimization: it provides better call information, which improves the accuracy of the profile data. + When using SEP: + + .. code-block:: console + + $ sep -start -ec BR_INST_RETIRED.NEAR_TAKEN:precise=yes:pdir -lbr no_filter:usr -perf-script ip,brstack -app ./code HaohaiWen wrote: Should we add `-out code.tb7 to sep'? Otherwise sep will generate a temp name (tbs17644.perf.data.script in my env). e.g. ``` sep -start -out code.tb7 -ec BR_INST_RETIRED.NEAR_TAKEN:precise=yes:pdir -lbr no_filter:usr -perf-script brstack -app ./code ``` https://github.com/llvm/llvm-project/pull/84864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Update documentation and release notes for llvm-profgen COFF support (PR #84864)
@@ -2434,6 +2449,15 @@ usual build cycle when using sample profilers for optimization: it provides better call information, which improves the accuracy of the profile data. + When using SEP: + + .. code-block:: console + + $ sep -start -ec BR_INST_RETIRED.NEAR_TAKEN:precise=yes:pdir -lbr no_filter:usr -perf-script ip,brstack -app ./code + + This produces a ``perf.data.script`` output which can be used with HaohaiWen wrote: Should change to code.perf.data.script if specify -out code.tb7 https://github.com/llvm/llvm-project/pull/84864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Update documentation and release notes for llvm-profgen COFF support (PR #84864)
@@ -2434,6 +2449,15 @@ usual build cycle when using sample profilers for optimization: it provides better call information, which improves the accuracy of the profile data. + When using SEP: + + .. code-block:: console + + $ sep -start -ec BR_INST_RETIRED.NEAR_TAKEN:precise=yes:pdir -lbr no_filter:usr -perf-script ip,brstack -app ./code HaohaiWen wrote: I think we should remove ip on output perf script and just leave `-perf-script brstack` https://github.com/llvm/llvm-project/pull/84864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Update documentation and release notes for llvm-profgen COFF support (PR #84864)
@@ -2454,7 +2481,14 @@ usual build cycle when using sample profilers for optimization: .. code-block:: console - $ llvm-profgen --binary=./code --output=code.prof--perfdata=perf.data + $ llvm-profgen --binary=./code --output=code.prof --perfdata=perf.data + + When using SEP the output is in the textual format corresponding to + ``llvm-profgen --perfscript``. For example: + + .. code-block:: console + + $ llvm-profgen --binary=./code --output=code.prof --perfscript=perf.data.script HaohaiWen wrote: code.perf.data.script https://github.com/llvm/llvm-project/pull/84864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f97b61e - [Driver][MSVC] Support DWARF fission when using LTO on Windows
Author: Haohai Wen Date: 2023-07-06T22:18:58+08:00 New Revision: f97b61ed27aa6b0cef21e86e71d683feab32ce34 URL: https://github.com/llvm/llvm-project/commit/f97b61ed27aa6b0cef21e86e71d683feab32ce34 DIFF: https://github.com/llvm/llvm-project/commit/f97b61ed27aa6b0cef21e86e71d683feab32ce34.diff LOG: [Driver][MSVC] Support DWARF fission when using LTO on Windows D154070 has added /dwodir to lld/COFF to tells LTO backend to create dwo directory and files. This patch makes clang to emit /dwodir to lld when user specify -gsplit-dwarf with LTO. This behavior is simiar to DWARF fission with LTO for ELF. A simple use case: $clang-cl -c -flto -gdwarf main.c -o main.o $clang-cl -c -flto -gdwarf a.c -o a.o $clang-cl -flto -fuse-ld=lld -gdwarf -gsplit-dwarf main.o a.o This'll generate a dwo file: main.exe_dwo/0.dwo Reviewed By: mstorsjo, MaskRay, hans Differential Revision: https://reviews.llvm.org/D154295 Added: Modified: clang/lib/Driver/ToolChains/MSVC.cpp clang/test/Driver/lto-dwo.c Removed: diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 6b2eaef1f2e7d1..4a6989d113f82b 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -277,11 +277,18 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, else if (Linker.equals_insensitive("lld")) Linker = "lld-link"; - if (Linker == "lld-link") + if (Linker == "lld-link") { for (Arg *A : Args.filtered(options::OPT_vfsoverlay)) CmdArgs.push_back( Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue())); +if (C.getDriver().isUsingLTO() && +Args.hasFlag(options::OPT_gsplit_dwarf, options::OPT_gno_split_dwarf, + false)) + CmdArgs.push_back(Args.MakeArgString(Twine("/dwodir:") + + Output.getFilename() + "_dwo")); + } + // Add filenames, libraries, and other linker inputs. for (const auto &Input : Inputs) { if (Input.isFilename()) { diff --git a/clang/test/Driver/lto-dwo.c b/clang/test/Driver/lto-dwo.c index 0bac5f25d4daac..206d4cba7f2a92 100644 --- a/clang/test/Driver/lto-dwo.c +++ b/clang/test/Driver/lto-dwo.c @@ -1,6 +1,9 @@ // Confirm that -gsplit-dwarf=DIR is passed to linker // RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t -// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s +// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s +// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto -gsplit-dwarf -o a.out -- %s 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s // -// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo" +// CHECK-LINK-ELF-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo" +// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 82dff24 - Reland [COFF] Support -gsplit-dwarf for COFF on Windows
Author: Haohai Wen Date: 2023-06-26T15:48:38+08:00 New Revision: 82dff24bde112984314568e7d581379fd0ea48e6 URL: https://github.com/llvm/llvm-project/commit/82dff24bde112984314568e7d581379fd0ea48e6 DIFF: https://github.com/llvm/llvm-project/commit/82dff24bde112984314568e7d581379fd0ea48e6.diff LOG: Reland [COFF] Support -gsplit-dwarf for COFF on Windows This relands 3eee5aa528abd67bb6d057e25ce1980d0d38c445 with fixes. Added: llvm/test/DebugInfo/COFF/dwarf-headers.ll llvm/test/DebugInfo/COFF/fission-cu.ll llvm/test/DebugInfo/COFF/fission-sections.ll Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/split-debug.c llvm/include/llvm/MC/MCWinCOFFObjectWriter.h llvm/lib/MC/MCAsmBackend.cpp llvm/lib/MC/WinCOFFObjectWriter.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index bb3d487886eb7..77dcef9c73b9e 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3434,11 +3434,13 @@ defm column_info : BoolOption<"g", "column-info", CodeGenOpts<"DebugColumnInfo">, DefaultTrue, NegFlag, PosFlag, BothFlags<[CoreOption]>>, Group; -def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group; +def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group, + Flags<[CoreOption]>; def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group, - HelpText<"Set DWARF fission mode">, + Flags<[CoreOption]>, HelpText<"Set DWARF fission mode">, Values<"split,single">; -def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group; +def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group, + Flags<[CoreOption]>; def gsimple_template_names : Flag<["-"], "gsimple-template-names">, Group; def gsimple_template_names_EQ : Joined<["-"], "gsimple-template-names=">, diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 696db21d97c51..1580f092bcde0 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3925,12 +3925,13 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args, // `-dumpdir x-` to cc1. If -o is unspecified, use // stem(getDefaultImageName()) (usually stem("a.out") = "a"). if (!Args.hasArg(options::OPT_dumpdir)) { + Arg *FinalOutput = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o); Arg *Arg = Args.MakeSeparateArg( nullptr, getOpts().getOption(options::OPT_dumpdir), - Args.MakeArgString(Args.getLastArgValue( - options::OPT_o, - llvm::sys::path::stem(getDefaultImageName())) + - "-")); + Args.MakeArgString( + (FinalOutput ? FinalOutput->getValue() + : llvm::sys::path::stem(getDefaultImageName())) + + "-")); Arg->claim(); Args.append(Arg); } diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index de22ea4455fa7..82e135012d6c9 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5647,7 +5647,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // can propagate it to the backend. bool SplitDWARF = (DwarfFission != DwarfFissionKind::None) && (TC.getTriple().isOSBinFormatELF() || - TC.getTriple().isOSBinFormatWasm()) && + TC.getTriple().isOSBinFormatWasm() || + TC.getTriple().isOSBinFormatCOFF()) && (isa(JA) || isa(JA) || isa(JA)); if (SplitDWARF) { diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 4afe3cc1f7a6e..61b26cf1d3d19 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1278,7 +1278,7 @@ const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args, if (const Arg *A = Args.getLastArg(options::OPT_dumpdir)) { T = A->getValue(); } else { -Arg *FinalOutput = Args.getLastArg(options::OPT_o); +Arg *FinalOutput = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o); if (FinalOutput && Args.hasArg(options::OPT_c)) { T = FinalOutput->getValue(); llvm::sys::path::remove_filename(T); diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index e45d2e19bb81e..269c3ae264d69 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -16,6 +16,7 @@ // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT // RUN: %clang -### -c -target amdgcn-amd-amdhsa -gsplit-dwarf -g %s 2>&1 | FileCheck
[clang] [Driver] Remove ignored Flag form of -fauto-profile/-fprofile-sample-use (PR #113528)
@@ -1729,8 +1729,6 @@ defm gnu_inline_asm : BoolFOption<"gnu-inline-asm", "Disable GNU style inline asm">, PosFlag>; -def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group, -Visibility<[ClangOption, CLOption]>; def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group, HaohaiWen wrote: Why don't also remove -fno-profile-sample-use and just leave -fprofile-sample-use=. Is there any scenario to use -fno-profile-sample-use? https://github.com/llvm/llvm-project/pull/113528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Do not add gno-column-info when using sampling PGO (PR #117954)
https://github.com/HaohaiWen created https://github.com/llvm/llvm-project/pull/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. >From 2307a8441a97fe5d436945c5826302d3e4c10147 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Fri, 22 Nov 2024 13:21:24 +0800 Subject: [PATCH] [Driver] Do not add gno-column-info when using sampling PGO 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..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" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Support fprofile-sample-use= for CL (PR #117282)
HaohaiWen wrote: > Adding CLOption to -fprofile-sample-use= suffices. We don't need these > CLJoined aliases. They are for MSVC options that are ported to clang. For > clang-specific options, we don't want to add unneeded aliases. Got it. I checked CL flags with MSVC. You're right. Let me revert those SLASH flags. https://github.com/llvm/llvm-project/pull/117282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Remove non MSVC CL flags /fprofile-sample-use (PR #117970)
https://github.com/HaohaiWen created https://github.com/llvm/llvm-project/pull/117970 Those flags are introduced in #117282. They are not supported by MSVC. >From 9809cd44885c43e879056db32fb2dcd8da580019 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 28 Nov 2024 15:08:44 +0800 Subject: [PATCH] [Driver] Remove non MSVC CL flags /fprofile-sample-use Those flags are introduced in #117282. They are not supported by MSVC. --- clang/include/clang/Driver/Options.td | 2 -- clang/test/Driver/cl-options.c| 6 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d3142fbdb06e69..9c356c9d2ea4ef 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8506,8 +8506,6 @@ def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias, A def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">, HelpText<"Enable AddressSanitizer">, Alias, AliasArgs<["address"]>; -def : CLJoined<"fprofile-sample-use:">, Alias; -def : CLJoined<"fprofile-sample-use=">, Alias; def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>, HelpText<"Assume thread-local variables are defined in the executable">; def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">; diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 695c0cfacd4b44..477e8489e74280 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -101,11 +101,6 @@ // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata" // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof" -// RUN: %clang_cl -### /FA -fprofile-sample-use=%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=CHECK-PROFILE-SAMPLE-USE %s -// RUN: %clang_cl -### /FA /fprofile-sample-use=%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=CHECK-PROFILE-SAMPLE-USE %s -// RUN: %clang_cl -### /FA /fprofile-sample-use:%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=CHECK-PROFILE-SAMPLE-USE %s -// CHECK-PROFILE-SAMPLE-USE: "-fprofile-sample-use={{.*}}/file.prof" - // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s // GA: -ftls-model=local-exec @@ -718,6 +713,7 @@ // RUN: -fbracket-depth=123 \ // RUN: -fprofile-generate \ // RUN: -fprofile-generate=dir \ +// RUN: -fprofile-sample-use=%S/Inputs/file.prof \ // RUN: -fno-profile-generate \ // RUN: -fno-profile-instr-generate \ // RUN: -fno-profile-instr-use \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Support fprofile-sample-use= for CL (PR #117282)
https://github.com/HaohaiWen closed https://github.com/llvm/llvm-project/pull/117282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix description for fprofile-sample-use= on Windows (PR #117973)
HaohaiWen wrote: /fprofile-sample-use was introduced in #117282 and waived in #117970 . https://github.com/llvm/llvm-project/pull/117973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Do not add gno-column-info when using sampling PGO (PR #117954)
https://github.com/HaohaiWen updated https://github.com/llvm/llvm-project/pull/117954 >From 2307a8441a97fe5d436945c5826302d3e4c10147 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Fri, 22 Nov 2024 13:21:24 +0800 Subject: [PATCH 1/2] [Driver] Do not add gno-column-info when using sampling PGO 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..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" >From 0233d9199420d280fe6d92f7ed70d69903a0d904 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 28 Nov 2024 15:46:34 +0800 Subject: [PATCH 2/2] Update flag --- clang/test/Driver/codeview-column-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Driver/codeview-column-info.c b/clang/test/Driver/codeview-column-info.c index 99b1d1d9f94689..0f1671a73acd57 100644 --- a/clang/test/Driver/codeview-column-info.c +++ b/clang/test/Driver/codeview-column-info.c @@ -14,6 +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 +// 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" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Remove non MSVC CL flags /fprofile-sample-use (PR #117970)
https://github.com/HaohaiWen closed https://github.com/llvm/llvm-project/pull/117970 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix description for fprofile-sample-use= on Windows (PR #117973)
https://github.com/HaohaiWen closed https://github.com/llvm/llvm-project/pull/117973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix description for fprofile-sample-use= on Windows (PR #117973)
https://github.com/HaohaiWen created https://github.com/llvm/llvm-project/pull/117973 We only support -fprofile-sample-use= for clang-cl. >From 8a922dd6dc115878c5e488345885432b4ec9f16f Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 28 Nov 2024 15:38:44 +0800 Subject: [PATCH] [clang] Fix description for fprofile-sample-use= on Windows We only support -fprofile-sample-use= for clang-cl. --- clang/docs/UsersManual.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index e5d67bc58350c7..43b41a2a826890 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -2660,7 +2660,7 @@ usual build cycle when using sample profilers for optimization: > clang-cl /O2 -gdwarf -gline-tables-only ^ /clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^ - /fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf + -fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf [OPTIONAL] Sampling-based profiles can have inaccuracies or missing block/ edge counters. The profile inference algorithm (profi) can be used to infer @@ -2679,7 +2679,7 @@ usual build cycle when using sample profilers for optimization: > clang-cl /clang:-fsample-profile-use-profi /O2 -gdwarf -gline-tables-only ^ /clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^ - /fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf + -fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf Sample Profile Formats "" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Remove ignored Flag form of -fauto-profile/-fprofile-sample-use (PR #113528)
https://github.com/HaohaiWen approved this pull request. https://github.com/llvm/llvm-project/pull/113528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Support fprofile-sample-use= for CL (PR #117282)
@@ -2660,7 +2660,7 @@ usual build cycle when using sample profilers for optimization: > clang-cl /O2 -gdwarf -gline-tables-only ^ /clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^ - /fprofile-sample-use=code.prof code.cc /Fe:code /fuse-ld=lld /link /debug:dwarf HaohaiWen wrote: Yes. I checked options.td. -fprofile-sample-use was not a CLOption and there's no /fuse-ld. https://github.com/llvm/llvm-project/pull/117282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Do not add gno-column-info when using sampling PGO (PR #117954)
https://github.com/HaohaiWen closed https://github.com/llvm/llvm-project/pull/117954 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Support fprofile-sample-use= for CL (PR #117282)
@@ -8484,6 +8484,9 @@ def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias, A def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">, HelpText<"Enable AddressSanitizer">, Alias, AliasArgs<["address"]>; +def : CLJoined<"fno-profile-sample-use">, Alias; HaohaiWen wrote: For me, /fprofile-sample-use= is needed. I saw other CL _EQ flags has _COL alias. In fact, I don't really need /fno-profile-sample-use. https://github.com/llvm/llvm-project/pull/117282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)
@@ -1055,11 +1055,11 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>, def offload_link : Flag<["--"], "offload-link">, Group, HelpText<"Use the new offloading linker to perform the link job.">; def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>, - Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>, + Visibility<[ClangOption, FlangOption]>, HaohaiWen wrote: For clang-cl, /link would pass all args after it to linker and that would cause some trouble when using cmake. e.g. cmake may use clang-cl as "linker" and append some args after flags specified by CMAKE_EXE_LINKER_FLAGS. In that case, -Xlinker is better choice. https://github.com/llvm/llvm-project/pull/118640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)
HaohaiWen wrote: Better to double check with author who specified those CL flags. https://github.com/llvm/llvm-project/pull/118640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)
https://github.com/HaohaiWen edited https://github.com/llvm/llvm-project/pull/118640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)
https://github.com/HaohaiWen approved this pull request. LGTM for -Xlinker. https://github.com/llvm/llvm-project/pull/118640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)
HaohaiWen wrote: @MaskRay, may need to merge https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/fprofile-sample-use.c to clang/test/Driver/unknown-arg-drivermodes.test https://github.com/llvm/llvm-project/pull/118640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Support fprofile-sample-use= for CL (PR #117282)
https://github.com/HaohaiWen created https://github.com/llvm/llvm-project/pull/117282 Sampling PGO has already been supported on Windows. This patch adds /fprofile-sample-use= /fprofile-sample-use: /fno-profile-sample-use and supports -fprofile-sample-use= for CL. >From 8fbe3ed35afd38e2d7b36a89ae9e126bc1e221a8 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Fri, 22 Nov 2024 12:28:11 +0800 Subject: [PATCH] [Driver] Support fprofile-sample-use= for CL Sampling PGO has already been supported on Windows. This patch adds /fprofile-sample-use= /fprofile-sample-use: /fno-profile-sample-use and supports -fprofile-sample-use= for CL. --- clang/docs/UsersManual.rst| 4 ++-- clang/include/clang/Driver/Options.td | 5 - clang/test/Driver/cl-options.c| 8 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 2ef603d64557f3..e5d67bc58350c7 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -2660,7 +2660,7 @@ usual build cycle when using sample profilers for optimization: > clang-cl /O2 -gdwarf -gline-tables-only ^ /clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^ - /fprofile-sample-use=code.prof code.cc /Fe:code /fuse-ld=lld /link /debug:dwarf + /fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf [OPTIONAL] Sampling-based profiles can have inaccuracies or missing block/ edge counters. The profile inference algorithm (profi) can be used to infer @@ -2679,7 +2679,7 @@ usual build cycle when using sample profilers for optimization: > clang-cl /clang:-fsample-profile-use-profi /O2 -gdwarf -gline-tables-only ^ /clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^ - /fprofile-sample-use=code.prof code.cc /Fe:code /fuse-ld=lld /link /debug:dwarf + /fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf Sample Profile Formats "" diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 5167c3c39e315a..3a9655d89ff67b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1736,7 +1736,7 @@ def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group; def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">, Group, -Visibility<[ClangOption, CC1Option]>, +Visibility<[ClangOption, CLOption, CC1Option]>, HelpText<"Enable sample-based profile guided optimizations">, MarshallingInfoString>; def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">, @@ -8484,6 +8484,9 @@ def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias, A def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">, HelpText<"Enable AddressSanitizer">, Alias, AliasArgs<["address"]>; +def : CLJoined<"fno-profile-sample-use">, Alias; +def : CLJoined<"fprofile-sample-use:">, Alias; +def : CLJoined<"fprofile-sample-use=">, Alias; def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>, HelpText<"Assume thread-local variables are defined in the executable">; def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">; diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 8191fda97788c1..f219304111a94c 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -101,6 +101,14 @@ // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata" // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof" +// RUN: %clang_cl -### /FA -fprofile-sample-use=%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=CHECK-PROFILE-SAMPLE-USE %s +// RUN: %clang_cl -### /FA /fprofile-sample-use=%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=CHECK-PROFILE-SAMPLE-USE %s +// RUN: %clang_cl -### /FA /fprofile-sample-use:%S/Inputs/file.prof -- %s 2>&1 | FileCheck --check-prefix=CHECK-PROFILE-SAMPLE-USE %s +// CHECK-PROFILE-SAMPLE-USE: "-fprofile-sample-use={{.*}}/file.prof" + +// RUN: %clang_cl -### /FA /fprofile-sample-use=%S/Inputs/file.prof /fno-profile-sample-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-SAMPLE-USE %s +// CHECK-NO-PROFILE-SAMPLE-USE-NOT: "-fprofile-sample-use={{.*}}/file.prof" + // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s // GA: -ftls-model=local-exec ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)
HaohaiWen wrote: > > Better to double check with author who specified those CLOption. > > Do you mean the person that added `CLOption` to these flags? That was > @tarunprabhu, but IIUC that was by mistake; his intention was to extend these > flags only to Flang. > > Otherwise `-Xlinker` has been around for very long. I guess I will revert > these flags to be clang and flang only, then open issues for the discussion > of potentially enabling them to clang-cl. Some of our project have already used -Xlinker on Windows. Is there any equivalent flag for CL? Can we keep this flag for CL in this PR and open an issue to discuss whether it should be disabled for CL? https://github.com/llvm/llvm-project/pull/118640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PseudoProbe] Support emitting to COFF object (PR #123870)
https://github.com/HaohaiWen updated https://github.com/llvm/llvm-project/pull/123870 >From 7c531922f20bf284a5cd83b20e94cb624ef031d2 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 9 Jan 2025 15:29:33 +0800 Subject: [PATCH 1/3] [COFF] Preserve UniqueID used to create MCSectionCOFF This UniqueID can be used later to create associative section. e.g. A .pseudo_probe associated to the section of the corresponding function. --- llvm/include/llvm/MC/MCSectionCOFF.h | 9 +++-- llvm/lib/MC/MCContext.cpp| 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h b/llvm/include/llvm/MC/MCSectionCOFF.h index 97540d985dbd1d..9c79c27f2a9152 100644 --- a/llvm/include/llvm/MC/MCSectionCOFF.h +++ b/llvm/include/llvm/MC/MCSectionCOFF.h @@ -47,16 +47,19 @@ class MCSectionCOFF final : public MCSection { /// section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0 mutable int Selection; + unsigned UniqueID; + private: friend class MCContext; // The storage of Name is owned by MCContext's COFFUniquingMap. MCSectionCOFF(StringRef Name, unsigned Characteristics, -MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin) +MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID, +MCSymbol *Begin) : MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE, Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA, Begin), Characteristics(Characteristics), COMDATSymbol(COMDATSymbol), -Selection(Selection) { +Selection(Selection), UniqueID(UniqueID) { assert((Characteristics & 0x00F0) == 0 && "alignment must not be set upon section creation"); } @@ -72,6 +75,8 @@ class MCSectionCOFF final : public MCSection { void setSelection(int Selection) const; + unsigned getUniqueID() const { return UniqueID; } + void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, uint32_t Subsection) const override; diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 46222fcaa5b152..56aba5de4445e4 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -718,7 +718,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, StringRef CachedName = Iter->first.SectionName; MCSymbol *Begin = getOrCreateSectionSymbol(Section); MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF( - CachedName, Characteristics, COMDATSymbol, Selection, Begin); + CachedName, Characteristics, COMDATSymbol, Selection, UniqueID, Begin); Iter->second = Result; auto *F = allocInitialFragment(*Result); Begin->setFragment(F); >From 5c201436acb13e3d0893893eabd6e128ccdff346 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Tue, 21 Jan 2025 11:44:50 +0800 Subject: [PATCH 2/3] [PseudoProbe] Support emitting to COFF object Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc COFF sections. --- clang/include/clang/Driver/Options.td | 2 +- clang/test/Driver/cl-options.c| 1 + .../llvm/Target/TargetLoweringObjectFile.h| 3 + .../CodeGen/TargetLoweringObjectFileImpl.cpp | 24 +- llvm/lib/MC/MCAsmStreamer.cpp | 3 +- llvm/lib/MC/MCContext.cpp | 8 + llvm/lib/MC/MCObjectFileInfo.cpp | 81 -- llvm/lib/Target/TargetLoweringObjectFile.cpp | 27 ++ .../pseudo-probe-callee-profile-mismatch.ll | 4 +- .../SampleProfile/pseudo-probe-dangle.ll | 2 +- .../SampleProfile/pseudo-probe-dangle2.ll | 2 +- .../SampleProfile/pseudo-probe-desc-guid.ll | 2 +- .../SampleProfile/pseudo-probe-eh.ll | 2 +- .../SampleProfile/pseudo-probe-emit-inline.ll | 73 -- .../SampleProfile/pseudo-probe-emit.ll| 233 +- .../SampleProfile/pseudo-probe-icp-factor.ll | 2 +- .../SampleProfile/pseudo-probe-inline.ll | 2 +- .../SampleProfile/pseudo-probe-instsched.ll | 2 +- .../SampleProfile/pseudo-probe-invoke.ll | 4 +- .../pseudo-probe-missing-probe.ll | 2 +- .../pseudo-probe-no-debug-info.ll | 2 +- .../SampleProfile/pseudo-probe-peep.ll| 2 +- .../pseudo-probe-profile-mismatch-error.ll| 2 +- .../pseudo-probe-profile-mismatch-thinlto.ll | 2 +- .../pseudo-probe-profile-mismatch.ll | 4 +- .../pseudo-probe-selectionDAG.ll | 2 +- .../SampleProfile/pseudo-probe-slotindex.ll | 4 +- ...pseudo-probe-stale-profile-matching-LCS.ll | 4 +- ...pseudo-probe-stale-profile-matching-lto.ll | 4 +- .../pseudo-probe-stale-profile-matching.ll| 4 +- ...-probe-stale-profile-renaming-recursive.ll | 4 +- .../pseudo-probe-stale-profile-renaming.ll| 4 +- .../pseudo-probe-stale-profile-toplev-func.ll | 4 +- .../SampleProfile/pseudo-probe
[clang] [llvm] [PseudoProbe] Support emitting to COFF object (PR #123870)
@@ -12,7 +12,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-unknown-linux-gnu" +target triple = "x86_64-unknown--" HaohaiWen wrote: Can we simply remove `target triple` and `target datalayout ` in IR? https://github.com/llvm/llvm-project/pull/123870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver][MSVC] Add lto-sample-profile option for lld-link (PR #127442)
HaohaiWen wrote: This tittle looks like you are adding a new option -lto-sample-profile for LLD. It's recommended to rename the tittle so that other developer can easily know you are trying to pass profile file to lto backend via -lto-sample-profile. https://github.com/llvm/llvm-project/pull/127442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits