[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)

2025-03-27 Thread Florian Mayer via cfe-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/133350

>From 8ece858e76fad0962b2567f03bf80bcaf2828348 Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Thu, 27 Mar 2025 18:25:23 -0700
Subject: [PATCH 1/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../SmartPointerAccessorCaching.h |   6 +-
 .../SmartPointerAccessorCaching.cpp   | 125 ++
 .../SmartPointerAccessorCachingTest.cpp   |  40 ++
 3 files changed, 114 insertions(+), 57 deletions(-)

diff --git 
a/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h 
b/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h
index b4291347e0969..e55b83aa845d4 100644
--- a/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h
+++ b/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h
@@ -62,8 +62,10 @@ ast_matchers::StatementMatcher isPointerLikeOperatorStar();
 ast_matchers::StatementMatcher isSmartPointerLikeOperatorStar();
 ast_matchers::StatementMatcher isPointerLikeOperatorArrow();
 ast_matchers::StatementMatcher isSmartPointerLikeOperatorArrow();
-ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall();
-ast_matchers::StatementMatcher isSmartPointerLikeGetMethodCall();
+ast_matchers::StatementMatcher
+isSmartPointerLikeValueMethodCall(clang::StringRef MethodName = "value");
+ast_matchers::StatementMatcher
+isSmartPointerLikeGetMethodCall(clang::StringRef MethodName = "get");
 
 // Common transfer functions.
 
diff --git a/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp 
b/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp
index 0860cc1dbaf8e..638f5211152b2 100644
--- a/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp
+++ b/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp
@@ -2,6 +2,7 @@
 
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/ASTMatchers/ASTMatchersMacros.h"
 #include "clang/Basic/OperatorKinds.h"
@@ -23,8 +24,7 @@ using ast_matchers::pointerType;
 using ast_matchers::referenceType;
 using ast_matchers::returns;
 
-bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet,
-   bool &HasValue) {
+CanQualType pointerLikeReturnType(const CXXRecordDecl &RD) {
   // We may want to cache this search, but in current profiles it hasn't shown
   // up as a hot spot (possibly because there aren't many hits, relatively).
   bool HasArrow = false;
@@ -55,38 +55,47 @@ bool hasSmartPointerClassShape(const CXXRecordDecl &RD, 
bool &HasGet,
   .getUnqualifiedType();
   }
   break;
-case OO_None: {
-  IdentifierInfo *II = MD->getIdentifier();
-  if (II == nullptr)
-continue;
-  if (II->isStr("get")) {
-if (MD->getReturnType()->isPointerType()) {
-  HasGet = true;
-  GetReturnType = MD->getReturnType()
-  ->getPointeeType()
-  ->getCanonicalTypeUnqualified()
-  .getUnqualifiedType();
-}
-  } else if (II->isStr("value")) {
-if (MD->getReturnType()->isReferenceType()) {
-  HasValue = true;
-  ValueReturnType = MD->getReturnType()
-.getNonReferenceType()
-->getCanonicalTypeUnqualified()
-.getUnqualifiedType();
-}
-  }
-} break;
 default:
   break;
 }
   }
+  if (HasStar && HasArrow && StarReturnType == ArrowReturnType)
+return StarReturnType;
 
-  if (!HasStar || !HasArrow || StarReturnType != ArrowReturnType)
-return false;
-  HasGet = HasGet && (GetReturnType == StarReturnType);
-  HasValue = HasValue && (ValueReturnType == StarReturnType);
-  return true;
+  return {};
+}
+CanQualType getLikeReturnType(QualType RT) {
+  if (!RT.isNull() && RT->isPointerType()) {
+return RT->getPointeeType()
+->getCanonicalTypeUnqualified()
+.getUnqualifiedType();
+  }
+  return {};
+}
+
+CanQualType valueLikeReturnType(QualType RT) {
+  if (!RT.isNull() && RT->isReferenceType()) {
+return RT.getNonReferenceType()
+->getCanonicalTypeUnqualified()
+.getUnqualifiedType();
+  }
+  return {};
+}
+
+QualType findReturnType(const CXXRecordDecl &RD, StringRef MethodName) {
+  for (const auto *MD : RD.methods()) {
+// We only consider methods that are const and have zero parameters.
+// It may be that there is a non-const overload for the method, but
+// there should at least be a const overload as well.
+if (!MD->isConst() || MD->getNumParams() != 0 ||
+MD->getOverloadedOp

[clang] [llvm] Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907) (PR #133366)

2025-03-27 Thread Mallikarjuna Gouda via cfe-commits

https://github.com/mgoudar created 
https://github.com/llvm/llvm-project/pull/133366

Relands #132907 with a fix in the testcase:
clang/test/CodeGen/Mips/subtarget-feature-test.c
enable this test for only mips64 target

PR #130587 defined same SubTargetFeature for CPUs i6400 and i6500 which 
resulted into following warning when -mcpu=i6500 was used:

+i6500' is not a recognized feature for this target (ignoring feature)

This PR fixes above issue by defining separate SubTargetFeature for i6500.

>From 1c4b804013f4fb3bb4ed6fa8323c64596fb01229 Mon Sep 17 00:00:00 2001
From: Mallikarjuna Gouda 
Date: Fri, 28 Mar 2025 10:27:02 +0530
Subject: [PATCH] Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907)

Relands #132907 with a fix in the testcase:
clang/test/CodeGen/Mips/subtarget-feature-test.c
enable this test for only mips64 target

PR #130587 defined same SubTargetFeature for CPUs i6400 and i6500 which
resulted into following warning when -mcpu=i6500 was used:

+i6500' is not a recognized feature for this target (ignoring feature)

This PR fixes above issue by defining separate SubTargetFeature for i6500.
---
 clang/test/CodeGen/Mips/subtarget-feature-test.c | 6 ++
 llvm/lib/Target/Mips/Mips.td | 8 ++--
 llvm/lib/Target/Mips/MipsSubtarget.h | 2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CodeGen/Mips/subtarget-feature-test.c

diff --git a/clang/test/CodeGen/Mips/subtarget-feature-test.c 
b/clang/test/CodeGen/Mips/subtarget-feature-test.c
new file mode 100644
index 0..4923e2d1fbfd4
--- /dev/null
+++ b/clang/test/CodeGen/Mips/subtarget-feature-test.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips64-registered-target
+// RUN: %clang --target=mips64-linux-gnu -mcpu=i6400 -o %t -c %s 2>&1 | 
FileCheck --allow-empty %s
+// CHECK-NOT: {{.*}} is not a recognized feature for this target
+
+// RUN: %clang --target=mips64-linux-gnu -mcpu=i6500 -o %t -c %s 2>&1 | 
FileCheck --allow-empty %s
+// CHECK-NOT: {{.*}} is not a recognized feature for this target
diff --git a/llvm/lib/Target/Mips/Mips.td b/llvm/lib/Target/Mips/Mips.td
index 9159d11fd486f..43a5ae8133d83 100644
--- a/llvm/lib/Target/Mips/Mips.td
+++ b/llvm/lib/Target/Mips/Mips.td
@@ -242,7 +242,11 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
 // same CPU architecture.
 def ImplI6400
 : SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400",
-   "MIPS I6400/I6500 Processors", [FeatureMips64r6]>;
+   "MIPS I6400 Processor", [FeatureMips64r6]>;
+
+def ImplI6500
+: SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500",
+   "MIPS I6500 Processor", [FeatureMips64r6]>;
 
 class Proc Features>
  : ProcessorModel;
@@ -268,7 +272,7 @@ def : Proc<"octeon", [FeatureMips64r2, FeatureCnMips]>;
 def : Proc<"octeon+", [FeatureMips64r2, FeatureCnMips, FeatureCnMipsP]>;
 def : ProcessorModel<"p5600", MipsP5600Model, [ImplP5600]>;
 def : ProcessorModel<"i6400", NoSchedModel, [ImplI6400]>;
-def : ProcessorModel<"i6500", NoSchedModel, [ImplI6400]>;
+def : ProcessorModel<"i6500", NoSchedModel, [ImplI6500]>;
 
 def MipsAsmParser : AsmParser {
   let ShouldEmitMatchRegisterName = 0;
diff --git a/llvm/lib/Target/Mips/MipsSubtarget.h 
b/llvm/lib/Target/Mips/MipsSubtarget.h
index 0c75597d3decf..15127b11d5cdd 100644
--- a/llvm/lib/Target/Mips/MipsSubtarget.h
+++ b/llvm/lib/Target/Mips/MipsSubtarget.h
@@ -43,7 +43,7 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
 Mips3, Mips4, Mips5, Mips64, Mips64r2, Mips64r3, Mips64r5, Mips64r6
   };
 
-  enum class CPU { P5600, I6400 };
+  enum class CPU { P5600, I6400, I6500 };
 
   // Used to avoid printing dsp warnings multiple times.
   static bool DspWarningPrinted;

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


[clang] [Clang] Link libgcc_s.1.dylib when building for macOS 10.5 and older (PR #124651)

2025-03-27 Thread via cfe-commits

https://github.com/Un1q32 updated 
https://github.com/llvm/llvm-project/pull/124651

>From d4e97c4113086c3d2dfa3bf6e9ecfee377f8c4b6 Mon Sep 17 00:00:00 2001
From: Un1q32 
Date: Mon, 27 Jan 2025 18:00:34 -0500
Subject: [PATCH 1/3] [Clang] Link libgcc_s.1.dylib when building for macOS
 10.5 and older

---
 clang/lib/Driver/ToolChains/Darwin.cpp | 9 +
 clang/test/Driver/darwin-ld.c  | 7 ++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 55c55bad73934..67f27a599b4c3 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1645,12 +1645,13 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList 
&Args,
 CmdArgs.push_back("-lSystem");
 
   // Select the dynamic runtime library and the target specific static library.
-  if (isTargetIOSBased()) {
+  if (isTargetIOSBased() || isTargetMacOSBased()) {
 // If we are compiling as iOS / simulator, don't attempt to link 
libgcc_s.1,
 // it never went into the SDK.
-// Linking against libgcc_s.1 isn't needed for iOS 5.0+
-if (isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator() &&
-getTriple().getArch() != llvm::Triple::aarch64)
+// Linking against libgcc_s.1 isn't needed for iOS 5.0+ or macOS 10.6+
+if ((isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator() &&
+ getTriple().getArch() != llvm::Triple::aarch64) ||
+isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.1");
   }
   AddLinkRuntimeLib(Args, CmdArgs, "builtins");
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index f0ca411430cc7..5b10daaf007a2 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -240,6 +240,11 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_LIBGCC_S %s < %t.log
 // LINK_NO_IOS_ARM64_LIBGCC_S-NOT: lgcc_s.1
 
+// Check that clang links with libgcc_s.1 for macOS 10.5 and earlier
+// RUN: %clang -target x86_64-apple-macos10.5 -mmacosx-version-min=10.5 -### 
%t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_OSX_LIBGCC_S %s < %t.log
+// LINK_OSX_LIBGCC_S: lgcc_s.1
+
 // RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \
 // RUN:   -fuse-ld= -mlinker-version=100 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_NO_EXPORT_DYNAMIC %s < %t.log
@@ -385,4 +390,4 @@
 // RUN:   %clang -target armv7em-apple-darwin -mno-outline -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=ARMV7EM-MNO_OUTLINE %s < %t.log
 // ARMV7EM-MNO_OUTLINE: {{ld(.exe)?"}}
-// ARMV7EM-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" 
"-mllvm" "-enable-linkonceodr-outlining"
\ No newline at end of file
+// ARMV7EM-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" 
"-mllvm" "-enable-linkonceodr-outlining"

>From 4407312c3b8f2edfd9279183a9d4fae316639469 Mon Sep 17 00:00:00 2001
From: Un1q32 
Date: Mon, 27 Jan 2025 18:59:53 -0500
Subject: [PATCH 2/3] fix

---
 clang/lib/Driver/ToolChains/Darwin.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 67f27a599b4c3..82f7d4597d0c7 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1645,15 +1645,15 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList 
&Args,
 CmdArgs.push_back("-lSystem");
 
   // Select the dynamic runtime library and the target specific static library.
-  if (isTargetIOSBased() || isTargetMacOSBased()) {
+  if (isTargetIOSBased()) {
 // If we are compiling as iOS / simulator, don't attempt to link 
libgcc_s.1,
 // it never went into the SDK.
 // Linking against libgcc_s.1 isn't needed for iOS 5.0+ or macOS 10.6+
-if ((isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator() &&
- getTriple().getArch() != llvm::Triple::aarch64) ||
-isMacosxVersionLT(10, 6))
+if (isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator() &&
+getTriple().getArch() != llvm::Triple::aarch64)
   CmdArgs.push_back("-lgcc_s.1");
-  }
+  } else if (isTargetMacOSBased() && isMacosxVersionLT(10, 6))
+CmdArgs.push_back("-lgcc_s.1");
   AddLinkRuntimeLib(Args, CmdArgs, "builtins");
 }
 

>From 31bdca90a631f744f86fa3e25e1a178455901503 Mon Sep 17 00:00:00 2001
From: Un1q32 
Date: Mon, 17 Mar 2025 18:44:08 -0400
Subject: [PATCH 3/3] tidy this up a bit, also don't link libgcc_s on arm64
 ever

---
 clang/lib/Driver/ToolChains/Darwin.cpp | 16 
 clang/test/Driver/darwin-ld.c  |  8 ++--
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 757ba50e4c865..acc0f9ca59316 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1642,14 +1642,14 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList 
&Args,
 C

[clang] [llvm] Hlsl asuint16 function (PR #132315)

2025-03-27 Thread Farzon Lotfi via cfe-commits


@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.2-library %s -fnative-half-type -verify
+
+uint16_t test_asuint16_less_argument()
+{
+return asuint16();
+  // expected-error@-1 {{no matching function for call to 'asuint16'}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not 
viable: requires single argument 'V', but no arguments were provided}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not 
viable: requires single argument 'F', but no arguments were provided}}
+
+}
+
+int16_t4 test_asuint16_too_many_arg(uint16_t p0, uint16_t p1)
+{
+return asuint16(p0, p1);
+  // expected-error@-1 {{no matching function for call to 'asuint16'}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not 
viable: requires single argument 'V', but 2 arguments were provided}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not 
viable: requires single argument 'F', but 2 arguments were provided}}
+
+}
+
+int16_t test_asuint16_int(int p1)
+{
+return asuint16(p1);
+  // expected-error@-1 {{no matching function for call to 'asuint16'}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: 
could not match 'vector' against 'int'}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: 
substitution failure [with T = int]: no type named 'Type'}}

farzonl wrote:

Since this is a language overload resolution rule and not one we defined in 
sema there is not much we can do in this PR. Atleast nothing that woudn't be 
considered scope creep. Worth talk with Chris about though and see if there is 
something we can change.

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


