[clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-05-23 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/92865
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Pass -fseparate-named-sections from the driver (PR #91567)

2024-05-10 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek closed 
https://github.com/llvm/llvm-project/pull/91567
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Pass -fseparate-named-sections from the driver (PR #91567)

2024-05-10 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/91567

>From ca2b9d52d31866a657e2eb19585cdcd11bcad7d3 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Thu, 9 May 2024 00:28:33 -0700
Subject: [PATCH 1/2] [Clang] Pass -fseparate-named-sections from the driver

This is a follow up to #91028.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0a2ea96de7382..ceb5eb835ddce 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6116,6 +6116,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 
   Args.addOptOutFlag(CmdArgs, options::OPT_funique_section_names,
  options::OPT_fno_unique_section_names);
+  Args.addOptInFlag(CmdArgs, options::OPT_fseparate_named_sections,
+options::OPT_fno_separate_named_sections);
   Args.addOptInFlag(CmdArgs, options::OPT_funique_internal_linkage_names,
 options::OPT_fno_unique_internal_linkage_names);
   Args.addOptInFlag(CmdArgs, options::OPT_funique_basic_block_section_names,

>From 9a7a23e62fca9bb2c3257732d6dcc66a2240c042 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 10 May 2024 00:29:28 -0700
Subject: [PATCH 2/2] Add test

---
 clang/test/Driver/fseparate-named-sections.c | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 clang/test/Driver/fseparate-named-sections.c

diff --git a/clang/test/Driver/fseparate-named-sections.c 
b/clang/test/Driver/fseparate-named-sections.c
new file mode 100644
index 0..6264b8fcf0d84
--- /dev/null
+++ b/clang/test/Driver/fseparate-named-sections.c
@@ -0,0 +1,4 @@
+// RUN: %clang -### -fseparate-named-sections %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-OPT %s
+// RUN: %clang -### -fseparate-named-sections -fno-separate-named-sections %s 
-c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// CHECK-OPT: "-fseparate-named-sections"
+// CHECK-NOOPT-NOT: "-fseparate-named-sections"

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


[clang] [Clang] Pass -fseparate-named-sections from the driver (PR #91567)

2024-05-09 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/91567

This is a follow up to #91028.

>From ca2b9d52d31866a657e2eb19585cdcd11bcad7d3 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Thu, 9 May 2024 00:28:33 -0700
Subject: [PATCH] [Clang] Pass -fseparate-named-sections from the driver

This is a follow up to #91028.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0a2ea96de7382..ceb5eb835ddce 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6116,6 +6116,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 
   Args.addOptOutFlag(CmdArgs, options::OPT_funique_section_names,
  options::OPT_fno_unique_section_names);
+  Args.addOptInFlag(CmdArgs, options::OPT_fseparate_named_sections,
+options::OPT_fno_separate_named_sections);
   Args.addOptInFlag(CmdArgs, options::OPT_funique_internal_linkage_names,
 options::OPT_fno_unique_internal_linkage_names);
   Args.addOptInFlag(CmdArgs, options::OPT_funique_basic_block_section_names,

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


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-07 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek closed 
https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-07 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/91028

>From 78193f68a149e378fbb180a1a5fa1f4551f2af66 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 3 May 2024 15:48:31 -0700
Subject: [PATCH 1/5] [Clang] -fseparate-named-sections option

When set, the compiler will use separate unique sections for global
symbols in named special sections (e.g. symbols that are annotated with
__attribute__((section(.... Doing so enables linker GC to collect
unused symbols without having to use a different section per-symbol.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 clang/include/clang/Driver/Options.td |  5 +++
 clang/lib/CodeGen/BackendUtil.cpp |  1 +
 llvm/include/llvm/CodeGen/CommandFlags.h  |  2 ++
 llvm/include/llvm/Target/TargetMachine.h  |  4 +++
 llvm/include/llvm/Target/TargetOptions.h  | 20 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  8 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 16 +++--
 .../X86/elf-separate-named-sections.ll| 36 +++
 9 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/elf-separate-named-sections.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..b964e45574782c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -57,6 +57,7 @@ CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for 
-funique-section-names.
 CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
///< Produce unique section 
names with
///< basic block sections.
+CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
 CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f86808145d9ab..deb1c2253c1ed2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,11 @@ defm unique_section_names : 
BoolFOption<"unique-section-names",
   NegFlag,
   PosFlag>;
+defm separate_named_sections : BoolFOption<"separate-named-sections",
+  CodeGenOpts<"SeparateNamedSections">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm split_machine_functions: BoolFOption<"split-machine-functions",
   CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8eb..119ec4704002cf 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -423,6 +423,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;
+  Options.SeparateNamedSections = CodeGenOpts.SeparateNamedSections;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EnableTLSDESC = CodeGenOpts.EnableTLSDESC;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 244dabd38cf65b..d5448d781363d4 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -122,6 +122,8 @@ bool getUniqueSectionNames();
 
 bool getUniqueBasicBlockSectionNames();
 
+bool getSeparateNamedSections();
+
 llvm::EABI getEABIVersion();
 
 llvm::DebuggerKind getDebuggerTuningOpt();
diff --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 48ea3cfe02775b..1ba99730ca7024 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -288,6 +288,10 @@ class TargetMachine {
 return Options.UniqueBasicBlockSectionNames;
   }
 
+  bool getSeparateNamedSections() const {
+return Options.SeparateNamedSections;
+  }
+
   /// Return true if data objects should be emitted into their own section,
   /// corresponds to -fdata-sections.
   bool getDataSections() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d37e9d9576ba75..25d1f3f81fc142 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -144,15 +144,15 @@ namespace llvm {
   DisableIntegratedAS(false), FunctionSections(false),
   DataSections(false), IgnoreXCOFFVisibility(false),
   XCOFFTracebackTable(true), UniqueSectionNames(true),
-  UniqueBasicBlockSectionNames(false), TrapUnreachable(false),
-  

[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-07 Thread Petr Hosek via cfe-commits


@@ -221,6 +221,11 @@ New Compiler Flags
 - ``-fexperimental-modules-reduced-bmi`` enables the Reduced BMI for C++20 
named modules.
   See the document of standard C++ modules for details.
 
+- ``-fseparate-named-sections`` uses separate unique sections for global
+  symbols in named special sections (i.e. symbols annotated with
+  ``__attribute__((section(...)))``. This enabled linker GC to collect unused

petrhosek wrote:

Done

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-07 Thread Petr Hosek via cfe-commits


@@ -277,6 +277,8 @@ namespace llvm {
 /// Use unique names for basic block sections.
 unsigned UniqueBasicBlockSectionNames : 1;
 
+unsigned SeparateNamedSections : 1;

petrhosek wrote:

Done

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-07 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/91028

>From 78193f68a149e378fbb180a1a5fa1f4551f2af66 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 3 May 2024 15:48:31 -0700
Subject: [PATCH 1/5] [Clang] -fseparate-named-sections option

When set, the compiler will use separate unique sections for global
symbols in named special sections (e.g. symbols that are annotated with
__attribute__((section(.... Doing so enables linker GC to collect
unused symbols without having to use a different section per-symbol.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 clang/include/clang/Driver/Options.td |  5 +++
 clang/lib/CodeGen/BackendUtil.cpp |  1 +
 llvm/include/llvm/CodeGen/CommandFlags.h  |  2 ++
 llvm/include/llvm/Target/TargetMachine.h  |  4 +++
 llvm/include/llvm/Target/TargetOptions.h  | 20 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  8 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 16 +++--
 .../X86/elf-separate-named-sections.ll| 36 +++
 9 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/elf-separate-named-sections.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a3..b964e45574782 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -57,6 +57,7 @@ CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for 
-funique-section-names.
 CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
///< Produce unique section 
names with
///< basic block sections.
+CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
 CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f86808145d9a..deb1c2253c1ed 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,11 @@ defm unique_section_names : 
BoolFOption<"unique-section-names",
   NegFlag,
   PosFlag>;
+defm separate_named_sections : BoolFOption<"separate-named-sections",
+  CodeGenOpts<"SeparateNamedSections">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm split_machine_functions: BoolFOption<"split-machine-functions",
   CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8e..119ec4704002c 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -423,6 +423,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;
+  Options.SeparateNamedSections = CodeGenOpts.SeparateNamedSections;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EnableTLSDESC = CodeGenOpts.EnableTLSDESC;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 244dabd38cf65..d5448d781363d 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -122,6 +122,8 @@ bool getUniqueSectionNames();
 
 bool getUniqueBasicBlockSectionNames();
 
+bool getSeparateNamedSections();
+
 llvm::EABI getEABIVersion();
 
 llvm::DebuggerKind getDebuggerTuningOpt();
diff --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 48ea3cfe02775..1ba99730ca702 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -288,6 +288,10 @@ class TargetMachine {
 return Options.UniqueBasicBlockSectionNames;
   }
 
+  bool getSeparateNamedSections() const {
+return Options.SeparateNamedSections;
+  }
+
   /// Return true if data objects should be emitted into their own section,
   /// corresponds to -fdata-sections.
   bool getDataSections() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d37e9d9576ba7..25d1f3f81fc14 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -144,15 +144,15 @@ namespace llvm {
   DisableIntegratedAS(false), FunctionSections(false),
   DataSections(false), IgnoreXCOFFVisibility(false),
   XCOFFTracebackTable(true), UniqueSectionNames(true),
-  UniqueBasicBlockSectionNames(false), TrapUnreachable(false),
-  NoTrapAfterNoreturn(false), 

[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits


@@ -0,0 +1,36 @@
+; Test that global values with explicit sections are placed into unique 
sections.
+
+; RUN: llc < %s 2>&1 | FileCheck %s

petrhosek wrote:

Done.

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits


@@ -733,16 +733,22 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, 
StringRef SectionName,
   Ctx.isELFGenericMergeableSection(SectionName);
   // If this is the first ocurrence of this section name, treat it as the
   // generic section
-  if (!SymbolMergeable && !SeenSectionNameBefore)
-return MCContext::GenericSectionID;
+  if (!SymbolMergeable && !SeenSectionNameBefore) {
+if (TM.getSeparateNamedSections())
+  return NextUniqueID++;
+else
+  return MCContext::GenericSectionID;
+  }
 
   // Symbols must be placed into sections with compatible entry sizes. Generate
   // unique sections for symbols that have not been assigned to compatible
   // sections.
   const auto PreviousID =
   Ctx.getELFUniqueIDForEntsize(SectionName, Flags, EntrySize);
-  if (PreviousID)
+  if (PreviousID && (!TM.getSeparateNamedSections() ||
+ *PreviousID == MCContext::GenericSectionID)) {
 return *PreviousID;

petrhosek wrote:

Done.

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/91028

>From 78193f68a149e378fbb180a1a5fa1f4551f2af66 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 3 May 2024 15:48:31 -0700
Subject: [PATCH 1/4] [Clang] -fseparate-named-sections option

When set, the compiler will use separate unique sections for global
symbols in named special sections (e.g. symbols that are annotated with
__attribute__((section(.... Doing so enables linker GC to collect
unused symbols without having to use a different section per-symbol.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 clang/include/clang/Driver/Options.td |  5 +++
 clang/lib/CodeGen/BackendUtil.cpp |  1 +
 llvm/include/llvm/CodeGen/CommandFlags.h  |  2 ++
 llvm/include/llvm/Target/TargetMachine.h  |  4 +++
 llvm/include/llvm/Target/TargetOptions.h  | 20 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  8 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 16 +++--
 .../X86/elf-separate-named-sections.ll| 36 +++
 9 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/elf-separate-named-sections.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..b964e45574782c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -57,6 +57,7 @@ CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for 
-funique-section-names.
 CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
///< Produce unique section 
names with
///< basic block sections.
+CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
 CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f86808145d9ab..deb1c2253c1ed2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,11 @@ defm unique_section_names : 
BoolFOption<"unique-section-names",
   NegFlag,
   PosFlag>;
+defm separate_named_sections : BoolFOption<"separate-named-sections",
+  CodeGenOpts<"SeparateNamedSections">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm split_machine_functions: BoolFOption<"split-machine-functions",
   CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8eb..119ec4704002cf 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -423,6 +423,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;
+  Options.SeparateNamedSections = CodeGenOpts.SeparateNamedSections;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EnableTLSDESC = CodeGenOpts.EnableTLSDESC;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 244dabd38cf65b..d5448d781363d4 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -122,6 +122,8 @@ bool getUniqueSectionNames();
 
 bool getUniqueBasicBlockSectionNames();
 
+bool getSeparateNamedSections();
+
 llvm::EABI getEABIVersion();
 
 llvm::DebuggerKind getDebuggerTuningOpt();
diff --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 48ea3cfe02775b..1ba99730ca7024 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -288,6 +288,10 @@ class TargetMachine {
 return Options.UniqueBasicBlockSectionNames;
   }
 
+  bool getSeparateNamedSections() const {
+return Options.SeparateNamedSections;
+  }
+
   /// Return true if data objects should be emitted into their own section,
   /// corresponds to -fdata-sections.
   bool getDataSections() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d37e9d9576ba75..25d1f3f81fc142 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -144,15 +144,15 @@ namespace llvm {
   DisableIntegratedAS(false), FunctionSections(false),
   DataSections(false), IgnoreXCOFFVisibility(false),
   XCOFFTracebackTable(true), UniqueSectionNames(true),
-  UniqueBasicBlockSectionNames(false), TrapUnreachable(false),
-  

[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits

petrhosek wrote:

> > This is an alternative approach to address the issue described in 
> > [discourse.llvm.org/t/rfc-support-for-memory-regions-in-elf/78570](https://discourse.llvm.org/t/rfc-support-for-memory-regions-in-elf/78570)
> >  which doesn't require a custom section type.
> 
> This RFC is about `SHT_LLVM_MEMORY` while this patch seems orthogonal?

We might still consider implementing `SHT_LLVM_MEMORY` since it'd enable new 
use cases, but this PR addresses one of the issues described in that RFC 
without requiring significant changes in either LLVM or the existing code.

> I agree that the option is useful in some cases. If `ld -r` is used, 
> `--unique` will be needed to not destroy granularity.

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits


@@ -75,6 +75,10 @@ static cl::opt JumpTableInFunctionSection(
 "jumptable-in-function-section", cl::Hidden, cl::init(false),
 cl::desc("Putting Jump Table in function section"));
 
+static cl::opt UniqueExplicitSections(
+"unique-explicit-sections", cl::Hidden, cl::init(true),

petrhosek wrote:

Removed, it was a leftover from earlier version.

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/91028

>From 78193f68a149e378fbb180a1a5fa1f4551f2af66 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 3 May 2024 15:48:31 -0700
Subject: [PATCH 1/3] [Clang] -fseparate-named-sections option

When set, the compiler will use separate unique sections for global
symbols in named special sections (e.g. symbols that are annotated with
__attribute__((section(.... Doing so enables linker GC to collect
unused symbols without having to use a different section per-symbol.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 clang/include/clang/Driver/Options.td |  5 +++
 clang/lib/CodeGen/BackendUtil.cpp |  1 +
 llvm/include/llvm/CodeGen/CommandFlags.h  |  2 ++
 llvm/include/llvm/Target/TargetMachine.h  |  4 +++
 llvm/include/llvm/Target/TargetOptions.h  | 20 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  8 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 16 +++--
 .../X86/elf-separate-named-sections.ll| 36 +++
 9 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/elf-separate-named-sections.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..b964e45574782c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -57,6 +57,7 @@ CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for 
-funique-section-names.
 CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
///< Produce unique section 
names with
///< basic block sections.
+CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
 CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f86808145d9ab..deb1c2253c1ed2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,11 @@ defm unique_section_names : 
BoolFOption<"unique-section-names",
   NegFlag,
   PosFlag>;
+defm separate_named_sections : BoolFOption<"separate-named-sections",
+  CodeGenOpts<"SeparateNamedSections">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm split_machine_functions: BoolFOption<"split-machine-functions",
   CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8eb..119ec4704002cf 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -423,6 +423,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;
+  Options.SeparateNamedSections = CodeGenOpts.SeparateNamedSections;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EnableTLSDESC = CodeGenOpts.EnableTLSDESC;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 244dabd38cf65b..d5448d781363d4 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -122,6 +122,8 @@ bool getUniqueSectionNames();
 
 bool getUniqueBasicBlockSectionNames();
 
+bool getSeparateNamedSections();
+
 llvm::EABI getEABIVersion();
 
 llvm::DebuggerKind getDebuggerTuningOpt();
diff --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 48ea3cfe02775b..1ba99730ca7024 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -288,6 +288,10 @@ class TargetMachine {
 return Options.UniqueBasicBlockSectionNames;
   }
 
+  bool getSeparateNamedSections() const {
+return Options.SeparateNamedSections;
+  }
+
   /// Return true if data objects should be emitted into their own section,
   /// corresponds to -fdata-sections.
   bool getDataSections() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d37e9d9576ba75..25d1f3f81fc142 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -144,15 +144,15 @@ namespace llvm {
   DisableIntegratedAS(false), FunctionSections(false),
   DataSections(false), IgnoreXCOFFVisibility(false),
   XCOFFTracebackTable(true), UniqueSectionNames(true),
-  UniqueBasicBlockSectionNames(false), TrapUnreachable(false),
-  

[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-04 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/91028

>From 78193f68a149e378fbb180a1a5fa1f4551f2af66 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 3 May 2024 15:48:31 -0700
Subject: [PATCH 1/2] [Clang] -fseparate-named-sections option

When set, the compiler will use separate unique sections for global
symbols in named special sections (e.g. symbols that are annotated with
__attribute__((section(.... Doing so enables linker GC to collect
unused symbols without having to use a different section per-symbol.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 clang/include/clang/Driver/Options.td |  5 +++
 clang/lib/CodeGen/BackendUtil.cpp |  1 +
 llvm/include/llvm/CodeGen/CommandFlags.h  |  2 ++
 llvm/include/llvm/Target/TargetMachine.h  |  4 +++
 llvm/include/llvm/Target/TargetOptions.h  | 20 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  8 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 16 +++--
 .../X86/elf-separate-named-sections.ll| 36 +++
 9 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/elf-separate-named-sections.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..b964e45574782c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -57,6 +57,7 @@ CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for 
-funique-section-names.
 CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
///< Produce unique section 
names with
///< basic block sections.
+CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
 CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f86808145d9ab..deb1c2253c1ed2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,11 @@ defm unique_section_names : 
BoolFOption<"unique-section-names",
   NegFlag,
   PosFlag>;
+defm separate_named_sections : BoolFOption<"separate-named-sections",
+  CodeGenOpts<"SeparateNamedSections">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm split_machine_functions: BoolFOption<"split-machine-functions",
   CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8eb..119ec4704002cf 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -423,6 +423,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;
+  Options.SeparateNamedSections = CodeGenOpts.SeparateNamedSections;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EnableTLSDESC = CodeGenOpts.EnableTLSDESC;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 244dabd38cf65b..d5448d781363d4 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -122,6 +122,8 @@ bool getUniqueSectionNames();
 
 bool getUniqueBasicBlockSectionNames();
 
+bool getSeparateNamedSections();
+
 llvm::EABI getEABIVersion();
 
 llvm::DebuggerKind getDebuggerTuningOpt();
diff --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 48ea3cfe02775b..1ba99730ca7024 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -288,6 +288,10 @@ class TargetMachine {
 return Options.UniqueBasicBlockSectionNames;
   }
 
+  bool getSeparateNamedSections() const {
+return Options.SeparateNamedSections;
+  }
+
   /// Return true if data objects should be emitted into their own section,
   /// corresponds to -fdata-sections.
   bool getDataSections() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d37e9d9576ba75..25d1f3f81fc142 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -144,15 +144,15 @@ namespace llvm {
   DisableIntegratedAS(false), FunctionSections(false),
   DataSections(false), IgnoreXCOFFVisibility(false),
   XCOFFTracebackTable(true), UniqueSectionNames(true),
-  UniqueBasicBlockSectionNames(false), TrapUnreachable(false),
-  

[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-03 Thread Petr Hosek via cfe-commits

petrhosek wrote:

This is an alternative approach to address the issue described in 
https://discourse.llvm.org/t/rfc-support-for-memory-regions-in-elf/78570 which 
doesn't require a custom section type.

https://github.com/llvm/llvm-project/pull/91028
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

2024-05-03 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/91028

When set, the compiler will use separate unique sections for global symbols in 
named special sections (e.g. symbols that are annotated with 
__attribute__((section(.... Doing so enables linker GC to collect unused 
symbols without having to use a different section per-symbol.

>From 78193f68a149e378fbb180a1a5fa1f4551f2af66 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 3 May 2024 15:48:31 -0700
Subject: [PATCH] [Clang] -fseparate-named-sections option

When set, the compiler will use separate unique sections for global
symbols in named special sections (e.g. symbols that are annotated with
__attribute__((section(.... Doing so enables linker GC to collect
unused symbols without having to use a different section per-symbol.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  1 +
 clang/include/clang/Driver/Options.td |  5 +++
 clang/lib/CodeGen/BackendUtil.cpp |  1 +
 llvm/include/llvm/CodeGen/CommandFlags.h  |  2 ++
 llvm/include/llvm/Target/TargetMachine.h  |  4 +++
 llvm/include/llvm/Target/TargetOptions.h  | 20 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  8 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 16 +++--
 .../X86/elf-separate-named-sections.ll| 36 +++
 9 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/elf-separate-named-sections.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..b964e45574782c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -57,6 +57,7 @@ CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for 
-funique-section-names.
 CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
///< Produce unique section 
names with
///< basic block sections.
+CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
 CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f86808145d9ab..deb1c2253c1ed2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,11 @@ defm unique_section_names : 
BoolFOption<"unique-section-names",
   NegFlag,
   PosFlag>;
+defm separate_named_sections : BoolFOption<"separate-named-sections",
+  CodeGenOpts<"SeparateNamedSections">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm split_machine_functions: BoolFOption<"split-machine-functions",
   CodeGenOpts<"SplitMachineFunctions">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8eb..119ec4704002cf 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -423,6 +423,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;
+  Options.SeparateNamedSections = CodeGenOpts.SeparateNamedSections;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EnableTLSDESC = CodeGenOpts.EnableTLSDESC;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h 
b/llvm/include/llvm/CodeGen/CommandFlags.h
index 244dabd38cf65b..d5448d781363d4 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -122,6 +122,8 @@ bool getUniqueSectionNames();
 
 bool getUniqueBasicBlockSectionNames();
 
+bool getSeparateNamedSections();
+
 llvm::EABI getEABIVersion();
 
 llvm::DebuggerKind getDebuggerTuningOpt();
diff --git a/llvm/include/llvm/Target/TargetMachine.h 
b/llvm/include/llvm/Target/TargetMachine.h
index 48ea3cfe02775b..1ba99730ca7024 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -288,6 +288,10 @@ class TargetMachine {
 return Options.UniqueBasicBlockSectionNames;
   }
 
+  bool getSeparateNamedSections() const {
+return Options.SeparateNamedSections;
+  }
+
   /// Return true if data objects should be emitted into their own section,
   /// corresponds to -fdata-sections.
   bool getDataSections() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h 
b/llvm/include/llvm/Target/TargetOptions.h
index d37e9d9576ba75..25d1f3f81fc142 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -144,15 +144,15 @@ namespace llvm {
   

[clang] [llvm] [cmake] Remove custom linker flag check function (PR #86602)

2024-04-21 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I'd actually prefer this not be merged as is. I have already made a similar 
change locally but during testing I discovered a major issue with 
`check_linker_flag`: unlike other CMake `check_*` functions, and even 
`llvm_check_linker_flag`, `check_linker_flag` doesn't apply 
`CMAKE_REQUIRED_LINK_OPTIONS` because [the implementation overrides 
it](https://gitlab.kitware.com/cmake/cmake/-/blob/14de6802e40edcdeebc73d81210fe8e1ec0f469e/Modules/Internal/CheckLinkerFlag.cmake#L25)
 and this can result in failed checks when `CMAKE_REQUIRED_LINK_OPTIONS` 
contains necessary flags (it actually breaks the runtimes build which this 
change doesn't touch). I'd rather prefer to continue using 
`llvm_check_linker_flag` with our own implementation [similar to the CMake 
one](https://gitlab.kitware.com/cmake/cmake/-/blob/14de6802e40edcdeebc73d81210fe8e1ec0f469e/Modules/Internal/CheckLinkerFlag.cmake)
 that appends `CMAKE_REQUIRED_LINK_OPTIONS` rather than overwriting it. If you 
want to implement such a change, that would be great, otherwise I can take a 
stab at it when I have some time.

https://github.com/llvm/llvm-project/pull/86602
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread Petr Hosek via cfe-commits

petrhosek wrote:

This is a re-upload of https://reviews.llvm.org/D140925, I plan to land this 
change if there are no objections.

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/89425

When using Clang as a compiler, use Clang to normalize the triple that's used 
to construct path for runtime library build and install paths. This ensures 
that paths are consistent and avoids the issue where the build uses a different 
triple spelling.

Differential Revision: https://reviews.llvm.org/D140925

>From eb2459876526b78c97b04801dd07bd53540b2892 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Tue, 15 Feb 2022 22:59:58 -0800
Subject: [PATCH] [CMake] Use Clang to infer the target triple

When using Clang as a compiler, use Clang to normalize the triple that's
used to construct path for runtime library build and install paths. This
ensures that paths are consistent and avoids the issue where the build
uses a different triple spelling.

Differential Revision: https://reviews.llvm.org/D140925
---
 clang/cmake/caches/Fuchsia-stage2.cmake |  2 +-
 compiler-rt/lib/builtins/CMakeLists.txt | 13 +
 runtimes/CMakeLists.txt | 14 ++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index d5546e20873b3c..029c069997396d 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -142,7 +142,7 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
-foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;riscv64-unknown-linux-gnu;x86_64-unknown-linux-gnu)
+foreach(target 
aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;riscv64-linux-gnu;x86_64-linux-gnu)
   if(LINUX_${target}_SYSROOT)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index f9611574a562b4..4c6de992204c16 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -28,6 +28,19 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   if (NOT LLVM_RUNTIMES_BUILD)
 load_llvm_config()
   endif()
+  if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+set(print_target_triple ${CMAKE_CXX_COMPILER} 
--target=${LLVM_RUNTIME_TRIPLE} -print-target-triple)
+execute_process(COMMAND ${print_target_triple}
+  RESULT_VARIABLE result
+  OUTPUT_VARIABLE output
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(result EQUAL 0)
+  set(LLVM_RUNTIME_TRIPLE ${output})
+else()
+  string(REPLACE ";" " " print_target_triple "${print_target_triple}")
+  message(WARNING "Failed to execute `${print_target_triple}` to normalize 
target triple.")
+endif()
+  endif()
   construct_compiler_rt_default_triple()
 
   include(SetPlatformToolchainTools)
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 6f24fbcccec955..bb1f544706f2bf 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -181,6 +181,20 @@ message(STATUS "LLVM default target triple: 
${LLVM_DEFAULT_TARGET_TRIPLE}")
 
 set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(print_target_triple ${CMAKE_CXX_COMPILER} 
--target=${LLVM_RUNTIME_TRIPLE} -print-target-triple)
+  execute_process(COMMAND ${print_target_triple}
+RESULT_VARIABLE result
+OUTPUT_VARIABLE output
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(result EQUAL 0)
+set(LLVM_RUNTIME_TRIPLE ${output})
+  else()
+string(REPLACE ";" " " print_target_triple "${print_target_triple}")
+message(WARNING "Failed to execute `${print_target_triple}` to normalize 
target triple.")
+  endif()
+endif()
+
 option(LLVM_INCLUDE_TESTS "Generate build targets for the runtimes unit 
tests." ON)
 option(LLVM_INCLUDE_DOCS "Generate build targets for the runtimes 
documentation." ON)
 option(LLVM_ENABLE_SPHINX "Use Sphinx to generate the runtimes documentation." 
OFF)

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


[clang] NFC: Make clang resource headers an interface library (PR #88317)

2024-04-11 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/88317
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-03-26 Thread Petr Hosek via cfe-commits


@@ -49,3 +49,62 @@ if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)
   # despite potential dllexports.
   target_link_options(clangInterpreter PRIVATE LINKER:--export-all-symbols)
 endif()
+
+if(MSVC)
+  set_target_properties(clangInterpreter PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 
1)
+
+  # RTTI/C++ symbols
+  set(clangInterpreter_exports ${clangInterpreter_exports} ??_7type_info@@6B@
+?__type_info_root_node@@3U__type_info_node@@A
+?nothrow@std@@3Unothrow_t@1@B
+  )
+
+  # Compiler added symbols for static variables. NOT for VStudio < 2015
+  set(clangInterpreter_exports ${clangInterpreter_exports} _Init_thread_abort 
_Init_thread_epoch
+_Init_thread_footer _Init_thread_header _tls_index
+  )
+
+  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+# new/delete variants needed when linking to static msvc runtime (esp. 
Debug)
+set(clangInterpreter_exports ${clangInterpreter_exports}
+  ??2@YAPEAX_K@Z
+  ??3@YAXPEAX@Z
+  ??_U@YAPEAX_K@Z
+  ??_V@YAXPEAX@Z
+  ??3@YAXPEAX_K@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z
+  
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
+  
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z
+  
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z
+  ?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z
+)
+  else()
+set(clangInterpreter_exports ${clangInterpreter_exports}
+  ??2@YAPAXI@Z
+  ??3@YAXPAX@Z
+  ??3@YAXPAXI@Z
+  ??_U@YAPAXI@Z
+  ??_V@YAXPAX@Z
+  ??_V@YAXPAXI@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z
+  
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z
+  
??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z
+  
??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z
+  ?_Facet_Register@std@@YAXPAV_Facet_base@1@@Z
+)
+  endif()
+
+  # List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'
+  foreach(sym ${clangInterpreter_exports})
+set(clangInterpreter_link_str "${clangInterpreter_link_str} 
/EXPORT:${sym}")
+  endforeach(sym ${clangInterpreter_exports})
+
+  set_property(TARGET clangInterpreter APPEND_STRING PROPERTY LINK_FLAGS 
${clangInterpreter_link_str})
+
+endif(MSVC)

petrhosek wrote:

Can you clarify what you mean by "`target_link_options` doesn't work", I'm not 
sure which part you're referring to?

https://github.com/llvm/llvm-project/pull/83774
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Change GCC_INSTALL_PREFIX from warning to fatal error (PR #85891)

2024-03-25 Thread Petr Hosek via cfe-commits

petrhosek wrote:

> @petrhosek Is there a way to pass flags only to the runtimes portion of the 
> build within the normal workflow? I know we have 
> `-DRUNTIMES_x86_64-unknown-linux-gnu_CMAKE_CXX_COMPILE_FLAGS=` that might 
> work, but I don't think this is respected if we're using the `default` target.

You can use `RUNTIMES_CMAKE_ARGS`, see for example: 
https://github.com/llvm/llvm-project/blob/c6a65e4b0c80245d766ae2f2f7305b5371d096f5/clang/cmake/caches/Fuchsia-stage2.cmake#L90

https://github.com/llvm/llvm-project/pull/85891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Change GCC_INSTALL_PREFIX from warning to fatal error (PR #85891)

2024-03-20 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/85891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)

2024-03-15 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/80480
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)

2024-03-15 Thread Petr Hosek via cfe-commits


@@ -1621,8 +1621,15 @@ function(add_unittest test_suite test_name)
   # The runtime benefits of LTO don't outweight the compile time costs for 
tests.
   if(LLVM_ENABLE_LTO)
 if((UNIX OR MINGW) AND LINKER_IS_LLD)
-  set_property(TARGET ${test_name} APPEND_STRING PROPERTY
-LINK_FLAGS " -Wl,--lto-O0")
+  if(LLVM_ENABLE_FATLTO)
+# When using FatLTO, just use relocatable linking.
+set_property(TARGET ${test_name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,--no-fat-lto-objects")
+set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS 
" -fno-lto")

petrhosek wrote:

I'd omit it since it shouldn't be necessary.

https://github.com/llvm/llvm-project/pull/80480
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix a bug on type constraint checking (PR #84671)

2024-03-12 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/84671

>From 1b71ce0ece77060591edaf69794e184d58ad9b15 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Sun, 10 Mar 2024 16:11:18 +0800
Subject: [PATCH] [Clang][Sema] Fix a bug on type constraint checking

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp |  1 +
 clang/test/Sema/PR84368.cpp| 16 
 3 files changed, 19 insertions(+)
 create mode 100644 clang/test/Sema/PR84368.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 88e552d5c46113..12b867330efff1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -351,6 +351,8 @@ Bug Fixes to C++ Support
   when one of the function had more specialized templates.
   Fixes (`#82509 `_)
   and (`#74494 `_)
+- Fix an issue where missing set friend declaration in template class 
instantiation.
+  Fixes (#GH84368).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 20c2c93ac9c7b4..765c5bc689ae1e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1698,6 +1698,7 @@ Decl 
*TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
 assert(!Owner->isDependentContext());
 Inst->setLexicalDeclContext(Owner);
 RecordInst->setLexicalDeclContext(Owner);
+Inst->setObjectOfFriendDecl();
 
 if (PrevClassTemplate) {
   Inst->setCommonPtr(PrevClassTemplate->getCommonPtr());
diff --git a/clang/test/Sema/PR84368.cpp b/clang/test/Sema/PR84368.cpp
new file mode 100644
index 00..073530ffd8abea
--- /dev/null
+++ b/clang/test/Sema/PR84368.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++23 -verify %s
+// expected-no-diagnostics
+
+template concept IsOk = requires() { typename T::Float; };
+
+template struct Thing;
+
+template struct Foobar {
+   template struct Inner {
+   template friend struct Thing;
+   };
+};
+
+struct MyType { using Float=float; };
+Foobar::Inner<0> foobar;

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


[clang] [Driver,BareMetal] Replace -lclang_rt.builtins{,-$arch}.a with an absolute path (PR #82424)

2024-03-07 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I agree with @MaskRay that prior to this change the BareMetal driver was using 
a logic that was inconsistent with all other drivers and not something we 
intend to support. The correct solution is to extend the BareMetal driver to 
support `multilib.yaml` for Clang runtime libraries; this includes not only 
compiler-rt builtins but also LLVM libc and libc++.

https://github.com/llvm/llvm-project/pull/82424
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Fuchsia] Include baremetal ARM builtins and libc (PR #83949)

2024-03-05 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek closed 
https://github.com/llvm/llvm-project/pull/83949
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Fuchsia] Include baremetal ARM builtins and libc (PR #83949)

2024-03-05 Thread Petr Hosek via cfe-commits


@@ -300,10 +300,43 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
+foreach(target armv6m-unknown-eabi)
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  foreach(lang C;CXX;ASM)
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-mcpu=cortex-m0plus -mthumb" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
+  foreach(lang C;CXX;ASM)
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-mcpu=cortex-m0plus -mthumb" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
+endforeach()
+
 foreach(target riscv32-unknown-elf)
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR riscv CACHE STRING "")

petrhosek wrote:

Removed

https://github.com/llvm/llvm-project/pull/83949
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Fuchsia] Include baremetal ARM builtins and libc (PR #83949)

2024-03-05 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/83949

>From 8c5829c6eb9607152b85dd0e99ccb39770d536fd Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Mon, 6 Mar 2023 19:31:13 +
Subject: [PATCH] [Fuchsia] Include baremetal ARM builtins and libc

For now we only include the armv6m-unknown-eabi target but we plan to
include more targets in the future (including multilibs).
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 33 +
 1 file changed, 33 insertions(+)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eee37c5e7901fa..db7430b3344c3e 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -300,6 +300,39 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
+foreach(target armv6m-unknown-eabi)
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  foreach(lang C;CXX;ASM)
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-mcpu=cortex-m0plus -mthumb" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
+  foreach(lang C;CXX;ASM)
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-mcpu=cortex-m0plus -mthumb" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
+endforeach()
+
 foreach(target riscv32-unknown-elf)
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")

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


[clang] [llvm] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)

2024-03-04 Thread Petr Hosek via cfe-commits


@@ -1621,8 +1621,15 @@ function(add_unittest test_suite test_name)
   # The runtime benefits of LTO don't outweight the compile time costs for 
tests.
   if(LLVM_ENABLE_LTO)
 if((UNIX OR MINGW) AND LINKER_IS_LLD)
-  set_property(TARGET ${test_name} APPEND_STRING PROPERTY
-LINK_FLAGS " -Wl,--lto-O0")
+  if(LLVM_ENABLE_FATLTO)
+# When using FatLTO, just use relocatable linking.
+set_property(TARGET ${test_name} APPEND_STRING PROPERTY
+  LINK_FLAGS " -Wl,--no-fat-lto-objects")
+set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS 
" -fno-lto")

petrhosek wrote:

What's the motivation for including `-fno-lto` in compile flags here?

https://github.com/llvm/llvm-project/pull/80480
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)

2024-03-04 Thread Petr Hosek via cfe-commits


@@ -1251,6 +1253,10 @@ elseif(LLVM_ENABLE_LTO)
   endif()
 endif()
 
+if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX))
+append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS 
CMAKE_SHARED_LINKER_FLAGS)

petrhosek wrote:

I'd also include the flag in `CMAKE_MODULE_LINKER_FLAGS` for completeness.

https://github.com/llvm/llvm-project/pull/80480
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Fuchsia] Include baremetal ARM builtins and libc (PR #83949)

2024-03-04 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/83949

For now we only include the armv6m-unknown-eabi target but we plan to include 
more targets in the future (including multilibs).

>From 7924ab437a5df81aa5d5481541ad4979335f5a9b Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Mon, 6 Mar 2023 19:31:13 +
Subject: [PATCH] [Fuchsia] Include baremetal ARM builtins and libc

For now we only include the armv6m-unknown-eabi target but we plan to
include more targets in the future (including multilibs).
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 37 +++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eee37c5e7901fa..97c93969e18e80 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -300,10 +300,43 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
+foreach(target armv6m-unknown-eabi)
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  foreach(lang C;CXX;ASM)
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-mcpu=cortex-m0plus -mthumb" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
+  foreach(lang C;CXX;ASM)
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-mcpu=cortex-m0plus -mthumb" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
+endforeach()
+
 foreach(target riscv32-unknown-elf)
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR riscv CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
   foreach(lang C;CXX;ASM)
@@ -316,7 +349,7 @@ foreach(target riscv32-unknown-elf)
 
   list(APPEND RUNTIME_TARGETS "${target}")
   set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
-  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR riscv CACHE STRING "")
   set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
   set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
   set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")

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


[clang] [compiler-rt] [llvm] [InstrProf] Single byte counters in coverage (PR #75425)

2024-02-27 Thread Petr Hosek via cfe-commits


@@ -1282,8 +1283,14 @@ class SegmentBuilder {
   // value for that area.
   // We add counts of the regions of the same kind as the active region
   // to handle the both situations.
-  if (I->Kind == Active->Kind)
-Active->ExecutionCount += I->ExecutionCount;
+  if (I->Kind == Active->Kind) {
+assert(I->HasSingleByteCoverage == Active->HasSingleByteCoverage &&
+   "Regions are generated in different coverage modes");

petrhosek wrote:

This is just a minor nit that I just noticed and could be addressed in some 
follow up change, but in all other `assert` cases the message is not 
capitalized so shouldn't capitalize here either for consistency.

https://github.com/llvm/llvm-project/pull/75425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Update -Wformat warnings for fixed-point format specifiers (PR #82855)

2024-02-24 Thread Petr Hosek via cfe-commits


@@ -2981,6 +2981,10 @@ class ASTContext : public RefCountedBase {
   // corresponding saturated type for a given fixed point type.
   QualType getCorrespondingSaturatedType(QualType Ty) const;
 
+  // Per ISO N1169, this method accepts fixed point types and returns the
+  // corresponding non-saturated type for a given fixed point type.

petrhosek wrote:

```suggestion
  // Per ISO/IEC TR 18037:2008, this method accepts fixed point types and
  // returns the corresponding non-saturated type for a given fixed point type.
```

https://github.com/llvm/llvm-project/pull/82855
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Update -Wformat warnings for fixed-point format specifiers (PR #82855)

2024-02-24 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek deleted 
https://github.com/llvm/llvm-project/pull/82855
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Update -Wformat warnings for fixed-point format specifiers (PR #82855)

2024-02-24 Thread Petr Hosek via cfe-commits


@@ -2981,6 +2981,10 @@ class ASTContext : public RefCountedBase {
   // corresponding saturated type for a given fixed point type.
   QualType getCorrespondingSaturatedType(QualType Ty) const;
 
+  // Per ISO N1169, this method accepts fixed point types and returns the

petrhosek wrote:

```suggestion
  // Per ISO/IEC TR 18037:2008, this method accepts fixed point types and 
returns the
```

https://github.com/llvm/llvm-project/pull/82855
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Update -Wformat warnings for fixed-point format specifiers (PR #82855)

2024-02-24 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/82855
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Update -Wformat warnings for fixed-point format specifiers (PR #82855)

2024-02-24 Thread Petr Hosek via cfe-commits

petrhosek wrote:

> Do you know a libc implementation that actually implements `%k` `%r` and who 
> are the potential users? From a quick glance, gcc avr supports fixed-point 
> types but avr-libc doesn't seem to support %k %r.

LLVM-libc will support them soon, PR should be coming next week. We have 
internal customers at Google that are starting to use fixed-point types in 
their embedded products.

https://github.com/llvm/llvm-project/pull/82855
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver,BareMetal] Replace -lclang_rt.builtins{,-$arch}.a with an absolute path (PR #82424)

2024-02-20 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/82424
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][driver] Allow unaligned access on ARMv7 and higher by default (PR #82400)

2024-02-20 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/82400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Disable generation of asynchronous unwind tables for RISCV baremetal (PR #81727)

2024-02-19 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/81727
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMake][PGO] Build Sema.cpp to generate profdata for PGO builds (PR #77347)

2024-02-13 Thread Petr Hosek via cfe-commits


@@ -26,9 +30,23 @@ if(LLVM_BUILD_INSTRUMENTED)
 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to 
llvm-profdata")
   else()
 add_custom_target(generate-profdata
-  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR}/profiles/
   COMMENT "Merging profdata"
   DEPENDS generate-profraw)
+if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR)
+  llvm_ExternalProject_Add(generate-profraw-external 
${CLANG_PGO_TRAINING_DATA_SOURCE_DIR}
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS 
generate-profraw)
+  add_dependencies(generate-profdata generate-profraw-external)
+else()
+  # Default to compiling a file from clang. This also builds all the
+  # dependencies needed to build this file, like TableGen.
+  set(generate_profraw_clang_sema 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.o)
+  llvm_ExternalProject_Add(generate-profraw-clang 
${CMAKE_CURRENT_SOURCE_DIR}/../../../llvm
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS generate-profraw
+  EXTRA_TARGETS generate_profraw_clang_sema

petrhosek wrote:

@tstellar For the numbers you reported (~34% and ~20%), what did you use to 
collect those numbers?

https://github.com/llvm/llvm-project/pull/77347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add fixed point precision macros (PR #81207)

2024-02-13 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/81207
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Diagnose invalid fixed point conversion (PR #80763)

2024-02-05 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/80763
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [lldb] [lld] [libc] [clang] [libcxx] [flang] [CMAKE] Enable FatLTO as a build option for LLVM (PR #80480)

2024-02-02 Thread Petr Hosek via cfe-commits


@@ -1251,6 +1253,10 @@ elseif(LLVM_ENABLE_LTO)
   endif()
 endif()
 
+if(LLVM_ENABLE_FATLTO AND (FUCHSIA OR UNIX))
+append("-ffat-lto-objects" CMAKE_EXE_LINKER_FLAGS 
CMAKE_SHARED_LINKER_FLAGS)

petrhosek wrote:

I think you also need to append this flag to `CMAKE_C_FLAGS` and 
`CMAKE_CXX_FLAGS` just like we do for `-flto` above.

https://github.com/llvm/llvm-project/pull/80480
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [llvm] [clang-tools-extra] [flang] [libunwind] [lld] [lldb] [mlir] [libcxx] [compiler-rt] [clang] Reland: [libc++][format] P2637R3: Member visit (std::basic_format_arg) #76449 (PR #79032)

2024-01-26 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I tried this branch on our Windows builders although I'm not sure if it's 
related or not to this patch:
```
# COMPILED WITH
C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/github-H-G-Hristov-llvm-project/libcxx/test/support 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
-Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings  -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\fuzzing\Output\random.pass.cpp.dir\t.tmp.exe
# executed command: C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
'C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp'
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/github-H-G-Hristov-llvm-project/libcxx/test/support 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
-Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
'C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\fuzzing\Output\random.pass.cpp.dir\t.tmp.exe'
# .---command stderr
# | In file included from 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:16:
# | In file included from C:/b/s/w/ir/x/w/llvm_build/include/c++/v1\cmath:319:
# | In file included from C:/b/s/w/ir/x/w/llvm_build/include/c++/v1\math.h:301:
# | In file included from C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\math.h:11:
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:413:16: error: call to 
'fpclassify' is ambiguous
# |   413 | return fpclassify(_X) == FP_NAN;
# |   |^~
# | 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:166:12:
 note: in instantiation of function template specialization 'isnan' 
requested here
# |   166 |   if (std::isnan(res)) {
# |   |^
# | 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:178:10:
 note: in instantiation of function template specialization 
'helper>' requested here
# |   178 |   return helper>(data, 
size)   ||
# |   |  ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:288:31: note: candidate 
function
# |   288 | _Check_return_ inline int fpclassify(_In_ float _X) throw()
# |   |   ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:293:31: note: candidate 
function
# |   293 | _Check_return_ inline int fpclassify(_In_ double _X) throw()
# |   |   ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:298:31: note: candidate 
function
# |   298 | 

[clang] [llvm] [CMake][PGO] Add option for using an external project to generate profile data (PR #78879)

2024-01-23 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/78879
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [CMake][PGO] Add option for using an external project to generate profile data (PR #78879)

2024-01-23 Thread Petr Hosek via cfe-commits


@@ -15,7 +19,7 @@ if(LLVM_BUILD_INSTRUMENTED)
 )

petrhosek wrote:

Looks like I added that in https://reviews.llvm.org/D138974 but I'm not aware 
of it being used anywhere at the moment. I'd still prefer renaming it to 
`CLANG_PGO_TRAINING_DEPS` for consistency, especially that we're now adding it 
to cache.

https://github.com/llvm/llvm-project/pull/78879
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMake][PGO] Add option for using an external project to generate profile data (PR #78879)

2024-01-23 Thread Petr Hosek via cfe-commits


@@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension):
 
 
 def clean(args):
-if len(args) != 2:
+if len(args) < 2:
 print(
-"Usage: %s clean  \n" % __file__
+"Usage: %s clean  \n" % __file__
 + "\tRemoves all files with extension from ."
 )
 return 1
-for filename in findFilesWithExtension(args[0], args[1]):
-os.remove(filename)
+for path in args[1:-1]:
+for filename in findFilesWithExtension(path, args[-1]):
+os.remove(filename)
 return 0
 
 
 def merge(args):
-if len(args) != 3:
+if len(args) < 3:
 print(
-"Usage: %s merge   \n" % __file__
+"Usage: %s merge   \n" % __file__
 + "\tMerges all profraw files from path into output."
 )
 return 1
 cmd = [args[0], "merge", "-o", args[1]]
-cmd.extend(findFilesWithExtension(args[2], "profraw"))
+for i in range(2, len(args)):
+cmd.extend(findFilesWithExtension(args[i], "profraw"))

petrhosek wrote:

```suggestion
for path in args[2:]:
cmd.extend(findFilesWithExtension(path, "profraw"))
```

https://github.com/llvm/llvm-project/pull/78879
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMake][PGO] Add option for using an external project to generate profile data (PR #78879)

2024-01-23 Thread Petr Hosek via cfe-commits


@@ -1,6 +1,10 @@
+include(LLVMExternalProjectUtils)
+
 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
   "The path to a lit testsuite containing samples for PGO and order file 
generation"
   )
+set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source 
directory containing cmake project with source files to use for generating pgo 
data")
+set(CLANG_PERF_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to 
build the PGO training data.")

petrhosek wrote:

I don't see this variable being used anywhere, should it be added as a 
dependency of `generate-profraw-external`? I'd also consider naming it 
`CLANG_PGO_TRAINING_DEPS` for consistency with other variables in this file.

https://github.com/llvm/llvm-project/pull/78879
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libc] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [lld] [clang-tools-extra] [flang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-22 Thread Petr Hosek via cfe-commits

petrhosek wrote:

This is still broken so I'm going to revert the change.

https://github.com/llvm/llvm-project/pull/76449
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [clang] [flang] [lld] [lldb] [openmp] [llvm] [compiler-rt] [clang-tools-extra] [libc] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-21 Thread Petr Hosek via cfe-commits

petrhosek wrote:

Please ignore 04c85587596ab10d885a957a00c8fa22740f15c1 which addresses a 
different issue, this is still broken in tip-of-tree.

https://github.com/llvm/llvm-project/pull/76449
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options (PR #69133)

2024-01-21 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/69133
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake][PGO] Add libunwind to list of stage1 runtimes (PR #78869)

2024-01-21 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/78869
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [openmp] [lld] [compiler-rt] [clang-tools-extra] [llvm] [clang] [libcxx] [mlir] [libc] [flang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-21 Thread Petr Hosek via cfe-commits

petrhosek wrote:

The `llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp` is 
failing on Windows with the following error:
```
Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support -D_CRT_SECURE_NO_WARNINGS 
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX 
-std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef 
-Wunused-template -Wno-unused-command-line-argument -Wno-attributes 
-Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment 
-Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor 
-Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare 
-Wunused-variable -Wunused-parameter -Wunreachable-code 
-Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions 
-Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete 
-Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 
-D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings  -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\std\utilities\format\format.arguments\format.arg\Output\visit.return_type.pass.cpp.dir\t.tmp.exe
# executed command: C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
'C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp'
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/support -D_CRT_SECURE_NO_WARNINGS 
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX 
-std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef 
-Wunused-template -Wno-unused-command-line-argument -Wno-attributes 
-Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment 
-Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor 
-Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare 
-Wunused-variable -Wunused-parameter -Wunreachable-code 
-Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions 
-Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete 
-Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 
-D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
'C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\std\utilities\format\format.arguments\format.arg\Output\visit.return_type.pass.cpp.dir\t.tmp.exe'
# .---command stderr
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:134:35:
 error: implicit conversion from 'long long' to 'const long' changes value from 
192812079084 to -461449236 [-Werror,-Wconstant-conversion]
# |   134 |   test(true, 192812079084L);
# |   |   ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:363:3:
 note: in instantiation of function template specialization 'test' 
requested here
# |   363 |   test();
# |   |   ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:135:36:
 error: implicit conversion from 'long long' to 'const long' changes value from 
192812079084 to -461449236 [-Werror,-Wconstant-conversion]
# |   135 |   test(false, 192812079084L);
# |   |    ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:40:12:
 error: implicit conversion from 'long long' to 'long' changes value from 
192812079084 to -461449236 [-Werror,-Wconstant-conversion]
# |40 | return 192812079084L;
# |   | ~~ ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:60:20:
 note: in instantiation of function template 

[clang] [Coverage] Map regions from system headers (PR #76950)

2024-01-20 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/76950
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMake][Release] Add option for enabling PGO to release cache file. (PR #78823)

2024-01-20 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/78823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CMake][Release] Add option for enabling PGO to release cache file. (PR #78823)

2024-01-20 Thread Petr Hosek via cfe-commits


@@ -37,11 +63,26 @@ set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
 
 # Stage 2 Options
 set(STAGE2_PROJECTS "clang")
-if (LLVM_RELEASE_ENABLE_LTO)
+set(STAGE2_RUNTIMES "")
+
+if (LLVM_RELEASE_ENABLE_LTO OR LLVM_RELEASE_ENABLE_PGO)
  list(APPEND STAGE2_PROJECTS "lld")
 endif()
+
+if (LLVM_RELEASE_ENABLE_PGO)
+  set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")

petrhosek wrote:

```suggestion
  set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "")
```

https://github.com/llvm/llvm-project/pull/78823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (PR #78323)

2024-01-16 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek closed 
https://github.com/llvm/llvm-project/pull/78323
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (PR #78323)

2024-01-16 Thread Petr Hosek via cfe-commits

petrhosek wrote:

This is a reland of 78550bef98347bccbf0e8e5fb66dc59718fc35ec, the 
cross-compilation issues should be resolved now.

https://github.com/llvm/llvm-project/pull/78323
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (PR #78323)

2024-01-16 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/78323

This contains compiler-rt builtins and llvm-libc for baremetal use.

Differential Revision: https://reviews.llvm.org/D155337

>From 900df95c16d8bef6f9758cd53db39bb885097cc7 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Sun, 7 Jan 2024 18:13:39 -0800
Subject: [PATCH] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia
 toolchain (#76849)

This contains compiler-rt builtins and llvm-libc for baremetal use.

Differential Revision: https://reviews.llvm.org/D155337
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 38 -
 clang/cmake/caches/Fuchsia.cmake|  3 +-
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index c4673c8a54c5ef5..eee37c5e7901fae 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -6,7 +6,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS 
"bolt;clang;clang-tools-extra;libc;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -22,8 +22,11 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_FORCE_BUILD_RUNTIME ON CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+set(LIBC_HDRGEN_ONLY ON CACHE BOOL "")
 set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
@@ -297,6 +300,39 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
+foreach(target riscv32-unknown-elf)
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  foreach(lang C;CXX;ASM)
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
+  foreach(lang C;CXX;ASM)
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
+endforeach()
+
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
 set(LLVM_RUNTIME_TARGETS "${RUNTIME_TARGETS}" CACHE STRING "")
 
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index bb2ed30690098e5..fe925901eb3dce7 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -6,7 +6,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS 
"bolt;clang;clang-tools-extra;libc;lld;llvm;polly")
 
 set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
@@ -18,6 +18,7 @@ set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LIBC_HDRGEN_ONLY ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
 set(LLDB_ENABLE_LIBEDIT OFF 

[clang] [llvm] [CMake][PGO] Build Sema.cpp to generate profdata for PGO builds (PR #77347)

2024-01-16 Thread Petr Hosek via cfe-commits


@@ -26,9 +30,23 @@ if(LLVM_BUILD_INSTRUMENTED)
 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to 
llvm-profdata")
   else()
 add_custom_target(generate-profdata
-  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR}/profiles/
   COMMENT "Merging profdata"
   DEPENDS generate-profraw)
+if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR)
+  llvm_ExternalProject_Add(generate-profraw-external 
${CLANG_PGO_TRAINING_DATA_SOURCE_DIR}
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS 
generate-profraw)
+  add_dependencies(generate-profdata generate-profraw-external)
+else()
+  # Default to compiling a file from clang. This also builds all the
+  # dependencies needed to build this file, like TableGen.
+  set(generate_profraw_clang_sema 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.o)
+  llvm_ExternalProject_Add(generate-profraw-clang 
${CMAKE_CURRENT_SOURCE_DIR}/../../../llvm
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS generate-profraw
+  EXTRA_TARGETS generate_profraw_clang_sema

petrhosek wrote:

The idea I'd like explore is using libc++ (and perhaps also libc) test suite 
for training. It consists of self-contained test programs which should 
sufficiently exercise various aspects of C/C++ frontend.

https://github.com/llvm/llvm-project/pull/77347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [lld] [mlir] [libcxx] [libcxxabi] [openmp] [llvm] [clang] [runtimes] Use LLVM libunwind from libc++abi by default (PR #77687)

2024-01-16 Thread Petr Hosek via cfe-commits

petrhosek wrote:

> @petrhosek @ldionne would it be better detect libunwind in 
> LLVM_ENABLE_RUNTIMES?
> 
> Asking because we have similar thing in compiler-rt, e.g. for lld, and I am 
> not sure which approach is better: There are trade offs:
> 
> 1. checking LLVM_ENABLE_RUNTIMES simplify end user experience
> 2. forcing default  ON simplifies cmake files and avoids unexpected use of 
> system lib

That would be my preference, specifically I'd set the default for 
`LIBCXXABI_USE_LLVM_UNWINDER` based on whether `libunwind` is present in 
`LLVM_ENABLE_RUNTIMES` (but still let user override it).

https://github.com/llvm/llvm-project/pull/77687
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [compiler-rt] [clang] [openmp] [mlir] [libcxxabi] [libcxx] [llvm] [runtimes] Use LLVM libunwind from libc++abi by default (PR #77687)

2024-01-10 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/77687
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind] Convert a few options from CACHE PATH to CACHE STRING (PR #77534)

2024-01-09 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/77534
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake][Release] Add option for enabling LTO to cache file (PR #77035)

2024-01-09 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/77035
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake][PGO] Use check targets to generate profdata for PGO builds (PR #77347)

2024-01-08 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I'd also prefer to make this configurable, we're using our own corpus which in 
my experiments both produces better results and takes less time than 
`check-llvm` and `check-clang`.

We should also consider updating the documentation since I don't think that 
`check-llvm` and `check-clang` is what we should be recommending; LLVM and 
Clang tests have different goal, that is to provide maximum coverage which 
often means exercising various corner cases and error conditions, but these are 
not helpful when collecting profiles, in fact they can be harmful.

I think that [LLVM test-suite](https://github.com/llvm/llvm-test-suite/) is 
actually a better fit since more representative of real code. In our  training 
corpus, I for example use 
[CppPerformanceBenchmarks](https://gitlab.com/chriscox/CppPerformanceBenchmarks)
 (an older version is also [included in LLVM test 
suite](https://github.com/llvm/llvm-test-suite/tree/9ca97f5027150f7e507e5ab4c56f38a29fb3c696/SingleSource/Benchmarks/Adobe-C%2B%2B)).

https://github.com/llvm/llvm-project/pull/77347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a90ed3e - Revert "[CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (#76849)"

2024-01-07 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2024-01-08T03:29:30Z
New Revision: a90ed3e8a4ea8c5238fd660bbac0371366afe3b5

URL: 
https://github.com/llvm/llvm-project/commit/a90ed3e8a4ea8c5238fd660bbac0371366afe3b5
DIFF: 
https://github.com/llvm/llvm-project/commit/a90ed3e8a4ea8c5238fd660bbac0371366afe3b5.diff

LOG: Revert "[CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain 
(#76849)"

This reverts commit 78550bef98347bccbf0e8e5fb66dc59718fc35ec since
it broke the two stage build.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eee37c5e7901fa..c4673c8a54c5ef 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -6,7 +6,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(_FUCHSIA_ENABLE_PROJECTS 
"bolt;clang;clang-tools-extra;libc;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -22,11 +22,8 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
-set(LLVM_FORCE_BUILD_RUNTIME ON CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
-set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
-set(LIBC_HDRGEN_ONLY ON CACHE BOOL "")
 set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
@@ -300,39 +297,6 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
-foreach(target riscv32-unknown-elf)
-  list(APPEND BUILTIN_TARGETS "${target}")
-  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
-  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-  foreach(lang C;CXX;ASM)
-set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
-  endforeach()
-  foreach(type SHARED;MODULE;EXE)
-set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
-  endforeach()
-  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
-
-  list(APPEND RUNTIME_TARGETS "${target}")
-  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
-  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
-  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
-  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
-  foreach(lang C;CXX;ASM)
-set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
-  endforeach()
-  foreach(type SHARED;MODULE;EXE)
-set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
-  endforeach()
-  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
-  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
-endforeach()
-
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
 set(LLVM_RUNTIME_TARGETS "${RUNTIME_TARGETS}" CACHE STRING "")
 



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


[clang] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (PR #76849)

2024-01-07 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek closed 
https://github.com/llvm/llvm-project/pull/76849
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (PR #76849)

2024-01-07 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/76849

>From 0cb22bea1e724ca62306081da2ae97bbcc395a86 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 9 Jun 2023 07:17:13 +
Subject: [PATCH] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia
 toolchain

This contains compiler-rt builtins and llvm-libc for baremetal use.

Differential Revision: https://reviews.llvm.org/D155337
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 38 -
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index c4673c8a54c5ef..eee37c5e7901fa 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -6,7 +6,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS 
"bolt;clang;clang-tools-extra;libc;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -22,8 +22,11 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_FORCE_BUILD_RUNTIME ON CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+set(LIBC_HDRGEN_ONLY ON CACHE BOOL "")
 set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
@@ -297,6 +300,39 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
+foreach(target riscv32-unknown-elf)
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  foreach(lang C;CXX;ASM)
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
+  foreach(lang C;CXX;ASM)
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
+endforeach()
+
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
 set(LLVM_RUNTIME_TARGETS "${RUNTIME_TARGETS}" CACHE STRING "")
 

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


[clang] [llvm] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (PR #76849)

2024-01-03 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/76849

This contains compiler-rt builtins and llvm-libc for baremetal use.

Differential Revision: https://reviews.llvm.org/D155337

>From 01dd937d31d398188e0f7c39d2318375e761a3ba Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 9 Jun 2023 07:17:13 +
Subject: [PATCH] [CMake] Include riscv32-unknown-elf runtimes in Fuchsia
 toolchain

This contains compiler-rt builtins and llvm-libc for baremetal use.

Differential Revision: https://reviews.llvm.org/D155337
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 38 -
 llvm/runtimes/CMakeLists.txt|  2 +-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index c4673c8a54c5ef..eee37c5e7901fa 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -6,7 +6,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS 
"bolt;clang;clang-tools-extra;libc;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -22,8 +22,11 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_FORCE_BUILD_RUNTIME ON CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+set(LIBC_HDRGEN_ONLY ON CACHE BOOL "")
 set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
@@ -297,6 +300,39 @@ if(FUCHSIA_SDK)
   set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS 
"aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
 endif()
 
+foreach(target riscv32-unknown-elf)
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  foreach(lang C;CXX;ASM)
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE 
STRING "")
+  foreach(lang C;CXX;ASM)
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+  endforeach()
+  foreach(type SHARED;MODULE;EXE)
+set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
+  endforeach()
+  set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
+endforeach()
+
 set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
 set(LLVM_RUNTIME_TARGETS "${RUNTIME_TARGETS}" CACHE STRING "")
 
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 77254b7eb5e622..cd2494cf0d3a45 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -414,7 +414,7 @@ if(runtimes)
   endif()
 endforeach()
   endif()
-  if("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND 
+  if("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND
   (LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES))
 if(TARGET libc-hdrgen)
   set(libc_tools libc-hdrgen)

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


[clang] [clang][Darwin] Remove legacy framework search path logic in the frontend (PR #75841)

2024-01-01 Thread Petr Hosek via cfe-commits

petrhosek wrote:

This appears to have broken the LSan build which is now failing with the 
following error:
```
FAILED: 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
 
/Volumes/Work/s/w/ir/x/w/llvm_build/./bin/clang++ 
--target=x86_64-apple-darwin22.6.0 
--sysroot=/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
 -DCOMPILER_RT_SHARED_LIB -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Dclang_rt_lsan_osx_dynamic_EXPORTS 
-I/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/.. -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm_build/runtimes/runtimes-bins=../../../llvm-llvm-project
 -ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/= 
-no-canonical-prefixes -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 
-arch arm64 -arch x86_64 -isysroot 
/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
 -fPIC -stdlib=libc++ -mmacosx-version-min=10.10 -isysroot 
/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
 -fno-lto -fPIC -fno-builtin -fno-exceptions -funwind-tables 
-fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu 
-Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -Wno-format -MD 
-MT 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
 -MF 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o.d
 -o 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
 -c 
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
In file included from 
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp:57:
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10:
 fatal error: 'CoreFoundation/CFBase.h' file not found
   20 | #include 
  |  ^
1 error generated.
```

https://github.com/llvm/llvm-project/pull/75841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [lld] [lldb] [flang] [clang] [mlir] [llvm] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-20 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I have discovered another issue, on Fuchsia `libclang_rt.builtins.a` now has a 
reference to `getauxval` which it didn't have before. This is really 
undesirable because on Fuchsia, there's no `auxv` to begin with. I believe this 
is because before, the `__init_cpu_features` definition was guarded by:

```
#if defined(__has_include)
#if __has_include()
#include 
...
#if __has_include()
#include 
```
These `#if __has_include(...)` conditionals would evaluate to false on Fuchsia 
since we don't have those headers, but they have been moved in the refactored 
version.

https://github.com/llvm/llvm-project/pull/75635
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Always use CLANG_VENDOR as a quoted string (PR #75935)

2023-12-19 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek requested changes to this pull request.

I agree with @smeenai, we shouldn't be setting `CLANG_VENDOR` as a global 
define.

https://github.com/llvm/llvm-project/pull/75935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [lld] [lldb] [libcxx] [mlir] [llvm] [compiler-rt] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-19 Thread Petr Hosek via cfe-commits

petrhosek wrote:

We're still seeing the following error on our builders:
```
/b/s/w/ir/x/w/llvm_build/./bin/clang --target=aarch64-unknown-linux-gnu 
--sysroot=/b/s/w/ir/x/w/cipd/linux -DHAS_ASM_LSE -DVISIBILITY_HIDDEN  
--target=aarch64-unknown-linux-gnu -O2 -g -DNDEBUG -fno-lto -std=c11 -fPIC 
-fno-builtin -fvisibility=hidden -fomit-frame-pointer -DCOMPILER_RT_HAS_FLOAT16 
-MD -MT CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o -MF 
CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o.d -o 
CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o -c 
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c
In file included from 
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c:43:
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc:5:41:
 error: use of undeclared identifier 'HWCAP_ATOMICS'
5 |   __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
  | ^
1 error generated.
```

https://github.com/llvm/llvm-project/pull/75635
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Provide `-fno-/-fvisibility-global-new-delete` option (PR #75364)

2023-12-19 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I don't think it's very clear from `-f[no-]visibility-global-new-delete` what 
the option does. How about `-f[no-]visibility-attribute-global-new-delete`?

https://github.com/llvm/llvm-project/pull/75364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind] Use -nostdlib++ when linking libunwind (PR #75646)

2023-12-19 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/75646
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] test-release.sh: Add a CMake cache file for 3-stage release builds (PR #75903)

2023-12-19 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.

Out of curiosity, what's the reason for using 3-stage (rather than 2-stage) 
build?

https://github.com/llvm/llvm-project/pull/75903
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [compiler-rt] [libc] [llvm] [clang] [compiler-rt]Add lld into dependency for apple builds now that lld Mach-O backend is available (PR #75884)

2023-12-18 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/75884
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libcxx] [libcxxabi] [runtimes] Don't link against compiler-rt explicitly when we use -nostdlib++ (PR #75089)

2023-12-14 Thread Petr Hosek via cfe-commits

petrhosek wrote:

> > I'm trying to implement support for building libunwind, libc++abi and 
> > libc++ against LLVM libc in which case we won't be able to rely on 
> > `-nostdlib++`, we'll need to use `-nostdlib` to avoid linking the C 
> > library. We can still use `-nostdlib++` when LLVM libc isn't being used 
> > used, but a lot of this logic will need to be refactored to support the new 
> > use case. With that in mind, I'm fine with change as an interim solution.
> 
> Is there a reason why `-nostdlib` also drops compiler-rt? If `-nostdlib++` 
> affects only the C++ library, it would make sense that `-nostdlib` affects 
> only the C library?

The reason is matching the behavior of GCC, but given that I don't think we can 
change the current semantics.

https://github.com/llvm/llvm-project/pull/75089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libcxxabi] [libcxx] [runtimes] Don't link against compiler-rt explicitly when we use -nostdlib++ (PR #75089)

2023-12-13 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I'm trying to implement support for building libunwind, libc++abi and libc++ 
against LLVM libc in which case we won't be able to rely on `-nostdlib++`, 
we'll need to use `-nostdlib` to avoid linking the C library. We can still use 
`-nostdlib++` when LLVM libc isn't being used used, but a lot of this logic 
will need to be refactored to support the new use case. With that in mind, I'm 
fine with change as an interim solution.

https://github.com/llvm/llvm-project/pull/75089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [lldb] [clang-tools-extra] [clang] [mlir] [llvm] [compiler-rt] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-13 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/69493
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV][RFC] BareMetal multilibs YAML usage (PR #75191)

2023-12-13 Thread Petr Hosek via cfe-commits

petrhosek wrote:

Regarding `-f[no-]exceptions` handling, see 
https://discourse.llvm.org/t/rfc-multilib/67494/32.

https://github.com/llvm/llvm-project/pull/75191
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Include opt-viewer in Fuchsia toolchain (PR #75296)

2023-12-13 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/75296

This is necessary for visualization of optimization remarks.

>From a35caa1369eabff183eb192fd4ad7566e55c8ea6 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Wed, 13 Dec 2023 08:03:37 +
Subject: [PATCH] [CMake] Include opt-viewer in Fuchsia toolchain

This is necessary for visualization of optimization remarks.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4b9085d99378c6..c4673c8a54c5ef 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -336,6 +336,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-symbolizer
   llvm-undname
   llvm-xray
+  opt-viewer
   sancov
   scan-build-py
   CACHE STRING "")

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


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-12-11 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I think we should close it, the current behavior is as expected.

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-12-11 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek closed 
https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [SpecialCaseList] Use glob by default (PR #74809)

2023-12-08 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/74809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [mlir] [compiler-rt] [llvm] [lldb] [clang] [flang] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-05 Thread Petr Hosek via cfe-commits

petrhosek wrote:

Can you break up all the changes to tests that replace `-debug-info-correlate` 
with `--profile-correlate=debug-info` into a separate PR to reduce the size of 
this PR?

https://github.com/llvm/llvm-project/pull/69493
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [mlir] [compiler-rt] [llvm] [lldb] [clang] [flang] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-05 Thread Petr Hosek via cfe-commits


@@ -702,6 +708,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 #define INSTR_PROF_COVMAP_COMMON __llvm_covmap
 #define INSTR_PROF_COVFUN_COMMON __llvm_covfun
 #define INSTR_PROF_ORDERFILE_COMMON __llvm_orderfile

petrhosek wrote:

This just a nit, but could you move `orderfile` here and elsewhere to the 
bottom so that all `__llvm_cov*` entries are next to each other for easier 
readability.

https://github.com/llvm/llvm-project/pull/69493
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-12-02 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/73845
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-12-01 Thread Petr Hosek via cfe-commits


@@ -4401,13 +4413,18 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   Instrument only functions from files where names 
don't match all the regexes separated by a semi-colon
   -fprofile-filter-files=
   Instrument only functions from files where names 
match any regex separated by a semi-colon
+  -fprofile-generate[=]

petrhosek wrote:

This is really surprising but I just tested this and you're correct. Do you 
know why that's the case, that is why `-fprofile-generate=` and 
`-fprofile-instr-generate=` have a different behavior?

https://github.com/llvm/llvm-project/pull/73845
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-12-01 Thread Petr Hosek via cfe-commits


@@ -4401,13 +4415,21 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   Instrument only functions from files where names 
don't match all the regexes separated by a semi-colon
   -fprofile-filter-files=
   Instrument only functions from files where names 
match any regex separated by a semi-colon
-  -fprofile-instr-generate=
-  Generate instrumented code to collect execution 
counts into 
+  -fprofile-generate=
+  Generate instrumented code to collect execution 
counts into a raw profile file in the directory specified by the argument. The 
filename uses the %m format. See :ref:`Profiling With Instrumentation 
`  section for details.
+  (overridden by LLVM_PROFILE_FILE env var)
+  -fprofile-generate
+  Generate instrumented code to collect execution 
counts into default_%m.profraw file
+  (overridden by '=' form of option or 
LLVM_PROFILE_FILE env var)
+  -fprofile-instr-generate=

petrhosek wrote:

Can you also add `-fprofile-instr-generate` case below for consistency?

https://github.com/llvm/llvm-project/pull/73845
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-12-01 Thread Petr Hosek via cfe-commits


@@ -4401,13 +4415,21 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   Instrument only functions from files where names 
don't match all the regexes separated by a semi-colon
   -fprofile-filter-files=
   Instrument only functions from files where names 
match any regex separated by a semi-colon
-  -fprofile-instr-generate=
-  Generate instrumented code to collect execution 
counts into 
+  -fprofile-generate=
+  Generate instrumented code to collect execution 
counts into a raw profile file in the directory specified by the argument. The 
filename uses the %m format. See :ref:`Profiling With Instrumentation 
`  section for details.

petrhosek wrote:

Should the second sentence say "The filename uses the default_%m.profraw."?

https://github.com/llvm/llvm-project/pull/73845
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

2023-11-30 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/69447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

2023-11-30 Thread Petr Hosek via cfe-commits


@@ -138,10 +164,34 @@ static const VersionTuple MultilibVersionCurrent(1, 0);
 struct MultilibSerialization {
   std::string Dir;
   std::vector Flags;
+  std::string Group;
+};
+
+struct MultilibGroupSerialization {
+  /*
+   * Future directions:
+   *
+   * If it's needed in future, we could introduce additional group types by
+   * permitting Type to contain strings other than "Exclusive". Another
+   * possibility is a group of library directories that are mutually
+   * _dependent_ rather than mutually exclusive: if you include one you must
+   * include them all.
+   *
+   * It might also be useful to allow groups to be members of other groups, so
+   * that a mutually exclusive group could contain a mutually dependent set of
+   * library directories, or vice versa.
+   *
+   * These additional features would need changes in the implementation, but
+   * the YAML schema is set up so they can be added without requiring changes
+   * in existing users' multilib.yaml files.
+   */
+  std::string Name;
+  std::string Type;

petrhosek wrote:

Could we make the type an `enum`?

https://github.com/llvm/llvm-project/pull/69447
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libc] [clang-tools-extra] [clang] [llvm] [mlir] [compiler-rt] [flang] [sanitizer_symbolizer] RenderContextual elements for symbolizer markup. (PR #73194)

2023-11-30 Thread Petr Hosek via cfe-commits
=?utf-8?q?Andr=C3=A9s?= Villegas ,
=?utf-8?q?Andr=C3=A9s?= Villegas 
Message-ID:
In-Reply-To: 


https://github.com/petrhosek approved this pull request.


https://github.com/llvm/llvm-project/pull/73194
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-11-30 Thread Petr Hosek via cfe-commits


@@ -4401,13 +4413,18 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   Instrument only functions from files where names 
don't match all the regexes separated by a semi-colon
   -fprofile-filter-files=
   Instrument only functions from files where names 
match any regex separated by a semi-colon
+  -fprofile-generate[=]
+  Generate instrumented code to collect execution 
counts into a raw profile file in 
+  (overridden by LLVM_PROFILE_FILE env var)
   -fprofile-instr-generate=
   Generate instrumented code to collect execution 
counts into 
   (overridden by LLVM_PROFILE_FILE env var)
   -fprofile-instr-generate
   Generate instrumented code to collect execution 
counts into default.profraw file
   (overridden by '=' form of option or 
LLVM_PROFILE_FILE env var)
   -fprofile-instr-use=
+  Use instrumentation data for coverage testing or 
profile-guided optimization
+  -fprofile--use=

petrhosek wrote:

This a nit, but there should be only a single `-`, so `-fprofile-use` not 
`-fprofile--use`.

https://github.com/llvm/llvm-project/pull/73845
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   >