[clang] [flang] [mlir] Add basic -mtune support (PR #98517)

2024-07-17 Thread David Spickett via cfe-commits

DavidSpickett wrote:

This was failing on our bots that build all backends, I've fixed that:
https://github.com/llvm/llvm-project/commit/8bf952d77fbe63f979e4293e95a5ca379e26eede

It will help you in future if you set an email address for your commits in this 
Github project. Buildbot will then use that to notify you of failures.

You can also glance at http://llvm.validation.linaro.org/ (the "Flang" section) 
or search flang in https://lab.llvm.org/buildbot/#/builders (not every one that 
includes flang, but all the ones that focus on it at least).

It will post on PRs too if it knows a single commit is the problem, but all the 
bots that would have been able to do that only build the AArch64 target and it 
worked fine in that case.

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


[clang-tools-extra] [clang-tools-extra] Fix typos in Modularize.rst (PR #99256)

2024-07-17 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I saw your email in the merge box so I've gone ahead and landed it (I think the 
workflow that checks for a private email may only be re-run when the changes in 
the PR are updated).

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


[clang-tools-extra] [clang-tools-extra] Fix typos in Modularize.rst (PR #99256)

2024-07-17 Thread David Spickett via cfe-commits

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


[clang] [clang][Interp] Implement dynamic memory allocation handling (PR #70306)

2024-07-16 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I know there is UB in there (https://github.com/llvm/llvm-project/issues/94741) 
so this is not unsurprising. Though so far none of that has been the cause of 
failures natively.

Let's see what Leandro finds.

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


[clang] [clang][Interp] Implement dynamic memory allocation handling (PR #70306)

2024-07-16 Thread David Spickett via cfe-commits

DavidSpickett wrote:

@luporl please help reproduce the bot failure 
https://lab.llvm.org/buildbot/#/builders/39/builds/528.

You can also try it under qemu - 
https://linaro.atlassian.net/wiki/spaces/TCWGPUB/pages/29360783374/How+to+Reproduce+32+bit+Arm+Builds+Without+Hardware.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-11 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-11 Thread David Spickett via cfe-commits


@@ -20,16 +20,15 @@ using namespace llvm;
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  const StringMap features = sys::getHostCPUFeatures(features);
+  if (features.empty())
 return 1;
 
-  if (features["sse"])
+  if (features->lookup("sse"))

DavidSpickett wrote:

It doesn't, I forgot to rebuild on x86. Fixed this and removed the parameter 
that's no longer needed.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-11 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/97824

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH 1/9] [llvm][TargetParser] Return optional from
 getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a136..77adbf3865ab1 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82dae..e4adfcac23ca0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a..16743164e6a5d 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67..d68655835a323 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// names to either true (if enabled) or false (if disabled). This routine
+  /// makes no guarantees about exactly which features may appear in this map,
+  /// except that they are all valid LLVM feature names. If feature detection
+  /// fails, an empty optional is returned.

[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread David Spickett via cfe-commits


@@ -492,6 +495,13 @@ Modified Compiler Flags
   now include dianostics about C++26 features that are not present in older
   versions.
 
+- Removed the "arm interrupt calling convention" warning that was included in
+  ``-Wextra`` without its own flag. This warning suggested adding
+  ``__attribute__((interrupt))`` to functions that are called from interrupt
+  handlers to prevent clobbering VFP registers. Following this suggestion leads
+  to unpredictable behavior by causing multiple exception returns from one
+  exception. Fixes #GH34876.
+

DavidSpickett wrote:

Note to other reviewers: This is in the modified flags section because -wextra 
itself is being modified. A part of it was removed but that part was never a 
separate flag so this doesn't need to go in the "removed compiler flags" 
section.

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


[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Everything LGTM but I'd like someone who works on Arm's downstream compiler to 
approve. @ostannard perhaps? 

(thanks for your patience @chrisnc)

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


[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread David Spickett via cfe-commits


@@ -1329,6 +1329,11 @@ void SemaARM::handleInterruptAttr(Decl *D, const 
ParsedAttr ) {
 return;
   }
 
+  const TargetInfo  = getASTContext().getTargetInfo();
+  if (TI.hasFeature("vfp")) {
+Diag(D->getLocation(), diag::warn_arm_interrupt_vfp_clobber);
+  }

DavidSpickett wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits


@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 

DavidSpickett wrote:

Done.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits


@@ -15,21 +15,22 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+

DavidSpickett wrote:

Done.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/97824

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH 1/5] [llvm][TargetParser] Return optional from
 getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a136..77adbf3865ab1 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82dae..e4adfcac23ca0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a..16743164e6a5d 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67..d68655835a323 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// names to either true (if enabled) or false (if disabled). This routine
+  /// makes no guarantees about exactly which features may appear in this map,
+  /// except that they are all valid LLVM feature names. If feature detection
+  /// fails, an empty optional is returned.

[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

DavidSpickett wrote:

>  Why not return a map every time?

Done.


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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/97824

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH 1/4] [llvm][TargetParser] Return optional from
 getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a136..77adbf3865ab1 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82dae..e4adfcac23ca0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a..16743164e6a5d 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67..d68655835a323 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// names to either true (if enabled) or false (if disabled). This routine
+  /// makes no guarantees about exactly which features may appear in this map,
+  /// except that they are all valid LLVM feature names. If feature detection
+  /// fails, an empty optional is returned.

[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Fair point, iirc all the callers go on to iterate the map so no one is handling 
failure in a special way. I'll update this.

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


[clang] [llvm] [AArch64][RISCV] Improve the tests for --print-enabled-extensions and --print-supported-extensions (PR #97829)

2024-07-09 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Re. the test failure, I've been disabling these and collecting them in 
https://github.com/llvm/llvm-project/issues/97712. Let me know if you see any 
others.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits


@@ -22,13 +22,13 @@ using namespace llvm;
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  if (std::optional> features =
+  if (const std::optional> features =
   sys::getHostCPUFeatures(features)) {
-if ((*features)["sse"])
+if (features->contains("sse"))

DavidSpickett wrote:

Fixed.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/97824

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH 1/3] [llvm][TargetParser] Return optional from
 getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a1368..77adbf3865ab11 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82daec..e4adfcac23ca0d 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a9..16743164e6a5d9 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67f..d68655835a3233 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// names to either true (if enabled) or false (if disabled). This routine
+  /// makes no guarantees about exactly which features may appear in this map,
+  /// except that they are all valid LLVM feature names. If feature detection
+  /// fails, an empty optional is 

[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits


@@ -22,13 +22,13 @@ using namespace llvm;
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  if (std::optional> features =
+  if (const std::optional> features =
   sys::getHostCPUFeatures(features)) {
-if ((*features)["sse"])
+if (features->contains("sse"))

DavidSpickett wrote:

Doh, of course.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits


@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])

DavidSpickett wrote:

Done.

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/97824

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH 1/2] [llvm][TargetParser] Return optional from
 getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a136..77adbf3865ab1 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82dae..e4adfcac23ca0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a..16743164e6a5d 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67..d68655835a323 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// names to either true (if enabled) or false (if disabled). This routine
+  /// makes no guarantees about exactly which features may appear in this map,
+  /// except that they are all valid LLVM feature names. If feature detection
+  /// fails, an empty optional is returned.

[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits


@@ -1710,15 +1710,17 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
 
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-bool sys::getHostCPUFeatures(StringMap ) {
+std::optional> sys::getHostCPUFeatures() {
   unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
   unsigned MaxLevel;
 
   if (getX86CpuIDAndInfo(0, , , , ) || MaxLevel < 1)
-return false;
+return {};
 
   getX86CpuIDAndInfo(1, , , , );
 
+  StringMap Features;

DavidSpickett wrote:

The caller creating a blank map to pass to this function is the symptom of what 
I'm looking to fix here. The implementations are still going to create a map if 
they're going to return features.

The motivation for the change is to allow:
```
if (auto features = sys::getCPUHostFeatures())
```
Instead of:
```
map features;
if (sys::getCPUHostFeatures(map)
```
As the optional better describes the situation. You either get a feature map or 
you don't. Versus bool+mutable ref which could allow any combination of states. 
The docstring helps but might as well use the typesystem to say the same thing 
as well.

If the callers were building a map as they went, I'd understand the mutable ref 
parameter. Like:
```
map features
if (add_some_features(features))
  if (add_some_more_features(features))
filter_features(features)
```
But all uses create an empty map specifically to pass to the function.

...which is to say yeah, I should include the motivation in the commit message, 
let me do that :)

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


[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-05 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/97824

Previously this took a reference to a map and returned a bool to say whether it 
succeeded. This is an optional but with more steps.

The only reason to keep it that way was if someone was appending to an existing 
map, but all callers made a new map before calling it.

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH] [llvm][TargetParser] Return optional from getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a1368..77adbf3865ab11 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82daec..e4adfcac23ca0d 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a9..16743164e6a5d9 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67f..d68655835a3233 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// 

[clang] [clang][AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)

2024-07-05 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Looks ok to me, X86 and ARM already do this.

> One point we noticed is that it could end up turning "aes+sha2" into "crypto" 
> and "crypto" back into "sha2+aes+sha3+sm4", as it uses the old meaning of 
> "crypto"

Then this needs to be fixed before this PR can go in, we don't want to be 
making binaries folks can't run. @davemgreen do we have a way that @neildhickey 
can reproduce that easily?


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


[clang] [clang][AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)

2024-07-05 Thread David Spickett via cfe-commits

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


[clang] [AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)

2024-07-05 Thread David Spickett via cfe-commits

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


[clang] [AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)

2024-07-05 Thread David Spickett via cfe-commits

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


[clang] [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (PR #97071)

2024-07-02 Thread David Spickett via cfe-commits
Stefan =?utf-8?q?Gränitz?= ,
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


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


[clang] [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (PR #97071)

2024-07-01 Thread David Spickett via cfe-commits
Stefan =?utf-8?q?Gr=C3=A4nitz?= ,
Stefan =?utf-8?q?Gr=C3=A4nitz?= 
Message-ID:
In-Reply-To: 


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


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


[clang] [clang-repl] Fix RuntimeInterfaceBuilder for 32-bit systems (PR #97071)

2024-07-01 Thread David Spickett via cfe-commits
Stefan =?utf-8?q?Gränitz?= 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

Also remove the comment that links to 
https://github.com/llvm/llvm-project/issues/94994 and add `Fixes #94994` to the 
commit message.

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


[clang] [flang] [llvm] Re-land: "[AArch64] Add ability to list extensions enabled for a target" (#95805) (PR #96795)

2024-06-27 Thread David Spickett via cfe-commits


@@ -343,7 +350,9 @@ bool isX18ReservedByDefault(const Triple );
 // themselves, they are sequential (0, 1, 2, 3, ...).
 uint64_t getCpuSupportsMask(ArrayRef FeatureStrs);
 
-void PrintSupportedExtensions(StringMap DescMap);
+void PrintSupportedExtensions();
+
+void printEnabledExtensions(std::set EnabledFeatureNames);

DavidSpickett wrote:

Might as well be const correct too if you're changing it.

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


[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-26 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I very much doubt it is, your change is still in the next build 
(https://lab.llvm.org/buildbot/#/builders/134/builds/681) and that's green.

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


[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-06-26 Thread David Spickett via cfe-commits


@@ -448,6 +448,11 @@ Modified Compiler Flags
   evaluating to ``true`` and an empty body such as ``while(1);``)
   are considered infinite, even when the ``-ffinite-loop`` flag is set.
 
+- Removed "arm interrupt calling convention" warning that was included in
+  ``-Wextra`` without its own flag.
+
+- Added ``-Warm-interrupt-vfp-clobber``, with its own warning group.

DavidSpickett wrote:

We should be very clear whether this warning is serving the same function as 
the one that was removed, or not.

If it is, perhaps it is better to merge the two points so it is clear one is 
replaced by the other. If not, perhaps you can include a sentence for each like 
"that would be emitted when..." - "that will be emitted when..." that shows the 
purpose of each one.

(I know this is in the help, but we can save interested parties a round trip 
here)

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


[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-06-26 Thread David Spickett via cfe-commits


@@ -336,9 +336,12 @@ def warn_anyx86_excessive_regsave : Warning<
   " with attribute 'no_caller_saved_registers'"
   " or be compiled with '-mgeneral-regs-only'">,
   InGroup>;
-def warn_arm_interrupt_calling_convention : Warning<
-   "call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
-   InGroup;
+def warn_arm_interrupt_vfp_clobber : Warning<
+  "interrupt service routine with vfp enabled may clobber the "
+  "interruptee's vfp state">,
+  InGroup>;
+def err_arm_interrupt_called : Error<
+  "interrupt service routine cannot be called directly">;

DavidSpickett wrote:

I don't see a test case for this error.

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


[libunwind] [llvm] [runtimes] remove workaround for old CMake when setting `--unwindlib=none` (PR #93429)

2024-06-21 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Linaro will look into this.

Reproducing the build is quite easy if you do want to look yourselves in the 
meantime:
```
$ ./libcxx/utils/ci/run-buildbot 
armv7m-picolibc-no-exceptions
```
You'll need a recent `qemu-system-arm` installed to run the tests, I have 8.1.3 
locally. Picolib is downloaded and built for you by the script.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-18 Thread David Spickett via cfe-commits


@@ -204,6 +238,10 @@ int cc1_main(ArrayRef Argv, const char 
*Argv0, void *MainAddr) {
   if (Clang->getFrontendOpts().PrintSupportedExtensions)
 return PrintSupportedExtensions(Clang->getTargetOpts().Triple);
 
+  // --print-enabled-extensions takes priority over the actual compilation.

DavidSpickett wrote:

Cool, I doubt anyone is going to combine them any time soon, but good that 
something deterministic happens.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-18 Thread David Spickett via cfe-commits


@@ -19,3 +19,19 @@
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-GENERICV81A %s
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-GENERICV81A %s
 // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon"
+
+// = Architecture extensions =
+
+// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 
2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s
+// ARCH-EXTENSION: FEAT_ETE

DavidSpickett wrote:

> the implications between them are not very clear

True. The visual difference might be `+whatever` but the user doesn't know what 
that requires or implies.

Leave it as is and if anyone actually finds it useful they can add the `+...` 
themselves. I don't have an immediate use case myself.

Just being able to compare 1 compiler command line against a technical 
reference manual is already an improvement.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-18 Thread David Spickett via cfe-commits


@@ -161,6 +162,39 @@ static int PrintSupportedExtensions(std::string TargetStr) 
{
   return 0;
 }
 
+static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {

DavidSpickett wrote:

Cool, happy to "when in Rome" here and leave it as is.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-18 Thread David Spickett via cfe-commits


@@ -13,3 +13,57 @@
 // RUN: %clang --target=aarch64_be -mbig-endian -march=armv8.6a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV86A-BE %s
 // RUN: %clang --target=aarch64_be -mbig-endian -march=armv8.6-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV86A-BE %s
 // GENERICV86A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+v8.6a"{{.*}} "-target-feature" "+neon"
+
+// = Architecture extensions =
+
+// RUN: %clang -target aarch64 -march=armv8.6-a --print-enabled-extensions 
2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s

DavidSpickett wrote:

Ok got it, the CHECK consumes the line so if there was anything left matching 
FEAT_, something was forgotten. Thanks.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -19,3 +19,19 @@
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-GENERICV81A %s
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-GENERICV81A %s
 // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon"
+
+// = Architecture extensions =
+
+// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 
2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s
+// ARCH-EXTENSION: FEAT_ETE

DavidSpickett wrote:

I'm also curious what it looks like just to confirm that it would be possible 
to do something like `clang --print-enabled-extensions | tail | cut ... | sort 
| uniq` if you wanted to extract the list. I assume we can because it's in a 
table.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Also please list the impact, if any, on `--print-supported-extensions` in the 
commit message. I think it got a column with the FEAT_ names added, which is a 
nice improvement.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -204,6 +238,10 @@ int cc1_main(ArrayRef Argv, const char 
*Argv0, void *MainAddr) {
   if (Clang->getFrontendOpts().PrintSupportedExtensions)
 return PrintSupportedExtensions(Clang->getTargetOpts().Triple);
 
+  // --print-enabled-extensions takes priority over the actual compilation.

DavidSpickett wrote:

What happens if I ask for `--print-supported-extensions` and 
`--print-enabled-extensions`?

I'd guess either both happen, or the last one in wins.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -134,17 +136,39 @@ std::optional 
AArch64::parseCpu(StringRef Name) {
   return {};
 }
 
-void AArch64::PrintSupportedExtensions(StringMap DescMap) {
+void AArch64::PrintSupportedExtensions() {
   outs() << "All available -march extensions for AArch64\n\n"
  << "" << left_justify("Name", 20)
- << (DescMap.empty() ? "\n" : "Description\n");
+ << left_justify("Architecture Feature(s)", 55)
+ << "Description\n";
   for (const auto  : Extensions) {
 // Extensions without a feature cannot be used with -march.
-if (!Ext.Feature.empty()) {
-  std::string Description = DescMap[Ext.Name].str();
+if (!Ext.UserVisibleName.empty() && !Ext.TargetFeature.empty()) {

DavidSpickett wrote:

Which test in this PR checks this formatting? Just one row is fine.

Perhaps the CPU tests do but it seems like they only want FEAT_XYZ to show up.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -13,3 +13,57 @@
 // RUN: %clang --target=aarch64_be -mbig-endian -march=armv8.6a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV86A-BE %s
 // RUN: %clang --target=aarch64_be -mbig-endian -march=armv8.6-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV86A-BE %s
 // GENERICV86A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+v8.6a"{{.*}} "-target-feature" "+neon"
+
+// = Architecture extensions =
+
+// RUN: %clang -target aarch64 -march=armv8.6-a --print-enabled-extensions 
2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s

DavidSpickett wrote:

What is the implicit-check-not doing here? Or rather, what possible bug is it 
making sure we don't miss?

Is it that in the information we list the names as "AMUv1" for example, so if 
we forgot to add a name, we'd output just "FEAT_" ?

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -161,6 +162,39 @@ static int PrintSupportedExtensions(std::string TargetStr) 
{
   return 0;
 }
 
+static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {

DavidSpickett wrote:

Is int here just following the local code style or would bool do? Since we only 
use 0 and 1.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -19,3 +19,19 @@
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-GENERICV81A %s
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-GENERICV81A %s
 // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon"
+
+// = Architecture extensions =
+
+// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 
2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s
+// ARCH-EXTENSION: FEAT_ETE

DavidSpickett wrote:

I'm surprised that this doesn't show the name the user would use with `-march`, 
is that expected?

Since `--print-supported-extensions` shows it:
```
All available -march extensions for AArch64

NameDescription
aes Enable AES support (FEAT_AES, FEAT_PMULL)
```

And if I were comparing two command lines I might want to know what `+foo` I 
need to add to one to make it equivalent to the other.

Or I am misreading the output and the name is there already :)

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett commented:

Cool idea, should be very useful.

The TableGen has changed so much since I last looked so I didn't look over that 
myself.

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits

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


[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

2024-06-17 Thread David Spickett via cfe-commits


@@ -5703,6 +5703,11 @@ def print_supported_extensions : Flag<["-", "--"], 
"print-supported-extensions">
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"Print supported -march extensions (RISC-V, AArch64 and ARM only)">,
   MarshallingInfoFlag>;
+def print_enabled_extensions : Flag<["-", "--"], "print-enabled-extensions">,
+  Visibility<[ClangOption, CC1Option, CLOption]>,
+  HelpText<"Print the -march/-mcpu extensions enabled for the given target"

DavidSpickett wrote:

This is tricky to word without it becoming a paragraph, but perhaps something 
like this is more accurate:
```
Print the extensions enabled by the given target and -march/-mcpu options.
```
This distinguishes it from `--print-supported-extensions`. Phrasing aside, the 
point is that it's listing a consequence of -march/-mcpu, not what you could 
add to -march and -mcpu.

`supported` is "here's what you could have", `enabled` is "this is what we gave 
you given the other options you used".

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> I'd like to also address https://github.com/llvm/llvm-project/issues/47815, 
> but I wasn't able to find the right path to answer "is this M-profile" from 
> TargetInfo.

Any ARM folks know if there are existing M profile only warnings to learn from?

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits


@@ -544,6 +548,14 @@ Improvements to Clang's diagnostics
 - Clang no longer emits a "declared here" note for a builtin function that has 
no declaration in source.
   Fixes #GH93369.
 
+- On ARM, Clang no longer suggests adding ``__attribute__((interrupt))`` to

DavidSpickett wrote:

I would phrase this "For the ARM target", since Clang could be running on any 
host architecture.

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits


@@ -384,6 +384,10 @@ Modified Compiler Flags
   evaluating to ``true`` and an empty body such as ``while(1);``)
   are considered infinite, even when the ``-ffinite-loop`` flag is set.
 
+- Removed "arm interrupt calling convention" warning that was included in

DavidSpickett wrote:

I would rephrase this a bit:
```
The "arm interrupt calling convention" warning previously included in 
``-Wextra`` has been removed and made into a unique warning enabled using 
``-Warm-interrrupt-vfp-clobber``.
```

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits


@@ -336,9 +336,10 @@ def warn_anyx86_excessive_regsave : Warning<
   " with attribute 'no_caller_saved_registers'"
   " or be compiled with '-mgeneral-regs-only'">,
   InGroup>;
-def warn_arm_interrupt_calling_convention : Warning<
-   "call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
-   InGroup;
+def warn_arm_interrupt_vfp_clobber : Warning<
+   "calling a VFP-enabled function from an interrupt could clobber the "

DavidSpickett wrote:

Unless "VFP-enabled" is some Arm defined, specific spelling, I would write it 
as "VFP enabled" without the "-".

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett commented:

I can't fully approve this, I leave that to other members of 
@llvm/pr-subscribers-arm .

2 overall comments:
* Calling a function marked interrupt from a function marked interrupt is still 
UB isn't it? Should there be another warning to cover that scenario as well?
* I see that gcc has a warning in `-Wattributes` for this, you should raise a 
bug there equivalent to the one llvm has, perhaps there even is one already.

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

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


[clang] c324281 - [clang][test] Update link for Arm clang-repl test disable

2024-06-10 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2024-06-10T16:14:53+01:00
New Revision: c32428151678f05fa3a9b5996e07f1e67094626c

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

LOG: [clang][test] Update link for Arm clang-repl test disable

The original bug is legitimate UB, but this is in the clang constant
expression interpreter, not clang-repl.

https://github.com/llvm/llvm-project/issues/94994 covers investigation
of this specific bug in clang-repl.

Added: 


Modified: 
clang/unittests/Interpreter/InterpreterTest.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 72b34dae378e5..683295a18d519 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -283,7 +283,7 @@ TEST_F(InterpreterTest, InstantiateTemplate) {
 }
 
 // This test exposes an ARM specific problem in the interpreter, see
-// https://github.com/llvm/llvm-project/issues/94741.
+// https://github.com/llvm/llvm-project/issues/94994.
 #ifndef __arm__
 TEST_F(InterpreterTest, Value) {
   std::unique_ptr Interp = createInterpreter();



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


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-10 Thread David Spickett via cfe-commits

DavidSpickett wrote:

You can debug it by cross-compiling a debug build, then running the unit tests 
binary and connecting to qemu's built in gdbserver. The Arm toolchain might 
have a copy of gdb in it already, but if not, gdb multiarch and lldb would also 
work (which are both installable from apt).

I'm going to try looking in a debugger myself today.

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


[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)

2024-06-07 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Looks like this fixed things: 
https://lab.llvm.org/buildbot/#/builders/245/builds/25578

Thanks for working with me on this.

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


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-07 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Actually, as someone pointed out, I've been conflating clang-repl with the 
constant expression interpreter. So the issue covers the latter and this must 
be something else.

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


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-07 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> I will get you instructions on how to do that (will be tomorrow at this 
> point).

https://github.com/llvm/llvm-project/issues/94741#issuecomment-2154656315

There is some underlying issue 
(https://github.com/llvm/llvm-project/issues/94741), so if you want to try and 
fix it, that's great, but it's also fine if you'd rather wait and see what I 
find on native hardware.

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


[clang] 54c5dbe - [clang][test] Skip interpreter value test on Arm 32 bit

2024-06-07 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2024-06-07T10:38:25Z
New Revision: 54c5dbe7c3812461decbccb6ed122e41777e02bd

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

LOG: [clang][test] Skip interpreter value test on Arm 32 bit

https://github.com/llvm/llvm-project/pull/89811 caused this test to fail,
somehow.

I think it may not be at fault, but actually be exposing some
existing undefined behaviour, see
https://github.com/llvm/llvm-project/issues/94741.

Skipping this for now to get the bots green again.

Added: 


Modified: 
clang/unittests/Interpreter/InterpreterTest.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index ab9b7a31094f7..72b34dae378e5 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -282,6 +282,9 @@ TEST_F(InterpreterTest, InstantiateTemplate) {
   EXPECT_EQ(42, fn(NewA.getPtr()));
 }
 
+// This test exposes an ARM specific problem in the interpreter, see
+// https://github.com/llvm/llvm-project/issues/94741.
+#ifndef __arm__
 TEST_F(InterpreterTest, Value) {
   std::unique_ptr Interp = createInterpreter();
 
@@ -379,5 +382,6 @@ TEST_F(InterpreterTest, Value) {
   EXPECT_EQ(V9.getKind(), Value::K_PtrOrObj);
   EXPECT_TRUE(V9.isManuallyAlloc());
 }
+#endif /* ifndef __arm__ */
 
 } // end anonymous namespace



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


[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)

2024-06-07 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Ok, this new version passes `check-llvm` and `check-clang` (ignoring the 
pre-existing failure), using the exact config from 
[clang-armv8-quick](https://lab.llvm.org/buildbot/#/builders/245).

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


[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)

2024-06-07 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Sure I'll test it now.

BTW if you see `Clang-Unit::ClangReplInterpreterTests/InterpreterTest/Value` 
failing on one of our bots, that's not due to your change.

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


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-06 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> My feeling is the latter but how can we get a debug build and debug?

I'm going to try a UBSAN build on the chance it pinpoints the issue right away, 
but failing that it'll be cross compiling to Arm 32 bit and using qemu-user to 
run the unit test binary. I will get you instructions on how to do that (will 
be tomorrow at this point).

If this is a generic 32 bit problem you could also build for 32 bit on x86. I 
don't know if it is because there are no bots for that.

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


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-06 Thread David Spickett via cfe-commits

DavidSpickett wrote:

It is a 32 bit container running on an arm64 host. As far as the compiler and 
tests know, it's a 32 bit system.

> But in either case the width of the int type should be the same, right?

Yes.

So I am wondering if someone of the assumptions about types being larger than 
one another do not hold on 32 bit. Or your change has exposed an existing 
issue, it wouldn't be the first time.

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


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-06 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I have bisected a 32 bit Arm failure down to this change: 
https://lab.llvm.org/buildbot/#/builders/245/builds/25526

Is it possible that something in this code is truncating a value when 
interpreting types intended for a 64 bit system, on a 32 bit system? I don't 
see this failure on any of our Arm64 buildbots.

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


[clang] Testing32 bit for https://github.com/llvm/llvm-project/pull/92083 (PR #94603)

2024-06-06 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I tested locally and this fixes all the test failures.

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


[clang] [serialization] no transitive decl change (PR #92083)

2024-06-06 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> Thanks. Reproduced. But it surprised me that I can't run the commands you 
> mentioned, but I need to run:
> ./bin/lldb-dotest -p TestTemplateWithSameArg.py -G gmodules

Running the tests as modules is perhaps opt in, we have the ability to run them 
with different debug info types too. So this is not surprising. Well, it is for 
you, but doesn't mean there's anything wrong here :)

> And I am also slightly surprised that after I change the code, it doesn't 
> work if I run ninja lldb-test only I need to run ninja clang lldb. Do I 
> misconfigure anything? I build lldb by:

My comment about `lld-test` referred to a different failing test I think (and 
if we did have some dependencies incorrect, it wouldn't surprise me). Nothing 
wrong with that config line though.

So good news is Linux and Windows lldb are ok (Mac will report back soon I 
assume), but now we have failures on 32 bit Arm builds:
https://lab.llvm.org/buildbot/#/builders/245/builds/25498

I'm going to reproduce this shortly but my bet is that this is undefined 
behaviour of some kind. It may not be due to your code but your code may be 
exposing a pre-existing issue.

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


[clang] [clang][AArch64] Add validation for Global Register Variable. (PR #94271)

2024-06-04 Thread David Spickett via cfe-commits

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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-04 Thread David Spickett via cfe-commits

DavidSpickett wrote:

https://github.com/llvm/llvm-project/pull/94325 will get us past the compiler 
error.

Some things I noticed testing that:
* There is an lld installed on the machine but it's in a path with spaces so 
lit can't run it. Generally we'd build lld along with lldb and use that in the 
test suite, when I did that it worked.
* LLDB is not being built with scripting enabled, so a lot of the API tests 
won't be run.

For a completed run I got these results:
https://buildkite.com/llvm-project/github-pull-requests/builds/69540#018fe2bf-1cf8-49f7-a680-f44bf01dbaec
```
Failed Tests (4):
  lldb-shell :: Process/Windows/process_load.cpp
  lldb-shell :: SymbolFile/DWARF/x86/dwp-separate-debug-file.cpp
  lldb-shell :: Target/dependent-modules-nodupe-windows.test
  lldb-shell :: Unwind/windows-unaligned-x86_64.test

Testing Time: 38.08s
Total Discovered Tests: 2901
  Unsupported  : 1337 (46.09%)
  Passed   : 1543 (53.19%)
  Expectedly Failed:   17 (0.59%)
  Failed   :4 (0.14%)
```

`dwp-separate-debug-file.cpp` I have fixed, it needed to require Python. 
`windows-unaligned-x86_64.test` just fails to breakpoint, I don't know why. The 
rest are something to do with `kernel32.dll` either not being able to load it, 
or it not showing up in the image list for a debugged program.

I have never seen that before but it does sound like something a security 
setting might effect.

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


[clang] [serialization] no transitive decl change (PR #92083)

2024-06-04 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Maybe you can run individual tests with lit but generally I use `lldb-dotest` 
instead:
```
./bin/lldb-dotest.py -p TestTemplateWithSameArg.py
```
(you only need the filename)

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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-04 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I think the issue is 
https://developercommunity.visualstudio.com/t/c-shared-state-futuresstate-default-constructs-the/60897
 which appears to have been fixed in 19.32 (https://godbolt.org/z/P594qGrc9).

But @slydiman reports 14.29.30133 which is earlier than that. Perhaps the 
versions in Compiler Explorer don't couple the compiler and standard library.

The CI job reports to be:
```
-- The C compiler identification is MSVC 19.29.30154.0
-- The CXX compiler identification is MSVC 19.29.30154.0
-- The ASM compiler identification is MSVC
-- Found assembler: 
C:/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
```

Which is even more confusing.

But the point is, we could `#if` it out for a given msvc version, if I can 
figure out which one.


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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-04 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> MSVC 14.29.30133 is VS 2019. We are using VS 2022 with the latest Windows SDK 
> to build lldb w/o problems.

I also couldn't reproduce it locally with `19.34.31937`, but I may still be 
able to reproduce by making my own version of this PR so I can use the CI's 
version.

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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-03 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> I'll do that, but I think LLDB should follow the example of MLIR here

https://github.com/llvm/llvm-project/pull/94220

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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-03 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> First Windows CI results: LLDB unit tests do not even build.

Linaro's Windows bot uses clang-cl, but I do remember something like this there 
too. I will do a local build with msvc and see what I can do.

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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-03 Thread David Spickett via cfe-commits

DavidSpickett wrote:

And I would bet that a majority of the unresolved are due to:
```
ModuleNotFoundError: No module named 'pexpect'
```
You can either install it with `pip` or pass 
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` to CMake.

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


[clang] [llvm] Enable LLDB tests in pre-merge CI (PR #94208)

2024-06-03 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> lldb-shell :: SymbolFile/DWARF/x86/module-ownership.mm

This is due to https://github.com/llvm/llvm-project/pull/92083, it's been 
reverted now.

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


[clang] [serialization] no transitive decl change (PR #92083)

2024-06-03 Thread David Spickett via cfe-commits

DavidSpickett wrote:

This also broke an lldb test: 
https://lab.llvm.org/buildbot/#/builders/96/builds/58449

`lldb-test: ../llvm-project/clang/lib/AST/DeclBase.cpp:132: void 
clang::Decl::setOwningModuleID(unsigned int): Assertion `!((*IDAddress) >> 48) 
&& "We should only set the module ID once"' failed.`

I can't say if right now whether lldb is being too strict or this is a real 
problem. Could be the result of the same thing UBSAN found.

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


[clang] [lldb] [llvm] [openmp] [polly] fix(python): fix comparison to True/False (PR #91858)

2024-05-14 Thread David Spickett via cfe-commits

DavidSpickett wrote:

If this is split out from the other larger PR, should there be `clang/` changes 
in here?

I've copied your commit message into the PR description, because with the way 
llvm is setup, we use the PR's description as the commit message for a squashed 
version of the changes.

(maybe Github uses the commit message if there's only one and the PR 
description is blank, but I wouldn't bet on it)

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


[clang] [lldb] [llvm] [openmp] [polly] fix(python): fix comparison to True/False (PR #91858)

2024-05-14 Thread David Spickett via cfe-commits

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


[clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-13 Thread David Spickett via cfe-commits

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

LLDB changes look good to me.

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


[clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-13 Thread David Spickett via cfe-commits

DavidSpickett wrote:

LLVM uses a GitHub setting where the PR is squashed, and the commit message is 
taken from the PR description rather than the commits themselves. So all you 
have to do here is copy the commit message you updated into the PR's 
description.

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


[clang] fb1c2db - Revert "Reapply "[clang][Interp] Create full type info for dummy pointers""

2024-05-03 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2024-05-03T09:56:23Z
New Revision: fb1c2dbc0a6ba641e0b39e0692ec6a4eec4b

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

LOG: Revert "Reapply "[clang][Interp] Create full type info for dummy pointers""

This reverts commit 1aeb64c8ec7b96b2301929d8a325a6e1d9ddaa2f.

Due to failures in 32 bit Arm builds:
https://lab.llvm.org/buildbot/#/builders/245/builds/24041

Added: 


Modified: 
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Descriptor.h
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Program.cpp
clang/test/AST/Interp/builtin-align-cxx.cpp
clang/test/AST/Interp/c.c

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index d0466902247b4b..954c58c8cb3716 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -347,6 +347,14 @@ Descriptor::Descriptor(const DeclTy )
   assert(Source && "Missing source");
 }
 
+/// Dummy array.
+Descriptor::Descriptor(const DeclTy , UnknownSize)
+: Source(D), ElemSize(1), Size(UnknownSizeMark), MDSize(0),
+  AllocSize(MDSize), ElemRecord(nullptr), IsConst(true), IsMutable(false),
+  IsTemporary(false), IsArray(true), IsDummy(true) {
+  assert(Source && "Missing source");
+}
+
 QualType Descriptor::getType() const {
   if (auto *E = asExpr())
 return E->getType();

diff  --git a/clang/lib/AST/Interp/Descriptor.h 
b/clang/lib/AST/Interp/Descriptor.h
index fcb14e76e7eb02..cd20495c259c7d 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -128,7 +128,7 @@ struct Descriptor final {
   /// Flag indicating if the block is an array.
   const bool IsArray = false;
   /// Flag indicating if this is a dummy descriptor.
-  bool IsDummy = false;
+  const bool IsDummy = false;
 
   /// Storage management methods.
   const BlockCtorFn CtorFn = nullptr;
@@ -162,8 +162,8 @@ struct Descriptor final {
   /// Allocates a dummy descriptor.
   Descriptor(const DeclTy );
 
-  /// Make this descriptor a dummy descriptor.
-  void makeDummy() { IsDummy = true; }
+  /// Allocates a dummy array descriptor.
+  Descriptor(const DeclTy , UnknownSize);
 
   QualType getType() const;
   QualType getElemQualType() const;

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index a0bf8743001208..66d30cc3fbaaba 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -823,9 +823,9 @@ inline bool CmpHelperEQ(InterpState , CodePtr 
OpPC, CompareFn Fn) {
 // element in the same array are NOT equal. They have the same Base value,
 // but a 
diff erent Offset. This is a pretty rare case, so we fix this here
 // by comparing pointers to the first elements.
-if (!LHS.isZero() && LHS.isArrayRoot())
+if (!LHS.isZero() && !LHS.isDummy() && LHS.isArrayRoot())
   VL = LHS.atIndex(0).getByteOffset();
-if (!RHS.isZero() && RHS.isArrayRoot())
+if (!RHS.isZero() && !RHS.isDummy() && RHS.isArrayRoot())
   VR = RHS.atIndex(0).getByteOffset();
 
 S.Stk.push(BoolT::from(Fn(Compare(VL, VR;
@@ -1241,16 +1241,14 @@ inline bool GetPtrField(InterpState , CodePtr OpPC, 
uint32_t Off) {
   !CheckNull(S, OpPC, Ptr, CSK_Field))
 return false;
 
-  if (!CheckExtern(S, OpPC, Ptr))
-return false;
-  if (!CheckRange(S, OpPC, Ptr, CSK_Field))
-return false;
-  if (!CheckSubobject(S, OpPC, Ptr, CSK_Field))
-return false;
-
-  if (Ptr.isBlockPointer() && Off > Ptr.block()->getSize())
-return false;
-
+  if (CheckDummy(S, OpPC, Ptr)) {
+if (!CheckExtern(S, OpPC, Ptr))
+  return false;
+if (!CheckRange(S, OpPC, Ptr, CSK_Field))
+  return false;
+if (!CheckSubobject(S, OpPC, Ptr, CSK_Field))
+  return false;
+  }
   S.Stk.push(Ptr.atField(Off));
   return true;
 }
@@ -2036,6 +2034,11 @@ inline bool ArrayElemPtr(InterpState , CodePtr OpPC) {
   if (!Ptr.isZero()) {
 if (!CheckArray(S, OpPC, Ptr))
   return false;
+
+if (Ptr.isDummy()) {
+  S.Stk.push(Ptr);
+  return true;
+}
   }
 
   if (!OffsetHelper(S, OpPC, Offset, Ptr))
@@ -2052,6 +2055,11 @@ inline bool ArrayElemPtrPop(InterpState , CodePtr 
OpPC) {
   if (!Ptr.isZero()) {
 if (!CheckArray(S, OpPC, Ptr))
   return false;
+
+if (Ptr.isDummy()) {
+  S.Stk.push(Ptr);
+  return true;
+}
   }
 
   if (!OffsetHelper(S, OpPC, Offset, Ptr))
@@ -2105,12 +2113,12 @@ inline bool CopyArray(InterpState , CodePtr OpPC, 
uint32_t SrcIndex, uint32_t
 inline bool ArrayDecay(InterpState , CodePtr OpPC) {
   const Pointer  = S.Stk.pop();
 
-  if (Ptr.isZero()) {
+  if (Ptr.isZero() || Ptr.isDummy()) {
 S.Stk.push(Ptr);
 return true;
   }
 
-  if (!Ptr.isUnknownSizeArray() || 

[clang] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-02 Thread David Spickett via cfe-commits

DavidSpickett wrote:

@wzssyqa thanks for working with us on this. Bare metal is always a wild card 
but I think in the end we'll all have cleaner builds because of these changes.

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


[clang] [clang][Docs] Add release note for {target}-none-{environment} triple normalization changes (PR #90734)

2024-05-02 Thread David Spickett via cfe-commits

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


[clang] [clang][Docs] Add release note for {target}-none-{environment} triple normalization changes (PR #90734)

2024-05-01 Thread David Spickett via cfe-commits

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


[clang] [clang][Docs] Add release note for *-none-* triple normalization changes (PR #90734)

2024-05-01 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/90734

That were implemented by https://github.com/llvm/llvm-project/pull/89638.

>From 2d4d5e1885cc8e722b9ebaab81caf2d39c9994da Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 1 May 2024 15:39:31 +0100
Subject: [PATCH] [clang][Docs] Add release note for *-none-* triple
 normalization changes

That were implemented by https://github.com/llvm/llvm-project/pull/89638.
---
 clang/docs/ReleaseNotes.rst | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2c5308fbcb319a..6f62daba6af081 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -85,6 +85,25 @@ Clang Frontend Potentially Breaking Changes
   of ``-Wno-gnu-binary-literal`` will no longer silence this pedantic warning,
   which may break existing uses with ``-Werror``.
 
+- The normalization of 3 element target triples where ``-none-`` is the middle
+  element has changed. For example, ``armv7m-none-eabi`` previously normalized
+  to ``armv7m-none-unknown-eabi``, with ``none`` for the vendor and ``unknown``
+  for the operating system. It now normalizes to ``armv7m-unknown-none-eabi``,
+  which has ``unknown`` vendor and ``none`` operating system.
+
+  The affected triples are primarily for bare metal Arm where it is intended
+  that ``none`` means that there is no operating system. As opposed to an 
unknown
+  type of operating system.
+
+  This change my cause clang to not find libraries, or libraries to be built at
+  different file system locations. This can be fixed by changing your builds to
+  use the new normalized triple. However, we recommend instead getting the
+  normalized triple from clang itself, as this will make your builds more
+  robust in case of future changes::
+
+$ clang --target= -print-target-triple
+
+
 What's New in Clang |release|?
 ==
 Some of the major new features and improvements to Clang are listed

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


[clang] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread David Spickett via cfe-commits

DavidSpickett wrote:

libcxx is sorted, and I will write up the release note given that I suggested 
it and have been fixing some builds myself.

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


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Also this change should be release noted with a tip that build scripts may want 
to change to asking clang for the triple instead.

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


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread David Spickett via cfe-commits


@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"

DavidSpickett wrote:

https://github.com/llvm/llvm-project/pull/90722

You can remove all changes to this file.

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


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I'm checking the picolib libcxx build right now so please hold off on landing 
this.

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


  1   2   3   4   >