[clang] [clang-repl] Implement LoadDynamicLibrary for clang-repl wasm use cases (PR #133037)

2025-03-27 Thread Anutosh Bhat via cfe-commits

https://github.com/anutosh491 updated 
https://github.com/llvm/llvm-project/pull/133037

>From dfe49e826705a5e9371e17e66e40c31602beea8e Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Wed, 26 Mar 2025 10:33:37 +0530
Subject: [PATCH 1/3] Implement LoadDynamicLibrary for clang-repl wasm use
 cases

---
 clang/lib/Interpreter/Interpreter.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index fa4c1439c9261..b4c68f340abc0 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #ifdef __EMSCRIPTEN__
 #include "Wasm.h"
+#include 
 #endif // __EMSCRIPTEN__
 
 #include "clang/AST/ASTConsumer.h"
@@ -711,6 +712,14 @@ llvm::Error Interpreter::Undo(unsigned N) {
 }
 
 llvm::Error Interpreter::LoadDynamicLibrary(const char *name) {
+#ifdef __EMSCRIPTEN__
+  void* handle = dlopen(name, RTLD_NOW | RTLD_GLOBAL);
+  if (!handle) {
+llvm::errs() << dlerror() << '\n';
+return llvm::make_error(
+"Failed to load dynamic library", llvm::inconvertibleErrorCode());
+  }
+#else
   auto EE = getExecutionEngine();
   if (!EE)
 return EE.takeError();
@@ -722,6 +731,7 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char 
*name) {
 EE->getMainJITDylib().addGenerator(std::move(*DLSG));
   else
 return DLSG.takeError();
+#endif
 
   return llvm::Error::success();
 }

>From cb274780d84c5355c4aede7b8fe7501dc300bc02 Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Wed, 26 Mar 2025 11:14:06 +0530
Subject: [PATCH 2/3] formatting

---
 clang/lib/Interpreter/Interpreter.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index b4c68f340abc0..f8c8d0a425659 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -713,11 +713,11 @@ llvm::Error Interpreter::Undo(unsigned N) {
 
 llvm::Error Interpreter::LoadDynamicLibrary(const char *name) {
 #ifdef __EMSCRIPTEN__
-  void* handle = dlopen(name, RTLD_NOW | RTLD_GLOBAL);
+  void *handle = dlopen(name, RTLD_NOW | RTLD_GLOBAL);
   if (!handle) {
 llvm::errs() << dlerror() << '\n';
-return llvm::make_error(
-"Failed to load dynamic library", llvm::inconvertibleErrorCode());
+return llvm::make_error("Failed to load dynamic 
library",
+   llvm::inconvertibleErrorCode());
   }
 #else
   auto EE = getExecutionEngine();

>From 0911ef1d634603718d5418694a02b0e9665d4552 Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Thu, 27 Mar 2025 12:34:23 +0530
Subject: [PATCH 3/3] Override getSymbolAddress

---
 clang/lib/Interpreter/IncrementalExecutor.h |  2 +-
 clang/lib/Interpreter/Wasm.cpp  | 13 +
 clang/lib/Interpreter/Wasm.h|  2 ++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index dbd61f0b8b1eb..71d71bc3883e2 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -57,7 +57,7 @@ class IncrementalExecutor {
   virtual llvm::Error removeModule(PartialTranslationUnit &PTU);
   virtual llvm::Error runCtors() const;
   virtual llvm::Error cleanUp();
-  llvm::Expected
+  virtual llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
 
   llvm::orc::LLJIT &GetExecutionEngine() { return *Jit; }
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index f7cb7598c77f8..c91fe950d428d 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -144,6 +144,19 @@ llvm::Error WasmIncrementalExecutor::cleanUp() {
   return llvm::Error::success();
 }
 
+llvm::Expected
+WasmIncrementalExecutor::getSymbolAddress(llvm::StringRef Name,
+  SymbolNameKind NameKind) const {
+  void* Sym = dlsym(RTLD_DEFAULT, Name.str().c_str());
+  if (!Sym) {
+return llvm::make_error(
+"dlsym failed for symbol: " + Name.str(),
+llvm::inconvertibleErrorCode());
+  }
+
+  return llvm::orc::ExecutorAddr::fromPtr(Sym);
+}
+
 WasmIncrementalExecutor::~WasmIncrementalExecutor() = default;
 
 } // namespace clang
diff --git a/clang/lib/Interpreter/Wasm.h b/clang/lib/Interpreter/Wasm.h
index 4632613326d39..beafb01be7d8a 100644
--- a/clang/lib/Interpreter/Wasm.h
+++ b/clang/lib/Interpreter/Wasm.h
@@ -29,6 +29,8 @@ class WasmIncrementalExecutor : public IncrementalExecutor {
   llvm::Error removeModule(PartialTranslationUnit &PTU) override;
   llvm::Error runCtors() const override;
   llvm::Error cleanUp() override;
+  llvm::Expected
+  getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
 
   ~WasmIncrementalExecutor() override;
 };

__

[clang] [PATCH] [clang][frontend] Fix AllocKind retrieving for `CXXConstructorDecl` refs #132794 (PR #133077)

2025-03-27 Thread Paul Schwabauer via cfe-commits


@@ -2601,10 +2601,11 @@ class CXXConstructorDecl final
   void anchor() override;
 
   size_t numTrailingObjects(OverloadToken) const {
-return CXXConstructorDeclBits.IsInheritingConstructor;
+return getCanonicalDecl()->CXXConstructorDeclBits.IsInheritingConstructor;
   }
   size_t numTrailingObjects(OverloadToken) const {
-return CXXConstructorDeclBits.HasTrailingExplicitSpecifier;
+return getCanonicalDecl()
+->CXXConstructorDeclBits.HasTrailingExplicitSpecifier;

koplas wrote:

Done

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


[clang] [compiler-rt] Reland [Coverage] Fix region termination for GNU statement expressions (PR #132222)

2025-03-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-pgo

Author: Justin Cady (justincady)


Changes

Relands #130976 with adjustments to test requirements.

Calls to __noreturn__ functions result in region termination for
coverage mapping. But this creates incorrect coverage results when
__noreturn__ functions (or other constructs that result in region
termination) occur within [GNU statement expressions][1].

In this scenario an extra gap region is introduced within VisitStmt,
such that if the following line does not introduce a new region it
is unconditionally counted as uncovered.

This change adjusts the mapping such that terminate statements
within statement expressions do not propagate that termination
state after the statement expression is processed.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

Fixes #124296


---
Full diff: https://github.com/llvm/llvm-project/pull/13.diff


3 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+8) 
- (modified) clang/test/CoverageMapping/terminate-statements.cpp (+7) 
- (added) compiler-rt/test/profile/Linux/coverage-statement-expression.cpp 
(+24) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index f09157771d2b5..73811d15979d5 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1505,6 +1505,14 @@ struct CounterCoverageMappingBuilder
 handleFileExit(getEnd(S));
   }
 
+  void VisitStmtExpr(const StmtExpr *E) {
+Visit(E->getSubStmt());
+// Any region termination (such as a noreturn CallExpr) within the 
statement
+// expression has been handled by visiting the sub-statement. The visitor
+// cannot be at a terminate statement leaving the statement expression.
+HasTerminateStmt = false;
+  }
+
   void VisitDecl(const Decl *D) {
 Stmt *Body = D->getBody();
 
diff --git a/clang/test/CoverageMapping/terminate-statements.cpp 
b/clang/test/CoverageMapping/terminate-statements.cpp
index 0067185fee8e6..3f8e43f0fbcb6 100644
--- a/clang/test/CoverageMapping/terminate-statements.cpp
+++ b/clang/test/CoverageMapping/terminate-statements.cpp
@@ -346,6 +346,12 @@ int elsecondnoret(void) {
   return 0;
 }
 
+// CHECK-LABEL: _Z18statementexprnoretb
+int statementexprnoret(bool crash) {
+  int rc = ({ if (crash) abort(); 0; }); // CHECK: File 0, 351:35 -> 352:12 = 
(#0 - #1)
+  return rc; // CHECK-NOT: Gap
+}
+
 int main() {
   foo(0);
   foo(1);
@@ -368,5 +374,6 @@ int main() {
   ornoret();
   abstractcondnoret();
   elsecondnoret();
+  statementexprnoret(false);
   return 0;
 }
diff --git a/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp 
b/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp
new file mode 100644
index 0..19300411d54a2
--- /dev/null
+++ b/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp
@@ -0,0 +1,24 @@
+// REQUIRES: lld-available
+// XFAIL: powerpc64-target-arch
+
+// RUN: %clangxx_profgen -std=gnu++17 -fuse-ld=lld -fcoverage-mapping -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile=%t.profdata 2>&1 | FileCheck %s
+
+#include 
+
+// clang-format off
+__attribute__ ((__noreturn__))
+void foo(void) { while (1); }   // CHECK:  [[@LINE]]| 0|void 
foo(void)
+_Noreturn void bar(void) { while (1); } // CHECK:  [[@LINE]]| 
0|_Noreturn void bar(void)
+// CHECK:  [[@LINE]]|  |
+int main(int argc, char **argv) {   // CHECK:  [[@LINE]]| 1|int 
main(
+  int rc = ({ if (argc > 3) foo(); 0; });   // CHECK:  [[@LINE]]| 1|  int 
rc =
+  printf("coverage after foo is present\n");// CHECK:  [[@LINE]]| 1|  
printf(
+// CHECK:  [[@LINE]]|  |
+  int rc2 = ({ if (argc > 3) bar(); 0; });  // CHECK:  [[@LINE]]| 1|  int 
rc2 =
+  printf("coverage after bar is present\n");// CHECK:  [[@LINE]]| 1|  
printf(
+  return rc + rc2;  // CHECK:  [[@LINE]]| 1|  
return rc
+}   // CHECK:  [[@LINE]]| 1|}
+// clang-format on

``




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


[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-03-27 Thread Martin Uecker via cfe-commits

uecker wrote:

> It seems to me that we could simplify the implementation by being a bit more 
> literal in the interpretation of the requirements: look only at the type, 
> alignment, name, and bitfield-width of members. Just don't bother checking 
> other stuff
> 
> I'd hope it can look more like a simple loop over the fields of the two 
> record types (similar to mergeFunctionTypes's checks of the functions' param 
> types), rather than starting with the very-complex 
> ASTStructuralEquivalence.cpp, and adding even more complexity to validate 
> attributes.

What I do in GCC is mostly look at those things required in the standard and I 
make sure that all field offsets are the same (e.g. if some attribute would 
change how fields are layed out, this would catch it).  This is a simple loop. 
GCC already had a generic mechanism to compare attributes on types which 
decides whether an attribute makes a type incompatible (.e.g. affects ABI such 
as "packed"), or requires a warning, or whether it is just fine. 

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


[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/133212

>From 34632d01840af89745dc79d27e06bd86aeb04c84 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 27 Mar 2025 13:58:36 +0800
Subject: [PATCH 1/3] [Clang] Correct the DeclRefExpr's Type after the
 initializer gets instantiated

The instantiation of a VarDecl's initializer might be deferred until
the variable is actually used. However, we were still building the
DeclRefExpr with a type that could later be changed by the
initializer's instantiation, which is incorrect when incomplete
arrays are involved.
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaExpr.cpp   | 11 +---
 .../cxx1y-variable-templates_top_level.cpp| 26 +++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8182bccdd2da8..6749369c91559 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -355,6 +355,7 @@ Bug Fixes to C++ Support
 - Correctly diagnoses if unresolved using declarations shadows template 
paramters (#GH129411)
 - Clang was previously coalescing volatile writes to members of volatile base 
class subobjects.
   The issue has been addressed by propagating qualifiers during 
derived-to-base conversions in the AST. (#GH127824)
+- Correctly propagates the instantiated array type to the ``DeclRefExpr`` that 
refers to it. (#GH79750), (#GH113936), (#GH133047)
 - Fixed a Clang regression in C++20 mode where unresolved dependent call 
expressions were created inside non-dependent contexts (#GH122892)
 - Clang now emits the ``-Wunused-variable`` warning when some structured 
bindings are unused
   and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..f837b047ddfb4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19849,11 +19849,14 @@ static void DoMarkVarDeclReferenced(
   SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
 });
 
-// Re-set the member to trigger a recomputation of the dependence bits
-// for the expression.
-if (auto *DRE = dyn_cast_or_null(E))
+if (auto *DRE = dyn_cast_or_null(E)) {
+  // Re-set the member to trigger a recomputation of the dependence 
bits
+  // for the expression.
   DRE->setDecl(DRE->getDecl());
-else if (auto *ME = dyn_cast_or_null(E))
+  if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
+  !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
+DRE->setType(Var->getType());
+} else if (auto *ME = dyn_cast_or_null(E))
   ME->setMemberDecl(ME->getMemberDecl());
   } else if (FirstInstantiation) {
 SemaRef.PendingInstantiations
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp 
b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index da1678ec68627..6fc2032ee7fb4 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -467,3 +467,29 @@ namespace VexingParse {
   template  int var; // expected-note {{declared here}}
   int x(var); // expected-error {{use of variable template 'var' requires 
template arguments}}
 }
+
+#ifndef PRECXX11
+
+namespace GH79750 {
+
+enum class Values { A };
+
+template
+constexpr Values values[] = {E::A};
+
+constexpr auto r = values[0] == Values::A;
+
+}
+
+namespace GH113956 {
+
+template 
+struct C {
+  static constexpr T VALUEARRAY[] = {VALUES...};
+};
+
+static_assert(C::VALUEARRAY[3] == 3, "");
+static_assert(C::VALUEARRAY[0] == 0, "");
+
+}
+#endif

>From 04e350f0a1d854345251f49dcaca5c9eaa9fe60a Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 27 Mar 2025 16:18:56 +0800
Subject: [PATCH 2/3] Add comment

---
 clang/lib/Sema/SemaExpr.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f837b047ddfb4..0e21dfb1fcc43 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19853,6 +19853,12 @@ static void DoMarkVarDeclReferenced(
   // Re-set the member to trigger a recomputation of the dependence 
bits
   // for the expression.
   DRE->setDecl(DRE->getDecl());
+  // The size of an incomplete array type can be updated by
+  // instantiating the initializer. The DeclRefExpr's type should be
+  // updated accordingly too, or users of it would be confused!
+  //
+  // FIXME: Do we need to recompute the type for all the Decls, as in
+  // BuildDeclarationNameExpr?
   if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
   !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
 DRE->setType(Var->

[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread Younan Zhang via cfe-commits


@@ -19849,11 +19849,14 @@ static void DoMarkVarDeclReferenced(
   SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
 });
 
-// Re-set the member to trigger a recomputation of the dependence bits
-// for the expression.
-if (auto *DRE = dyn_cast_or_null(E))
+if (auto *DRE = dyn_cast_or_null(E)) {
+  // Re-set the member to trigger a recomputation of the dependence 
bits
+  // for the expression.
   DRE->setDecl(DRE->getDecl());
-else if (auto *ME = dyn_cast_or_null(E))
+  if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
+  !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
+DRE->setType(Var->getType());
+} else if (auto *ME = dyn_cast_or_null(E))

zyn0217 wrote:

> And I found out we have a completeExprArrayBound function - I suspect we 
> might want to use that. Can you look into it?

I'm surprised we have such a function, thanks! I made it call 
`getCompletedType()` which seems to target to the IncompleteArrayTypes and 
calls `completeExprArrayBound()` if possible

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


[clang] [PATCH] [clang][frontend] Fix AllocKind retrieving for `CXXConstructorDecl` refs #132794 (PR #133077)

2025-03-27 Thread via cfe-commits


@@ -316,6 +316,7 @@ Bug Fixes in This Version
 - Fixed a modules crash where exception specifications were not propagated 
properly (#GH121245, relanded in #GH129982)
 - Fixed a problematic case with recursive deserialization within 
``FinishedDeserializing()`` where
   ``PassInterestingDeclsToConsumer()`` was called before the declarations were 
safe to be passed. (#GH129982)
+- Fixed a modules crash where an explicit Constructor was deserialized. 
(GH#132794)

cor3ntin wrote:

Can you also update the commit message to reflect the change better?

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


[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/133212

>From 34632d01840af89745dc79d27e06bd86aeb04c84 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 27 Mar 2025 13:58:36 +0800
Subject: [PATCH 1/3] [Clang] Correct the DeclRefExpr's Type after the
 initializer gets instantiated

The instantiation of a VarDecl's initializer might be deferred until
the variable is actually used. However, we were still building the
DeclRefExpr with a type that could later be changed by the
initializer's instantiation, which is incorrect when incomplete
arrays are involved.
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaExpr.cpp   | 11 +---
 .../cxx1y-variable-templates_top_level.cpp| 26 +++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8182bccdd2da8..6749369c91559 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -355,6 +355,7 @@ Bug Fixes to C++ Support
 - Correctly diagnoses if unresolved using declarations shadows template 
paramters (#GH129411)
 - Clang was previously coalescing volatile writes to members of volatile base 
class subobjects.
   The issue has been addressed by propagating qualifiers during 
derived-to-base conversions in the AST. (#GH127824)
+- Correctly propagates the instantiated array type to the ``DeclRefExpr`` that 
refers to it. (#GH79750), (#GH113936), (#GH133047)
 - Fixed a Clang regression in C++20 mode where unresolved dependent call 
expressions were created inside non-dependent contexts (#GH122892)
 - Clang now emits the ``-Wunused-variable`` warning when some structured 
bindings are unused
   and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..f837b047ddfb4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19849,11 +19849,14 @@ static void DoMarkVarDeclReferenced(
   SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
 });
 
-// Re-set the member to trigger a recomputation of the dependence bits
-// for the expression.
-if (auto *DRE = dyn_cast_or_null(E))
+if (auto *DRE = dyn_cast_or_null(E)) {
+  // Re-set the member to trigger a recomputation of the dependence 
bits
+  // for the expression.
   DRE->setDecl(DRE->getDecl());
-else if (auto *ME = dyn_cast_or_null(E))
+  if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
+  !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
+DRE->setType(Var->getType());
+} else if (auto *ME = dyn_cast_or_null(E))
   ME->setMemberDecl(ME->getMemberDecl());
   } else if (FirstInstantiation) {
 SemaRef.PendingInstantiations
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp 
b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index da1678ec68627..6fc2032ee7fb4 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -467,3 +467,29 @@ namespace VexingParse {
   template  int var; // expected-note {{declared here}}
   int x(var); // expected-error {{use of variable template 'var' requires 
template arguments}}
 }
+
+#ifndef PRECXX11
+
+namespace GH79750 {
+
+enum class Values { A };
+
+template
+constexpr Values values[] = {E::A};
+
+constexpr auto r = values[0] == Values::A;
+
+}
+
+namespace GH113956 {
+
+template 
+struct C {
+  static constexpr T VALUEARRAY[] = {VALUES...};
+};
+
+static_assert(C::VALUEARRAY[3] == 3, "");
+static_assert(C::VALUEARRAY[0] == 0, "");
+
+}
+#endif

>From 04e350f0a1d854345251f49dcaca5c9eaa9fe60a Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 27 Mar 2025 16:18:56 +0800
Subject: [PATCH 2/3] Add comment

---
 clang/lib/Sema/SemaExpr.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f837b047ddfb4..0e21dfb1fcc43 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19853,6 +19853,12 @@ static void DoMarkVarDeclReferenced(
   // Re-set the member to trigger a recomputation of the dependence 
bits
   // for the expression.
   DRE->setDecl(DRE->getDecl());
+  // The size of an incomplete array type can be updated by
+  // instantiating the initializer. The DeclRefExpr's type should be
+  // updated accordingly too, or users of it would be confused!
+  //
+  // FIXME: Do we need to recompute the type for all the Decls, as in
+  // BuildDeclarationNameExpr?
   if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
   !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
 DRE->setType(Var->

[libclc] [libclc] Move log1p/asinh/acosh/atanh to the CLC library (PR #132956)

2025-03-27 Thread Fraser Cormack via cfe-commits

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


[clang] [libc] [Clang] Make `--lto-partitions` only default for HIP (PR #133164)

2025-03-27 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/133164

>From 8c8885d486ac72145d7fd7ba003db7ea9ab17a1f Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Wed, 26 Mar 2025 16:03:20 -0500
Subject: [PATCH 1/3] [Clang] Make `--lto-partitions` only default for HIP

Summary:
The default behavior for LTO on other targets does not specify the
number of LTO partitions. Recent changes made this default to 8 on
AMDGPU which had some issues with the `libc` project. The option to
disable this is HIP only so I think for now we should restrict this just
to HIP.

I'm definitely on board with getting some more parallelism here, but I
think it should probably be restricted to just offloading languages. The
new driver goes through the `--target=amdgcn-amd-amdhsa` for its output,
which means we'd need to forward the default somehow.
---
 clang/lib/Driver/ToolChains/AMDGPU.cpp | 22 --
 clang/test/Driver/amdgpu-toolchain.c   | 16 +---
 libc/startup/gpu/CMakeLists.txt| 10 ++
 3 files changed, 11 insertions(+), 37 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index e919f4e941f47..c754cae2f96b2 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -625,6 +625,7 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-shared");
   }
 
+  llvm::errs() << JA.getOffloadingDeviceKind() << "\n";
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
@@ -633,7 +634,7 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 const bool ThinLTO = (C.getDriver().getLTOMode() == LTOK_Thin);
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0], ThinLTO);
 
-if (!ThinLTO)
+if (!ThinLTO && JA.getOffloadingDeviceKind() == Action::OFK_HIP)
   addFullLTOPartitionOption(C.getDriver(), Args, CmdArgs);
   } else if (Args.hasArg(options::OPT_mcpu_EQ)) {
 CmdArgs.push_back(Args.MakeArgString(
@@ -712,14 +713,12 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D,
 }
 
 static unsigned getFullLTOPartitions(const Driver &D, const ArgList &Args) {
-  const Arg *A = Args.getLastArg(options::OPT_flto_partitions_EQ);
-  // In the absence of an option, use 8 as the default.
-  if (!A)
-return 8;
   int Value = 0;
-  if (StringRef(A->getValue()).getAsInteger(10, Value) || (Value < 1)) {
+  StringRef A = Args.getLastArgValue(options::OPT_flto_partitions_EQ, "8");
+  if (A.getAsInteger(10, Value) || (Value < 1)) {
+Arg *Arg = Args.getLastArg(options::OPT_flto_partitions_EQ);
 D.Diag(diag::err_drv_invalid_int_value)
-<< A->getAsString(Args) << A->getValue();
+<< Arg->getAsString(Args) << Arg->getValue();
 return 1;
   }
 
@@ -729,13 +728,8 @@ static unsigned getFullLTOPartitions(const Driver &D, 
const ArgList &Args) {
 void amdgpu::addFullLTOPartitionOption(const Driver &D,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) {
-  // TODO: Should this be restricted to fgpu-rdc only ? Currently we'll
-  //   also do it for non gpu-rdc LTO
-
-  if (unsigned NumParts = getFullLTOPartitions(D, Args); NumParts > 1) {
-CmdArgs.push_back(
-Args.MakeArgString("--lto-partitions=" + Twine(NumParts)));
-  }
+  CmdArgs.push_back(Args.MakeArgString("--lto-partitions=" +
+   Twine(getFullLTOPartitions(D, Args;
 }
 
 /// AMDGPU Toolchain
diff --git a/clang/test/Driver/amdgpu-toolchain.c 
b/clang/test/Driver/amdgpu-toolchain.c
index 6617108e59fcf..20656f1fadeb7 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -21,7 +21,7 @@
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+:sramecc- 
-nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefix=LTO %s
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
-// LTO: 
ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx90a"{{.*}}"--lto-partitions={{[0-9]+}}"{{.*}}"-plugin-opt=-mattr=-sramecc,+xnack"
+// LTO: 
ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx90a"{{.*}}"-plugin-opt=-mattr=-sramecc,+xnack"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+:sramecc- 
-nogpulib \
 // RUN:   -L. -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=MCPU %s
@@ -38,17 +38,3 @@
 // RUN: %clang -target amdgcn-amd-amdhsa -march=gfx90a -stdlib -startfiles \
 // RUN:   -nogpulib -nogpuinc -### %s 2>&1 | FileCheck -check-prefix=STARTUP %s
 // STARTUP: ld.lld{{.*}}"-lc" "-lm" "{{.*}}crt1.o"
-
-// Check --flto-partitions
-
-// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a -nogpulib \
-// RUN:   -L. -flto --flto-partitions=42 %s 2>&1 | FileCheck 
-check-p

[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/133212

>From 34632d01840af89745dc79d27e06bd86aeb04c84 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 27 Mar 2025 13:58:36 +0800
Subject: [PATCH 1/4] [Clang] Correct the DeclRefExpr's Type after the
 initializer gets instantiated

The instantiation of a VarDecl's initializer might be deferred until
the variable is actually used. However, we were still building the
DeclRefExpr with a type that could later be changed by the
initializer's instantiation, which is incorrect when incomplete
arrays are involved.
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaExpr.cpp   | 11 +---
 .../cxx1y-variable-templates_top_level.cpp| 26 +++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8182bccdd2da8..6749369c91559 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -355,6 +355,7 @@ Bug Fixes to C++ Support
 - Correctly diagnoses if unresolved using declarations shadows template 
paramters (#GH129411)
 - Clang was previously coalescing volatile writes to members of volatile base 
class subobjects.
   The issue has been addressed by propagating qualifiers during 
derived-to-base conversions in the AST. (#GH127824)
+- Correctly propagates the instantiated array type to the ``DeclRefExpr`` that 
refers to it. (#GH79750), (#GH113936), (#GH133047)
 - Fixed a Clang regression in C++20 mode where unresolved dependent call 
expressions were created inside non-dependent contexts (#GH122892)
 - Clang now emits the ``-Wunused-variable`` warning when some structured 
bindings are unused
   and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..f837b047ddfb4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19849,11 +19849,14 @@ static void DoMarkVarDeclReferenced(
   SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
 });
 
-// Re-set the member to trigger a recomputation of the dependence bits
-// for the expression.
-if (auto *DRE = dyn_cast_or_null(E))
+if (auto *DRE = dyn_cast_or_null(E)) {
+  // Re-set the member to trigger a recomputation of the dependence 
bits
+  // for the expression.
   DRE->setDecl(DRE->getDecl());
-else if (auto *ME = dyn_cast_or_null(E))
+  if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
+  !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
+DRE->setType(Var->getType());
+} else if (auto *ME = dyn_cast_or_null(E))
   ME->setMemberDecl(ME->getMemberDecl());
   } else if (FirstInstantiation) {
 SemaRef.PendingInstantiations
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp 
b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index da1678ec68627..6fc2032ee7fb4 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -467,3 +467,29 @@ namespace VexingParse {
   template  int var; // expected-note {{declared here}}
   int x(var); // expected-error {{use of variable template 'var' requires 
template arguments}}
 }
+
+#ifndef PRECXX11
+
+namespace GH79750 {
+
+enum class Values { A };
+
+template
+constexpr Values values[] = {E::A};
+
+constexpr auto r = values[0] == Values::A;
+
+}
+
+namespace GH113956 {
+
+template 
+struct C {
+  static constexpr T VALUEARRAY[] = {VALUES...};
+};
+
+static_assert(C::VALUEARRAY[3] == 3, "");
+static_assert(C::VALUEARRAY[0] == 0, "");
+
+}
+#endif

>From 04e350f0a1d854345251f49dcaca5c9eaa9fe60a Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 27 Mar 2025 16:18:56 +0800
Subject: [PATCH 2/4] Add comment

---
 clang/lib/Sema/SemaExpr.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f837b047ddfb4..0e21dfb1fcc43 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19853,6 +19853,12 @@ static void DoMarkVarDeclReferenced(
   // Re-set the member to trigger a recomputation of the dependence 
bits
   // for the expression.
   DRE->setDecl(DRE->getDecl());
+  // The size of an incomplete array type can be updated by
+  // instantiating the initializer. The DeclRefExpr's type should be
+  // updated accordingly too, or users of it would be confused!
+  //
+  // FIXME: Do we need to recompute the type for all the Decls, as in
+  // BuildDeclarationNameExpr?
   if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
   !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
 DRE->setType(Var->

[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)

2025-03-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/133119

>From afb5cf51ce0b2de2a3d58dbd493c80173e970fac Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 26 Mar 2025 16:18:34 +
Subject: [PATCH 1/2] [libclc] Pass -fapprox-func when compiling 'native'
 builtins

The libclc build system isn't well set up to pass arbitrary options to
arbitrary source files in a non-intrusive way. There isn't currently any
other motivating example to warrant rewriting the build system just to
satisfy this requirement. So this commit uses a filename-based approach
to inserting this option into the list of compile flags.
---
 libclc/cmake/modules/AddLibclc.cmake | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index be8937cd13107..0bc93eb4cf091 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -260,12 +260,21 @@ function(add_libclc_builtin_set)
 endif()
 
 get_filename_component( file_dir ${file} DIRECTORY )
+get_filename_component( input_filename ${file} NAME_WE )
+
+# If this is a 'native' function (as judged by its filename beginning with
+# "(clc_)?native_") then pass extra args.
+set( native_flag )
+string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
+if( NOT "${is_native}" STREQUAL "" )
+  set( native_flag -fapprox-func )
+endif()
 
 compile_to_bc(
   TRIPLE ${ARG_TRIPLE}
   INPUT ${input_file}
   OUTPUT ${output_file}
-  EXTRA_OPTS -fno-builtin -nostdlib
+  EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
 "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
   DEPENDENCIES ${input_file_dep}
 )

>From 2199b0e71c17b235baa6f29c1de8ffa529b9beeb Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Thu, 27 Mar 2025 10:29:41 +
Subject: [PATCH 2/2] refactor; use COMPILE_OPTIONS property

---
 libclc/CMakeLists.txt| 22 ++
 libclc/cmake/modules/AddLibclc.cmake | 12 +---
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 3de7ee9b707a8..7f0d01e17fb3a 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -262,6 +262,28 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- 
IN_LIST LIBCLC_TARGETS
   set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER 
"libclc/Sourcegenning" )
 endif()
 
+set_source_files_properties(
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_exp.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/r600/lib/math/native_rsqrt.cl
+  PROPERTIES COMPILE_OPTIONS -fapprox-func
+)
+
 enable_testing()
 
 foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index 0bc93eb4cf091..bbaeff921ec18 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -262,19 +262,17 @@ function(add_libclc_builtin_set)
 get_filename_component( file_dir ${file} DIRECTORY )
 get_filename_component( input_filename ${file} NAME_WE )
 
-# If this is a 'native' function (as judged by its filename beginning with
-# "(clc_)?native_") then pass extra args.
-set( native_flag )
-string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
-if( NOT "${is_native}" STREQUAL "" )
-  set( native_flag -fapprox-func )
+set( file_specific_compile_options )
+get_source_file_property( compile_opts ${file} COMPILE_OPTIONS)
+if( compile_opts )
+  set( file_specific_compile_options "${compile_opts}" )
 endif()
 
 compile_to_bc(
   TRIPLE ${ARG_TRIPLE}
   INPUT ${input_file}
   OUTPUT ${output_file}
-  EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
+  EXTRA_OPTS -fno-builtin -nostdlib "${file_specific_compile_options}"
 "${ARG_COMPILE_FLA

[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)

2025-03-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/133119

>From afb5cf51ce0b2de2a3d58dbd493c80173e970fac Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 26 Mar 2025 16:18:34 +
Subject: [PATCH 1/4] [libclc] Pass -fapprox-func when compiling 'native'
 builtins

The libclc build system isn't well set up to pass arbitrary options to
arbitrary source files in a non-intrusive way. There isn't currently any
other motivating example to warrant rewriting the build system just to
satisfy this requirement. So this commit uses a filename-based approach
to inserting this option into the list of compile flags.
---
 libclc/cmake/modules/AddLibclc.cmake | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index be8937cd13107..0bc93eb4cf091 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -260,12 +260,21 @@ function(add_libclc_builtin_set)
 endif()
 
 get_filename_component( file_dir ${file} DIRECTORY )
+get_filename_component( input_filename ${file} NAME_WE )
+
+# If this is a 'native' function (as judged by its filename beginning with
+# "(clc_)?native_") then pass extra args.
+set( native_flag )
+string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
+if( NOT "${is_native}" STREQUAL "" )
+  set( native_flag -fapprox-func )
+endif()
 
 compile_to_bc(
   TRIPLE ${ARG_TRIPLE}
   INPUT ${input_file}
   OUTPUT ${output_file}
-  EXTRA_OPTS -fno-builtin -nostdlib
+  EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
 "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
   DEPENDENCIES ${input_file_dep}
 )

>From 2199b0e71c17b235baa6f29c1de8ffa529b9beeb Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Thu, 27 Mar 2025 10:29:41 +
Subject: [PATCH 2/4] refactor; use COMPILE_OPTIONS property

---
 libclc/CMakeLists.txt| 22 ++
 libclc/cmake/modules/AddLibclc.cmake | 12 +---
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 3de7ee9b707a8..7f0d01e17fb3a 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -262,6 +262,28 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- 
IN_LIST LIBCLC_TARGETS
   set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER 
"libclc/Sourcegenning" )
 endif()
 
+set_source_files_properties(
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_exp.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/r600/lib/math/native_rsqrt.cl
+  PROPERTIES COMPILE_OPTIONS -fapprox-func
+)
+
 enable_testing()
 
 foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index 0bc93eb4cf091..bbaeff921ec18 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -262,19 +262,17 @@ function(add_libclc_builtin_set)
 get_filename_component( file_dir ${file} DIRECTORY )
 get_filename_component( input_filename ${file} NAME_WE )
 
-# If this is a 'native' function (as judged by its filename beginning with
-# "(clc_)?native_") then pass extra args.
-set( native_flag )
-string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
-if( NOT "${is_native}" STREQUAL "" )
-  set( native_flag -fapprox-func )
+set( file_specific_compile_options )
+get_source_file_property( compile_opts ${file} COMPILE_OPTIONS)
+if( compile_opts )
+  set( file_specific_compile_options "${compile_opts}" )
 endif()
 
 compile_to_bc(
   TRIPLE ${ARG_TRIPLE}
   INPUT ${input_file}
   OUTPUT ${output_file}
-  EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
+  EXTRA_OPTS -fno-builtin -nostdlib "${file_specific_compile_options}"
 "${ARG_COMPILE_FLA

[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)

2025-03-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/133119

>From afb5cf51ce0b2de2a3d58dbd493c80173e970fac Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 26 Mar 2025 16:18:34 +
Subject: [PATCH 1/3] [libclc] Pass -fapprox-func when compiling 'native'
 builtins

The libclc build system isn't well set up to pass arbitrary options to
arbitrary source files in a non-intrusive way. There isn't currently any
other motivating example to warrant rewriting the build system just to
satisfy this requirement. So this commit uses a filename-based approach
to inserting this option into the list of compile flags.
---
 libclc/cmake/modules/AddLibclc.cmake | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index be8937cd13107..0bc93eb4cf091 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -260,12 +260,21 @@ function(add_libclc_builtin_set)
 endif()
 
 get_filename_component( file_dir ${file} DIRECTORY )
+get_filename_component( input_filename ${file} NAME_WE )
+
+# If this is a 'native' function (as judged by its filename beginning with
+# "(clc_)?native_") then pass extra args.
+set( native_flag )
+string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
+if( NOT "${is_native}" STREQUAL "" )
+  set( native_flag -fapprox-func )
+endif()
 
 compile_to_bc(
   TRIPLE ${ARG_TRIPLE}
   INPUT ${input_file}
   OUTPUT ${output_file}
-  EXTRA_OPTS -fno-builtin -nostdlib
+  EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
 "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
   DEPENDENCIES ${input_file_dep}
 )

>From 2199b0e71c17b235baa6f29c1de8ffa529b9beeb Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Thu, 27 Mar 2025 10:29:41 +
Subject: [PATCH 2/3] refactor; use COMPILE_OPTIONS property

---
 libclc/CMakeLists.txt| 22 ++
 libclc/cmake/modules/AddLibclc.cmake | 12 +---
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 3de7ee9b707a8..7f0d01e17fb3a 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -262,6 +262,28 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- 
IN_LIST LIBCLC_TARGETS
   set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER 
"libclc/Sourcegenning" )
 endif()
 
+set_source_files_properties(
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_exp.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log10.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log.cl
+  ${CMAKE_CURRENT_SOURCE_DIR}/r600/lib/math/native_rsqrt.cl
+  PROPERTIES COMPILE_OPTIONS -fapprox-func
+)
+
 enable_testing()
 
 foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index 0bc93eb4cf091..bbaeff921ec18 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -262,19 +262,17 @@ function(add_libclc_builtin_set)
 get_filename_component( file_dir ${file} DIRECTORY )
 get_filename_component( input_filename ${file} NAME_WE )
 
-# If this is a 'native' function (as judged by its filename beginning with
-# "(clc_)?native_") then pass extra args.
-set( native_flag )
-string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
-if( NOT "${is_native}" STREQUAL "" )
-  set( native_flag -fapprox-func )
+set( file_specific_compile_options )
+get_source_file_property( compile_opts ${file} COMPILE_OPTIONS)
+if( compile_opts )
+  set( file_specific_compile_options "${compile_opts}" )
 endif()
 
 compile_to_bc(
   TRIPLE ${ARG_TRIPLE}
   INPUT ${input_file}
   OUTPUT ${output_file}
-  EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
+  EXTRA_OPTS -fno-builtin -nostdlib "${file_specific_compile_options}"
 "${ARG_COMPILE_FLA

[libclc] [libclc] Move atan2/atan2pi to the CLC library (PR #133226)

2025-03-27 Thread Fraser Cormack via cfe-commits

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


[clang] [llvm] [llvm] Add triples for managarm (PR #87845)

2025-03-27 Thread via cfe-commits

https://github.com/no92 updated https://github.com/llvm/llvm-project/pull/87845

>From 696b5b24601d2ef773833a9e4b2336107efd586c Mon Sep 17 00:00:00 2001
From: no92 
Date: Fri, 6 Sep 2024 21:17:53 +0200
Subject: [PATCH 1/3] [llvm] Add managarm OS target

---
 llvm/include/llvm/ADT/bit.h|  2 +-
 llvm/include/llvm/TargetParser/Triple.h|  4 
 llvm/lib/Support/Unix/Path.inc | 13 -
 llvm/lib/TargetParser/Triple.cpp   |  6 ++
 llvm/unittests/TargetParser/TripleTest.cpp | 18 ++
 5 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 915a7de50aaff..8544efb5c45d4 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -30,7 +30,7 @@
 
 #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||
\
 defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) ||  
\
-defined(__OpenBSD__) || defined(__DragonFly__)
+defined(__OpenBSD__) || defined(__DragonFly__) || defined(__managarm__)
 #include 
 #elif defined(_AIX)
 #include 
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index da5b05632f2ec..a1e162bdb5ead 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -208,6 +208,7 @@ class Triple {
 Linux,
 Lv2, // PS3
 MacOSX,
+Managarm,
 NetBSD,
 OpenBSD,
 Solaris,
@@ -299,6 +300,7 @@ class Triple {
 Amplification,
 OpenCL,
 OpenHOS,
+Mlibc,
 
 PAuthTest,
 
@@ -849,6 +851,8 @@ class Triple {
 
   bool isVulkanOS() const { return getOS() == Triple::Vulkan; }
 
+  bool isOSManagarm() const { return getOS() == Triple::Managarm; }
+
   bool isShaderStageEnvironment() const {
 EnvironmentType Env = getEnvironment();
 return Env == Triple::Pixel || Env == Triple::Vertex ||
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 6004e007c0c7a..593f4111d06c1 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -69,7 +69,8 @@ extern char **environ;
 
 #include 
 #if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) &&   
\
-!defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX)
+!defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX) &&   
\
+!defined(__managarm__)
 #include 
 #define STATVFS statvfs
 #define FSTATVFS fstatvfs
@@ -78,7 +79,7 @@ extern char **environ;
 #if defined(__OpenBSD__) || defined(__FreeBSD__)
 #include 
 #include 
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__managarm__)
 #if defined(HAVE_LINUX_MAGIC_H)
 #include 
 #else
@@ -124,7 +125,8 @@ const file_t kInvalidFile = -1;
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || 
 \
 defined(__FreeBSD_kernel__) || defined(__linux__) || defined(__CYGWIN__) 
|| \
 defined(__DragonFly__) || defined(_AIX) || defined(__GNU__) || 
 \
-(defined(__sun__) && defined(__svr4__) || defined(__HAIKU__))
+(defined(__sun__) && defined(__svr4__) || defined(__HAIKU__)) ||   
 \
+defined(__managarm__)
 static int test_dir(char ret[PATH_MAX], const char *dir, const char *bin) {
   struct stat sb;
   char fullpath[PATH_MAX];
@@ -245,7 +247,8 @@ std::string getMainExecutable(const char *argv0, void 
*MainAddr) {
   // If we don't have procfs mounted, fall back to argv[0]
   if (getprogpath(exe_path, argv0) != NULL)
 return exe_path;
-#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
+#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__) ||
\
+defined(__managarm__)
   char exe_path[PATH_MAX];
   const char *aPath = "/proc/self/exe";
   if (sys::fs::exists(aPath)) {
@@ -472,7 +475,7 @@ std::error_code remove(const Twine &path, bool 
IgnoreNonExisting) {
 }
 
 static bool is_local_impl(struct STATVFS &Vfs) {
-#if defined(__linux__) || defined(__GNU__)
+#if defined(__linux__) || defined(__GNU__) || defined(__managarm__)
 #ifndef NFS_SUPER_MAGIC
 #define NFS_SUPER_MAGIC 0x6969
 #endif
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index e9e6f130f757c..7ab150264cdac 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -299,6 +299,8 @@ StringRef Triple::getOSTypeName(OSType Kind) {
   case Linux: return "linux";
   case Lv2: return "lv2";
   case MacOSX: return "macosx";
+  case Managarm:
+return "managarm";
   case Mesa3D: return "mesa3d";
   case NVCL: return "nvcl";
   case NaCl: return "nacl";
@@ -384,6 +386,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType 
Kind) {
 return "pauthtest";
   case LLVM:
 return "llvm";
+  case Mlibc:
+return "mlibc";
   }
 
   llvm_unreachable("Invalid EnvironmentType!");
@@ -678,6 +682,7 @@ static Triple::OSType parseOS(StringRef OSName) {
 .S

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/133125

>From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 26 Mar 2025 12:54:29 -0400
Subject: [PATCH 1/5] [C2y] Implement WG14 N3369 and N3469 (_Countof)

C2y adds the _Countof operator which returns the number of elements in
an array. As with sizeof, _Countof either accepts a parenthesized type
name or an expression. Its operand must be (of) an array type. When
passed a constant-size array operand, the operator is a constant
expression which is valid for use as an integer constant expression.

Fixes #102836
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  6 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  5 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/TokenKinds.def  |  2 +
 clang/lib/AST/ExprConstant.cpp| 19 +++-
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp| 15 ++-
 clang/lib/Parse/ParseExpr.cpp | 21 -
 clang/lib/Sema/SemaExpr.cpp   | 39 ++--
 clang/test/C/C2y/n3369.c  | 61 
 clang/test/C/C2y/n3369_1.c| 25 +
 clang/test/C/C2y/n3369_2.c| 92 +++
 clang/test/C/C2y/n3469.c  | 14 +++
 clang/www/c_status.html   |  4 +-
 15 files changed, 288 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/C/C2y/n3369.c
 create mode 100644 clang/test/C/C2y/n3369_1.c
 create mode 100644 clang/test/C/C2y/n3369_2.c
 create mode 100644 clang/test/C/C2y/n3469.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index d4771775c9739..8b5707ce2acac 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1653,6 +1653,7 @@ Array & element qualification (N2607) 
 C
 Attributes (N2335) 
C23   C89
 ``#embed`` (N3017) 
C23   C89, C++
 Octal literals prefixed with ``0o`` or ``0O``  
C2y   C89, C++
+``_Countof`` (N3369, N3469)
C2y   C89
 =  
= =
 
 Builtin type aliases
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 04ec2cfef679c..b82e79c092c4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -141,6 +141,12 @@ C2y Feature Support
   paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
   ``"\x{12}\o{12}"``) which are also supported as an extension in older C
   language modes.
+- Implemented `WG14 N3369 
`_
+  which introduces the ``_Lengthof`` operator, and `WG14 N3469 
`_
+  which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
+  a conforming extension in earlier C language modes, but not in C++ language
+  modes (``std::extent`` and ``std::rank`` already provide the same
+  functionality but with more granularity).
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 4dc956f7ae6f7..86c361b4dbcf7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -171,12 +171,17 @@ def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup;
 def ext_c11_feature : Extension<
   "'%0' is a C11 extension">, InGroup;
+def ext_c2y_feature : Extension<
+  "'%0' is a C2y extension">, InGroup;
 def warn_c11_compat_keyword : Warning<
   "'%0' is incompatible with C standards before C11">,
   InGroup, DefaultIgnore;
 def warn_c23_compat_keyword : Warning<
  "'%0' is incompatible with C standards before C23">,
  InGroup, DefaultIgnore;
+def warn_c2y_compat_keyword : Warning<
+  "'%0' is incompatible with C standards before C2y">,
+  InGroup, DefaultIgnore;
 
 def err_c11_noreturn_misplaced : Error<
   "'_Noreturn' keyword must precede function declarator">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c77cde297dc32..1e900437d41ce 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7022,6 +7022,8 @@ def err_sizeof_alignof_typeof_bitfield : Error<
   "bit-field">;
 def err_alignof_member_of_incomplete_type : Error<
   "invalid application of 'alignof' to a field of a class still being 

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/133125

>From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 26 Mar 2025 12:54:29 -0400
Subject: [PATCH 1/6] [C2y] Implement WG14 N3369 and N3469 (_Countof)

C2y adds the _Countof operator which returns the number of elements in
an array. As with sizeof, _Countof either accepts a parenthesized type
name or an expression. Its operand must be (of) an array type. When
passed a constant-size array operand, the operator is a constant
expression which is valid for use as an integer constant expression.

Fixes #102836
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  6 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  5 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/TokenKinds.def  |  2 +
 clang/lib/AST/ExprConstant.cpp| 19 +++-
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp| 15 ++-
 clang/lib/Parse/ParseExpr.cpp | 21 -
 clang/lib/Sema/SemaExpr.cpp   | 39 ++--
 clang/test/C/C2y/n3369.c  | 61 
 clang/test/C/C2y/n3369_1.c| 25 +
 clang/test/C/C2y/n3369_2.c| 92 +++
 clang/test/C/C2y/n3469.c  | 14 +++
 clang/www/c_status.html   |  4 +-
 15 files changed, 288 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/C/C2y/n3369.c
 create mode 100644 clang/test/C/C2y/n3369_1.c
 create mode 100644 clang/test/C/C2y/n3369_2.c
 create mode 100644 clang/test/C/C2y/n3469.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index d4771775c9739..8b5707ce2acac 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1653,6 +1653,7 @@ Array & element qualification (N2607) 
 C
 Attributes (N2335) 
C23   C89
 ``#embed`` (N3017) 
C23   C89, C++
 Octal literals prefixed with ``0o`` or ``0O``  
C2y   C89, C++
+``_Countof`` (N3369, N3469)
C2y   C89
 =  
= =
 
 Builtin type aliases
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 04ec2cfef679c..b82e79c092c4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -141,6 +141,12 @@ C2y Feature Support
   paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
   ``"\x{12}\o{12}"``) which are also supported as an extension in older C
   language modes.
+- Implemented `WG14 N3369 
`_
+  which introduces the ``_Lengthof`` operator, and `WG14 N3469 
`_
+  which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
+  a conforming extension in earlier C language modes, but not in C++ language
+  modes (``std::extent`` and ``std::rank`` already provide the same
+  functionality but with more granularity).
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 4dc956f7ae6f7..86c361b4dbcf7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -171,12 +171,17 @@ def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup;
 def ext_c11_feature : Extension<
   "'%0' is a C11 extension">, InGroup;
+def ext_c2y_feature : Extension<
+  "'%0' is a C2y extension">, InGroup;
 def warn_c11_compat_keyword : Warning<
   "'%0' is incompatible with C standards before C11">,
   InGroup, DefaultIgnore;
 def warn_c23_compat_keyword : Warning<
  "'%0' is incompatible with C standards before C23">,
  InGroup, DefaultIgnore;
+def warn_c2y_compat_keyword : Warning<
+  "'%0' is incompatible with C standards before C2y">,
+  InGroup, DefaultIgnore;
 
 def err_c11_noreturn_misplaced : Error<
   "'_Noreturn' keyword must precede function declarator">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c77cde297dc32..1e900437d41ce 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7022,6 +7022,8 @@ def err_sizeof_alignof_typeof_bitfield : Error<
   "bit-field">;
 def err_alignof_member_of_incomplete_type : Error<
   "invalid application of 'alignof' to a field of a class still being 

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits


@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify 
%s
+
+/* WG14 N3369: Clang 21
+ * _Lengthof operator
+ *
+ * Adds an operator to get the length of an array. Note that WG14 N3469 renamed
+ * this operator to _Countof.
+ */

cor3ntin wrote:

I'm blind!

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits


@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
 
 return false;
   }
+  case UETT_CountOf: {
+QualType Ty = E->getTypeOfArgument();
+assert(Ty->isArrayType());
+
+// We don't need to worry about array element qualifiers, so getting the
+// unsafe array type is fine.
+if (const auto *CAT =
+dyn_cast(Ty->getAsArrayTypeUnsafe())) {
+  return Success(CAT->getSize(), E);
+}
+
+assert(!Ty->isConstantSizeType());
+
+// If it's a variable-length array type, we need to check whether it is a
+// multidimensional array. If so, we need to check the size expression of
+// the VLA to see if it's a constant size. If so, we can return that value.
+const auto *VAT = Info.Ctx.getAsVariableArrayType(Ty);
+assert(VAT);
+if (VAT->getElementType()->isArrayType()) {
+  std::optional Res =
+  VAT->getSizeExpr()->getIntegerConstantExpr(Info.Ctx);
+  if (Res) {
+// The resulting value always has type size_t, so we need to make the
+// returned APInt have the correct sign and bit-width.
+APInt Val{
+
static_cast(Info.Ctx.getTypeSize(Info.Ctx.getSizeType())),
+Res->getZExtValue()};
+return Success(Val, E);
+  }
+}

cor3ntin wrote:

How about `int another_array[n][n][7];` ?

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits


@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify 
%s
+
+/* WG14 N3369: Clang 21
+ * _Lengthof operator
+ *
+ * Adds an operator to get the length of an array. Note that WG14 N3469 renamed
+ * this operator to _Countof.
+ */

cor3ntin wrote:

Can you make `m` non-const for added clarity?

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


[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-03-27 Thread Martin Uecker via cfe-commits


@@ -450,6 +453,116 @@ class StmtComparer {
 };
 } // namespace
 
+static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
+ const Attr *Attr1, const Attr *Attr2) {
+  // Two attributes are structurally equivalent if they are the same kind
+  // of attribute, spelled with the same spelling kind, and have the same
+  // arguments. This means that [[noreturn]] and __attribute__((noreturn)) are
+  // not structurally equivalent, nor are [[nodiscard("foo")]] and
+  // [[nodiscard("bar")]].
+  if (Attr1->getKind() != Attr2->getKind())
+return false;
+
+  if (Attr1->getSyntax() != Attr2->getSyntax())
+return false;
+
+  if (Attr1->getSpellingListIndex() != Attr2->getSpellingListIndex())
+return false;
+
+  auto GetAttrName = [](const Attr *A) {
+if (const IdentifierInfo *II = A->getAttrName())
+  return II->getName();
+return StringRef{};
+  };
+
+  if (GetAttrName(Attr1) != GetAttrName(Attr2))
+return false;
+
+  // FIXME: check the attribute arguments. Attr does not track the arguments on
+  // the base class, which makes this awkward. We may want to tablegen a
+  // comparison function for attributes? In the meantime, we're doing this the
+  // cheap way by pretty printing the attributes and checking they produce

uecker wrote:

> > The standard defines when things are compatible and it explicitly does not 
> > require attributes to match for types to be compatible.
> 
> Anything the standard doesn't talk about is UB by omission, and the standard 
> makes no mention of attributes. There is nothing explicit about this 
> situation.

I don't think this applies here.  We say that types are compatible under 
conditions A B and C. That we do not mention D does not mean there is UB. We 
also do not mention E, F and G or a billion other things. For me, an omission 
is when something is not precisely specified and you can reasonable interpret 
it either way. This is not the case here. But this only applies to standard 
attributes, vendor attributes can do whatever they want.
> 
> I want to dispense with this topic because I feel very strongly we move 
> forward with the current approach. To make this more explicit as to why:
> 
> 0. The goal of this feature is that two types which were compatible 
> across TU boundaries are now compatible if defined within the same TU. So 
> this is about naming and object layout, in general. Attributes impact these 
> kinds of things (packed, transparent_union, type_visibility, preferred_name, 
> randomize_layout, etc), and attribute arguments do as well (btf_decl_tag, 
> objc_bridge_related, uuid, etc)
> 
> 1. The ideal situation is we have individual attributes specify whether 
> they do or do not make two types [in]compatible, then the equivalence checker 
> can generically check this rather than requiring special logic that's trivial 
> for us to forget when adding new attributes.
> 
> 2. I'm not implementing the ideal solution because that's a significant 
> undertaking, attributes are an edge case, and I only have so much bandwidth. 
> I have a FIXME in the patch that makes this clear.
> 
> 3. Since we're not getting the ideal solution today, we can either be 
> safe by default (require attributes to be the same) or we can be unsafe by 
> default (ignore attributes). I'm adamant we go with safe by default until the 
> ideal solution can be implemented.

Sounds reasonable, but I would exempt standard attributes, because I believe 
this is what the standard requires.




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


[clang] [llvm] [llvm][clang] Allocate a new stack instead of spawning a new thread to get more stack space (PR #133173)

2025-03-27 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> If split stacks are negatively impacting profiling, debugging, or other 
> compiler development tasks, I have to ask, have we considered optimizing 
> clang stack usage?

Strong +1 to this.

> Apple platforms and tools are known to support this, so this only enables it 
> there for now.

I'm a bit concerned about this changing behavior only for Apple platforms; 
that's a different folks doing triage really need to understand. Doesn't Linux 
also support this functionality, so we'd at least get the coverage on more than 
one platform? (Linux could be done in a follow-up, but I'm mostly worried we'll 
only ever implement this for Apple at which point I question whether the extra 
complexity is something the community should maintain or not.)

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits

cor3ntin wrote:

> There is weak consensus to add `stdcountof.h` which supplies a `countof` 
> macro. However, there's no changes to the standard which add one (yet), so I 
> figured that can be done in a follow-up.

Then I'd really like a feature.
We already have a bunch, It makes sense to add one for that imo
```
include/clang/Basic/Features.def:FEATURE(c_alignas, LangOpts.C11)
include/clang/Basic/Features.def:FEATURE(c_alignof, LangOpts.C11)
include/clang/Basic/Features.def:FEATURE(c_atomic, LangOpts.C11)
include/clang/Basic/Features.def:FEATURE(c_generic_selections, LangOpts.C11)
include/clang/Basic/Features.def:FEATURE(c_static_assert, LangOpts.C11)
include/clang/Basic/Features.def:FEATURE(c_thread_local, LangOpts.C11 
&&PP.getTargetInfo().isTLSSupported())
include/clang/Basic/Features.def:FEATURE(c_fixed_enum, LangOpts.C23)
```


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


[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -450,6 +453,116 @@ class StmtComparer {
 };
 } // namespace
 
+static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
+ const Attr *Attr1, const Attr *Attr2) {
+  // Two attributes are structurally equivalent if they are the same kind
+  // of attribute, spelled with the same spelling kind, and have the same
+  // arguments. This means that [[noreturn]] and __attribute__((noreturn)) are
+  // not structurally equivalent, nor are [[nodiscard("foo")]] and
+  // [[nodiscard("bar")]].
+  if (Attr1->getKind() != Attr2->getKind())
+return false;
+
+  if (Attr1->getSyntax() != Attr2->getSyntax())
+return false;
+
+  if (Attr1->getSpellingListIndex() != Attr2->getSpellingListIndex())
+return false;
+
+  auto GetAttrName = [](const Attr *A) {
+if (const IdentifierInfo *II = A->getAttrName())
+  return II->getName();
+return StringRef{};
+  };
+
+  if (GetAttrName(Attr1) != GetAttrName(Attr2))
+return false;
+
+  // FIXME: check the attribute arguments. Attr does not track the arguments on
+  // the base class, which makes this awkward. We may want to tablegen a
+  // comparison function for attributes? In the meantime, we're doing this the
+  // cheap way by pretty printing the attributes and checking they produce

AaronBallman wrote:

> I don't think this applies here.

I think it does, but I think WG14 has some serious problems around their 
interpretation of attributes as the feature was intended when I standardized 
it, at least as they relate to types. I'm not surprised we come down 
differently here. :-)

> Sounds reasonable, but I would exempt standard attributes, because I believe 
> this is what the standard requires.

We make no distinction between standard and vendor attributes in our AST, 
they're both represented by an `Attr` subclass. And given that we have to 
handle things like differences between `[[noreturn]]` and 
`__attribute__((noreturn))`, I don't think we should exempt standard attributes.

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


[libclc] [libclc] Move atan2/atan2pi to the CLC library (PR #133226)

2025-03-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/133226

As with other work in this area, these builtins are now vectorized.

A further table has been split into two. There was discrepancy between comments 
above the table describing the values as "lead" and "tail" and variables taken 
from the table called "head" and "tail", so these have been unified as 
head/tail.

>From 497781f9fe1d1750d37a36948be285cdb6c14b04 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Tue, 25 Mar 2025 18:19:38 +
Subject: [PATCH] [libclc] Move atan2/atan2pi to the CLC library

---
 libclc/clc/include/clc/math/clc_atan2.h |  20 ++
 libclc/clc/include/clc/math/clc_atan2pi.h   |  20 ++
 libclc/clc/include/clc/math/tables.h|   3 +-
 libclc/clc/lib/generic/SOURCES  |   2 +
 libclc/clc/lib/generic/math/clc_atan2.cl|  26 ++
 libclc/clc/lib/generic/math/clc_atan2.inc   | 243 +++
 libclc/clc/lib/generic/math/clc_atan2pi.cl  |  26 ++
 libclc/clc/lib/generic/math/clc_atan2pi.inc | 227 ++
 libclc/clc/lib/generic/math/clc_tables.cl   | 177 ++
 libclc/generic/lib/math/atan2.cl| 222 +
 libclc/generic/lib/math/atan2pi.cl  | 206 +---
 libclc/generic/lib/math/tables.cl   | 253 
 12 files changed, 751 insertions(+), 674 deletions(-)
 create mode 100644 libclc/clc/include/clc/math/clc_atan2.h
 create mode 100644 libclc/clc/include/clc/math/clc_atan2pi.h
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2.inc
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2pi.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2pi.inc

diff --git a/libclc/clc/include/clc/math/clc_atan2.h 
b/libclc/clc/include/clc/math/clc_atan2.h
new file mode 100644
index 0..85b99d0279ee7
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_atan2.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ATAN2_H__
+#define __CLC_MATH_CLC_ATAN2_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_atan2
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ATAN2_H__
diff --git a/libclc/clc/include/clc/math/clc_atan2pi.h 
b/libclc/clc/include/clc/math/clc_atan2pi.h
new file mode 100644
index 0..af41165f7dcf2
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_atan2pi.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ATAN2PI_H__
+#define __CLC_MATH_CLC_ATAN2PI_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_atan2pi
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ATAN2PI_H__
diff --git a/libclc/clc/include/clc/math/tables.h 
b/libclc/clc/include/clc/math/tables.h
index b801ba65bb945..6a0cd80f9c8cb 100644
--- a/libclc/clc/include/clc/math/tables.h
+++ b/libclc/clc/include/clc/math/tables.h
@@ -79,7 +79,8 @@ CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl);
 TABLE_FUNCTION_DECL(double2, ln_tbl);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
-TABLE_FUNCTION_DECL(double2, atan_jby256_tbl);
+CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);
+CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_tail);
 TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl);
 TABLE_FUNCTION_DECL(double2, sinh_tbl);
 TABLE_FUNCTION_DECL(double2, cosh_tbl);
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index dd94d97303944..d851065bb2e23 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -24,6 +24,8 @@ math/clc_asin.cl
 math/clc_asinh.cl
 math/clc_asinpi.cl
 math/clc_atan.cl
+math/clc_atan2.cl
+math/clc_atan2pi.cl
 math/clc_atanh.cl
 math/clc_atanpi.cl
 math/clc_ceil.cl
diff --git a/libclc/clc/lib/generic/math/clc_atan2.cl 
b/libclc/clc/lib/generic/math/clc_atan2.cl
new file mode 100644
index 0..b10bf32333a32
--- /dev/null
+++ b/libclc/clc/lib/generic/math/clc_atan2.cl
@@ -0,0 +1,26 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+//

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
 
 return false;
   }
+  case UETT_CountOf: {
+QualType Ty = E->getTypeOfArgument();
+assert(Ty->isArrayType());
+
+// We don't need to worry about array element qualifiers, so getting the
+// unsafe array type is fine.
+if (const auto *CAT =
+dyn_cast(Ty->getAsArrayTypeUnsafe())) {
+  return Success(CAT->getSize(), E);
+}
+
+assert(!Ty->isConstantSizeType());
+
+// If it's a variable-length array type, we need to check whether it is a
+// multidimensional array. If so, we need to check the size expression of
+// the VLA to see if it's a constant size. If so, we can return that value.
+const auto *VAT = Info.Ctx.getAsVariableArrayType(Ty);
+assert(VAT);
+if (VAT->getElementType()->isArrayType()) {
+  std::optional Res =
+  VAT->getSizeExpr()->getIntegerConstantExpr(Info.Ctx);
+  if (Res) {
+// The resulting value always has type size_t, so we need to make the
+// returned APInt have the correct sign and bit-width.
+APInt Val{
+
static_cast(Info.Ctx.getTypeSize(Info.Ctx.getSizeType())),
+Res->getZExtValue()};
+return Success(Val, E);
+  }
+}

AaronBallman wrote:

Sure, added!

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> > There is weak consensus to add `stdcountof.h` which supplies a `countof` 
> > macro. However, there's no changes to the standard which add one (yet), so 
> > I figured that can be done in a follow-up.
> 
> Then I'd really like a feature. We already have a bunch, It makes sense to 
> add one for that imo
> 
> ```
> include/clang/Basic/Features.def:FEATURE(c_alignas, LangOpts.C11)
> include/clang/Basic/Features.def:FEATURE(c_alignof, LangOpts.C11)
> include/clang/Basic/Features.def:FEATURE(c_atomic, LangOpts.C11)
> include/clang/Basic/Features.def:FEATURE(c_generic_selections, LangOpts.C11)
> include/clang/Basic/Features.def:FEATURE(c_static_assert, LangOpts.C11)
> include/clang/Basic/Features.def:FEATURE(c_thread_local, LangOpts.C11 
> &&PP.getTargetInfo().isTLSSupported())
> include/clang/Basic/Features.def:FEATURE(c_fixed_enum, LangOpts.C23)
> ```

So you want this to be a `FEATURE` in C2y and an `EXTENSION` in older language 
modes? And when we get the `countof` macro in a few months, this becomes 
unnecessary?

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


[libclc] [libclc] Move atan2/atan2pi to the CLC library (PR #133226)

2025-03-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/133226

>From 497781f9fe1d1750d37a36948be285cdb6c14b04 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Tue, 25 Mar 2025 18:19:38 +
Subject: [PATCH 1/2] [libclc] Move atan2/atan2pi to the CLC library

---
 libclc/clc/include/clc/math/clc_atan2.h |  20 ++
 libclc/clc/include/clc/math/clc_atan2pi.h   |  20 ++
 libclc/clc/include/clc/math/tables.h|   3 +-
 libclc/clc/lib/generic/SOURCES  |   2 +
 libclc/clc/lib/generic/math/clc_atan2.cl|  26 ++
 libclc/clc/lib/generic/math/clc_atan2.inc   | 243 +++
 libclc/clc/lib/generic/math/clc_atan2pi.cl  |  26 ++
 libclc/clc/lib/generic/math/clc_atan2pi.inc | 227 ++
 libclc/clc/lib/generic/math/clc_tables.cl   | 177 ++
 libclc/generic/lib/math/atan2.cl| 222 +
 libclc/generic/lib/math/atan2pi.cl  | 206 +---
 libclc/generic/lib/math/tables.cl   | 253 
 12 files changed, 751 insertions(+), 674 deletions(-)
 create mode 100644 libclc/clc/include/clc/math/clc_atan2.h
 create mode 100644 libclc/clc/include/clc/math/clc_atan2pi.h
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2.inc
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2pi.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_atan2pi.inc

diff --git a/libclc/clc/include/clc/math/clc_atan2.h 
b/libclc/clc/include/clc/math/clc_atan2.h
new file mode 100644
index 0..85b99d0279ee7
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_atan2.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ATAN2_H__
+#define __CLC_MATH_CLC_ATAN2_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_atan2
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ATAN2_H__
diff --git a/libclc/clc/include/clc/math/clc_atan2pi.h 
b/libclc/clc/include/clc/math/clc_atan2pi.h
new file mode 100644
index 0..af41165f7dcf2
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_atan2pi.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ATAN2PI_H__
+#define __CLC_MATH_CLC_ATAN2PI_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_atan2pi
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ATAN2PI_H__
diff --git a/libclc/clc/include/clc/math/tables.h 
b/libclc/clc/include/clc/math/tables.h
index b801ba65bb945..6a0cd80f9c8cb 100644
--- a/libclc/clc/include/clc/math/tables.h
+++ b/libclc/clc/include/clc/math/tables.h
@@ -79,7 +79,8 @@ CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl);
 TABLE_FUNCTION_DECL(double2, ln_tbl);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
-TABLE_FUNCTION_DECL(double2, atan_jby256_tbl);
+CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);
+CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_tail);
 TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl);
 TABLE_FUNCTION_DECL(double2, sinh_tbl);
 TABLE_FUNCTION_DECL(double2, cosh_tbl);
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index dd94d97303944..d851065bb2e23 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -24,6 +24,8 @@ math/clc_asin.cl
 math/clc_asinh.cl
 math/clc_asinpi.cl
 math/clc_atan.cl
+math/clc_atan2.cl
+math/clc_atan2pi.cl
 math/clc_atanh.cl
 math/clc_atanpi.cl
 math/clc_ceil.cl
diff --git a/libclc/clc/lib/generic/math/clc_atan2.cl 
b/libclc/clc/lib/generic/math/clc_atan2.cl
new file mode 100644
index 0..b10bf32333a32
--- /dev/null
+++ b/libclc/clc/lib/generic/math/clc_atan2.cl
@@ -0,0 +1,26 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)

2025-03-27 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

I've pushed an update with uses the `COMPILE_OPTIONS` property. It's definitely 
better, thanks for the suggestion.

It would be best if there were `CMakeLists.txt` in each sub-directory which 
added the properties. However, because we currently have this system where 
targets include from multiple directories (e.g., r600 includes stuff from 
`r600/`, `amdgpu/` and `generic/`), and you can only `add_subdirectory` once, 
it gets a bit complicated. We'd have to ensure that `generic` is only included 
once, but that would also mean that it would be harder to do target-specific 
things in there. It might be possible (I think you can set a custom 
(target-specific?) build directory in `add_subdirectory`), but for now I'm just 
setting the properties in the top-level CMakeLists.txt. I'd be a bit nervous of 
rewriting the build system at this time.

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


[libclc] [libclc] Move __clc_(remainder|fmod|remquo) to the CLC library (PR #132054)

2025-03-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/132054

>From e480113652a1a371e296192d4e1460af26a8a436 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Wed, 19 Mar 2025 14:52:09 +
Subject: [PATCH 1/3] [libclc] Move __clc_remainder to CLC library

It was already nominally in the CLC namespace; this commit just formally
moves it over.

Note that a fp16 version of __clc_remainder is now provided. It is
defined as forwarding on to the fp32 version. This makes a difference in
the OpenCL layer, where the fp16 remainder builtin will forward to the
fp16 __clc_remainder builtin, rather than directly forwarding onto the
fp32 __clc_remainder builtin.

No changes to the generated code for non-SPIR-V targets is observed.
---
 .../include/clc/math/binary_def_via_fp32.inc  | 13 +++
 .../include/clc}/math/clc_remainder.h | 10 +++-
 libclc/clc/include/clc/math/gentype.inc   |  7 --
 libclc/clc/lib/generic/SOURCES|  1 +
 .../lib/generic}/math/clc_remainder.cl| 23 +++
 libclc/clspv/lib/SOURCES  |  1 -
 libclc/generic/lib/SOURCES|  1 -
 libclc/generic/lib/math/clc_fmod.cl   |  1 -
 libclc/generic/lib/math/clc_remquo.cl |  1 -
 libclc/generic/lib/math/remainder.cl  |  6 ++---
 libclc/spirv/lib/SOURCES  |  1 -
 11 files changed, 50 insertions(+), 15 deletions(-)
 create mode 100644 libclc/clc/include/clc/math/binary_def_via_fp32.inc
 rename libclc/{generic/include => clc/include/clc}/math/clc_remainder.h (71%)
 rename libclc/{generic/lib => clc/lib/generic}/math/clc_remainder.cl (92%)

diff --git a/libclc/clc/include/clc/math/binary_def_via_fp32.inc 
b/libclc/clc/include/clc/math/binary_def_via_fp32.inc
new file mode 100644
index 0..0b4108adb0610
--- /dev/null
+++ b/libclc/clc/include/clc/math/binary_def_via_fp32.inc
@@ -0,0 +1,13 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
+__CLC_GENTYPE y) {
+  return __CLC_CONVERT_GENTYPE(
+  __CLC_FUNCTION(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y)));
+}
diff --git a/libclc/generic/include/math/clc_remainder.h 
b/libclc/clc/include/clc/math/clc_remainder.h
similarity index 71%
rename from libclc/generic/include/math/clc_remainder.h
rename to libclc/clc/include/clc/math/clc_remainder.h
index e6c2c84a6dc91..2a1c88297d260 100644
--- a/libclc/generic/include/math/clc_remainder.h
+++ b/libclc/clc/include/clc/math/clc_remainder.h
@@ -6,7 +6,15 @@
 //
 
//===--===//
 
+#ifndef __CLC_MATH_CLC_REMAINDER_H__
+#define __CLC_MATH_CLC_REMAINDER_H__
+
 #define __CLC_FUNCTION __clc_remainder
-#define __CLC_BODY 
+#define __CLC_BODY 
+
 #include 
+
+#undef __CLC_BODY
 #undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_REMAINDER_H__
diff --git a/libclc/clc/include/clc/math/gentype.inc 
b/libclc/clc/include/clc/math/gentype.inc
index 31aa16401e647..f65ccc2d42f71 100644
--- a/libclc/clc/include/clc/math/gentype.inc
+++ b/libclc/clc/include/clc/math/gentype.inc
@@ -68,6 +68,7 @@
 #define __CLC_CONVERT_S_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_S_GENTYPE)
 #define __CLC_CONVERT_U_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_U_GENTYPE)
 
+#if (!defined(__HALF_ONLY) && !defined(__DOUBLE_ONLY))
 #define __CLC_SCALAR_GENTYPE float
 #define __CLC_FPSIZE 32
 #define __CLC_FP_LIT(x) x##F
@@ -133,7 +134,9 @@
 #undef __CLC_FPSIZE
 #undef __CLC_SCALAR_GENTYPE
 
-#ifndef __FLOAT_ONLY
+#endif
+
+#if (!defined(__HALF_ONLY) && !defined(__FLOAT_ONLY))
 #ifdef cl_khr_fp64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
@@ -204,7 +207,7 @@
 #endif
 #endif
 
-#ifndef __FLOAT_ONLY
+#if (!defined(__FLOAT_ONLY) && !defined(__DOUBLE_ONLY))
 #ifdef cl_khr_fp16
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index d851065bb2e23..5e33e88c612ef 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -45,6 +45,7 @@ math/clc_mad.cl
 math/clc_modf.cl
 math/clc_nan.cl
 math/clc_nextafter.cl
+math/clc_remainder.cl
 math/clc_rint.cl
 math/clc_round.cl
 math/clc_rsqrt.cl
diff --git a/libclc/generic/lib/math/clc_remainder.cl 
b/libclc/clc/lib/generic/math/clc_remainder.cl
similarity index 92%
rename from libclc/generic/lib/math/clc_remainder.cl
rename to libclc/clc/lib/generic/math/clc_remainder.cl
index e7ab4c653fd28..c79d271c624e2 100644
--- a/libclc/generic/lib/math/clc_remainder.cl
+++ b/libclc/clc/lib/g

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
 
 return false;
   }
+  case UETT_CountOf: {

AaronBallman wrote:

I'll add support for this there.

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


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-03-27 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

> > but won't merge them until they are ratified just like Zvzip/Zvabd/Zibimm
> 
> I think this patch is supported to be the vendor instruction set of `SiFive 
> Xsfmm* Attached Matrix Extensions` if I understand correctly of this PR.
> 
> AME is another issue that we don’t have ratified AME but just SiFive AME 
> proposal, XuanTie AME proposal.

SiFive's AME proposal locates in OP-V/OP-VE category, I think it is not 
designed as vendor extension. IIUC, this patch is just for early evaluation.

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


[clang] [CIR] Upstream CmpOp (PR #133159)

2025-03-27 Thread Henrich Lauko via cfe-commits


@@ -710,6 +710,89 @@ class ScalarExprEmitter : public 
StmtVisitor {
   HANDLEBINOP(Xor)
   HANDLEBINOP(Or)
 #undef HANDLEBINOP
+
+  mlir::Value emitCmp(const BinaryOperator *e) {
+mlir::Value result;
+QualType lhsTy = e->getLHS()->getType();
+QualType rhsTy = e->getRHS()->getType();
+
+auto clangCmpToCIRCmp =
+[](clang::BinaryOperatorKind clangCmp) -> cir::CmpOpKind {
+  switch (clangCmp) {
+  case BO_LT:
+return cir::CmpOpKind::lt;
+  case BO_GT:
+return cir::CmpOpKind::gt;
+  case BO_LE:
+return cir::CmpOpKind::le;
+  case BO_GE:
+return cir::CmpOpKind::ge;
+  case BO_EQ:
+return cir::CmpOpKind::eq;
+  case BO_NE:
+return cir::CmpOpKind::ne;
+  default:
+llvm_unreachable("unsupported comparison kind");
+  }
+};
+
+if (lhsTy->getAs()) {
+  assert(e->getOpcode() == BO_EQ || e->getOpcode() == BO_NE);
+  mlir::Value lhs = cgf.emitScalarExpr(e->getLHS());
+  mlir::Value rhs = cgf.emitScalarExpr(e->getRHS());
+  cir::CmpOpKind kind = clangCmpToCIRCmp(e->getOpcode());
+  result =
+  builder.createCompare(cgf.getLoc(e->getExprLoc()), kind, lhs, rhs);
+} else if (!lhsTy->isAnyComplexType() && !rhsTy->isAnyComplexType()) {
+  BinOpInfo boInfo = emitBinOps(e);
+  mlir::Value lhs = boInfo.lhs;
+  mlir::Value rhs = boInfo.rhs;
+
+  if (lhsTy->isVectorType()) {
+assert(!cir::MissingFeatures::vectorType());
+cgf.cgm.errorNYI(boInfo.loc, "vector comparisons");
+result = builder.getBool(false, cgf.getLoc(boInfo.loc));
+  } else if (boInfo.isFixedPointOp()) {
+assert(!cir::MissingFeatures::fixedPointType());
+cgf.cgm.errorNYI(boInfo.loc, "fixed point comparisons");
+result = builder.getBool(false, cgf.getLoc(boInfo.loc));
+  } else if (lhsTy->hasSignedIntegerRepresentation()) {
+cir::CmpOpKind kind = clangCmpToCIRCmp(e->getOpcode());
+result = builder.createCompare(cgf.getLoc(boInfo.loc), kind, lhs, rhs);
+  } else {
+// Unsigned integers and pointers.
+if (cgf.cgm.getCodeGenOpts().StrictVTablePointers &&
+mlir::isa(lhs.getType()) &&
+mlir::isa(rhs.getType())) {
+  cgf.cgm.errorNYI(boInfo.loc, "strict vtable pointer comparisons");
+  result = builder.getBool(false, cgf.getLoc(boInfo.loc));
+}
+
+cir::CmpOpKind kind = clangCmpToCIRCmp(e->getOpcode());
+result = builder.createCompare(cgf.getLoc(boInfo.loc), kind, lhs, rhs);
+  }
+} else {
+  // Complex Comparison: can only be an equality comparison.
+  assert(!cir::MissingFeatures::complexType());
+  const mlir::Location loc = cgf.getLoc(e->getSourceRange());
+  cgf.cgm.errorNYI(loc, "complex comparison");
+  result = builder.getBool(false, loc);
+}
+
+return emitScalarConversion(result, cgf.getContext().BoolTy, e->getType(),
+e->getExprLoc());
+  }

xlauko wrote:

There is a bit of a mess how locations are emitted here:

`cgf.getLoc(e->getExprLoc())` vs. `cgf.getLoc(boInfo.loc)` vs. 
`cgf.getLoc(e->getSourceRange())`

tbf I am not sure what is correct way, or whether clangir even has some rule of 
thumb how AST locations are translated to mlir locations. Just the 
inconsistency caught my eye. @bcardosolopes @andykaylor ?


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


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-03-27 Thread Jiuyang Liu via cfe-commits

sequencer wrote:

> SiFive's AME proposal locates in OP-V/OP-VE category

Yes, this is a good point.
I do think we should also remove other vendor instruction sets which abused the 
standard op fields. 

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


[clang] [llvm] Revert "[MIPS] Define SubTargetFeature for i6500 cpu" (PR #133215)

2025-03-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Djordje Todorovic (djtodoro)


Changes

Reverts llvm/llvm-project#132907 due to some test failures.

---
Full diff: https://github.com/llvm/llvm-project/pull/133215.diff


3 Files Affected:

- (removed) clang/test/CodeGen/Mips/subtarget-feature-test.c (-5) 
- (modified) llvm/lib/Target/Mips/Mips.td (+2-6) 
- (modified) llvm/lib/Target/Mips/MipsSubtarget.h (+1-1) 


``diff
diff --git a/clang/test/CodeGen/Mips/subtarget-feature-test.c 
b/clang/test/CodeGen/Mips/subtarget-feature-test.c
deleted file mode 100644
index 7f0b8e7e77135..0
--- a/clang/test/CodeGen/Mips/subtarget-feature-test.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang --target=mips64-linux-gnu -mcpu=i6400 -o %t -c %s 2>&1 | 
FileCheck --allow-empty %s
-// CHECK-NOT: {{.*}} is not a recognized feature for this target
-
-// RUN: %clang --target=mips64-linux-gnu -mcpu=i6500 -o %t -c %s 2>&1 | 
FileCheck --allow-empty %s
-// CHECK-NOT: {{.*}} is not a recognized feature for this target
diff --git a/llvm/lib/Target/Mips/Mips.td b/llvm/lib/Target/Mips/Mips.td
index 43a5ae8133d83..9159d11fd486f 100644
--- a/llvm/lib/Target/Mips/Mips.td
+++ b/llvm/lib/Target/Mips/Mips.td
@@ -242,11 +242,7 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
 // same CPU architecture.
 def ImplI6400
 : SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400",
-   "MIPS I6400 Processor", [FeatureMips64r6]>;
-
-def ImplI6500
-: SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500",
-   "MIPS I6500 Processor", [FeatureMips64r6]>;
+   "MIPS I6400/I6500 Processors", [FeatureMips64r6]>;
 
 class Proc Features>
  : ProcessorModel;
@@ -272,7 +268,7 @@ def : Proc<"octeon", [FeatureMips64r2, FeatureCnMips]>;
 def : Proc<"octeon+", [FeatureMips64r2, FeatureCnMips, FeatureCnMipsP]>;
 def : ProcessorModel<"p5600", MipsP5600Model, [ImplP5600]>;
 def : ProcessorModel<"i6400", NoSchedModel, [ImplI6400]>;
-def : ProcessorModel<"i6500", NoSchedModel, [ImplI6500]>;
+def : ProcessorModel<"i6500", NoSchedModel, [ImplI6400]>;
 
 def MipsAsmParser : AsmParser {
   let ShouldEmitMatchRegisterName = 0;
diff --git a/llvm/lib/Target/Mips/MipsSubtarget.h 
b/llvm/lib/Target/Mips/MipsSubtarget.h
index 15127b11d5cdd..0c75597d3decf 100644
--- a/llvm/lib/Target/Mips/MipsSubtarget.h
+++ b/llvm/lib/Target/Mips/MipsSubtarget.h
@@ -43,7 +43,7 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
 Mips3, Mips4, Mips5, Mips64, Mips64r2, Mips64r3, Mips64r5, Mips64r6
   };
 
-  enum class CPU { P5600, I6400, I6500 };
+  enum class CPU { P5600, I6400 };
 
   // Used to avoid printing dsp warnings multiple times.
   static bool DspWarningPrinted;

``




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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify 
%s
+
+/* WG14 N3369: Clang 21
+ * _Lengthof operator
+ *
+ * Adds an operator to get the length of an array. Note that WG14 N3469 renamed
+ * this operator to _Countof.
+ */

AaronBallman wrote:

Then it wouldn't be testing constant folding, so I feel like I must be 
misunderstanding something.

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -141,6 +141,12 @@ C2y Feature Support
   paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
   ``"\x{12}\o{12}"``) which are also supported as an extension in older C
   language modes.
+- Implemented `WG14 N3369 
`_
+  which introduces the ``_Lengthof`` operator, and `WG14 N3469 
`_
+  which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
+  a conforming extension in earlier C language modes, but not in C++ language
+  modes (``std::extent`` and ``std::rank`` already provide the same

AaronBallman wrote:

Fair point!

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits

cor3ntin wrote:

> So you want this to be a FEATURE in C2y and an EXTENSION in older language 
> modes? 

Presumably yes.

> And when we get the countof macro in a few months, this becomes unnecessary?

Are most users going to include `stdcountof.h` ?

My assumption is that they would not, so having the feature thingy  is useful 
(especially in a library that may be concerned about not defining `countof`)

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


[clang] [RFC][clang] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)

2025-03-27 Thread Dmitry Polukhin via cfe-commits


@@ -2572,7 +2572,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
   // Friend function defined withing class template may stop being function
   // definition during AST merges from different modules, in this case decl
   // with function body should be used for instantiation.
-  if (isFriend) {
+  if (isFriend && D->hasOwningModule()) {

dmpolukhin wrote:

I would prefer ExternalASTSource approach because it won't add any additional 
memory overhead and we already have hashtable ASTReader::DefinitionSource. 
Access to the filed should be super cold so it won't slowdown things. I will 
update this PR soon.

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


[clang] [flang] [flang] Expose -m32 and -m64 options (PR #132409)

2025-03-27 Thread Jean-Didier PAILLEUX via cfe-commits

https://github.com/JDPailleux updated 
https://github.com/llvm/llvm-project/pull/132409

>From 9522fe01070c44cdb5562b048aa94d68a8117fd1 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux 
Date: Tue, 18 Mar 2025 14:51:05 +0100
Subject: [PATCH] [flang] Expose -m64 option

---
 clang/include/clang/Driver/Options.td | 2 +-
 flang/test/Driver/m64-option.f90  | 7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Driver/m64-option.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 66ae8f1c7f064..05c9163bb8b68 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4678,7 +4678,7 @@ def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, 
Group,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">,
   MarshallingInfoFlag>;
 def m64 : Flag<["-"], "m64">, Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
 def maix64 : Flag<["-"], "maix64">, Group, Flags<[NoXarchOption]>;
 def mx32 : Flag<["-"], "mx32">, Group, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption]>;
diff --git a/flang/test/Driver/m64-option.f90 b/flang/test/Driver/m64-option.f90
new file mode 100644
index 0..30f290582c621
--- /dev/null
+++ b/flang/test/Driver/m64-option.f90
@@ -0,0 +1,7 @@
+! Check support of -m64.
+! RUN: %flang -target i386-pc-win32 -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+! RUN: %flang -target x86_64-linux-gnu -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+! RUN: %flang -target x86_64-unknown-windows -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+! RUN: %flang -target x86_64-unknown-macosx -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+
+! M64: "-triple" "x86_64-{{.*}}"

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


[clang] [libc] [Clang] Make `--lto-partitions` only default for HIP (PR #133164)

2025-03-27 Thread Joseph Huber via cfe-commits

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


[clang] [flang] [libcxx] [llvm] [llvm-reduce]: print short form, actionable names in the log (PR #132813)

2025-03-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: None (YLChenZ)


Changes

Closes #132696.

before the patch like this:
```

*** Reducing GlobalObjects...

*** Reducing GV Initializers...

*** Reducing GlobalVariables...

```

after the patch like this:
```

*** Reducing GlobalObjects (global-objects)...

*** Reducing GV Initializers (global-initializers)...

*** Reducing GlobalVariables (global-variables)...

```

---

Patch is 69.52 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/132813.diff


81 Files Affected:

- (modified) clang/lib/Frontend/ASTUnit.cpp (+4-5) 
- (modified) clang/lib/Lex/ModuleMap.cpp (+1-2) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+4-2) 
- (modified) flang/lib/Evaluate/fold-logical.cpp (+1-1) 
- (modified) libcxx/test/std/utilities/utility/forward/forward_like.verify.cpp 
(+2-2) 
- (modified) llvm/tools/llvm-reduce/DeltaManager.cpp (+72-83) 
- (added) llvm/tools/llvm-reduce/DeltaPass.h (+25) 
- (added) llvm/tools/llvm-reduce/DeltaPasses.def (+68) 
- (modified) llvm/tools/llvm-reduce/deltas/Delta.h (+1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceAliases.cpp (+4-4) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceAliases.h (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceArguments.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceAttributes.h (+3-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp (+4-4) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.h (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDbgRecords.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDbgRecords.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp (+4-4) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.h (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceFunctions.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp 
(+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceIRReferences.cpp (+6-8) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceIRReferences.h (+5-3) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructionFlagsMIR.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructionFlagsMIR.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructions.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.h (+2-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInvokes.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceInvokes.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceMemoryOperations.cpp (+6-6) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceMemoryOperations.h (+3-3) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp (+4-4) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceMetadata.h (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceModuleData.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOpcodes.h (+1-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOperandBundles.cpp (+2-2) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOperandBundles.h (+3-1) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp (+6-6) 
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOperands.h (+3-3) 
- (modified) llvm/t

[clang] [flang] [flang] Expose -m32 and -m64 options (PR #132409)

2025-03-27 Thread Jean-Didier PAILLEUX via cfe-commits

https://github.com/JDPailleux updated 
https://github.com/llvm/llvm-project/pull/132409

>From 10add8793e15a4767c772556763a8c063c0eb667 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux 
Date: Tue, 18 Mar 2025 14:51:05 +0100
Subject: [PATCH] [flang] Expose -m64 option

---
 clang/include/clang/Driver/Options.td | 2 +-
 flang/test/Driver/m64-option.f90  | 7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Driver/m64-option.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 66ae8f1c7f064..05c9163bb8b68 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4678,7 +4678,7 @@ def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, 
Group,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">,
   MarshallingInfoFlag>;
 def m64 : Flag<["-"], "m64">, Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
 def maix64 : Flag<["-"], "maix64">, Group, Flags<[NoXarchOption]>;
 def mx32 : Flag<["-"], "mx32">, Group, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption]>;
diff --git a/flang/test/Driver/m64-option.f90 b/flang/test/Driver/m64-option.f90
new file mode 100644
index 0..8720a00f40380
--- /dev/null
+++ b/flang/test/Driver/m64-option.f90
@@ -0,0 +1,7 @@
+! Check support of -m64.
+! RUN: %flang -target aarch64-linux-gnu -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+! RUN: %flang -target x86_64-linux-gnu -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+! RUN: %flang -target x86_64-unknown-windows -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+! RUN: %flang -target x86_64-unknown-macosx -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+
+! M64: "-triple" "{{[^-]+}}64-{{.*}}"

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


[clang] Fix complex long division with -mno-x87. (PR #133152)

2025-03-27 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-03-27 Thread Martin Uecker via cfe-commits


@@ -450,6 +453,116 @@ class StmtComparer {
 };
 } // namespace
 
+static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
+ const Attr *Attr1, const Attr *Attr2) {
+  // Two attributes are structurally equivalent if they are the same kind
+  // of attribute, spelled with the same spelling kind, and have the same
+  // arguments. This means that [[noreturn]] and __attribute__((noreturn)) are
+  // not structurally equivalent, nor are [[nodiscard("foo")]] and
+  // [[nodiscard("bar")]].
+  if (Attr1->getKind() != Attr2->getKind())
+return false;
+
+  if (Attr1->getSyntax() != Attr2->getSyntax())
+return false;
+
+  if (Attr1->getSpellingListIndex() != Attr2->getSpellingListIndex())
+return false;
+
+  auto GetAttrName = [](const Attr *A) {
+if (const IdentifierInfo *II = A->getAttrName())
+  return II->getName();
+return StringRef{};
+  };
+
+  if (GetAttrName(Attr1) != GetAttrName(Attr2))
+return false;
+
+  // FIXME: check the attribute arguments. Attr does not track the arguments on
+  // the base class, which makes this awkward. We may want to tablegen a
+  // comparison function for attributes? In the meantime, we're doing this the
+  // cheap way by pretty printing the attributes and checking they produce

uecker wrote:

I guess then everything is UB because we never mention whether the time of day 
plays a role in type compatibility.

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


[clang-tools-extra] [clang-tidy][misc-const-correctness] fix fp when using const array type. (PR #133018)

2025-03-27 Thread Carlos Galvez via cfe-commits


@@ -1007,3 +1007,11 @@ template  void f() {
   x[T{}] = 3;
 }
 } // namespace gh127776_false_positive
+
+namespace gh132931_false_positive {
+using T = const int;
+void valid(int i) {
+  const int arr0[] = {1, 2, 3};
+  T arr1[] = {1, 2, 3};

carlosgalvezp wrote:

Shouldn't we get a warning here, since `arr1` is not used and can therefore be 
const?

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


[clang] [PATCH] [clang][frontend] Fix AllocKind retrieving for `CXXConstructorDecl` refs #132794 (PR #133077)

2025-03-27 Thread via cfe-commits


@@ -316,6 +316,7 @@ Bug Fixes in This Version
 - Fixed a modules crash where exception specifications were not propagated 
properly (#GH121245, relanded in #GH129982)
 - Fixed a problematic case with recursive deserialization within 
``FinishedDeserializing()`` where
   ``PassInterestingDeclsToConsumer()`` was called before the declarations were 
safe to be passed. (#GH129982)
+- Fixed a modules crash where an explicit Constructor was deserialized. 
(GH#132794)

cor3ntin wrote:

```suggestion
- Fixed a modules crash where an explicit Constructor was deserialized. 
(#GH132794)
```

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


[clang-tools-extra] [clang-tidy][misc-const-correctness] fix fp when using const array type. (PR #133018)

2025-03-27 Thread Carlos Galvez via cfe-commits


@@ -1007,3 +1007,11 @@ template  void f() {
   x[T{}] = 3;
 }
 } // namespace gh127776_false_positive
+
+namespace gh132931_false_positive {
+using T = const int;
+void valid(int i) {
+  const int arr0[] = {1, 2, 3};
+  T arr1[] = {1, 2, 3};

carlosgalvezp wrote:

Ah sorry I see now `T` is `const int` :man_facepalming: 

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


[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -450,6 +453,116 @@ class StmtComparer {
 };
 } // namespace
 
+static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
+ const Attr *Attr1, const Attr *Attr2) {
+  // Two attributes are structurally equivalent if they are the same kind
+  // of attribute, spelled with the same spelling kind, and have the same
+  // arguments. This means that [[noreturn]] and __attribute__((noreturn)) are
+  // not structurally equivalent, nor are [[nodiscard("foo")]] and
+  // [[nodiscard("bar")]].
+  if (Attr1->getKind() != Attr2->getKind())
+return false;
+
+  if (Attr1->getSyntax() != Attr2->getSyntax())
+return false;
+
+  if (Attr1->getSpellingListIndex() != Attr2->getSpellingListIndex())
+return false;
+
+  auto GetAttrName = [](const Attr *A) {
+if (const IdentifierInfo *II = A->getAttrName())
+  return II->getName();
+return StringRef{};
+  };
+
+  if (GetAttrName(Attr1) != GetAttrName(Attr2))
+return false;
+
+  // FIXME: check the attribute arguments. Attr does not track the arguments on
+  // the base class, which makes this awkward. We may want to tablegen a
+  // comparison function for attributes? In the meantime, we're doing this the
+  // cheap way by pretty printing the attributes and checking they produce

AaronBallman wrote:

> The standard defines when things are compatible and it explicitly does not 
> require attributes to match for types to be compatible.

Anything the standard doesn't talk about is UB by omission, and the standard 
makes no mention of attributes. There is nothing explicit about this situation.

I want to dispense with this topic because I feel very strongly we move forward 
with the current approach. To make this more explicit as to why:

0) The goal of this feature is that two types which were compatible across TU 
boundaries are now compatible if defined within the same TU. So this is about 
naming and object layout, in general. Attributes impact these kinds of things 
(packed, transparent_union, type_visibility, preferred_name, randomize_layout, 
etc), and attribute arguments do as well (btf_decl_tag, objc_bridge_related, 
uuid, etc)
1) The ideal situation is we have individual attributes specify whether they do 
or do not make two types [in]compatible, then the equivalence checker can 
generically check this rather than requiring special logic that's trivial for 
us to forget when adding new attributes.
2) I'm not implementing the ideal solution because that's a significant 
undertaking, attributes are an edge case, and I only have so much bandwidth. I 
have a FIXME in the patch that makes this clear.
3) Since we're not getting the ideal solution today, we can either be safe by 
default (require attributes to be the same) or we can be unsafe by default 
(ignore attributes). I'm adamant we go with safe by default until the ideal 
solution can be implemented.

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify 
%s
+
+/* WG14 N3369: Clang 21
+ * _Lengthof operator
+ *
+ * Adds an operator to get the length of an array. Note that WG14 N3469 renamed
+ * this operator to _Countof.
+ */

AaronBallman wrote:

Good call, I'll add these tests. FWIW, I already show constant folding:
```
  // Constant folding works the same way as sizeof, too.
  const int m = 12;
  int other_array[m];
  static_assert(sizeof(other_array));   // expected-error {{static assertion 
expression is not an integral constant expression}}
  static_assert(_Countof(other_array)); // expected-error {{static assertion 
expression is not an integral constant expression}}
  static_assert(sizeof(int[m]));// expected-error {{static assertion 
expression is not an integral constant expression}}
  static_assert(_Countof(int[m]));  // expected-error {{static assertion 
expression is not an integral constant expression}}
```
or did you have something else in mind?

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -4338,6 +4338,21 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
E->getSourceRange(), ExprKind))
 return true;
 
+  if (ExprKind == UETT_CountOf) {
+// The type has to be an array type. We already checked for incomplete
+// types above.
+QualType ExprType = E->IgnoreParens()->getType();
+if (!ExprType->isArrayType()) {
+  Diag(E->getExprLoc(), diag::err_countof_arg_not_array_type) << ExprType;
+  return true;

AaronBallman wrote:

Absolutely!

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


[clang-tools-extra] [clang-tidy][misc-const-correctness] fix fp when using const array type. (PR #133018)

2025-03-27 Thread Carlos Galvez via cfe-commits


@@ -89,6 +89,8 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder 
*Finder) {
   const auto ConstReference = hasType(references(isConstQualified()));

carlosgalvezp wrote:

All the tests (including the FP at hand) pass if you remove 
`unless(arrayType()` from line 87 (as well as the part of the comment), so I 
think it would be preferable to do that instead of creating a `ConstArrayType`.

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits


@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
 
 return false;
   }
+  case UETT_CountOf: {
+QualType Ty = E->getTypeOfArgument();
+assert(Ty->isArrayType());
+
+// We don't need to worry about array element qualifiers, so getting the
+// unsafe array type is fine.
+if (const auto *CAT =
+dyn_cast(Ty->getAsArrayTypeUnsafe())) {
+  return Success(CAT->getSize(), E);
+}
+
+assert(!Ty->isConstantSizeType());
+
+// If it's a variable-length array type, we need to check whether it is a
+// multidimensional array. If so, we need to check the size expression of
+// the VLA to see if it's a constant size. If so, we can return that value.
+const auto *VAT = Info.Ctx.getAsVariableArrayType(Ty);
+assert(VAT);
+if (VAT->getElementType()->isArrayType()) {
+  std::optional Res =
+  VAT->getSizeExpr()->getIntegerConstantExpr(Info.Ctx);
+  if (Res) {
+// The resulting value always has type size_t, so we need to make the
+// returned APInt have the correct sign and bit-width.
+APInt Val{
+
static_cast(Info.Ctx.getTypeSize(Info.Ctx.getSizeType())),
+Res->getZExtValue()};
+return Success(Val, E);
+  }
+}

AaronBallman wrote:

See `test_constant_expression_behavior()`: 
```
  // Note that this applies to each array dimension.
  int another_array[n][7];
  static_assert(_Countof(another_array)); // expected-error {{static assertion 
expression is not an integral constant expression}}
  static_assert(_Countof(*another_array) == 7);

  // Only the first dimension is needed for constant evaluation; other
  // dimensions can be ignored.
  int yet_another_array[7][n];
  static_assert(_Countof(yet_another_array) == 7);
  static_assert(_Countof(*yet_another_array)); // expected-error {{static 
assertion expression is not an integral constant expression}}
```
Without this code, `static_assert(_Countof(yet_another_array) == 7);` would 
give an error that the assertion is not an ICE.

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


[clang] [llvm] [clang][CodeGen] Generate follow-up metadata for loops in correct format (PR #131985)

2025-03-27 Thread Ryotaro Kasuga via cfe-commits

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


[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread via cfe-commits

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

Thanks

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


[clang] a967251 - [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (#133212)

2025-03-27 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-03-27T19:40:02+08:00
New Revision: a9672515ce6b8b1bc6976ed1225f4fb4d53fa381

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

LOG: [Clang] Correct the DeclRefExpr's Type after the initializer gets 
instantiated (#133212)

The instantiation of a VarDecl's initializer might be deferred until the
variable is actually used. However, we were still building the
DeclRefExpr with a type that could later be changed by the initializer's
instantiation, which is incorrect when incomplete arrays are involved.

Fixes #79750
Fixes #113936
Fixes #133047

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 04ec2cfef679c..fb94c0c183033 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -359,6 +359,7 @@ Bug Fixes to C++ Support
 - Fixed C++20 aggregate initialization rules being incorrectly applied in 
certain contexts. (#GH131320)
 - Clang was previously coalescing volatile writes to members of volatile base 
class subobjects.
   The issue has been addressed by propagating qualifiers during 
derived-to-base conversions in the AST. (#GH127824)
+- Correctly propagates the instantiated array type to the ``DeclRefExpr`` that 
refers to it. (#GH79750), (#GH113936), (#GH133047)
 - Fixed a Clang regression in C++20 mode where unresolved dependent call 
expressions were created inside non-dependent contexts (#GH122892)
 - Clang now emits the ``-Wunused-variable`` warning when some structured 
bindings are unused
   and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..0ccc19437827c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19849,6 +19849,12 @@ static void DoMarkVarDeclReferenced(
   SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
 });
 
+// The size of an incomplete array type can be updated by
+// instantiating the initializer. The DeclRefExpr's type should be
+// updated accordingly too, or users of it would be confused!
+if (E)
+  SemaRef.getCompletedType(E);
+
 // Re-set the member to trigger a recomputation of the dependence bits
 // for the expression.
 if (auto *DRE = dyn_cast_or_null(E))

diff  --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp 
b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index da1678ec68627..6fc2032ee7fb4 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -467,3 +467,29 @@ namespace VexingParse {
   template  int var; // expected-note {{declared here}}
   int x(var); // expected-error {{use of variable template 'var' requires 
template arguments}}
 }
+
+#ifndef PRECXX11
+
+namespace GH79750 {
+
+enum class Values { A };
+
+template
+constexpr Values values[] = {E::A};
+
+constexpr auto r = values[0] == Values::A;
+
+}
+
+namespace GH113956 {
+
+template 
+struct C {
+  static constexpr T VALUEARRAY[] = {VALUES...};
+};
+
+static_assert(C::VALUEARRAY[3] == 3, "");
+static_assert(C::VALUEARRAY[0] == 0, "");
+
+}
+#endif



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


[clang] [RFC][clang] Fix for regression #130917 (PR #132214)

2025-03-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Dmitry Polukhin (dmpolukhin)


Changes

Changes in #111992 was too broad. This change reduces scope of previous 
fix. Unfortunately in clang there is no way to know when redeclaration was 
craeted artificially due to AST mergse and when it was the case in the original 
code.

I'm not sure that this fix covers all cases but at least it should fix 
regression in clang-20. The ideas how to fix it better are very wellcome.

---
Full diff: https://github.com/llvm/llvm-project/pull/132214.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+1-1) 
- (added) clang/test/SemaCXX/friend-default-parameters.cpp (+21) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 539c2fdb83797..eda5d1151ab19 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2572,7 +2572,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
   // Friend function defined withing class template may stop being function
   // definition during AST merges from different modules, in this case decl
   // with function body should be used for instantiation.
-  if (isFriend) {
+  if (isFriend && D->hasOwningModule()) {
 const FunctionDecl *Defn = nullptr;
 if (D->hasBody(Defn)) {
   D = const_cast(Defn);
diff --git a/clang/test/SemaCXX/friend-default-parameters.cpp 
b/clang/test/SemaCXX/friend-default-parameters.cpp
new file mode 100644
index 0..7190477ac496a
--- /dev/null
+++ b/clang/test/SemaCXX/friend-default-parameters.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -verify -emit-llvm-only %s
+
+template 
+void Create(const void* = nullptr);
+
+template 
+struct ObjImpl {
+  template 
+  friend void ::Create(const void*);
+};
+
+template 
+void Create(const void*) {
+  (void) ObjImpl{};
+}
+
+int main() {
+  Create<42>();
+}
+
+// expected-no-diagnostics

``




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


[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread Younan Zhang via cfe-commits

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


[libclc] [libclc] Move atan2/atan2pi to the CLC library (PR #133226)

2025-03-27 Thread Matt Arsenault via cfe-commits

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


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


[libclc] 3284559 - [libclc] Move atan2/atan2pi to the CLC library (#133226)

2025-03-27 Thread via cfe-commits

Author: Fraser Cormack
Date: 2025-03-27T10:59:09Z
New Revision: 3284559cca4bc64e78e8243bb34195216e8979ee

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

LOG: [libclc] Move atan2/atan2pi to the CLC library (#133226)

As with other work in this area, these builtins are now vectorized.

A further table has been split into two. There was discrepancy between
comments above the table describing the values as "lead" and "tail" and
variables taken from the table called "head" and "tail", so these have
been unified as head/tail.

Added: 
libclc/clc/include/clc/math/clc_atan2.h
libclc/clc/include/clc/math/clc_atan2pi.h
libclc/clc/lib/generic/math/clc_atan2.cl
libclc/clc/lib/generic/math/clc_atan2.inc
libclc/clc/lib/generic/math/clc_atan2pi.cl
libclc/clc/lib/generic/math/clc_atan2pi.inc

Modified: 
libclc/clc/include/clc/math/tables.h
libclc/clc/lib/generic/SOURCES
libclc/clc/lib/generic/math/clc_tables.cl
libclc/generic/lib/math/atan2.cl
libclc/generic/lib/math/atan2pi.cl
libclc/generic/lib/math/tables.cl

Removed: 




diff  --git a/libclc/clc/include/clc/math/clc_atan2.h 
b/libclc/clc/include/clc/math/clc_atan2.h
new file mode 100644
index 0..85b99d0279ee7
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_atan2.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ATAN2_H__
+#define __CLC_MATH_CLC_ATAN2_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_atan2
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ATAN2_H__

diff  --git a/libclc/clc/include/clc/math/clc_atan2pi.h 
b/libclc/clc/include/clc/math/clc_atan2pi.h
new file mode 100644
index 0..af41165f7dcf2
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_atan2pi.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ATAN2PI_H__
+#define __CLC_MATH_CLC_ATAN2PI_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_atan2pi
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ATAN2PI_H__

diff  --git a/libclc/clc/include/clc/math/tables.h 
b/libclc/clc/include/clc/math/tables.h
index b801ba65bb945..6a0cd80f9c8cb 100644
--- a/libclc/clc/include/clc/math/tables.h
+++ b/libclc/clc/include/clc/math/tables.h
@@ -79,7 +79,8 @@ CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl);
 TABLE_FUNCTION_DECL(double2, ln_tbl);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
-TABLE_FUNCTION_DECL(double2, atan_jby256_tbl);
+CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);
+CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_tail);
 TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl);
 TABLE_FUNCTION_DECL(double2, sinh_tbl);
 TABLE_FUNCTION_DECL(double2, cosh_tbl);

diff  --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index dd94d97303944..d851065bb2e23 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -24,6 +24,8 @@ math/clc_asin.cl
 math/clc_asinh.cl
 math/clc_asinpi.cl
 math/clc_atan.cl
+math/clc_atan2.cl
+math/clc_atan2pi.cl
 math/clc_atanh.cl
 math/clc_atanpi.cl
 math/clc_ceil.cl

diff  --git a/libclc/clc/lib/generic/math/clc_atan2.cl 
b/libclc/clc/lib/generic/math/clc_atan2.cl
new file mode 100644
index 0..b10bf32333a32
--- /dev/null
+++ b/libclc/clc/lib/generic/math/clc_atan2.cl
@@ -0,0 +1,26 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define __CLC_BODY 
+#include 

diff  --git a/libclc/clc/lib/generic/math/clc_atan2.inc 
b/libclc/clc/lib/generic/math/clc_atan2.inc
new file mode 100

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/133125

>From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 26 Mar 2025 12:54:29 -0400
Subject: [PATCH 1/7] [C2y] Implement WG14 N3369 and N3469 (_Countof)

C2y adds the _Countof operator which returns the number of elements in
an array. As with sizeof, _Countof either accepts a parenthesized type
name or an expression. Its operand must be (of) an array type. When
passed a constant-size array operand, the operator is a constant
expression which is valid for use as an integer constant expression.

Fixes #102836
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  6 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  5 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/TokenKinds.def  |  2 +
 clang/lib/AST/ExprConstant.cpp| 19 +++-
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp| 15 ++-
 clang/lib/Parse/ParseExpr.cpp | 21 -
 clang/lib/Sema/SemaExpr.cpp   | 39 ++--
 clang/test/C/C2y/n3369.c  | 61 
 clang/test/C/C2y/n3369_1.c| 25 +
 clang/test/C/C2y/n3369_2.c| 92 +++
 clang/test/C/C2y/n3469.c  | 14 +++
 clang/www/c_status.html   |  4 +-
 15 files changed, 288 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/C/C2y/n3369.c
 create mode 100644 clang/test/C/C2y/n3369_1.c
 create mode 100644 clang/test/C/C2y/n3369_2.c
 create mode 100644 clang/test/C/C2y/n3469.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index d4771775c9739..8b5707ce2acac 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1653,6 +1653,7 @@ Array & element qualification (N2607) 
 C
 Attributes (N2335) 
C23   C89
 ``#embed`` (N3017) 
C23   C89, C++
 Octal literals prefixed with ``0o`` or ``0O``  
C2y   C89, C++
+``_Countof`` (N3369, N3469)
C2y   C89
 =  
= =
 
 Builtin type aliases
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 04ec2cfef679c..b82e79c092c4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -141,6 +141,12 @@ C2y Feature Support
   paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
   ``"\x{12}\o{12}"``) which are also supported as an extension in older C
   language modes.
+- Implemented `WG14 N3369 
`_
+  which introduces the ``_Lengthof`` operator, and `WG14 N3469 
`_
+  which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
+  a conforming extension in earlier C language modes, but not in C++ language
+  modes (``std::extent`` and ``std::rank`` already provide the same
+  functionality but with more granularity).
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 4dc956f7ae6f7..86c361b4dbcf7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -171,12 +171,17 @@ def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup;
 def ext_c11_feature : Extension<
   "'%0' is a C11 extension">, InGroup;
+def ext_c2y_feature : Extension<
+  "'%0' is a C2y extension">, InGroup;
 def warn_c11_compat_keyword : Warning<
   "'%0' is incompatible with C standards before C11">,
   InGroup, DefaultIgnore;
 def warn_c23_compat_keyword : Warning<
  "'%0' is incompatible with C standards before C23">,
  InGroup, DefaultIgnore;
+def warn_c2y_compat_keyword : Warning<
+  "'%0' is incompatible with C standards before C2y">,
+  InGroup, DefaultIgnore;
 
 def err_c11_noreturn_misplaced : Error<
   "'_Noreturn' keyword must precede function declarator">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c77cde297dc32..1e900437d41ce 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7022,6 +7022,8 @@ def err_sizeof_alignof_typeof_bitfield : Error<
   "bit-field">;
 def err_alignof_member_of_incomplete_type : Error<
   "invalid application of 'alignof' to a field of a class still being 

[clang] [Clang] Correct the DeclRefExpr's Type after the initializer gets instantiated (PR #133212)

2025-03-27 Thread via cfe-commits


@@ -19849,11 +19849,14 @@ static void DoMarkVarDeclReferenced(
   SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var);
 });
 
-// Re-set the member to trigger a recomputation of the dependence bits
-// for the expression.
-if (auto *DRE = dyn_cast_or_null(E))
+if (auto *DRE = dyn_cast_or_null(E)) {
+  // Re-set the member to trigger a recomputation of the dependence 
bits
+  // for the expression.
   DRE->setDecl(DRE->getDecl());
-else if (auto *ME = dyn_cast_or_null(E))
+  if (SemaRef.Context.getAsIncompleteArrayType(DRE->getType()) &&
+  !SemaRef.Context.getAsIncompleteArrayType(Var->getType()))
+DRE->setType(Var->getType());
+} else if (auto *ME = dyn_cast_or_null(E))

cor3ntin wrote:

Let's just add a comment. I suspect this is not the right place for this code 
(it feels too late), but i do not have a better suggestion. 

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


[clang] [NFC][clang] Remove superfluous header files after refactor in #132252 (PR #132495)

2025-03-27 Thread Jonathan Thackray via cfe-commits

jthackray wrote:

> How'd you manage to find the right ones? IMO we should be using 
> include-what-you-use on these to make sure we get it right (if you have 
> already, disregard this).

Yes, I used iwyu.
 
> Also, can you share before-split/after-split/after-this build time 
> benchmarks? Does this get us back to reasonable?

I've pasted my own benchmarks in an above message. tl;dr, I didn't see any 
overall build time increase, but incremental build time reduction if only 
modifying `CGBuiltin.cpp` and `ARM.cpp` is cut in half from 35 seconds to 16 
seconds, using clang. gcc 13 reduction was even greater, but mainly because gcc 
is so much slower at compilation than clang for this code.

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


[clang] [llvm] [llvm][clang] Allocate a new stack instead of spawning a new thread to get more stack space (PR #133173)

2025-03-27 Thread via cfe-commits

cor3ntin wrote:

> > If split stacks are negatively impacting profiling, debugging, or other 
> > compiler development tasks, I have to ask, have we considered optimizing 
> > clang stack usage?
> 
> Strong +1 to this.

I removed a few uses of ParsedAttributes recently, it helped 
https://github.com/llvm/llvm-project/pull/132021#issue-2931754944 - I'm sure 
there is a lot more room for improvement

I wish we had some way to profile whether our SmallVectors and other SSO 
optimizations are reasonably dimensioned.
We also store references to Sema in a ton of places where, realistically, Sema 
might as well be a singleton. I wonder if we do that enough to have a 
measurable impact on stack size.


But anyway, we still need a way to grow the stack :)

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


[clang] [llvm] [llvm] Add triples for managarm (PR #87845)

2025-03-27 Thread via cfe-commits

no92 wrote:

Rebased on main, pinging @MaskRay for re-review.

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


[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)

2025-03-27 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> set_source_files_properties

That's true but since we're compiling with custom commands (I think) the 
properties won't automatically get picked up.

That said, we could perhaps set the properties as you suggest and retrieve them 
with `get_source_file_property`. We'd still need to set the properties 
"explicitly" as the `SOURCES` system isn't well set up to add arbitrary (lists 
of) stuff on top of the file name. But at least we could do it in the top-level 
CMakeLists which feels less hacky to me.

I'll play around with it.

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


[clang] [Clang] Improve subsumption. (PR #132849)

2025-03-27 Thread via cfe-commits


@@ -170,102 +132,112 @@ struct alignas(ConstraintAlignment) 
FoldExpandedConstraint {
  const Expr *Pattern)
   : Kind(K), Constraint(std::move(C)), Pattern(Pattern) {};
 
-  template 
-  bool subsumes(const FoldExpandedConstraint &Other,
-const AtomicSubsumptionEvaluator &E) const;
-
   static bool AreCompatibleForSubsumption(const FoldExpandedConstraint &A,
   const FoldExpandedConstraint &B);
+
+  llvm::FoldingSetNodeID ProfileForSubsumption() const;

cor3ntin wrote:

Oh, that's actually not used, I should get rid of it thanks!

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


[libclc] [libclc] Move fmod, remainder & remquo to the CLC library (PR #132054)

2025-03-27 Thread Fraser Cormack via cfe-commits

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


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-27 Thread Nathan Gauër via cfe-commits


@@ -5386,6 +5386,23 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const 
VarDecl *D) {
 if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS))
   return AS;
   }
+
+  if (LangOpts.HLSL) {
+if (D == nullptr)
+  return LangAS::hlsl_private;
+
+// Except resources (Uniform, UniformConstant) & instanglble (handles)

Keenuts wrote:

done thanks

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits


@@ -14926,6 +14926,42 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
 
 return false;
   }
+  case UETT_CountOf: {
+QualType Ty = E->getTypeOfArgument();
+assert(Ty->isArrayType());
+
+// We don't need to worry about array element qualifiers, so getting the
+// unsafe array type is fine.
+if (const auto *CAT =
+dyn_cast(Ty->getAsArrayTypeUnsafe())) {
+  return Success(CAT->getSize(), E);
+}
+
+assert(!Ty->isConstantSizeType());
+
+// If it's a variable-length array type, we need to check whether it is a
+// multidimensional array. If so, we need to check the size expression of
+// the VLA to see if it's a constant size. If so, we can return that value.
+const auto *VAT = Info.Ctx.getAsVariableArrayType(Ty);
+assert(VAT);
+if (VAT->getElementType()->isArrayType()) {
+  std::optional Res =
+  VAT->getSizeExpr()->getIntegerConstantExpr(Info.Ctx);
+  if (Res) {
+// The resulting value always has type size_t, so we need to make the
+// returned APInt have the correct sign and bit-width.
+APInt Val{
+
static_cast(Info.Ctx.getTypeSize(Info.Ctx.getSizeType())),
+Res->getZExtValue()};
+return Success(Val, E);
+  }
+}

cor3ntin wrote:

I can't find a test that exercises this

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


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-27 Thread Nathan Gauër via cfe-commits


@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x 
-emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-compute -std=hlsl202x -emit-llvm 
-o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK
+
+struct S {
+  static int Value;
+};
+
+int S::Value = 1;
+// CHECK: @_ZN1S5ValueE = global i32 1, align 4
+
+[shader("compute")]
+[numthreads(1,1,1)]
+void main() {
+  S s;
+  int value1, value2;
+// CHECK:  %s = alloca %struct.S, align 1
+// CHECK: %value1 = alloca i32, align 4
+// CHECK: %value2 = alloca i32, align 4
+
+// CHECK: [[tmp:%.*]] = load i32, ptr @_ZN1S5ValueE, align 4
+// CHECK: store i32 [[tmp]], ptr %value1, align 4
+  value1 = S::Value;
+
+// CHECK: [[tmp:%.*]] = load i32, ptr @_ZN1S5ValueE, align 4

Keenuts wrote:

Is it? The codegen is the same, but the syntax is slightly different, hence 
could imagine the code paths would be different?

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


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-27 Thread Nathan Gauër via cfe-commits

https://github.com/Keenuts updated 
https://github.com/llvm/llvm-project/pull/122103

From c11ace708fab316f422e12cf9785a5a362d7250c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= 
Date: Thu, 28 Nov 2024 15:00:56 +0100
Subject: [PATCH 1/3] [SPIR-V] Add hlsl_private address space for SPIR-V
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In SPIR-V, private global variables have the `Private` storage class.
This PR adds a new address space which allows frontend to emit variable
with this storage class.

Before this change, global variable were emitted with the 'Function'
storage class, which was wrong.

Signed-off-by: Nathan Gauër 
---
 clang/include/clang/Basic/AddressSpaces.h |  1 +
 clang/lib/AST/TypePrinter.cpp |  2 +
 clang/lib/Basic/TargetInfo.cpp|  2 +
 clang/lib/Basic/Targets/AArch64.h |  1 +
 clang/lib/Basic/Targets/AMDGPU.cpp|  2 +
 clang/lib/Basic/Targets/DirectX.h | 21 +
 clang/lib/Basic/Targets/NVPTX.h   |  1 +
 clang/lib/Basic/Targets/SPIR.h| 46 ++-
 clang/lib/Basic/Targets/SystemZ.h |  1 +
 clang/lib/Basic/Targets/TCE.h |  1 +
 clang/lib/Basic/Targets/WebAssembly.h |  1 +
 clang/lib/Basic/Targets/X86.h |  1 +
 clang/lib/CodeGen/CodeGenModule.cpp   | 17 +++
 clang/test/CodeGenHLSL/GlobalDestructors.hlsl |  2 +-
 ...uffer_with_static_global_and_function.hlsl | 22 +
 .../test/CodeGenHLSL/out-of-line-static.hlsl  | 27 +++
 .../SemaTemplate/address_space-dependent.cpp  |  4 +-
 17 files changed, 107 insertions(+), 45 deletions(-)
 create mode 100644 clang/test/CodeGenHLSL/out-of-line-static.hlsl

diff --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index d18bfe54931f9..5787e6dac0e36 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -59,6 +59,7 @@ enum class LangAS : unsigned {
   // HLSL specific address spaces.
   hlsl_groupshared,
   hlsl_constant,
+  hlsl_private,
 
   // Wasm specific address spaces.
   wasm_funcref,
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 8762cc7b1e4e1..1486e2477f4e5 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2576,6 +2576,8 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
 return "groupshared";
   case LangAS::hlsl_constant:
 return "hlsl_constant";
+  case LangAS::hlsl_private:
+return "hlsl_private";
   case LangAS::wasm_funcref:
 return "__funcref";
   default:
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 0699ec686e4e6..ab13c32f6943e 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -47,6 +47,8 @@ static const LangASMap FakeAddrSpaceMap = {
 11, // ptr32_uptr
 12, // ptr64
 13, // hlsl_groupshared
+14, // hlsl_constant
+15, // hlsl_private
 20, // wasm_funcref
 };
 
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 9b6451bd06316..58822e467ce39 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -45,6 +45,7 @@ static const unsigned ARM64AddrSpaceMap[] = {
 static_cast(AArch64AddrSpace::ptr64),
 0, // hlsl_groupshared
 0, // hlsl_constant
+0, // hlsl_private
 // Wasm address space values for this target are dummy values,
 // as it is only enabled for Wasm targets.
 20, // wasm_funcref
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index a42b4589fb5ac..513e7fe22597f 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -60,6 +60,7 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
 llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
 llvm::AMDGPUAS::CONSTANT_ADDRESS, // hlsl_constant
+llvm::AMDGPUAS::PRIVATE_ADDRESS,  // hlsl_private
 };
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
@@ -85,6 +86,7 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
 llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
 llvm::AMDGPUAS::CONSTANT_ADDRESS, // hlsl_constant
+llvm::AMDGPUAS::PRIVATE_ADDRESS,  // hlsl_private
 };
 } // namespace targets
 } // namespace clang
diff --git a/clang/lib/Basic/Targets/DirectX.h 
b/clang/lib/Basic/Targets/DirectX.h
index 6e3ddad626341..0610216ae7065 100644
--- a/clang/lib/Basic/Targets/DirectX.h
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -33,16 +33,17 @@ static const unsigned DirectXAddrSpaceMap[] = {
 0, // cuda_constant
 0, // cuda_shared
 // SYCL address space values for this map are dummy
-0, // sycl_global
-0, // sycl_global_device
-0, // s

[clang] [SYCL] Basic code generation for SYCL kernel caller offload entry point functions. (PR #133030)

2025-03-27 Thread Fraser Cormack via cfe-commits


@@ -229,6 +229,12 @@ class CodeGenTypes {
   const CGFunctionInfo &arrangeBuiltinFunctionCall(QualType resultType,
const CallArgList &args);
 
+  /// A SYCL device kernel function is a free standing function with
+  /// spir_kernel calling convention

frasercrmck wrote:

IIUC, using NVVM metadata to identify kernels is now legacy/deprecated. I 
believe the NVPTX target now uses the `ptx_kernel` calling convention 
exclusively. See https://github.com/llvm/llvm-project/pull/119261 and 
https://github.com/llvm/llvm-project/pull/120806 for example.

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


[clang-tools-extra] [clang-tidy][C++20] Add support for Initialization Forwarding in Nested Objects (PR #131969)

2025-03-27 Thread David Rivera via cfe-commits

RiverDave wrote:

Ping

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


[clang] [llvm] [clang][CodeGen] Generate follow-up metadata for loops in correct format (PR #131985)

2025-03-27 Thread Michael Kruse via cfe-commits


@@ -44,23 +44,19 @@ MDNode *LoopInfo::createPipeliningMetadata(const 
LoopAttributes &Attrs,
   else if (Attrs.PipelineInitiationInterval != 0)
 Enabled = true;
 
+  SmallVector Args;
+  Args.append(LoopProperties.begin(), LoopProperties.end());
+
   if (Enabled != true) {
-SmallVector NewLoopProperties;
 if (Enabled == false) {
-  NewLoopProperties.append(LoopProperties.begin(), LoopProperties.end());

Meinersbur wrote:

In principle, LoopVectorize should know that if the original loop had a 
progress guarantee, then the vectorized loop will as well, so it should add 
`llvm.loop.must_progress` no matter what. I don't think it currently does.

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


[clang] [analyzer] Add metrics tracking time spent in Z3 solver (PR #133236)

2025-03-27 Thread Balázs Benics via cfe-commits

https://github.com/balazs-benics-sonarsource created 
https://github.com/llvm/llvm-project/pull/133236

These metrics would turn out to be useful for verifying an upgrade of Z3.

From 5fe04bcbb3eaf5682037ada6ab64fd7e021f787e Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Thu, 27 Mar 2025 12:13:59 +0100
Subject: [PATCH] [analyzer] Add metrics tracking time spent in Z3 solver

---
 clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp| 7 +++
 clang/test/Analysis/analyzer-stats/entry-point-stats.cpp | 4 
 2 files changed, 11 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp 
b/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
index fca792cdf86f7..836fc375809ad 100644
--- a/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
@@ -41,6 +41,11 @@ STAT_COUNTER(NumTimesZ3QueryRejectReport,
 STAT_COUNTER(NumTimesZ3QueryRejectEQClass,
  "Number of times rejecting an report equivalenece class");
 
+STAT_COUNTER(TimeSpentSolvingZ3Queries,
+ "Total time spent solving Z3 queries excluding retries");
+STAT_MAX(MaxTimeSpentSolvingZ3Queries,
+ "Max time spent solving a Z3 query excluding retries");
+
 using namespace clang;
 using namespace ento;
 
@@ -145,6 +150,8 @@ Z3CrosscheckOracle::Z3Decision 
Z3CrosscheckOracle::interpretQueryResult(
 const Z3CrosscheckVisitor::Z3Result &Query) {
   ++NumZ3QueriesDone;
   AccumulatedZ3QueryTimeInEqClass += Query.Z3QueryTimeMilliseconds;
+  TimeSpentSolvingZ3Queries += Query.Z3QueryTimeMilliseconds;
+  MaxTimeSpentSolvingZ3Queries.updateMax(Query.Z3QueryTimeMilliseconds);
 
   if (Query.IsSAT && Query.IsSAT.value()) {
 ++NumTimesZ3QueryAcceptsReport;
diff --git a/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp 
b/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
index bddba084ee4bf..1ff31d114ee99 100644
--- a/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
+++ b/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
@@ -31,10 +31,12 @@
 // CHECK-NEXT: "NumTimesZ3SpendsTooMuchTimeOnASingleEQClass": "{{[0-9]+}}",
 // CHECK-NEXT: "NumTimesZ3TimedOut": "{{[0-9]+}}",
 // CHECK-NEXT: "NumZ3QueriesDone": "{{[0-9]+}}",
+// CHECK-NEXT: "TimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxCFGSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxQueueSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxReachableSize": "{{[0-9]+}}",
+// CHECK-NEXT: "MaxTimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxValidBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "PathRunningTime": "{{[0-9]+}}"
 // CHECK-NEXT:   },
@@ -64,10 +66,12 @@
 // CHECK-NEXT: "NumTimesZ3SpendsTooMuchTimeOnASingleEQClass": "{{[0-9]+}}",
 // CHECK-NEXT: "NumTimesZ3TimedOut": "{{[0-9]+}}",
 // CHECK-NEXT: "NumZ3QueriesDone": "{{[0-9]+}}",
+// CHECK-NEXT: "TimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxCFGSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxQueueSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxReachableSize": "{{[0-9]+}}",
+// CHECK-NEXT: "MaxTimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxValidBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "PathRunningTime": "{{[0-9]+}}"
 // CHECK-NEXT:   }

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


[clang] [analyzer] Add metrics tracking time spent in Z3 solver (PR #133236)

2025-03-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balázs Benics (balazs-benics-sonarsource)


Changes

These metrics would turn out to be useful for verifying an upgrade of Z3.

---
Full diff: https://github.com/llvm/llvm-project/pull/133236.diff


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp (+7) 
- (modified) clang/test/Analysis/analyzer-stats/entry-point-stats.cpp (+4) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp 
b/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
index fca792cdf86f7..836fc375809ad 100644
--- a/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
@@ -41,6 +41,11 @@ STAT_COUNTER(NumTimesZ3QueryRejectReport,
 STAT_COUNTER(NumTimesZ3QueryRejectEQClass,
  "Number of times rejecting an report equivalenece class");
 
+STAT_COUNTER(TimeSpentSolvingZ3Queries,
+ "Total time spent solving Z3 queries excluding retries");
+STAT_MAX(MaxTimeSpentSolvingZ3Queries,
+ "Max time spent solving a Z3 query excluding retries");
+
 using namespace clang;
 using namespace ento;
 
@@ -145,6 +150,8 @@ Z3CrosscheckOracle::Z3Decision 
Z3CrosscheckOracle::interpretQueryResult(
 const Z3CrosscheckVisitor::Z3Result &Query) {
   ++NumZ3QueriesDone;
   AccumulatedZ3QueryTimeInEqClass += Query.Z3QueryTimeMilliseconds;
+  TimeSpentSolvingZ3Queries += Query.Z3QueryTimeMilliseconds;
+  MaxTimeSpentSolvingZ3Queries.updateMax(Query.Z3QueryTimeMilliseconds);
 
   if (Query.IsSAT && Query.IsSAT.value()) {
 ++NumTimesZ3QueryAcceptsReport;
diff --git a/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp 
b/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
index bddba084ee4bf..1ff31d114ee99 100644
--- a/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
+++ b/clang/test/Analysis/analyzer-stats/entry-point-stats.cpp
@@ -31,10 +31,12 @@
 // CHECK-NEXT: "NumTimesZ3SpendsTooMuchTimeOnASingleEQClass": "{{[0-9]+}}",
 // CHECK-NEXT: "NumTimesZ3TimedOut": "{{[0-9]+}}",
 // CHECK-NEXT: "NumZ3QueriesDone": "{{[0-9]+}}",
+// CHECK-NEXT: "TimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxCFGSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxQueueSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxReachableSize": "{{[0-9]+}}",
+// CHECK-NEXT: "MaxTimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxValidBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "PathRunningTime": "{{[0-9]+}}"
 // CHECK-NEXT:   },
@@ -64,10 +66,12 @@
 // CHECK-NEXT: "NumTimesZ3SpendsTooMuchTimeOnASingleEQClass": "{{[0-9]+}}",
 // CHECK-NEXT: "NumTimesZ3TimedOut": "{{[0-9]+}}",
 // CHECK-NEXT: "NumZ3QueriesDone": "{{[0-9]+}}",
+// CHECK-NEXT: "TimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxCFGSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxQueueSize": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxReachableSize": "{{[0-9]+}}",
+// CHECK-NEXT: "MaxTimeSpentSolvingZ3Queries": "{{[0-9]+}}",
 // CHECK-NEXT: "MaxValidBugClassSize": "{{[0-9]+}}",
 // CHECK-NEXT: "PathRunningTime": "{{[0-9]+}}"
 // CHECK-NEXT:   }

``




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


[clang] [clang-repl] Implement LoadDynamicLibrary for clang-repl wasm use cases (PR #133037)

2025-03-27 Thread Anutosh Bhat via cfe-commits

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/133125

>From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 26 Mar 2025 12:54:29 -0400
Subject: [PATCH 1/8] [C2y] Implement WG14 N3369 and N3469 (_Countof)

C2y adds the _Countof operator which returns the number of elements in
an array. As with sizeof, _Countof either accepts a parenthesized type
name or an expression. Its operand must be (of) an array type. When
passed a constant-size array operand, the operator is a constant
expression which is valid for use as an integer constant expression.

Fixes #102836
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  6 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  5 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/TokenKinds.def  |  2 +
 clang/lib/AST/ExprConstant.cpp| 19 +++-
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp| 15 ++-
 clang/lib/Parse/ParseExpr.cpp | 21 -
 clang/lib/Sema/SemaExpr.cpp   | 39 ++--
 clang/test/C/C2y/n3369.c  | 61 
 clang/test/C/C2y/n3369_1.c| 25 +
 clang/test/C/C2y/n3369_2.c| 92 +++
 clang/test/C/C2y/n3469.c  | 14 +++
 clang/www/c_status.html   |  4 +-
 15 files changed, 288 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/C/C2y/n3369.c
 create mode 100644 clang/test/C/C2y/n3369_1.c
 create mode 100644 clang/test/C/C2y/n3369_2.c
 create mode 100644 clang/test/C/C2y/n3469.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index d4771775c9739..8b5707ce2acac 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1653,6 +1653,7 @@ Array & element qualification (N2607) 
 C
 Attributes (N2335) 
C23   C89
 ``#embed`` (N3017) 
C23   C89, C++
 Octal literals prefixed with ``0o`` or ``0O``  
C2y   C89, C++
+``_Countof`` (N3369, N3469)
C2y   C89
 =  
= =
 
 Builtin type aliases
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 04ec2cfef679c..b82e79c092c4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -141,6 +141,12 @@ C2y Feature Support
   paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
   ``"\x{12}\o{12}"``) which are also supported as an extension in older C
   language modes.
+- Implemented `WG14 N3369 
`_
+  which introduces the ``_Lengthof`` operator, and `WG14 N3469 
`_
+  which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
+  a conforming extension in earlier C language modes, but not in C++ language
+  modes (``std::extent`` and ``std::rank`` already provide the same
+  functionality but with more granularity).
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 4dc956f7ae6f7..86c361b4dbcf7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -171,12 +171,17 @@ def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup;
 def ext_c11_feature : Extension<
   "'%0' is a C11 extension">, InGroup;
+def ext_c2y_feature : Extension<
+  "'%0' is a C2y extension">, InGroup;
 def warn_c11_compat_keyword : Warning<
   "'%0' is incompatible with C standards before C11">,
   InGroup, DefaultIgnore;
 def warn_c23_compat_keyword : Warning<
  "'%0' is incompatible with C standards before C23">,
  InGroup, DefaultIgnore;
+def warn_c2y_compat_keyword : Warning<
+  "'%0' is incompatible with C standards before C2y">,
+  InGroup, DefaultIgnore;
 
 def err_c11_noreturn_misplaced : Error<
   "'_Noreturn' keyword must precede function declarator">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c77cde297dc32..1e900437d41ce 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7022,6 +7022,8 @@ def err_sizeof_alignof_typeof_bitfield : Error<
   "bit-field">;
 def err_alignof_member_of_incomplete_type : Error<
   "invalid application of 'alignof' to a field of a class still being 

[clang] [flang] [flang] Expose -m32 and -m64 options (PR #132409)

2025-03-27 Thread Jean-Didier PAILLEUX via cfe-commits


@@ -0,0 +1,4 @@
+! Check support of -m64.
+! RUN: %flang -target i386-pc-win32 -m64 -### - %s 2>&1 | FileCheck 
-check-prefix=M64 %s
+
+! M64: "-triple" "{{[^-]+}}64-{{.*}}"

JDPailleux wrote:

Ok :-)

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


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-03-27 Thread Jiuyang Liu via cfe-commits

sequencer wrote:

> but won't merge them until they are ratified just like Zvzip/Zvabd/Zibimm

I think this patch is supported to be the vendor instruction set of `SiFive 
Xsfmm* Attached Matrix Extensions` if I understand correctly of this PR. 

AME is another issue that we don’t have ratified AME but just SiFive AME 
proposal, XuanTie AME proposal. 

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


[clang] [flang] [flang] Expose -m64 option (PR #132409)

2025-03-27 Thread Jean-Didier PAILLEUX via cfe-commits

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


[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-03-27 Thread via cfe-commits

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

Thanks!

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


[clang] [flang] [libcxx] [llvm] [llvm-reduce]: print short form, actionable names in the log (PR #132813)

2025-03-27 Thread via cfe-commits

YLChenZ wrote:

I'm having some problems with my code branch, I guess I should resubmit a PR, I 
apologize for that!

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


[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)

2025-03-27 Thread Mohamed Emad via cfe-commits

https://github.com/hulxv updated 
https://github.com/llvm/llvm-project/pull/131280

>From bf9bd4156cb7f652c9cf0477f537e5c58b470448 Mon Sep 17 00:00:00 2001
From: hulxv 
Date: Fri, 14 Mar 2025 07:39:15 +0200
Subject: [PATCH 01/14] [clang-doc] [feat] add `--repository-line-prefix`
 argument (fix #59814)

---
 clang-tools-extra/clang-doc/HTMLGenerator.cpp | 66 ---
 clang-tools-extra/clang-doc/MDGenerator.cpp   |  7 +-
 .../clang-doc/Representation.cpp  |  4 ++
 clang-tools-extra/clang-doc/Representation.h  |  5 +-
 .../clang-doc/tool/ClangDocMain.cpp   | 13 ++--
 5 files changed, 64 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 18a0de826630c..967275f93193b 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -491,9 +491,9 @@ genReferencesBlock(const std::vector &References,
   return Out;
 }
 
-static std::unique_ptr
-writeFileDefinition(const Location &L,
-std::optional RepositoryUrl = std::nullopt) {
+static std::unique_ptr writeFileDefinition(
+const Location &L, std::optional RepositoryUrl = std::nullopt,
+std::optional RepositoryLinePrefix = std::nullopt) {
   if (!L.IsFileInRootDir && !RepositoryUrl)
 return std::make_unique(
 HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) +
@@ -514,17 +514,21 @@ writeFileDefinition(const Location &L,
   Node->Children.emplace_back(std::make_unique("Defined at line "));
   auto LocNumberNode =
   std::make_unique(HTMLTag::TAG_A, std::to_string(L.LineNumber));
-  // The links to a specific line in the source code use the github /
-  // googlesource notation so it won't work for all hosting pages.
-  // FIXME: we probably should have a configuration setting for line number
-  // rendering in the HTML. For example, GitHub uses #L22, while googlesource
-  // uses #22 for line numbers.
-  LocNumberNode->Attributes.emplace_back(
-  "href", (FileURL + "#" + std::to_string(L.LineNumber)).str());
+
+  std::string LineAnchor = "#";
+
+  if (RepositoryLinePrefix)
+LineAnchor += RepositoryLinePrefix.value().str();
+
+  LineAnchor += std::to_string(L.LineNumber);
+
+  LocNumberNode->Attributes.emplace_back("href", (FileURL + LineAnchor).str());
   Node->Children.emplace_back(std::move(LocNumberNode));
   Node->Children.emplace_back(std::make_unique(" of file "));
+
   auto LocFileNode = std::make_unique(
   HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
+
   LocFileNode->Attributes.emplace_back("href", std::string(FileURL));
   Node->Children.emplace_back(std::move(LocFileNode));
   return Node;
@@ -750,11 +754,15 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
   Out.emplace_back(std::move(Table));
 
   if (I.DefLoc) {
-if (!CDCtx.RepositoryUrl)
-  Out.emplace_back(writeFileDefinition(*I.DefLoc));
-else
-  Out.emplace_back(
-  writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
+std::optional RepoUrl;
+std::optional RepoLinePrefix;
+
+if (CDCtx.RepositoryUrl)
+  RepoUrl = StringRef{*CDCtx.RepositoryUrl};
+if (CDCtx.RepositoryLinePrefix)
+  RepoLinePrefix = StringRef{*CDCtx.RepositoryLinePrefix};
+
+Out.emplace_back(writeFileDefinition(*I.DefLoc, RepoUrl, RepoLinePrefix));
   }
 
   std::string Description;
@@ -799,11 +807,15 @@ genHTML(const FunctionInfo &I, const ClangDocContext 
&CDCtx,
   FunctionHeader->Children.emplace_back(std::make_unique(")"));
 
   if (I.DefLoc) {
-if (!CDCtx.RepositoryUrl)
-  Out.emplace_back(writeFileDefinition(*I.DefLoc));
-else
-  Out.emplace_back(writeFileDefinition(
-  *I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
+std::optional RepoUrl;
+std::optional RepoLinePrefix;
+
+if (CDCtx.RepositoryUrl)
+  RepoUrl = StringRef{*CDCtx.RepositoryUrl};
+if (CDCtx.RepositoryLinePrefix)
+  RepoLinePrefix = StringRef{*CDCtx.RepositoryLinePrefix};
+
+Out.emplace_back(writeFileDefinition(*I.DefLoc, RepoUrl, RepoLinePrefix));
   }
 
   std::string Description;
@@ -866,11 +878,15 @@ genHTML(const RecordInfo &I, Index &InfoIndex, const 
ClangDocContext &CDCtx,
   Out.emplace_back(std::make_unique(HTMLTag::TAG_H1, InfoTitle));
 
   if (I.DefLoc) {
-if (!CDCtx.RepositoryUrl)
-  Out.emplace_back(writeFileDefinition(*I.DefLoc));
-else
-  Out.emplace_back(writeFileDefinition(
-  *I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
+std::optional RepoUrl;
+std::optional RepoLinePrefix;
+
+if (CDCtx.RepositoryUrl)
+  RepoUrl = StringRef{*CDCtx.RepositoryUrl};
+if (CDCtx.RepositoryLinePrefix)
+  RepoLinePrefix = StringRef{*CDCtx.RepositoryLinePrefix};
+
+Out.emplace_back(writeFileDefinition(*I.DefLoc, RepoUrl, RepoLinePrefix));
   }
 
   std::string Description;
diff --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-too

[clang] [flang] [llvm] [AMDGPU] Add "lds-buffer-load-insts" attribute for all targets < gfx11 (PR #133055)

2025-03-27 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez updated 
https://github.com/llvm/llvm-project/pull/133055

From 70fbaa4e4f2334cf6134adf02b4af2bcc0bf9847 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Thu, 20 Mar 2025 13:23:25 +0100
Subject: [PATCH 1/3] [AMDGPU] Add "lds-buffer-load-insts" attribute for all
 targets < gfx11

This are used to restrict the availability of buffer_load_lds
intrinsics to targets that actually have this instructions.
---
 clang/lib/Basic/Targets/AMDGPU.cpp   |  2 +-
 clang/test/CodeGen/link-builtin-bitcode.c|  6 +++---
 .../CodeGenCXX/dynamic-cast-address-space.cpp|  4 ++--
 flang/test/Lower/OpenMP/target_cpu_features.f90  |  4 ++--
 llvm/lib/Target/AMDGPU/AMDGPU.td | 16 +++-
 .../Target/AMDGPU/AMDGPUInstructionSelector.cpp  |  3 ++-
 llvm/lib/Target/AMDGPU/GCNSubtarget.h|  3 +++
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp|  3 ++-
 llvm/lib/TargetParser/TargetParser.cpp   |  5 +
 9 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index a42b4589fb5ac..ed578890fc71f 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -260,7 +260,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   CUMode = !(GPUFeatures & llvm::AMDGPU::FEATURE_WGP);
-  for (auto F : {"image-insts", "gws"})
+  for (auto F : {"image-insts", "gws", "lds-buffer-load-insts"})
 ReadOnlyFeatures.insert(F);
   HalfArgsAndReturns = true;
 }
diff --git a/clang/test/CodeGen/link-builtin-bitcode.c 
b/clang/test/CodeGen/link-builtin-bitcode.c
index 470180efa4247..efce9d0af5d49 100644
--- a/clang/test/CodeGen/link-builtin-bitcode.c
+++ b/clang/test/CodeGen/link-builtin-bitcode.c
@@ -44,6 +44,6 @@ int bar() { return no_attr() + attr_in_target() + 
attr_not_in_target() + attr_in
 // CHECK-SAME: () #[[ATTR_INCOMPATIBLE:[0-9]+]] {
 
 // CHECK: attributes #[[ATTR_BAR]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
-// CHECK: attributes #[[ATTR_COMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
-// CHECK: attributes #[[ATTR_EXTEND]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+extended-image-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
-// CHECK: attributes #[[ATTR_INCOMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-gfx9-insts"
 }
+// CHECK: attributes #[[ATTR_COMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+lds-buffer-load-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
+// CHECK: attributes #[[ATTR_EXTEND]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+extended-image-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+lds-buffer-load-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
+// CHECK: attributes #[[ATTR_INCOMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx90a-insts,+gws,+image-insts,+lds-buffer-load-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavef

[clang] [Driver] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON on AIX. (PR #132821)

2025-03-27 Thread Daniel Chen via cfe-commits

DanielCChen wrote:

Thanks to @MaskRay for reviewing the PR and @ldionne for the comments that led 
us to find another issue. 
Would the reviewers please let me know if you are still reviewing the change? I 
am planning to merge it if you have no further comments.

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


[clang] Remove duplicate API (PR #132776)

2025-03-27 Thread Jannick Kremer via cfe-commits

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


[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-03-27 Thread Juan Manuel Martinez Caamaño via cfe-commits

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


[clang] Remove duplicate API (PR #132776)

2025-03-27 Thread Jannick Kremer via cfe-commits

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

Oh wow, what an oversight. Thank you for this PR!
Looks good to me for the most part, it just needs a release note (especially 
for the breaking change).
I'd also like @Endilll to sign off on this as well

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


[clang] [Clang] Improve subsumption. (PR #132849)

2025-03-27 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Improve subsumption. (PR #132849)

2025-03-27 Thread Younan Zhang via cfe-commits


@@ -170,102 +132,112 @@ struct alignas(ConstraintAlignment) 
FoldExpandedConstraint {
  const Expr *Pattern)
   : Kind(K), Constraint(std::move(C)), Pattern(Pattern) {};
 
-  template 
-  bool subsumes(const FoldExpandedConstraint &Other,
-const AtomicSubsumptionEvaluator &E) const;
-
   static bool AreCompatibleForSubsumption(const FoldExpandedConstraint &A,
   const FoldExpandedConstraint &B);
+
+  llvm::FoldingSetNodeID ProfileForSubsumption() const;

zyn0217 wrote:

I think naming it Profile is enough? After all the class is not used for other 
purposes

(Just want to keep it consistent with other Profile functions)

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


[clang] [Clang] Improve subsumption. (PR #132849)

2025-03-27 Thread Younan Zhang via cfe-commits

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

One small nit

Otherwise looks great, thanks! 

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


[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-03-27 Thread Juan Manuel Martinez Caamaño via cfe-commits

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


[clang] [llvm] [NFC][HLSL] Move emitter out of AMDGPU.cpp (PR #133251)

2025-03-27 Thread Farzon Lotfi via cfe-commits

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


  1   2   3   4   5   >