[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 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-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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

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

In D154176#4466190 , @mstorsjo wrote:

> In D154176#4466186 , @mstorsjo 
> wrote:
>
>> Ok, thanks for clarifying. However I still don’t understand the “why” aspect 
>> here. You’re writing
>>
>>> so that lld specific flags can be append before inputs
>>
>> Are you planning on adding such flags in a later patch, position dependent 
>> flags that need to be supplied before input files?
>>
>> Or does the change in order of command line arguments have an effect on the 
>> behavior of the linker in this case?
>
> Ok, on second thought, I guess that parsing the vfsoverlay option before the 
> inputs makes it have an effect where it didn’t before. Is that right? (Most 
> flags in lld aren’t very order dependent since it just checks for any 
> occurrence of a flag anywhere among the arguments.)

I'm planing to add /dwodir to linker when user specify -gsplit-dwarf and using 
lld and lto.
The order does not matter.
I just want it looks more consistent and elegent since most flags are before 
inputs so that user can easily look for inputs when using -###.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-07-01 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 536518.
HaohaiWen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/msvc-link.c


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+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()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-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 (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+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()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-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 (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

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

In D154176#4465223 , @mstorsjo wrote:

> Is this a NFC change, as a preparation for a separate change? In that case, 
> please add an NFC tag to the subject - if not, please explain (and test) the 
> expected behaviour change.

The order of lld cmdargs would change from 
lld "flags" "inputs" "/vfsoverlay:xxx"

  to 

lld "flags" "/vfsoverlay:xxx" "inputs".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-06-30 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 536502.
HaohaiWen added a comment.

Add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154176

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/msvc-link.c


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+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()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-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 (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install


Index: clang/test/Driver/msvc-link.c
===
--- clang/test/Driver/msvc-link.c
+++ clang/test/Driver/msvc-link.c
@@ -35,4 +35,4 @@
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
 // VFSOVERLAY: lld-link
-// VFSOVERLAY: "/vfsoverlay:
+// VFSOVERLAY: "/vfsoverlay:{{.*}}" "{{.*}}.obj"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+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()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-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 (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154070: [lld/COFF] Add /dwodir to enable DWARF fission with LTO

2023-06-30 Thread Haohai, Wen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a631a8fedc2: [lld/COFF] Add /dwodir to enable DWARF fission 
with LTO (authored by HaohaiWen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

Files:
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/COFF/Options.td
  lld/test/COFF/lto-debug-fission.ll


Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = 
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = 
args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = args.hasArg(OPT_thinlto_index_only) ||
  args.hasArg(OPT_thinlto_index_only_arg);
Index: lld/COFF/Config.h
===
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -203,6 +203,9 @@
   StringRef manifestUIAccess = "'false'";
   StringRef manifestFile;
 
+  // used for /dwodir
+  StringRef dwoDir;
+
   // Used for /aligncomm.
   std::map alignComm;
 


Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = 

[PATCH] D154070: [lld/COFF] Add /dwodir to enable DWARF fission with LTO

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

In D154070#4461674 , @MaskRay wrote:

> I'll be away for a few days and back on July 5. Clicked "Accept" if you keep 
> just the lld/COFF part for this patch and create another patch for 
> clang/lib/Driver.
>
> I guess @mstorsjo may have some opinions.

Thank you.

Patch has been split to:
https://reviews.llvm.org/D154176


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

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


[PATCH] D154176: [Driver][MSVC] Move lld specific flags before inputs

2023-06-29 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Check linker earlier so that lld specific flags can be append before
inputs. Just like position of other flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154176

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+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()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-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 (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -269,6 +269,19 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+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()));
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto  : Inputs) {
 if (Input.isFilename()) {
@@ -301,22 +314,9 @@
 
   std::vector Environment;
 
-  // We need to special case some linker paths.  In the case of lld, we need to
-  // translate 'lld' into 'lld-link', and in the case of the regular msvc
+  // We need to special case some linker paths. In the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker
-= Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
-  if (Linker.empty())
-Linker = "link";
-  if (Linker.equals_insensitive("lld"))
-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 (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154070: [Driver][lld/COFF] Support DWARF fission when using LTO on Windows

2023-06-29 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 536084.
HaohaiWen added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Remove driver changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154070

Files:
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/COFF/Options.td
  lld/test/COFF/lto-debug-fission.ll


Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = 
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = 
args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = args.hasArg(OPT_thinlto_index_only) ||
  args.hasArg(OPT_thinlto_index_only_arg);
Index: lld/COFF/Config.h
===
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -203,6 +203,9 @@
   StringRef manifestUIAccess = "'false'";
   StringRef manifestFile;
 
+  // used for /dwodir
+  StringRef dwoDir;
+
   // Used for /aligncomm.
   std::map alignComm;
 


Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = 

[PATCH] D154070: [Driver][lld/COFF] Support DWARF fission when using LTO on Windows

2023-06-29 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.

This patch added /dwodir to lld/COFF which is equivalent to lld/ELF
option -plugin-opt=dwo_dir=. This option tells LTO backend to create
dwo directory and files and all dwo files will be in it. Otherwise all
dwarf sections will be embeded into image even if -gsplit-dwarf is
specified when using LTO.
For Driver, when user specify -gsplit-dwarf and LTO, /dwodir will be
automatically added.

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/D154070

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/lto-dwo.c
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/COFF/Options.td
  lld/test/COFF/lto-debug-fission.ll

Index: lld/test/COFF/lto-debug-fission.ll
===
--- /dev/null
+++ lld/test/COFF/lto-debug-fission.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; RUN: opt %s -o %t1.o
+; RUN: rm -rf %t.dir
+
+; Test to ensure that -dwodir:$DIR creates .dwo files under $DIR
+; RUN: lld-link -dwodir:%t.dir -noentry -dll %t1.o -out:%t.dll
+; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
+
+; CHECK: Format: COFF-x86-64
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/COFF/Options.td
===
--- lld/COFF/Options.td
+++ lld/COFF/Options.td
@@ -42,6 +42,8 @@
 def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
 def delayload : P<"delayload", "Delay loaded DLL name">;
 def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
+def dwodir : P<"dwodir",
+"Directory to store .dwo files when LTO and debug fission are used">;
 def entry   : P<"entry", "Name of entry point symbol">;
 def errorlimit : P<"errorlimit",
 "Maximum number of errors to emit before stopping (0 = no limit)">;
Index: lld/COFF/LTO.cpp
===
--- lld/COFF/LTO.cpp
+++ lld/COFF/LTO.cpp
@@ -84,6 +84,7 @@
   c.DisableVerify = true;
 #endif
   c.DiagHandler = diagnosticHandler;
+  c.DwoDir = ctx.config.dwoDir.str();
   c.OptLevel = ctx.config.ltoo;
   c.CPU = getCPUStr();
   c.MAttrs = getMAttrs();
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1910,6 +1910,9 @@
 fatal("/manifestinput: requires /manifest:embed");
   }
 
+  // Handle /dwodir
+  config->dwoDir = args.getLastArgValue(OPT_dwodir);
+
   config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files);
   config->thinLTOIndexOnly = args.hasArg(OPT_thinlto_index_only) ||
  args.hasArg(OPT_thinlto_index_only_arg);
Index: lld/COFF/Config.h
===
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -203,6 +203,9 @@
   StringRef manifestUIAccess = "'false'";
   StringRef manifestFile;
 
+  // used for /dwodir
+  StringRef dwoDir;
+
   // Used for /aligncomm.
   std::map alignComm;
 
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
@@ -269,6 +269,26 @@
 AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
   }
 
+  StringRef Linker =
+  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
+  // We need to translate 'lld' into 'lld-link'.
+  else if (Linker.equals_insensitive("lld"))
+Linker 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

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

Reland 82dff24bde112984314568e7d581379fd0ea48e6 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 534417.
HaohaiWen added a comment.

Add -- to clang_cl input file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; CHECK: [2] 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 534413.
HaohaiWen edited the summary of this revision.
HaohaiWen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_id

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen reopened this revision.
HaohaiWen added a comment.
This revision is now accepted and ready to land.

The path of this test you were running 
(/Users/thakis/src/llvm-project/clang/test/Driver/split-debug.c) started with 
/User which was interpreted as OPT_U option. Therefore split-debug.c haven't 
been treated as input file.
I'll add -- to tests to force clang-cl treat it as input file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-24 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen closed this revision.
HaohaiWen added a comment.

Thanks.
This patch has been landed. 
https://github.com/llvm/llvm-project/commit/3eee5aa528abd67bb6d057e25ce1980d0d38c445


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

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

@MaskRay, any other comments? I'd like to land this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-23 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 533967.
HaohaiWen added a comment.

Restore DWARFContext.cpp since D153602  has 
fixed that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-22 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 533623.
HaohaiWen added a comment.

Remove CoreOption for dumpdir


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_id 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-21 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1167
 // GCC style -dumpdir. We intentionally don't implement the less useful 
-dumpbase{,-ext}.
-def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option]>,
+def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option, CoreOption]>,
   MetaVarName<"">,

MaskRay wrote:
> This exposes `-dumpdir ` to clang-cl which may not be useful.
clang -gdwarf -gsplit-dwarf foo.cpp -o foo.exe -### will be expanded to
clang -cc1 ... "-dumpdir" "foo.exe-"  "-split-dwarf-file" "foo.exe-foo.dwo"

dwo name will be prefixed by dumpdir if it's specified.

This dumpdir is required for clang-cl to have same dwo filename behavior as 
clang.



Comment at: clang/lib/Driver/Driver.cpp:3898
 if (!Args.hasArg(options::OPT_dumpdir)) {
+  Arg *FinalOutput = Args.getLastArg(options::OPT_o, 
options::OPT__SLASH_o);
   Arg *Arg = Args.MakeSeparateArg(

MaskRay wrote:
> Add a test to show how OPT__SLASH_o passes a `-dumpdir `to CC1.
Already tested in (-o is OPT__SLASH_o in cl mode)

```
clang/test/Driver/split-debug.c: 62
// RUN: %clang_cl -### --target=x86_64-unknown-windows-msvc -gsplit-dwarf -g %s 
-o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
/ SPLIT_LINK:  "-dumpdir" "obj/out-"
// SPLIT_LINK:  "-debug-info-kind=constructor"
// SPLIT_LINK-SAME: "-split-dwarf-file" "obj/out-split-debug.dwo" 
"-split-dwarf-output" "obj/out-split-debug.dwo"
```



Comment at: clang/test/Driver/split-debug.c:19
 // RUN: %clang -### -c -target amdgcn-amd-amdhsa -gsplit-dwarf -g %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT
+// RUN: %clang_cl -### -c -target x86_64-unknown-windows-msvc -gsplit-dwarf -g 
%s 2>&1 | FileCheck %s --check-prefix=SPLIT
 

MaskRay wrote:
> MaskRay wrote:
> > Use `--target=` for new tests. `-target ` has been deprecated since Clang 
> > 3.x
> You can use `-gno-split-dwarf -gsplit-dwarf` to test `CoreOption` on 
> `-gno-split-dwarf`.
Good suggestion.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1895
+  if (RelocatedSection != Obj.section_end() && Name.contains(".dwo")) {
+// Each section in COFF can directly contain relocations.
+if (isa() && Section.relocations().empty())

MaskRay wrote:
> skan wrote:
> > The comment is confusing according to line 1900. Could you refine it?
> I'll change this to `ends_with(".dwo")` separately.
> 
> `check-llvm check-clang` passes even if I remove `if 
> (isa() && Section.relocations().empty()) continue`. What 
> does it do?
For ELF, if section a.dwo has relocations, it'll have a a.dwo.rela section, 
this section is RelocatedSection.
All dwo section should not have relocations, so if this is a dwo file, then 
RelocatedSection should be Obj.section_end(). Otherwise it will report warning.

For COFF, relocations of section A are directly stored in section A. 
RelocatedSection is Section itself so it will never be Obj.section_end(). Then 
this warning will always be reported. What we need to do is to check 
Section.relocations().empty() for COFF sections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-21 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 533182.
HaohaiWen marked 10 inline comments as done.
HaohaiWen added a comment.

Address maskray's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-19 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen marked an inline comment as done.
HaohaiWen added a comment.

Any other comments? If not , I'll land this patch tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-18 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen marked 7 inline comments as done.
HaohaiWen added inline comments.



Comment at: llvm/lib/MC/WinCOFFObjectWriter.cpp:124
 
+bool isDwoSection(const MCSection ) {
+  return Sec.getName().endswith(".dwo");

MaskRay wrote:
> static
It's already in anonymous namespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-18 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 532507.
HaohaiWen added a comment.

Use --target


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_id

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-16 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added inline comments.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1896
+// Each section in COFF can directly contain relocations.
+if (isa() && Section.relocations().empty())
+  continue;

skan wrote:
> Should we merge the check into line 1894?
It's more elegant to not merge. 



Comment at: llvm/test/DebugInfo/COFF/dwarf-headers.ll:75
+!14 = !{i32 1, !"MaxTLSAlign", i32 65536}
+!15 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
f1106ef6c9d14d5b516ec352279aeee8f9d12818)"}

skan wrote:
> Simplify it to "clang"?
I have attached source code in comments. It's better to save llvm version here 
to help to reproduce it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-16 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 532060.
HaohaiWen marked an inline comment as done.
HaohaiWen added a comment.

Address skan's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-14 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 531219.
HaohaiWen added a comment.

Fix sections binding check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_id

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-13 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 530825.
HaohaiWen added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-13 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1, MaskRay, 
aheejin.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

D152340  has split WinCOFFObjectWriter to 
WinCOFFWriter. This patch adds
another WinCOFFWriter as DwoWriter to write Dwo sections to dwo file.
Driver options are also updated accordingly to support -gsplit-dwarf in
CL mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152785

Files:
  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/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; 

[PATCH] D123609: [Clang] Remove support for legacy pass manager

2022-04-14 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added a comment.

Hi @nikic,
We recently noticed legacy PM was removed from many places.
Does community plan to remove legacy PM completely?
Do you know when will CG switch to new PM?
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123609

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