[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-11 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D154295#4482818 , @HaohaiWen wrote:

> In D154295#4477203 , @hans wrote:
>
>> In D154295#4477165 , @HaohaiWen 
>> wrote:
>>
 It would be nice to have some documentation for this feature though.
>>>
>>> This feature is same as Linux -gsplit-dwarf.
>>
>> Right, but it would be nice to document that clang-cl supports it (which is 
>> not obvious since it's mostly trying to be cl.exe compatible).
>
> Do you know which doc file should be updated? I haven't found a doc describe 
> -gdwarf for Windows.

I'd suggest putting it under 
https://clang.llvm.org/docs/UsersManual.html#clang-cl

But it seems we might not even have any docs for `-gsplit-dwarf` on non-Windows 
either, I suppose this is already as documented as it was before :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-08 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added a comment.

In D154295#4477203 , @hans wrote:

> In D154295#4477165 , @HaohaiWen 
> wrote:
>
>>> It would be nice to have some documentation for this feature though.
>>
>> This feature is same as Linux -gsplit-dwarf.
>
> Right, but it would be nice to document that clang-cl supports it (which is 
> not obvious since it's mostly trying to be cl.exe compatible).

Do you know which doc file should be updated? I haven't found a doc describe 
-gdwarf for Windows.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D154295#4477165 , @HaohaiWen wrote:

>> It would be nice to have some documentation for this feature though.
>
> This feature is same as Linux -gsplit-dwarf.

Right, but it would be nice to document that clang-cl supports it (which is not 
obvious since it's mostly trying to be cl.exe compatible).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added a comment.

Thanks everyone.

> It would be nice to have some documentation for this feature though.

This feature is same as Linux -gsplit-dwarf.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Haohai, Wen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf97b61ed27aa: [Driver][MSVC] Support DWARF fission when 
using LTO on Windows (authored by HaohaiWen).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/lto-dwo.c


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ 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"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   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  : Inputs) {
 if (Input.isFilename()) {


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ 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"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   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  : Inputs) {
 if (Input.isFilename()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

Looks reasonable to me too.

It would be nice to have some documentation for this feature though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-05 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added subscribers: hans, rnk.
mstorsjo added a comment.
This revision is now accepted and ready to land.

I think this looks reasonable, unless e.g. @hans or @rnk would disagree.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154295/new/

https://reviews.llvm.org/D154295

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154295: [Driver][MSVC] Support DWARF fission when using LTO on Windows

2023-07-01 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154295

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/lto-dwo.c


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ 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"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   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  : Inputs) {
 if (Input.isFilename()) {


Index: clang/test/Driver/lto-dwo.c
===
--- clang/test/Driver/lto-dwo.c
+++ 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"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -277,11 +277,18 @@
   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  : Inputs) {
 if (Input.isFilename()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits