[clang] [Clang][RISCV] Recognize unsupport target feature by supporting... (PR #106495)

2024-08-29 Thread Piyou Chen via cfe-commits


@@ -391,7 +391,14 @@ void RISCVTargetInfo::fillValidTuneCPUList(
 
 static void handleFullArchString(StringRef FullArchStr,
  std::vector &Features) {
-  Features.push_back("__RISCV_TargetAttrNeedOverride");
+
+  // Should be full arch string.
+  if (!FullArchStr.starts_with("rv")) {
+Features.push_back(FullArchStr.str());

BeMg wrote:

Sorry for the imprecise comment. The behavior is as follows: when the input 
FullArchStr is invalid, it is simply passed to the next stage. The 
`checkTargetAttr` function will handle the invalid arch string and emit the 
corresponding warning.

For example, `int __attribute__((target("arch=zba")))`.

I think the comment could be rewrite as `reject the invalid FullArchStr`. 

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


[clang] [C++20] [Modules] Don't insert class not in named modules to PendingEmittingVTables (PR #106501)

2024-08-29 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/106501

>From b5bb3c27c13f1d0f6af21e5f7d8fdad3727bf2d0 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 29 Aug 2024 14:40:50 +0800
Subject: [PATCH 1/2] [C++20] [Modules] Don't insert class not in named modules
 to PendingEmittingVTables

Close https://github.com/llvm/llvm-project/issues/102933

The root cause of the issue is an oversight in
https://github.com/llvm/llvm-project/pull/102287 that I didn't notice
that PendingEmittingVTables should only accept classes in named modules.
---
 clang/include/clang/Serialization/ASTWriter.h |  4 +-
 clang/lib/Serialization/ASTWriter.cpp |  3 ++
 clang/test/Modules/pr106483.cppm  | 39 +++
 3 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Modules/pr106483.cppm

diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index a4cc95cd1373fa..10a50b711043a8 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -500,8 +500,8 @@ class ASTWriter : public ASTDeserializationListener,
   std::vector NonAffectingRanges;
   std::vector NonAffectingOffsetAdjustments;
 
-  /// A list of classes which need to emit the VTable in the corresponding
-  /// object file.
+  /// A list of classes in named modules which need to emit the VTable in
+  /// the corresponding object file.
   llvm::SmallVector PendingEmittingVTables;
 
   /// Computes input files that didn't affect compilation of the current 
module,
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 5cfb98c2a1060a..3e60f1425f88ea 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3963,6 +3963,9 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
 }
 
 void ASTWriter::handleVTable(CXXRecordDecl *RD) {
+  if (!RD->isInNamedModule())
+return;
+
   PendingEmittingVTables.push_back(RD);
 }
 
diff --git a/clang/test/Modules/pr106483.cppm b/clang/test/Modules/pr106483.cppm
new file mode 100644
index 00..08f124dd0d08ca
--- /dev/null
+++ b/clang/test/Modules/pr106483.cppm
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++23 %t/b.cppm -emit-module-interface -o %t/b.pcm \
+// RUN:   -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++23 -fprebuilt-module-path=%t %t/b.pcm -emit-llvm \
+// RUN: -disable-llvm-passes -o - | FileCheck %t/b.cppm
+
+//--- a.cppm
+module;
+
+struct base {
+virtual void f() const;
+};
+
+inline void base::f() const {
+}
+
+export module a;
+export using ::base;
+
+//--- b.cppm
+module;
+
+struct base {
+virtual void f() const;
+};
+
+inline void base::f() const {
+}
+
+export module b;
+import a;
+export using ::base;
+
+// We only need to check that the IR are successfully emitted instead of crash.
+// CHECK: define

>From e671e237a618af14bff1b3bb4e1720f3c69a297a Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 29 Aug 2024 15:10:31 +0800
Subject: [PATCH 2/2] update test

---
 clang/test/Modules/pr106483.cppm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/test/Modules/pr106483.cppm b/clang/test/Modules/pr106483.cppm
index 08f124dd0d08ca..a19316b9dd50cc 100644
--- a/clang/test/Modules/pr106483.cppm
+++ b/clang/test/Modules/pr106483.cppm
@@ -35,5 +35,7 @@ export module b;
 import a;
 export using ::base;
 
+export extern "C" void func() {}
+
 // We only need to check that the IR are successfully emitted instead of crash.
-// CHECK: define
+// CHECK: func

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


[clang] [Clang][RISCV] Recognize unsupport target feature by supporting isValidFeatureName (PR #106495)

2024-08-29 Thread Yingwei Zheng via cfe-commits

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


[clang] [Clang][RISCV] Recognize unsupport target feature by supporting isValidFeatureName (PR #106495)

2024-08-29 Thread Yingwei Zheng via cfe-commits

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


[clang] [C++20] [Modules] Embed all source files for C++20 Modules (PR #102444)

2024-08-29 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/102444

>From 4777ed31ebf1d631c394cd8f13a9355d177536d0 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 8 Aug 2024 15:30:35 +0800
Subject: [PATCH 1/2] [C++20] [Modules] Embed all source files for C++20
 Modules

---
 clang/include/clang/CodeGen/CodeGenAction.h|  2 +-
 clang/include/clang/Frontend/FrontendActions.h |  4 +++-
 clang/include/clang/Serialization/ModuleFile.h | 10 +-
 clang/lib/CodeGen/CodeGenAction.cpp|  5 +++--
 clang/lib/Frontend/FrontendActions.cpp | 15 ---
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/CodeGen/CodeGenAction.h 
b/clang/include/clang/CodeGen/CodeGenAction.h
index 186dbb43f01ef7..461450d875ec50 100644
--- a/clang/include/clang/CodeGen/CodeGenAction.h
+++ b/clang/include/clang/CodeGen/CodeGenAction.h
@@ -57,7 +57,7 @@ class CodeGenAction : public ASTFrontendAction {
   bool loadLinkModules(CompilerInstance &CI);
 
 protected:
-  bool BeginSourceFileAction(CompilerInstance &CI) override;
+  bool BeginInvocation(CompilerInstance &CI) override;
 
   /// Create a new code generation action.  If the optional \p _VMContext
   /// parameter is supplied, the action uses it without taking ownership,
diff --git a/clang/include/clang/Frontend/FrontendActions.h 
b/clang/include/clang/Frontend/FrontendActions.h
index a620ddfc40447d..e82f15f89b6432 100644
--- a/clang/include/clang/Frontend/FrontendActions.h
+++ b/clang/include/clang/Frontend/FrontendActions.h
@@ -152,11 +152,13 @@ class GenerateModuleFromModuleMapAction : public 
GenerateModuleAction {
   CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
 };
 
+bool BeginInvocationForModules(CompilerInstance &CI);
+
 /// Generates full BMI (which contains full information to generate the object
 /// files) for C++20 Named Modules.
 class GenerateModuleInterfaceAction : public GenerateModuleAction {
 protected:
-  bool BeginSourceFileAction(CompilerInstance &CI) override;
+  bool BeginInvocation(CompilerInstance &CI) override;
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override;
diff --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index 3e920c0f683601..30e7f6b3e57bd8 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -88,13 +88,13 @@ class InputFile {
 
   InputFile(FileEntryRef File, bool isOverridden = false,
 bool isOutOfDate = false) {
-assert(!(isOverridden && isOutOfDate) &&
-   "an overridden cannot be out-of-date");
 unsigned intVal = 0;
-if (isOverridden)
-  intVal = Overridden;
-else if (isOutOfDate)
+// Make isOutOfDate with higher priority than isOverridden.
+// It is possible if the recorded hash value mismatches.
+if (isOutOfDate)
   intVal = OutOfDate;
+else if (isOverridden)
+  intVal = Overridden;
 Val.setPointerAndInt(&File.getMapEntry(), intVal);
   }
 
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index e87226e60297c0..8900faf07eeafe 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -969,9 +969,10 @@ CodeGenerator *CodeGenAction::getCodeGenerator() const {
   return BEConsumer->getCodeGenerator();
 }
 
-bool CodeGenAction::BeginSourceFileAction(CompilerInstance &CI) {
+bool CodeGenAction::BeginInvocation(CompilerInstance &CI) {
   if (CI.getFrontendOpts().GenReducedBMI)
-CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
+return BeginInvocationForModules(CI);
+
   return true;
 }
 
diff --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 9f5d09e33ce244..8c7b749fe845cb 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -262,11 +262,20 @@ 
GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
 /*ForceUseTemporary=*/true);
 }
 
-bool GenerateModuleInterfaceAction::BeginSourceFileAction(
-CompilerInstance &CI) {
+bool clang::BeginInvocationForModules(CompilerInstance &CI) {
+  // Embed all module files for named modules.
+  // See https://github.com/llvm/llvm-project/issues/72383 for discussion.
+  CI.getFrontendOpts().ModulesEmbedAllFiles = true;
   CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
+  return true;
+}
 
-  return GenerateModuleAction::BeginSourceFileAction(CI);
+bool GenerateModuleInterfaceAction::BeginInvocation(
+CompilerInstance &CI) {
+  if (!BeginInvocationForModules(CI))
+return false;
+
+  return GenerateModuleAction::BeginInvocation(CI);
 }
 
 std::unique_ptr

>From c61641a8901e99841916288d54a4e8d3d3894c89 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu

[clang] [clang-format] Correctly identifies token-pasted record names (PR #106484)

2024-08-29 Thread kadir çetinkaya via cfe-commits

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

thanks!

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


[clang] [clang-format] Correctly identify token-pasted record names (PR #106484)

2024-08-29 Thread Owen Pan via cfe-commits

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


[clang] [Clang][RISCV] Recognize unsupport target feature by supporting isValidFeatureName (PR #106495)

2024-08-29 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/106495

>From 64557cf6950c17a92b6d85980530abe1e193e111 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 28 Aug 2024 21:15:57 -0700
Subject: [PATCH 1/2] [Clang][RISCV] Recognize unsupport feature by supporting
 isValidFeatureName

---
 clang/lib/Basic/Targets/RISCV.cpp   | 18 --
 clang/lib/Basic/Targets/RISCV.h |  1 +
 clang/lib/Sema/SemaDeclAttr.cpp | 15 +++
 clang/test/Sema/attr-target-riscv.c |  9 +
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 1f8a8cd1462c9d..1d6f49ca232692 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -257,7 +257,7 @@ bool RISCVTargetInfo::initFeatureMap(
 
   // If a target attribute specified a full arch string, override all the ISA
   // extension target features.
-  const auto I = llvm::find(FeaturesVec, "__RISCV_TargetAttrNeedOverride");
+  const auto I = llvm::find(FeaturesVec, "+__RISCV_TargetAttrNeedOverride");
   if (I != FeaturesVec.end()) {
 std::vector OverrideFeatures(std::next(I), FeaturesVec.end());
 
@@ -391,7 +391,14 @@ void RISCVTargetInfo::fillValidTuneCPUList(
 
 static void handleFullArchString(StringRef FullArchStr,
  std::vector &Features) {
-  Features.push_back("__RISCV_TargetAttrNeedOverride");
+
+  // Should be full arch string.
+  if (!FullArchStr.starts_with("rv")) {
+Features.push_back(FullArchStr.str());
+return;
+  }
+
+  Features.push_back("+__RISCV_TargetAttrNeedOverride");
   auto RII = llvm::RISCVISAInfo::parseArchString(
   FullArchStr, /* EnableExperimentalExtension */ true);
   if (llvm::errorToBool(RII.takeError())) {
@@ -485,3 +492,10 @@ bool RISCVTargetInfo::validateCpuSupports(StringRef 
Feature) const {
   // __riscv_feature_bits structure.
   return -1 != llvm::RISCVISAInfo::getRISCVFeaturesBitsInfo(Feature).second;
 }
+
+bool RISCVTargetInfo::isValidFeatureName(StringRef Name) const {
+  if (Name == "__RISCV_TargetAttrNeedOverride")
+return true;
+
+  return llvm::RISCVISAInfo::isSupportedExtensionFeature(Name);
+}
diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 626274b8fc437c..b808ccc8e9cfe9 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -130,6 +130,7 @@ class RISCVTargetInfo : public TargetInfo {
   bool supportsCpuSupports() const override { return getTriple().isOSLinux(); }
   bool supportsCpuInit() const override { return getTriple().isOSLinux(); }
   bool validateCpuSupports(StringRef Feature) const override;
+  bool isValidFeatureName(StringRef Name) const override;
 };
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 1e074298ac5289..81cff8d7362ad5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2993,10 +2993,17 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, 
StringRef AttrStr) {
 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
<< Unknown << Tune << ParsedAttrs.Tune << Target;
 
-  if (Context.getTargetInfo().getTriple().isRISCV() &&
-  ParsedAttrs.Duplicate != "")
-return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
-   << Duplicate << None << ParsedAttrs.Duplicate << Target;
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+if (ParsedAttrs.Duplicate != "")
+  return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
+ << Duplicate << None << ParsedAttrs.Duplicate << Target;
+for (const auto &Feature : ParsedAttrs.Features) {
+  auto CurFeature = StringRef(Feature);
+  if (!CurFeature.starts_with("+") && !CurFeature.starts_with("-"))
+return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+   << Unsupported << None << AttrStr << Target;
+}
+  }
 
   if (ParsedAttrs.Duplicate != "")
 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
diff --git a/clang/test/Sema/attr-target-riscv.c 
b/clang/test/Sema/attr-target-riscv.c
index ed4e2915d6c6ef..01d928c1d78e48 100644
--- a/clang/test/Sema/attr-target-riscv.c
+++ b/clang/test/Sema/attr-target-riscv.c
@@ -4,3 +4,12 @@
 int __attribute__((target("arch=rv64g"))) foo(void) { return 0; }
 //expected-error@+1 {{redefinition of 'foo'}}
 int __attribute__((target("arch=rv64gc"))) foo(void) { return 0; }
+
+//expected-warning@+1 {{unsupported 'notafeature' in the 'target' attribute 
string; 'target' attribute ignored}}
+int __attribute__((target("arch=+notafeature"))) UnsupportFeature(void) { 
return 0; }
+
+//expected-warning@+1 {{unsupported 'arch=+zba,zbb' in the 'target' attribute 
string; 'target' attribute ignored}}
+int __attribute__((target("arch=+zba,zbb"))) WithoutAddSigned(void) { ret

[clang] 47615ff - [C++20] [Modules] Don't insert class not in named modules to PendingEmittingVTables (#106501)

2024-08-29 Thread via cfe-commits

Author: Chuanqi Xu
Date: 2024-08-29T15:42:57+08:00
New Revision: 47615ff2347a8be429404285de3b1c03b411e7af

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

LOG: [C++20] [Modules] Don't insert class not in named modules to 
PendingEmittingVTables (#106501)

Close https://github.com/llvm/llvm-project/issues/102933

The root cause of the issue is an oversight in
https://github.com/llvm/llvm-project/pull/102287 that I didn't notice
that PendingEmittingVTables should only accept classes in named modules.

Added: 
clang/test/Modules/pr106483.cppm

Modified: 
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index a4cc95cd1373fa..10a50b711043a8 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -500,8 +500,8 @@ class ASTWriter : public ASTDeserializationListener,
   std::vector NonAffectingRanges;
   std::vector NonAffectingOffsetAdjustments;
 
-  /// A list of classes which need to emit the VTable in the corresponding
-  /// object file.
+  /// A list of classes in named modules which need to emit the VTable in
+  /// the corresponding object file.
   llvm::SmallVector PendingEmittingVTables;
 
   /// Computes input files that didn't affect compilation of the current 
module,

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 5cfb98c2a1060a..3e60f1425f88ea 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3963,6 +3963,9 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
 }
 
 void ASTWriter::handleVTable(CXXRecordDecl *RD) {
+  if (!RD->isInNamedModule())
+return;
+
   PendingEmittingVTables.push_back(RD);
 }
 

diff  --git a/clang/test/Modules/pr106483.cppm 
b/clang/test/Modules/pr106483.cppm
new file mode 100644
index 00..a19316b9dd50cc
--- /dev/null
+++ b/clang/test/Modules/pr106483.cppm
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++23 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++23 %t/b.cppm -emit-module-interface -o %t/b.pcm \
+// RUN:   -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++23 -fprebuilt-module-path=%t %t/b.pcm -emit-llvm \
+// RUN: -disable-llvm-passes -o - | FileCheck %t/b.cppm
+
+//--- a.cppm
+module;
+
+struct base {
+virtual void f() const;
+};
+
+inline void base::f() const {
+}
+
+export module a;
+export using ::base;
+
+//--- b.cppm
+module;
+
+struct base {
+virtual void f() const;
+};
+
+inline void base::f() const {
+}
+
+export module b;
+import a;
+export using ::base;
+
+export extern "C" void func() {}
+
+// We only need to check that the IR are successfully emitted instead of crash.
+// CHECK: func



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


[clang] [C++20] [Modules] Don't insert class not in named modules to PendingEmittingVTables (PR #106501)

2024-08-29 Thread Chuanqi Xu via cfe-commits

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


[clang] [C++20] [Modules] Don't insert class not in named modules to PendingEmittingVTables (PR #106501)

2024-08-29 Thread Chuanqi Xu via cfe-commits

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


[clang] [C++20] [Modules] Don't insert class not in named modules to PendingEmittingVTables (PR #106501)

2024-08-29 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

/cherry-pick 47615ff2347a8be429404285de3b1c03b411e7af

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


[clang] [Clang][RISCV] Recognize unsupport target feature by supporting isValidFeatureName (PR #106495)

2024-08-29 Thread Piyou Chen via cfe-commits


@@ -391,7 +391,14 @@ void RISCVTargetInfo::fillValidTuneCPUList(
 
 static void handleFullArchString(StringRef FullArchStr,
  std::vector &Features) {
-  Features.push_back("__RISCV_TargetAttrNeedOverride");
+
+  // Should be full arch string.
+  if (!FullArchStr.starts_with("rv")) {
+Features.push_back(FullArchStr.str());

BeMg wrote:

Oh, I found the `parseArchString` also check whether FullArchStr start with 
"rv". 

I removed this statement and drop the unnecessary "+" sign to trigger the Sema 
check.

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


[clang] [C++20] [Modules] Don't insert class not in named modules to PendingEmittingVTables (PR #106501)

2024-08-29 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#106504

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


[clang] e5b55e6 - [clang-repl] Fix clang-repl for LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES=Off.

2024-08-29 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2024-08-29T17:50:49+10:00
New Revision: e5b55e606796bac0e28e2f0fdc6fb39a419f6b15

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

LOG: [clang-repl] Fix clang-repl for 
LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES=Off.

clang-repl should stil work when LLVM is built with
-DLLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES=Off.

This fix uses the approach implemented in
https://github.com/llvm/llvm-project/pull/101741.

rdar://134910110

Added: 


Modified: 
clang/tools/clang-repl/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-repl/CMakeLists.txt 
b/clang/tools/clang-repl/CMakeLists.txt
index a35ff13494e115..9ffe853d759caf 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -9,6 +9,8 @@ set( LLVM_LINK_COMPONENTS
 
 add_clang_tool(clang-repl
   ClangRepl.cpp
+
+  EXPORT_SYMBOLS
   )
 
 if(MSVC)
@@ -61,8 +63,6 @@ clang_target_link_libraries(clang-repl PRIVATE
   clangInterpreter
   )
 
-export_executable_symbols_for_plugins(clang-repl)
-
 # The clang-repl binary can get huge with static linking in debug mode.
 # Some 32-bit targets use PLT slots with limited branch range by default and we
 # start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with



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


[clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-08-29 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/106505

This is so that we are consistent with other sanitizers. Importantly, this 
makes the docs clearer.

Driver flags are left unchanged (We are not proposing to rename `sancov` 
either). The good thing is that flags were already consistent with other 
sanitizers so there would not be any motivation to change them, even if we were 
feeling disruptive.


>From adb4a0eb00972811343ff05eac6977512f01970a Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Thu, 29 Aug 2024 09:43:56 +0200
Subject: [PATCH] Rename Sanitizer Coverage => Coverage Sanitizer

This is so that we are consistent with other sanitizers.
Importantly, this makes the docs clearer.

Driver flags are left unchanged. The good thing is that flags
were already consistent with other sanitizers so there
would not be any motivation to change them,
even if we were feeling disruptive.
---
 ...izerCoverage.rst => CoverageSanitizer.rst} |  16 ++--
 clang/docs/SourceBasedCodeCoverage.rst|   2 +-
 clang/docs/UsersManual.rst|   2 +-
 clang/docs/index.rst  |   2 +-
 clang/docs/tools/clang-formatted-files.txt|   2 +-
 clang/include/clang/Basic/AttrDocs.td |   4 +-
 clang/include/clang/Basic/CodeGenOptions.def  |  18 ++--
 clang/include/clang/Basic/CodeGenOptions.h|   2 +-
 .../clang/Basic/DiagnosticDriverKinds.td  |   8 +-
 clang/include/clang/Driver/Options.td |  26 +++---
 clang/lib/CodeGen/BackendUtil.cpp |  10 +--
 clang/lib/Driver/SanitizerArgs.cpp|   4 +-
 clang/test/CodeGen/Inputs/memprof.exe | Bin 1394680 -> 1394680 bytes
 clang/test/CodeGen/sancov-new-pm.c|   2 +-
 clang/test/Driver/sancov.c|   2 +-
 .../include/sanitizer/common_interface_defs.h |   2 +-
 .../include/sanitizer/coverage_interface.h|   2 +-
 compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp  |   4 +-
 .../lib/sanitizer_common/CMakeLists.txt   |  18 ++--
 ...sia.cpp => coverage_sanitizer_fuchsia.cpp} |   6 +-
 ...e.inc => coverage_sanitizer_interface.inc} |   4 +-
 ...cpp => coverage_sanitizer_libcdep_new.cpp} |   8 +-
 ...p => coverage_sanitizer_win_dll_thunk.cpp} |   6 +-
 ...e_sanitizer_win_dynamic_runtime_thunk.cpp} |   8 +-
 ...pp => coverage_sanitizer_win_sections.cpp} |   4 +-
 ...erage_sanitizer_win_weak_interception.cpp} |   6 +-
 .../lib/sanitizer_common/sancov_flags.cpp |   2 +-
 .../lib/sanitizer_common/sancov_flags.h   |   2 +-
 .../lib/sanitizer_common/sancov_flags.inc |   2 +-
 .../Darwin/interface_symbols_darwin.cpp   |   2 +-
 .../Linux/interface_symbols_linux.cpp |   2 +-
 .../asan/TestCases/Posix/coverage-reset.cpp   |  14 +--
 .../test/asan/TestCases/coverage-and-lsan.cpp |   2 +-
 ...verage_sanitizer_allowlist_ignorelist.cpp} |   0
 ...pp => coverage_sanitizer_control_flow.cpp} |   0
 ...coverage_sanitizer_inline8bit_counter.cpp} |   0
 ...tizer_inline8bit_counter_default_impl.cpp} |   0
 ...> coverage_sanitizer_inline_bool_flag.cpp} |   0
 ...ne.cpp => coverage_sanitizer_no_prune.cpp} |   0
 ...cpp => coverage_sanitizer_stack_depth.cpp} |   0
 ...e.cpp => coverage_sanitizer_symbolize.cpp} |   2 +-
 ...coverage_sanitizer_trace_loads_stores.cpp} |   0
 ...coverage_sanitizer_trace_pc_guard-dso.cpp} |  10 +--
 ...overage_sanitizer_trace_pc_guard-init.cpp} |   0
 ... => coverage_sanitizer_trace_pc_guard.cpp} |   8 +-
 libcxx/docs/VendorDocumentation.rst   |   2 +-
 lldb/docs/resources/fuzzing.rst   |   4 +-
 llvm/docs/FuzzingLLVM.rst |   2 +-
 llvm/docs/LangRef.rst |   2 +-
 llvm/docs/LibFuzzer.rst   |  12 +--
 llvm/docs/SymbolizerMarkupFormat.rst  |   2 +-
 .../include/llvm/Transforms/Instrumentation.h |   6 +-
 ...anitizerCoverage.h => CoverageSanitizer.h} |  14 +--
 llvm/lib/Passes/PassBuilder.cpp   |   2 +-
 llvm/lib/Passes/PassRegistry.def  |   2 +-
 .../Transforms/Instrumentation/CMakeLists.txt |   2 +-
 ...izerCoverage.cpp => CoverageSanitizer.cpp} |  82 +-
 .../SanitizerCoverage/crit-edge-sancov.ll |   4 +-
 .../Transforms/PGOProfile/Inputs/memprof.exe  | Bin 1606400 -> 1606400 bytes
 .../PGOProfile/Inputs/memprof.nocolinfo.exe   | Bin 1606168 -> 1606168 bytes
 .../Inputs/memprof_internal_linkage.exe   | Bin 1605160 -> 1605160 bytes
 .../PGOProfile/Inputs/memprof_loop_unroll.exe | Bin 1605960 -> 1605960 bytes
 .../Inputs/memprof_missing_leaf.exe   | Bin 1605072 -> 1605072 bytes
 .../Inputs/basic-histogram.memprofexe | Bin 1611256 -> 1611256 bytes
 .../llvm-profdata/Inputs/basic.memprofexe | Bin 1604896 -> 1604896 bytes
 .../llvm-profdata/Inputs/basic_v3.memprofexe  | Bin 1379856 -> 1379856 bytes
 .../llvm-profdata/Inputs/buildid.memprofexe   | Bin 1604904 -> 1604904 bytes
 .../llvm-profdata/Inputs/inline.memprofexe| Bin 1605480 -> 1605480 bytes
 .../l

[clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-08-29 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-lldb

@llvm/pr-subscribers-libcxx

Author: cor3ntin (cor3ntin)


Changes

This is so that we are consistent with other sanitizers. Importantly, this 
makes the docs clearer.

Driver flags are left unchanged (We are not proposing to rename `sancov` 
either). The good thing is that flags were already consistent with other 
sanitizers so there would not be any motivation to change them, even if we were 
feeling disruptive.


---

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


79 Files Affected:

- (renamed) clang/docs/CoverageSanitizer.rst (+8-8) 
- (modified) clang/docs/SourceBasedCodeCoverage.rst (+1-1) 
- (modified) clang/docs/UsersManual.rst (+1-1) 
- (modified) clang/docs/index.rst (+1-1) 
- (modified) clang/docs/tools/clang-formatted-files.txt (+1-1) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+2-2) 
- (modified) clang/include/clang/Basic/CodeGenOptions.def (+9-9) 
- (modified) clang/include/clang/Basic/CodeGenOptions.h (+1-1) 
- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+4-4) 
- (modified) clang/include/clang/Driver/Options.td (+13-13) 
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+5-5) 
- (modified) clang/lib/Driver/SanitizerArgs.cpp (+2-2) 
- (modified) clang/test/CodeGen/Inputs/memprof.exe () 
- (modified) clang/test/CodeGen/sancov-new-pm.c (+1-1) 
- (modified) clang/test/Driver/sancov.c (+1-1) 
- (modified) compiler-rt/include/sanitizer/common_interface_defs.h (+1-1) 
- (modified) compiler-rt/include/sanitizer/coverage_interface.h (+1-1) 
- (modified) compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp (+2-2) 
- (modified) compiler-rt/lib/sanitizer_common/CMakeLists.txt (+9-9) 
- (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp 
(+3-3) 
- (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_interface.inc 
(+2-2) 
- (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp 
(+4-4) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dll_thunk.cpp (+3-3) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dynamic_runtime_thunk.cpp
 (+4-4) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_sections.cpp (+2-2) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_weak_interception.cpp 
(+3-3) 
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.cpp (+1-1) 
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.h (+1-1) 
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.inc (+1-1) 
- (modified) 
compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp (+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp 
(+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp (+7-7) 
- (modified) compiler-rt/test/asan/TestCases/coverage-and-lsan.cpp (+1-1) 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_allowlist_ignorelist.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_control_flow.cpp 
() 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter_default_impl.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline_bool_flag.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_no_prune.cpp () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_stack_depth.cpp 
() 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_symbolize.cpp 
(+1-1) 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_loads_stores.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-dso.cpp
 (+5-5) 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-init.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard.cpp
 (+4-4) 
- (modified) libcxx/docs/VendorDocumentation.rst (+1-1) 
- (modified) lldb/docs/resources/fuzzing.rst (+2-2) 
- (modified) llvm/docs/FuzzingLLVM.rst (+1-1) 
- (modified) llvm/docs/LangRef.rst (+1-1) 
- (modified) llvm/docs/LibFuzzer.rst (+6-6) 
- (modified) llvm/docs/SymbolizerMarkupFormat.rst (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation.h (+3-3) 
- (renamed) llvm/include/llvm/Transforms/Instrumentation/CoverageSanitizer.h 
(+7-7) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1-1) 
- (renamed) llvm/lib/Transforms/Instrumentation/CoverageSanitizer.cpp (+41-41) 
- (modified) llvm/test/Instrumentation/SanitizerCoverage/crit-edge-sancov.ll 
(+2-2) 
- (modified) llvm/t

[clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-08-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: cor3ntin (cor3ntin)


Changes

This is so that we are consistent with other sanitizers. Importantly, this 
makes the docs clearer.

Driver flags are left unchanged (We are not proposing to rename `sancov` 
either). The good thing is that flags were already consistent with other 
sanitizers so there would not be any motivation to change them, even if we were 
feeling disruptive.


---

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


79 Files Affected:

- (renamed) clang/docs/CoverageSanitizer.rst (+8-8) 
- (modified) clang/docs/SourceBasedCodeCoverage.rst (+1-1) 
- (modified) clang/docs/UsersManual.rst (+1-1) 
- (modified) clang/docs/index.rst (+1-1) 
- (modified) clang/docs/tools/clang-formatted-files.txt (+1-1) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+2-2) 
- (modified) clang/include/clang/Basic/CodeGenOptions.def (+9-9) 
- (modified) clang/include/clang/Basic/CodeGenOptions.h (+1-1) 
- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+4-4) 
- (modified) clang/include/clang/Driver/Options.td (+13-13) 
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+5-5) 
- (modified) clang/lib/Driver/SanitizerArgs.cpp (+2-2) 
- (modified) clang/test/CodeGen/Inputs/memprof.exe () 
- (modified) clang/test/CodeGen/sancov-new-pm.c (+1-1) 
- (modified) clang/test/Driver/sancov.c (+1-1) 
- (modified) compiler-rt/include/sanitizer/common_interface_defs.h (+1-1) 
- (modified) compiler-rt/include/sanitizer/coverage_interface.h (+1-1) 
- (modified) compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp (+2-2) 
- (modified) compiler-rt/lib/sanitizer_common/CMakeLists.txt (+9-9) 
- (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp 
(+3-3) 
- (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_interface.inc 
(+2-2) 
- (renamed) compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp 
(+4-4) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dll_thunk.cpp (+3-3) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dynamic_runtime_thunk.cpp
 (+4-4) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_sections.cpp (+2-2) 
- (renamed) 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_weak_interception.cpp 
(+3-3) 
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.cpp (+1-1) 
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.h (+1-1) 
- (modified) compiler-rt/lib/sanitizer_common/sancov_flags.inc (+1-1) 
- (modified) 
compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp (+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp 
(+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp (+7-7) 
- (modified) compiler-rt/test/asan/TestCases/coverage-and-lsan.cpp (+1-1) 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_allowlist_ignorelist.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_control_flow.cpp 
() 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter_default_impl.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline_bool_flag.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_no_prune.cpp () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_stack_depth.cpp 
() 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_symbolize.cpp 
(+1-1) 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_loads_stores.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-dso.cpp
 (+5-5) 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-init.cpp
 () 
- (renamed) 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard.cpp
 (+4-4) 
- (modified) libcxx/docs/VendorDocumentation.rst (+1-1) 
- (modified) lldb/docs/resources/fuzzing.rst (+2-2) 
- (modified) llvm/docs/FuzzingLLVM.rst (+1-1) 
- (modified) llvm/docs/LangRef.rst (+1-1) 
- (modified) llvm/docs/LibFuzzer.rst (+6-6) 
- (modified) llvm/docs/SymbolizerMarkupFormat.rst (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation.h (+3-3) 
- (renamed) llvm/include/llvm/Transforms/Instrumentation/CoverageSanitizer.h 
(+7-7) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1-1) 
- (renamed) llvm/lib/Transforms/Instrumentation/CoverageSanitizer.cpp (+41-41) 
- (modified) llvm/test/Instrumentation/SanitizerCoverage/crit-edge-sancov.ll 
(+2-2) 
- (modified) llvm/test/Transforms/PGOP

[clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)

2024-08-29 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff ec9f36a624fa9f8fea6e40384ce513b6da8c08e4 
adb4a0eb00972811343ff05eac6977512f01970a --extensions c,h,inc,cpp -- 
clang/include/clang/Basic/CodeGenOptions.h clang/lib/CodeGen/BackendUtil.cpp 
clang/lib/Driver/SanitizerArgs.cpp clang/test/CodeGen/sancov-new-pm.c 
clang/test/Driver/sancov.c 
compiler-rt/include/sanitizer/common_interface_defs.h 
compiler-rt/include/sanitizer/coverage_interface.h 
compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp 
compiler-rt/lib/sanitizer_common/sancov_flags.cpp 
compiler-rt/lib/sanitizer_common/sancov_flags.h 
compiler-rt/lib/sanitizer_common/sancov_flags.inc 
compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp 
compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp 
compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp 
compiler-rt/test/asan/TestCases/coverage-and-lsan.cpp 
llvm/include/llvm/Transforms/Instrumentation.h llvm/lib/Passes/PassBuilder.cpp 
llvm/tools/sancov/sancov.cpp 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_interface.inc 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dll_thunk.cpp 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_dynamic_runtime_thunk.cpp
 compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_sections.cpp 
compiler-rt/lib/sanitizer_common/coverage_sanitizer_win_weak_interception.cpp 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_allowlist_ignorelist.cpp
 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_control_flow.cpp 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter.cpp
 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline8bit_counter_default_impl.cpp
 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_inline_bool_flag.cpp
 compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_no_prune.cpp 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_stack_depth.cpp 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_symbolize.cpp 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_loads_stores.cpp
 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-dso.cpp
 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard-init.cpp
 
compiler-rt/test/sanitizer_common/TestCases/coverage_sanitizer_trace_pc_guard.cpp
 llvm/include/llvm/Transforms/Instrumentation/CoverageSanitizer.h 
llvm/lib/Transforms/Instrumentation/CoverageSanitizer.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3301a0f9b5..382cee4527 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
+#include "llvm/Transforms/Instrumentation/CoverageSanitizer.h"
 #include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
@@ -80,7 +81,6 @@
 #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
 #include "llvm/Transforms/Instrumentation/RealtimeSanitizer.h"
 #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
-#include "llvm/Transforms/Instrumentation/CoverageSanitizer.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar/EarlyCSE.h"
diff --git a/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp 
b/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp
index 9343079f78..026b669a1c 100644
--- a/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp
+++ b/compiler-rt/lib/sanitizer_common/coverage_sanitizer_fuchsia.cpp
@@ -27,14 +27,14 @@
 
 #include "sanitizer_platform.h"
 #if SANITIZER_FUCHSIA
-#include 
-#include 
-#include 
-
-#include "sanitizer_atomic.h"
-#include "sanitizer_common.h"
-#include "sanitizer_interface_internal.h"
-#include "sanitizer_internal_defs.h"
+#  include 
+#  include 
+#  include 
+
+#  include "sanitizer_atomic.h"
+#  include "sanitizer_common.h"
+#  include "sanitizer_interface_internal.h"
+#  include "sanitizer_internal_defs.h"
 #  include "sanitizer_symbolizer_markup_constants.h"
 
 using namespace __sanitizer;
diff --git 
a/compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp 
b/compiler-rt/lib/sanitizer_common/coverage_sanitizer_libcdep_new.cpp
index ab4

[clang] [clang-format] Don't merge a short block for SBS_Never (PR #88238)

2024-08-29 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

This seems to be recognizing some initliazer list statements as blocks as well, 
e.g:

```objc
$ cat a.m
[bar bat:{{0, 1, 2, 3}} qq: qq];
```

this seems to be formatted as:
```objc
$ ~/repos/llvm/build/bin/clang-format -style='{AllowShortBlocksOnASingleLine: 
Never}' a.m
[bar bat:{
  {
0, 1, 2, 3
  }
}
  qq:qq];
```

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


[clang] `__noop` not marked as constexpr #102064 (PR #105983)

2024-08-29 Thread via cfe-commits

ofAlpaca wrote:

@cor3ntin 
Sure, thank you for the help.

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


[clang] 2eeeff8 - [C++20] [Modules] Embed all source files for C++20 Modules (#102444)

2024-08-29 Thread via cfe-commits

Author: Chuanqi Xu
Date: 2024-08-29T16:06:03+08:00
New Revision: 2eeeff842f993a694159183a2834b4d305549cad

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

LOG: [C++20] [Modules] Embed all source files for C++20 Modules (#102444)

Close https://github.com/llvm/llvm-project/issues/72383

The implementation rationale is, I don't want to pass
`-fmodules-embed-all-files` all the time since we can't test it in lit
tests (we're using `clang_cc1`). So I tried to set it in FrontendActions
for modules.

Added: 


Modified: 
clang/include/clang/CodeGen/CodeGenAction.h
clang/include/clang/Frontend/FrontendActions.h
clang/include/clang/Serialization/ModuleFile.h
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/test/Modules/no-local-decl-in-reduced-bmi.cppm
clang/test/Modules/reduced-bmi-empty-module-purview-std.cppm
clang/test/Modules/reduced-bmi-empty-module-purview.cppm
clang/test/Modules/unreached-static-entities.cppm

Removed: 




diff  --git a/clang/include/clang/CodeGen/CodeGenAction.h 
b/clang/include/clang/CodeGen/CodeGenAction.h
index 186dbb43f01ef7..461450d875ec50 100644
--- a/clang/include/clang/CodeGen/CodeGenAction.h
+++ b/clang/include/clang/CodeGen/CodeGenAction.h
@@ -57,7 +57,7 @@ class CodeGenAction : public ASTFrontendAction {
   bool loadLinkModules(CompilerInstance &CI);
 
 protected:
-  bool BeginSourceFileAction(CompilerInstance &CI) override;
+  bool BeginInvocation(CompilerInstance &CI) override;
 
   /// Create a new code generation action.  If the optional \p _VMContext
   /// parameter is supplied, the action uses it without taking ownership,

diff  --git a/clang/include/clang/Frontend/FrontendActions.h 
b/clang/include/clang/Frontend/FrontendActions.h
index a620ddfc40447d..e82f15f89b6432 100644
--- a/clang/include/clang/Frontend/FrontendActions.h
+++ b/clang/include/clang/Frontend/FrontendActions.h
@@ -152,11 +152,13 @@ class GenerateModuleFromModuleMapAction : public 
GenerateModuleAction {
   CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
 };
 
+bool BeginInvocationForModules(CompilerInstance &CI);
+
 /// Generates full BMI (which contains full information to generate the object
 /// files) for C++20 Named Modules.
 class GenerateModuleInterfaceAction : public GenerateModuleAction {
 protected:
-  bool BeginSourceFileAction(CompilerInstance &CI) override;
+  bool BeginInvocation(CompilerInstance &CI) override;
 
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override;

diff  --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index 3e920c0f683601..30e7f6b3e57bd8 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -88,13 +88,13 @@ class InputFile {
 
   InputFile(FileEntryRef File, bool isOverridden = false,
 bool isOutOfDate = false) {
-assert(!(isOverridden && isOutOfDate) &&
-   "an overridden cannot be out-of-date");
 unsigned intVal = 0;
-if (isOverridden)
-  intVal = Overridden;
-else if (isOutOfDate)
+// Make isOutOfDate with higher priority than isOverridden.
+// It is possible if the recorded hash value mismatches.
+if (isOutOfDate)
   intVal = OutOfDate;
+else if (isOverridden)
+  intVal = Overridden;
 Val.setPointerAndInt(&File.getMapEntry(), intVal);
   }
 

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index e87226e60297c0..8900faf07eeafe 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -969,9 +969,10 @@ CodeGenerator *CodeGenAction::getCodeGenerator() const {
   return BEConsumer->getCodeGenerator();
 }
 
-bool CodeGenAction::BeginSourceFileAction(CompilerInstance &CI) {
+bool CodeGenAction::BeginInvocation(CompilerInstance &CI) {
   if (CI.getFrontendOpts().GenReducedBMI)
-CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
+return BeginInvocationForModules(CI);
+
   return true;
 }
 

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 9f5d09e33ce244..8c7b749fe845cb 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -262,11 +262,20 @@ 
GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
 /*ForceUseTemporary=*/true);
 }
 
-bool GenerateModuleInterfaceAction::BeginSourceFileAction(
-CompilerInstance &CI) {
+bool clang::BeginInvocationForModules(CompilerInstance &CI) {
+  // Embed all module files for named modules.
+  // See https://g

[clang] [C++20] [Modules] Embed all source files for C++20 Modules (PR #102444)

2024-08-29 Thread Chuanqi Xu via cfe-commits

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


[clang-tools-extra] [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit (PR #106430)

2024-08-29 Thread kadir çetinkaya via cfe-commits


@@ -203,7 +203,7 @@ class ASTWalker : public RecursiveASTVisitor {
   bool VisitUsingDecl(UsingDecl *UD) {
 for (const auto *Shadow : UD->shadows()) {
   auto *TD = Shadow->getTargetDecl();
-  auto IsUsed = TD->isUsed() || TD->isReferenced();
+  auto IsUsed = TD->isUsed() || TD->isReferenced() || !TD->getAsFunction();

kadircet wrote:

Well I was actually thinking that `usedness` is still the right concept here, 
spelling of the type name in the using declaration is enough to trigger that 
use for records.

I added comments also along those lines, LMK if it still doesn't resonate with 
you.

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


[clang-tools-extra] [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit (PR #106430)

2024-08-29 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet updated 
https://github.com/llvm/llvm-project/pull/106430

From 9a96724fba63c91eefca804112c8e862e5427c10 Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Wed, 28 Aug 2024 20:30:08 +0200
Subject: [PATCH] [include-cleaner] Mark RecordDecls referenced in UsingDecls
 as explicit

We were reporting ambigious references from using declarations as user
can be depending on different overloads of a function just because they
are visible in the TU.
This doesn't apply to records, or primary templates as declaration being
referenced in such cases is unambigious, the ambiguity applies to
specializations though.

Hence this patch returns an explicit reference to record decls and
primary templates of those.
---
 clang-tools-extra/include-cleaner/lib/WalkAST.cpp |  7 ++-
 .../include-cleaner/unittests/WalkASTTest.cpp | 11 ---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index 598484d09712e5..f7a2ebd5260681 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -203,7 +203,12 @@ class ASTWalker : public RecursiveASTVisitor {
   bool VisitUsingDecl(UsingDecl *UD) {
 for (const auto *Shadow : UD->shadows()) {
   auto *TD = Shadow->getTargetDecl();
-  auto IsUsed = TD->isUsed() || TD->isReferenced();
+  // For function-decls, we might have overloads brought in due to
+  // transitive dependencies. Hence we only want to report explicit
+  // references for those if they're used.
+  // But for record decls, spelling of the type always refers to primary
+  // decl non-ambiguously. Hence spelling is already a use.
+  auto IsUsed = TD->isUsed() || TD->isReferenced() || !TD->getAsFunction();
   report(UD->getLocation(), TD,
  IsUsed ? RefType::Explicit : RefType::Ambiguous);
 
diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index 6c8eacbff1cea3..9286758cab081c 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -255,7 +255,7 @@ TEST(WalkAST, TemplateSpecializationsFromUsingDecl) {
   // Class templates
   testWalk(R"cpp(
 namespace ns {
-template class $ambiguous^Z {};  // primary template
+template class $explicit^Z {};  // primary template
 template class $ambiguous^Z {};  // partial specialization
 template<> class $ambiguous^Z {};// full specialization
 }
@@ -265,7 +265,7 @@ template<> class $ambiguous^Z {};// full 
specialization
   // Var templates
   testWalk(R"cpp(
 namespace ns {
-template T $ambiguous^foo;  // primary template
+template T $explicit^foo;  // primary template
 template T $ambiguous^foo;  // partial specialization
 template<> int* $ambiguous^foo; // full specialization
 }
@@ -335,7 +335,12 @@ TEST(WalkAST, Using) {
   testWalk(R"cpp(
 namespace ns {
   template
-  class $ambiguous^Y {};
+  class $explicit^Y {};
+})cpp",
+   "using ns::^Y;");
+  testWalk(R"cpp(
+namespace ns {
+  class $explicit^Y {};
 })cpp",
"using ns::^Y;");
   testWalk(R"cpp(

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


[clang] b822b69 - [Driver] Add -mbranch-protection to ARM and AArch64 multilib flags (#106391)

2024-08-29 Thread via cfe-commits

Author: Lucas Duarte Prates
Date: 2024-08-29T09:11:48+01:00
New Revision: b822b69ff54bcd2f08445bd02b8dad0584422874

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

LOG: [Driver] Add -mbranch-protection to ARM and AArch64 multilib flags 
(#106391)

This adds the `-mbranch-protection` command line option to the set of
flags used by the multilib selection for ARM and AArch64 targets.

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/print-multi-selection-flags.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index c93c97146b6104..76901875c66959 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -221,6 +221,12 @@ static void getAArch64MultilibFlags(const Driver &D,
   assert(!ArchName.empty() && "at least one architecture should be found");
   MArch.insert(MArch.begin(), ("-march=" + ArchName).str());
   Result.push_back(llvm::join(MArch, "+"));
+
+  const Arg *BranchProtectionArg =
+  Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ);
+  if (BranchProtectionArg) {
+Result.push_back(BranchProtectionArg->getAsString(Args));
+  }
 }
 
 static void getARMMultilibFlags(const Driver &D,
@@ -268,6 +274,12 @@ static void getARMMultilibFlags(const Driver &D,
   case arm::FloatABI::Invalid:
 llvm_unreachable("Invalid float ABI");
   }
+
+  const Arg *BranchProtectionArg =
+  Args.getLastArgNoClaim(options::OPT_mbranch_protection_EQ);
+  if (BranchProtectionArg) {
+Result.push_back(BranchProtectionArg->getAsString(Args));
+  }
 }
 
 static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,

diff  --git a/clang/test/Driver/print-multi-selection-flags.c 
b/clang/test/Driver/print-multi-selection-flags.c
index 2770a3ad5eaa1d..0116c7f5a03b9a 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -59,6 +59,10 @@
 // CHECK-SVE2: --target=aarch64-unknown-none-elf
 // CHECK-SVE2: -march=armv{{.*}}-a{{.*}}+simd{{.*}}+sve{{.*}}+sve2{{.*}}
 
+// RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi 
-mbranch-protection=standard| FileCheck 
--check-prefix=CHECK-BRANCH-PROTECTION %s
+// RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf 
-mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION 
%s
+// CHECK-BRANCH-PROTECTION: -mbranch-protection=standard
+
 // RUN: %clang -print-multi-flags-experimental --target=riscv32-none-elf 
-march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s
 // CHECK-RV32: --target=riscv32-unknown-none-elf
 // CHECK-RV32: -mabi=ilp32d



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


[clang] [Driver] Add -mbranch-protection to ARM and AArch64 multilib flags (PR #106391)

2024-08-29 Thread Lucas Duarte Prates via cfe-commits

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


[clang] [C++20] [Modules] Embed all source files for C++20 Modules (PR #102444)

2024-08-29 Thread via cfe-commits

cor3ntin wrote:

What this discussed/reviewed/motivated?

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


[clang] [C++20] [Modules] Embed all source files for C++20 Modules (PR #102444)

2024-08-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-hip-vega20` running 
on `hip-vega20-0` while building `clang` at step 3 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/123/builds/4498


Here is the relevant piece of the build log for the reference

```
Step 3 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure)
...
[38/40] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 
-DNDEBUG  External/HIP/CMakeFiles/memmove-hip-6.0.2.dir/memmove.hip.o -o 
External/HIP/memmove-hip-6.0.2  --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 
--hip-link -rtlib=compiler-rt -unwindlib=libgcc -frtlib-add-rpath && cd 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && 
/usr/local/bin/cmake -E create_symlink 
/buildbot/llvm-test-suite/External/HIP/memmove.reference_output 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/memmove.reference_output-hip-6.0.2
[39/40] /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -DNDEBUG  -O3 
-DNDEBUG   -w -Werror=date-time --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 
--offload-arch=gfx908 --offload-arch=gfx90a --offload-arch=gfx1030 
--offload-arch=gfx1100 -xhip -mfma -MD -MT 
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o
 -MF 
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o.d
 -o 
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o
 -c 
/buildbot/llvm-test-suite/External/HIP/workload/ray-tracing/TheNextWeek/main.cc
[40/40] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 
-DNDEBUG  
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o
 -o External/HIP/TheNextWeek-hip-6.0.2  
--rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt 
-unwindlib=libgcc -frtlib-add-rpath && cd 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && 
/usr/local/bin/cmake -E create_symlink 
/buildbot/llvm-test-suite/External/HIP/TheNextWeek.reference_output 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/TheNextWeek.reference_output-hip-6.0.2
+ build_step 'Testing HIP test-suite'
+ echo '@@@BUILD_STEP Testing HIP test-suite@@@'
@@@BUILD_STEP Testing HIP test-suite@@@
+ ninja -v check-hip-simple
[0/1] cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP 
&& /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv 
empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test 
memmove-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test 
blender.test
-- Testing: 7 tests, 7 workers --
Testing:  0.. 10.. 20.. 30.. 40
FAIL: test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test (4 of 7)
 TEST 'test-suite :: 
External/HIP/InOneWeekend-hip-6.0.2.test' FAILED 

/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/timeit-target 
--timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 
--limit-rss-size 838860800 --append-exitstatus --redirect-output 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out
 --redirect-input /dev/null --summary 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.time
 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend-hip-6.0.2
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP ; 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out
 InOneWeekend.reference_output-hip-6.0.2

+ cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP
+ /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out
 InOneWeekend.reference_output-hip-6.0.2
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target: 
Comparison failed, textual difference between 'M' and 'i'


/usr/bin/strip: /bin/bash.stripped: Bad file descriptor
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

Failed Tests (1):
  test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test


Testing Time: 378.40s

Total Discovered Tests: 7
  Passed: 6 (85.71%)
  Failed: 1 (14.29%)
FAILED: External/HIP/CMakeFiles/check-hip-simple-hip-6.0.2 
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && 
/buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv 
empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test 
memmove-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.

[clang] [C++20] [Modules] Embed all source files for C++20 Modules (PR #102444)

2024-08-29 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> Was this discussed/reviewed/motivated? There are drawbacks to this approach 
> outlined in #72383
> 
> @iains @jyknight @AaronBallman @Bigcheese

The motivation is in https://github.com/llvm/llvm-project/issues/72383 and I 
comment in 
https://github.com/llvm/llvm-project/issues/72383#issuecomment-2275135890

This is not reviewed. I wait for several weeks but got no response. And I think 
it is good. So I choose to land it.

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,565 @@
+/*===--- avx10_2_512bf16intrin.h - AVX10-BF16 intrinsics -===
+ *
+ * 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 __IMMINTRIN_H
+#error 
\
+"Never use  directly; include  
instead."
+#endif
+
+#ifdef __SSE2__
+
+#ifndef __AVX10_2_512BF16INTRIN_H
+#define __AVX10_2_512BF16INTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+typedef __bf16 __m512bh_u __attribute__((__vector_size__(64), __aligned__(1)));
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS512  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-512"),
\
+ __min_vector_width__(512)))
+
+static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_setzero_pbh(void) {
+  return __builtin_bit_cast(__m512bh, _mm512_setzero_ps());
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_undefined_pbh(void) {
+  return (__m512bh)__builtin_ia32_undef512();
+}
+
+static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_set1_pbh(__bf16 bf) {
+  return (__m512bh)(__v32bf){bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, bf,
+ bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, bf,
+ bf, bf, bf, bf, bf, bf, bf, bf, bf, bf};
+}
+
+static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_set_pbh(
+__bf16 bf1, __bf16 bf2, __bf16 bf3, __bf16 bf4, __bf16 bf5, __bf16 bf6,
+__bf16 bf7, __bf16 bf8, __bf16 bf9, __bf16 bf10, __bf16 bf11, __bf16 bf12,
+__bf16 bf13, __bf16 bf14, __bf16 bf15, __bf16 bf16, __bf16 bf17,
+__bf16 bf18, __bf16 bf19, __bf16 bf20, __bf16 bf21, __bf16 bf22,
+__bf16 bf23, __bf16 bf24, __bf16 bf25, __bf16 bf26, __bf16 bf27,
+__bf16 bf28, __bf16 bf29, __bf16 bf30, __bf16 bf31, __bf16 bf32) {
+  return (__m512bh)(__v32bf){bf32, bf31, bf30, bf29, bf28, bf27, bf26, bf25,
+ bf24, bf23, bf22, bf21, bf20, bf19, bf18, bf17,
+ bf16, bf15, bf14, bf13, bf12, bf11, bf10, bf9,
+ bf8,  bf7,  bf6,  bf5,  bf4,  bf3,  bf2,  bf1};
+}
+
+#define _mm512_setr_pbh(bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8, bf9, bf10, 
\
+bf11, bf12, bf13, bf14, bf15, bf16, bf17, bf18, bf19,  
\
+bf20, bf21, bf22, bf23, bf24, bf25, bf26, bf27, bf28,  
\
+bf29, bf30, bf31, bf32)
\
+  _mm512_set_pbh((bf32), (bf31), (bf30), (bf29), (bf28), (bf27), (bf26),   
\
+ (bf25), (bf24), (bf23), (bf22), (bf21), (bf20), (bf19),   
\
+ (bf18), (bf17), (bf16), (bf15), (bf14), (bf13), (bf12),   
\
+ (bf11), (bf10), (bf9), (bf8), (bf7), (bf6), (bf5), (bf4), 
\
+ (bf3), (bf2), (bf1))
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS512
+_mm512_castpbf16_ps(__m512bh __a) {
+  return (__m512)__a;
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS512
+_mm512_castpbf16_pd(__m512bh __a) {
+  return (__m512d)__a;
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS512
+_mm512_castpbf16_si512(__m512bh __a) {
+  return (__m512i)__a;
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_castps_pbh(__m512 __a) 
{
+  return (__m512bh)__a;
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castpd_pbh(__m512d __a) {
+  return (__m512bh)__a;
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castsi512_pbh(__m512i __a) {
+  return (__m512bh)__a;
+}
+
+static __inline__ __m128bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16512_pbh128(__m512bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7);
+}
+
+static __inline__ __m256bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16512_pbh256(__m512bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11,
+ 12, 13, 14, 15);
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16128_pbh512(__m128bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
-1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16256_pbh512(__m256bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11,
+ 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, 
-1,
+ -1, -1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512bh __DEFAULT_FN_AT

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,1054 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64 -target-feature +avx10.2-512 -emit-llvm -o - 
-Wno-invalid-feature-combination -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386 -target-feature +avx10.2-512 -emit-llvm -o - 
-Wno-invalid-feature-combination -Wall -Werror | FileCheck %s
+
+#include 
+
+__m512bh test_mm512_setzero_pbh() {
+  // CHECK-LABEL: @test_mm512_setzero_pbh
+  // CHECK: zeroinitializer
+  return _mm512_setzero_pbh();
+}
+
+__m512bh test_mm512_undefined_pbh(void) {
+  // CHECK-LABEL: @test_mm512_undefined_pbh
+  // CHECK: ret <32 x bfloat> zeroinitializer
+  return _mm512_undefined_pbh();
+}
+
+__m512bh test_mm512_set1_pbh(__bf16 h) {
+  // CHECK-LABEL: @test_mm512_set1_pbh
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 0
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 1
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 2
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 3
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 4
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 5
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 6
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 7
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 8
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 9
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 10
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 11
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 12
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 13
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 14
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 15
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 16
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 17
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 18
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 19
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 20
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 21
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 22
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 23
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 24
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 25
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 26
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 27
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 28
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 29
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 30
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 31
+  return _mm512_set1_pbh(h);
+}
+
+__m512bh test_mm512_set_pbh(__bf16 bf1, __bf16 bf2, __bf16 bf3, __bf16 bf4,
+  __bf16 bf5, __bf16 bf6, __bf16 bf7, __bf16 bf8,
+  __bf16 bf9, __bf16 bf10, __bf16 bf11, __bf16 bf12,
+  __bf16 bf13, __bf16 bf14, __bf16 bf15, __bf16 bf16,
+  __bf16 bf17, __bf16 bf18, __bf16 bf19, __bf16 bf20,
+  __bf16 bf21, __bf16 bf22, __bf16 bf23, __bf16 bf24,
+  __bf16 bf25, __bf16 bf26, __bf16 bf27, __bf16 bf28,
+  __bf16 bf29, __bf16 bf30, __bf16 bf31, __bf16 bf32) {
+  // CHECK-LABEL: @test_mm512_set_pbh
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 0
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 1
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 2
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 3
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 4
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 5
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 6
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 7
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 8
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 9
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 10
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 11
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 12
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 13
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 14
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 15
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 16
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 17
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 18
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 19
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 20
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 21
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 22
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 23
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 24
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 25
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 26
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 27
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 28
+  // CHECK: insertelement <32 x bfloat> {{.*}}, i32 29
+  // CHEC

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -7219,3 +7219,413 @@ def int_x86_avx10_mask_vcvtneph2hf8s512 : 
ClangBuiltin<"__builtin_ia32_vcvtneph2
 DefaultAttrsIntrinsic<[llvm_v32i8_ty], [llvm_v32f16_ty, llvm_v32i8_ty, 
llvm_i32_ty],
   [IntrNoMem]>;
 }
+
+//===--===//
+let TargetPrefix = "x86" in {
+  def int_x86_avx10_vaddnepbf16512
+  : ClangBuiltin<"__builtin_ia32_vaddnepbf16512">,
+DefaultAttrsIntrinsic<[ llvm_v32bf16_ty ],
+  [ llvm_v32bf16_ty, llvm_v32bf16_ty ],
+  [ IntrNoMem ]>;

FreddyLeaf wrote:

[7957436](https://github.com/llvm/llvm-project/pull/101603/commits/7957436ac07d1902f3f510de756577c00353dd02)

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,565 @@
+/*===--- avx10_2_512bf16intrin.h - AVX10-BF16 intrinsics -===
+ *
+ * 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 __IMMINTRIN_H
+#error 
\
+"Never use  directly; include  
instead."
+#endif
+
+#ifdef __SSE2__
+
+#ifndef __AVX10_2_512BF16INTRIN_H
+#define __AVX10_2_512BF16INTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+typedef __bf16 __m512bh_u __attribute__((__vector_size__(64), __aligned__(1)));
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS512  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-512"),
\
+ __min_vector_width__(512)))
+
+static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_setzero_pbh(void) {
+  return __builtin_bit_cast(__m512bh, _mm512_setzero_ps());
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_undefined_pbh(void) {
+  return (__m512bh)__builtin_ia32_undef512();
+}
+
+static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_set1_pbh(__bf16 bf) {
+  return (__m512bh)(__v32bf){bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, bf,
+ bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, bf,
+ bf, bf, bf, bf, bf, bf, bf, bf, bf, bf};
+}
+
+static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_set_pbh(
+__bf16 bf1, __bf16 bf2, __bf16 bf3, __bf16 bf4, __bf16 bf5, __bf16 bf6,
+__bf16 bf7, __bf16 bf8, __bf16 bf9, __bf16 bf10, __bf16 bf11, __bf16 bf12,
+__bf16 bf13, __bf16 bf14, __bf16 bf15, __bf16 bf16, __bf16 bf17,
+__bf16 bf18, __bf16 bf19, __bf16 bf20, __bf16 bf21, __bf16 bf22,
+__bf16 bf23, __bf16 bf24, __bf16 bf25, __bf16 bf26, __bf16 bf27,
+__bf16 bf28, __bf16 bf29, __bf16 bf30, __bf16 bf31, __bf16 bf32) {
+  return (__m512bh)(__v32bf){bf32, bf31, bf30, bf29, bf28, bf27, bf26, bf25,
+ bf24, bf23, bf22, bf21, bf20, bf19, bf18, bf17,
+ bf16, bf15, bf14, bf13, bf12, bf11, bf10, bf9,
+ bf8,  bf7,  bf6,  bf5,  bf4,  bf3,  bf2,  bf1};
+}
+
+#define _mm512_setr_pbh(bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8, bf9, bf10, 
\
+bf11, bf12, bf13, bf14, bf15, bf16, bf17, bf18, bf19,  
\
+bf20, bf21, bf22, bf23, bf24, bf25, bf26, bf27, bf28,  
\
+bf29, bf30, bf31, bf32)
\
+  _mm512_set_pbh((bf32), (bf31), (bf30), (bf29), (bf28), (bf27), (bf26),   
\
+ (bf25), (bf24), (bf23), (bf22), (bf21), (bf20), (bf19),   
\
+ (bf18), (bf17), (bf16), (bf15), (bf14), (bf13), (bf12),   
\
+ (bf11), (bf10), (bf9), (bf8), (bf7), (bf6), (bf5), (bf4), 
\
+ (bf3), (bf2), (bf1))
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS512
+_mm512_castpbf16_ps(__m512bh __a) {
+  return (__m512)__a;
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS512
+_mm512_castpbf16_pd(__m512bh __a) {
+  return (__m512d)__a;
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS512
+_mm512_castpbf16_si512(__m512bh __a) {
+  return (__m512i)__a;
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_castps_pbh(__m512 __a) 
{
+  return (__m512bh)__a;
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castpd_pbh(__m512d __a) {
+  return (__m512bh)__a;
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castsi512_pbh(__m512i __a) {
+  return (__m512bh)__a;
+}
+
+static __inline__ __m128bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16512_pbh128(__m512bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7);
+}
+
+static __inline__ __m256bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16512_pbh256(__m512bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11,
+ 12, 13, 14, 15);
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16128_pbh512(__m128bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
-1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_castpbf16256_pbh512(__m256bh __a) {
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11,
+ 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, 
-1,
+ -1, -1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512bh __DEFAULT_FN_AT

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+v32bf16_info, sched.PH.ZMM, IsCommutable>, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm PBF16Z128 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+v8bf16x_info, sched.PH.XMM, IsCommutable>, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm PBF16Z256 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+v16bf16x_info, sched.PH.YMM, IsCommutable>, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+multiclass avx10_fp_binop_pbf16 opc, string OpcodeStr, 
SDPatternOperator OpNode,
+  X86SchedWriteSizes sched,
+  bit IsCommutable = 0,
+  SDPatternOperator MaskOpNode = OpNode> {
+  let Predicates = [HasAVX10_2_512] in
+defm NEPBF16Z : avx512_fp_packed, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm NEPBF16Z128 : avx512_fp_packed, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm NEPBF16Z256 : avx512_fp_packed, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+let Uses = [], mayRaiseFPException = 0 in {
+defm VADD : avx10_fp_binop_pbf16<0x58, "vaddne", fadd, SchedWriteFAddSizes, 1>;
+defm VSUB : avx10_fp_binop_pbf16<0x5C, "vsubne", fsub, SchedWriteFAddSizes, 0>;
+defm VMUL : avx10_fp_binop_pbf16<0x59, "vmulne", fmul, SchedWriteFMulSizes, 0>;
+defm VDIV : avx10_fp_binop_pbf16<0x5E, "vdivne", fdiv, SchedWriteFDivSizes, 0>;
+defm VMIN : avx10_fp_binopne_int_pbf16<0x5D, "vmin", SchedWriteFCmpSizes, 0>;
+defm VMAX : avx10_fp_binopne_int_pbf16<0x5F, "vmax", SchedWriteFCmpSizes, 0>;
+}
+
+// VCOMSBF16
+let Uses = [], mayRaiseFPException = 0,
+  Defs = [EFLAGS], Predicates = [HasAVX10_2_512] in {
+  defm VCOMSBF16Z : sse12_ord_cmp<0x2F, FR16X, null_frag, bf16, f16mem, 
loadf16,
+  "comsbf16", SSEPackedSingle>, T_MAP5, PD, EVEX,
+  VEX_LIG, EVEX_CD8<16, CD8VT1>;
+
+  let isCodeGenOnly = 1 in {
+defm VCOMSBF16Z : sse12_ord_cmp_int<0x2F, VR128X, X86comi, v8bf16, f16mem,
+sse_load_bf16, "comsbf16", SSEPackedSingle>,
+T_MAP5, PD, EVEX, VEX_LIG, EVEX_CD8<16, CD8VT1>;
+  }
+}
+
+// VCMPPBF16
+multiclass avx10_vcmp_common_bf16 {
+  let mayRaiseFPException = 0 in {
+  defm  rri  : AVX512_maskable_cmp<0xC2, MRMSrcReg, _,
+   (outs _.KRC:$dst), (ins _.RC:$src1, _.RC:$src2, u8imm:$cc),
+   "vcmp"#_.Suffix,
+   "$cc, $src2, $src1", "$src1, $src2, $cc",
+   (X86cmpm (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   (X86cmpm_su (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   1>, Sched<[sched]>;
+
+  defm  rmi  : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),(ins _.RC:$src1, _.MemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, $src2, $src1", "$src1, $src2, $cc",
+(X86cmpm (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+timm:$cc)>,
+Sched<[sched.Folded, sched.ReadAfterFold]>;
+
+  defm  rmbi : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),
+(ins _.RC:$src1, _.ScalarMemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, ${src2}"#_.BroadcastStr#", $src1",
+"$src1, ${src2}"#_.BroadcastStr#", $cc",
+(X86cmpm (_.VT _.RC:$src1),
+ (_.VT (_.BroadcastLdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1),
+(_.VT (_.BroadcastLdFrag addr:$sr

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+v32bf16_info, sched.PH.ZMM, IsCommutable>, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm PBF16Z128 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+v8bf16x_info, sched.PH.XMM, IsCommutable>, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm PBF16Z256 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+v16bf16x_info, sched.PH.YMM, IsCommutable>, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+multiclass avx10_fp_binop_pbf16 opc, string OpcodeStr, 
SDPatternOperator OpNode,
+  X86SchedWriteSizes sched,
+  bit IsCommutable = 0,
+  SDPatternOperator MaskOpNode = OpNode> {
+  let Predicates = [HasAVX10_2_512] in
+defm NEPBF16Z : avx512_fp_packed, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm NEPBF16Z128 : avx512_fp_packed, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm NEPBF16Z256 : avx512_fp_packed, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+let Uses = [], mayRaiseFPException = 0 in {
+defm VADD : avx10_fp_binop_pbf16<0x58, "vaddne", fadd, SchedWriteFAddSizes, 1>;
+defm VSUB : avx10_fp_binop_pbf16<0x5C, "vsubne", fsub, SchedWriteFAddSizes, 0>;
+defm VMUL : avx10_fp_binop_pbf16<0x59, "vmulne", fmul, SchedWriteFMulSizes, 0>;
+defm VDIV : avx10_fp_binop_pbf16<0x5E, "vdivne", fdiv, SchedWriteFDivSizes, 0>;
+defm VMIN : avx10_fp_binopne_int_pbf16<0x5D, "vmin", SchedWriteFCmpSizes, 0>;
+defm VMAX : avx10_fp_binopne_int_pbf16<0x5F, "vmax", SchedWriteFCmpSizes, 0>;
+}
+
+// VCOMSBF16
+let Uses = [], mayRaiseFPException = 0,
+  Defs = [EFLAGS], Predicates = [HasAVX10_2_512] in {
+  defm VCOMSBF16Z : sse12_ord_cmp<0x2F, FR16X, null_frag, bf16, f16mem, 
loadf16,
+  "comsbf16", SSEPackedSingle>, T_MAP5, PD, EVEX,
+  VEX_LIG, EVEX_CD8<16, CD8VT1>;
+
+  let isCodeGenOnly = 1 in {
+defm VCOMSBF16Z : sse12_ord_cmp_int<0x2F, VR128X, X86comi, v8bf16, f16mem,
+sse_load_bf16, "comsbf16", SSEPackedSingle>,
+T_MAP5, PD, EVEX, VEX_LIG, EVEX_CD8<16, CD8VT1>;
+  }
+}
+
+// VCMPPBF16
+multiclass avx10_vcmp_common_bf16 {
+  let mayRaiseFPException = 0 in {
+  defm  rri  : AVX512_maskable_cmp<0xC2, MRMSrcReg, _,
+   (outs _.KRC:$dst), (ins _.RC:$src1, _.RC:$src2, u8imm:$cc),
+   "vcmp"#_.Suffix,
+   "$cc, $src2, $src1", "$src1, $src2, $cc",
+   (X86cmpm (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   (X86cmpm_su (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   1>, Sched<[sched]>;
+
+  defm  rmi  : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),(ins _.RC:$src1, _.MemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, $src2, $src1", "$src1, $src2, $cc",
+(X86cmpm (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+timm:$cc)>,
+Sched<[sched.Folded, sched.ReadAfterFold]>;
+
+  defm  rmbi : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),
+(ins _.RC:$src1, _.ScalarMemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, ${src2}"#_.BroadcastStr#", $src1",
+"$src1, ${src2}"#_.BroadcastStr#", $cc",
+(X86cmpm (_.VT _.RC:$src1),
+ (_.VT (_.BroadcastLdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1),
+(_.VT (_.BroadcastLdFrag addr:$sr

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {

FreddyLeaf wrote:

[7957436](https://github.com/llvm/llvm-project/pull/101603/commits/7957436ac07d1902f3f510de756577c00353dd02)

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packedhttps://github.com/llvm/llvm-project/pull/101603/commits/7957436ac07d1902f3f510de756577c00353dd02)

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+v32bf16_info, sched.PH.ZMM, IsCommutable>, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm PBF16Z128 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+v8bf16x_info, sched.PH.XMM, IsCommutable>, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm PBF16Z256 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+v16bf16x_info, sched.PH.YMM, IsCommutable>, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+multiclass avx10_fp_binop_pbf16 opc, string OpcodeStr, 
SDPatternOperator OpNode,
+  X86SchedWriteSizes sched,
+  bit IsCommutable = 0,
+  SDPatternOperator MaskOpNode = OpNode> {
+  let Predicates = [HasAVX10_2_512] in
+defm NEPBF16Z : avx512_fp_packed, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm NEPBF16Z128 : avx512_fp_packed, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm NEPBF16Z256 : avx512_fp_packed, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+let Uses = [], mayRaiseFPException = 0 in {
+defm VADD : avx10_fp_binop_pbf16<0x58, "vaddne", fadd, SchedWriteFAddSizes, 1>;
+defm VSUB : avx10_fp_binop_pbf16<0x5C, "vsubne", fsub, SchedWriteFAddSizes, 0>;
+defm VMUL : avx10_fp_binop_pbf16<0x59, "vmulne", fmul, SchedWriteFMulSizes, 0>;
+defm VDIV : avx10_fp_binop_pbf16<0x5E, "vdivne", fdiv, SchedWriteFDivSizes, 0>;
+defm VMIN : avx10_fp_binopne_int_pbf16<0x5D, "vmin", SchedWriteFCmpSizes, 0>;
+defm VMAX : avx10_fp_binopne_int_pbf16<0x5F, "vmax", SchedWriteFCmpSizes, 0>;
+}
+
+// VCOMSBF16
+let Uses = [], mayRaiseFPException = 0,
+  Defs = [EFLAGS], Predicates = [HasAVX10_2_512] in {
+  defm VCOMSBF16Z : sse12_ord_cmp<0x2F, FR16X, null_frag, bf16, f16mem, 
loadf16,
+  "comsbf16", SSEPackedSingle>, T_MAP5, PD, EVEX,
+  VEX_LIG, EVEX_CD8<16, CD8VT1>;
+
+  let isCodeGenOnly = 1 in {
+defm VCOMSBF16Z : sse12_ord_cmp_int<0x2F, VR128X, X86comi, v8bf16, f16mem,
+sse_load_bf16, "comsbf16", SSEPackedSingle>,
+T_MAP5, PD, EVEX, VEX_LIG, EVEX_CD8<16, CD8VT1>;
+  }
+}
+
+// VCMPPBF16
+multiclass avx10_vcmp_common_bf16 {
+  let mayRaiseFPException = 0 in {
+  defm  rri  : AVX512_maskable_cmp<0xC2, MRMSrcReg, _,
+   (outs _.KRC:$dst), (ins _.RC:$src1, _.RC:$src2, u8imm:$cc),
+   "vcmp"#_.Suffix,
+   "$cc, $src2, $src1", "$src1, $src2, $cc",
+   (X86cmpm (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   (X86cmpm_su (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   1>, Sched<[sched]>;
+
+  defm  rmi  : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),(ins _.RC:$src1, _.MemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, $src2, $src1", "$src1, $src2, $cc",
+(X86cmpm (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+timm:$cc)>,
+Sched<[sched.Folded, sched.ReadAfterFold]>;
+
+  defm  rmbi : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),
+(ins _.RC:$src1, _.ScalarMemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, ${src2}"#_.BroadcastStr#", $src1",
+"$src1, ${src2}"#_.BroadcastStr#", $cc",
+(X86cmpm (_.VT _.RC:$src1),
+ (_.VT (_.BroadcastLdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1),
+(_.VT (_.BroadcastLdFrag addr:$sr

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+v32bf16_info, sched.PH.ZMM, IsCommutable>, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm PBF16Z128 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+v8bf16x_info, sched.PH.XMM, IsCommutable>, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm PBF16Z256 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+v16bf16x_info, sched.PH.YMM, IsCommutable>, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+multiclass avx10_fp_binop_pbf16 opc, string OpcodeStr, 
SDPatternOperator OpNode,
+  X86SchedWriteSizes sched,
+  bit IsCommutable = 0,
+  SDPatternOperator MaskOpNode = OpNode> {
+  let Predicates = [HasAVX10_2_512] in
+defm NEPBF16Z : avx512_fp_packed, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm NEPBF16Z128 : avx512_fp_packed, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm NEPBF16Z256 : avx512_fp_packed, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+let Uses = [], mayRaiseFPException = 0 in {
+defm VADD : avx10_fp_binop_pbf16<0x58, "vaddne", fadd, SchedWriteFAddSizes, 1>;
+defm VSUB : avx10_fp_binop_pbf16<0x5C, "vsubne", fsub, SchedWriteFAddSizes, 0>;
+defm VMUL : avx10_fp_binop_pbf16<0x59, "vmulne", fmul, SchedWriteFMulSizes, 0>;
+defm VDIV : avx10_fp_binop_pbf16<0x5E, "vdivne", fdiv, SchedWriteFDivSizes, 0>;
+defm VMIN : avx10_fp_binopne_int_pbf16<0x5D, "vmin", SchedWriteFCmpSizes, 0>;
+defm VMAX : avx10_fp_binopne_int_pbf16<0x5F, "vmax", SchedWriteFCmpSizes, 0>;
+}
+
+// VCOMSBF16
+let Uses = [], mayRaiseFPException = 0,
+  Defs = [EFLAGS], Predicates = [HasAVX10_2_512] in {
+  defm VCOMSBF16Z : sse12_ord_cmp<0x2F, FR16X, null_frag, bf16, f16mem, 
loadf16,

FreddyLeaf wrote:

Added a todo 
[7957436](https://github.com/llvm/llvm-project/pull/101603/commits/7957436ac07d1902f3f510de756577c00353dd02)

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+v32bf16_info, sched.PH.ZMM, IsCommutable>, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm PBF16Z128 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+v8bf16x_info, sched.PH.XMM, IsCommutable>, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm PBF16Z256 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+v16bf16x_info, sched.PH.YMM, IsCommutable>, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+multiclass avx10_fp_binop_pbf16 opc, string OpcodeStr, 
SDPatternOperator OpNode,
+  X86SchedWriteSizes sched,
+  bit IsCommutable = 0,
+  SDPatternOperator MaskOpNode = OpNode> {
+  let Predicates = [HasAVX10_2_512] in
+defm NEPBF16Z : avx512_fp_packed, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm NEPBF16Z128 : avx512_fp_packed, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm NEPBF16Z256 : avx512_fp_packed, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+let Uses = [], mayRaiseFPException = 0 in {
+defm VADD : avx10_fp_binop_pbf16<0x58, "vaddne", fadd, SchedWriteFAddSizes, 1>;
+defm VSUB : avx10_fp_binop_pbf16<0x5C, "vsubne", fsub, SchedWriteFAddSizes, 0>;
+defm VMUL : avx10_fp_binop_pbf16<0x59, "vmulne", fmul, SchedWriteFMulSizes, 0>;

FreddyLeaf wrote:

[7957436](https://github.com/llvm/llvm-project/pull/101603/commits/7957436ac07d1902f3f510de756577c00353dd02)

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -147,11 +147,13 @@ set(x86_files
   amxcomplexintrin.h
   amxfp16intrin.h
   amxintrin.h
+  avx10_2_512bf16intrin.h
   avx10_2_512convertintrin.h
   avx10_2_512minmaxintrin.h
   avx10_2_512niintrin.h
   avx10_2_512satcvtintrin.h
   avx10_2convertintrin.h
+  avx10_2bf16intrin.h

FreddyLeaf wrote:

[7957436](https://github.com/llvm/llvm-project/pull/101603/commits/7957436ac07d1902f3f510de756577c00353dd02)

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


[clang] `__noop` not marked as constexpr #102064 (PR #105983)

2024-08-29 Thread Timm Baeder via cfe-commits

tbaederr wrote:

You have to resolve the conflict in `ReleaseNotes.rst` firsrt

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


[clang] [CodeGen] Apply 'readonly' to 'this' pointer argument. (PR #106499)

2024-08-29 Thread Nikita Popov via cfe-commits

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

I'm very confused. `readonly` means that the memory behind `this` cannot be 
changed, not that the pointer cannot be changed.

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


[clang] [CodeGen] Apply 'readonly' to 'this' pointer argument. (PR #106499)

2024-08-29 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> I'm very confused. `readonly` means that the memory behind `this` cannot be 
> changed, not that the pointer cannot be changed.

Out of curiosity, it looks not same in https://llvm.org/docs/LangRef.html:

> This attribute indicates that the function does not write through this 
> pointer argument, even though it may write to the memory that the pointer 
> points to.
>
> If a function writes to a readonly pointer argument, the behavior is 
> undefined.

My understanding for ` it may write to the memory that the pointer points to.` 
is what you said. Or do we need to update the document?

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)

2024-08-29 Thread Freddy Ye via cfe-commits


@@ -910,3 +910,313 @@ multiclass avx10_convert_2op_nomb,
   AVX512XDIi8Base, T_MAP5, EVEX, EVEX_CD8<16, CD8VH>;
+
+//-
+// AVX10 BF16 instructions
+//-
+
+// VADDNEPBF16, VSUBNEPBF16, VMULNEPBF16, VDIVNEPBF16, VMAXPBF16, VMINPBF16
+multiclass avx10_fp_binopne_int_pbf16 opc, string OpcodeStr,
+   X86SchedWriteSizes sched,
+   bit IsCommutable = 0> {
+  let Predicates = [HasAVX10_2_512] in
+defm PBF16Z : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16512"),
+v32bf16_info, sched.PH.ZMM, IsCommutable>, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm PBF16Z128 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16128"),
+v8bf16x_info, sched.PH.XMM, IsCommutable>, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm PBF16Z256 : avx512_fp_packed("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+
!cast("int_x86_avx10_"#OpcodeStr#"pbf16256"),
+v16bf16x_info, sched.PH.YMM, IsCommutable>, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+multiclass avx10_fp_binop_pbf16 opc, string OpcodeStr, 
SDPatternOperator OpNode,
+  X86SchedWriteSizes sched,
+  bit IsCommutable = 0,
+  SDPatternOperator MaskOpNode = OpNode> {
+  let Predicates = [HasAVX10_2_512] in
+defm NEPBF16Z : avx512_fp_packed, 
EVEX_V512,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  let Predicates = [HasAVX10_2] in {
+defm NEPBF16Z128 : avx512_fp_packed, 
EVEX_V128,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+defm NEPBF16Z256 : avx512_fp_packed, 
EVEX_V256,
+T_MAP5, PD, EVEX_CD8<16, CD8VF>;
+  }
+}
+
+let Uses = [], mayRaiseFPException = 0 in {
+defm VADD : avx10_fp_binop_pbf16<0x58, "vaddne", fadd, SchedWriteFAddSizes, 1>;
+defm VSUB : avx10_fp_binop_pbf16<0x5C, "vsubne", fsub, SchedWriteFAddSizes, 0>;
+defm VMUL : avx10_fp_binop_pbf16<0x59, "vmulne", fmul, SchedWriteFMulSizes, 0>;
+defm VDIV : avx10_fp_binop_pbf16<0x5E, "vdivne", fdiv, SchedWriteFDivSizes, 0>;
+defm VMIN : avx10_fp_binopne_int_pbf16<0x5D, "vmin", SchedWriteFCmpSizes, 0>;
+defm VMAX : avx10_fp_binopne_int_pbf16<0x5F, "vmax", SchedWriteFCmpSizes, 0>;
+}
+
+// VCOMSBF16
+let Uses = [], mayRaiseFPException = 0,
+  Defs = [EFLAGS], Predicates = [HasAVX10_2_512] in {
+  defm VCOMSBF16Z : sse12_ord_cmp<0x2F, FR16X, null_frag, bf16, f16mem, 
loadf16,
+  "comsbf16", SSEPackedSingle>, T_MAP5, PD, EVEX,
+  VEX_LIG, EVEX_CD8<16, CD8VT1>;
+
+  let isCodeGenOnly = 1 in {
+defm VCOMSBF16Z : sse12_ord_cmp_int<0x2F, VR128X, X86comi, v8bf16, f16mem,
+sse_load_bf16, "comsbf16", SSEPackedSingle>,
+T_MAP5, PD, EVEX, VEX_LIG, EVEX_CD8<16, CD8VT1>;
+  }
+}
+
+// VCMPPBF16
+multiclass avx10_vcmp_common_bf16 {
+  let mayRaiseFPException = 0 in {
+  defm  rri  : AVX512_maskable_cmp<0xC2, MRMSrcReg, _,
+   (outs _.KRC:$dst), (ins _.RC:$src1, _.RC:$src2, u8imm:$cc),
+   "vcmp"#_.Suffix,
+   "$cc, $src2, $src1", "$src1, $src2, $cc",
+   (X86cmpm (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   (X86cmpm_su (_.VT _.RC:$src1), (_.VT _.RC:$src2), timm:$cc),
+   1>, Sched<[sched]>;
+
+  defm  rmi  : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),(ins _.RC:$src1, _.MemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, $src2, $src1", "$src1, $src2, $cc",
+(X86cmpm (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1), (_.VT (_.LdFrag addr:$src2)),
+timm:$cc)>,
+Sched<[sched.Folded, sched.ReadAfterFold]>;
+
+  defm  rmbi : AVX512_maskable_cmp<0xC2, MRMSrcMem, _,
+(outs _.KRC:$dst),
+(ins _.RC:$src1, _.ScalarMemOp:$src2, u8imm:$cc),
+"vcmp"#_.Suffix,
+"$cc, ${src2}"#_.BroadcastStr#", $src1",
+"$src1, ${src2}"#_.BroadcastStr#", $cc",
+(X86cmpm (_.VT _.RC:$src1),
+ (_.VT (_.BroadcastLdFrag addr:$src2)),
+ timm:$cc),
+(X86cmpm_su (_.VT _.RC:$src1),
+(_.VT (_.BroadcastLdFrag addr:$sr

[clang] [llvm] [ValueTracking] use KnownBits to compute fpclass from bitcast (PR #97762)

2024-08-29 Thread Matt Arsenault via cfe-commits

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


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


[clang] b9f4afa - [clang][ExtractAPI] Fix iteration order of TopLevelRecords (#106411)

2024-08-29 Thread via cfe-commits

Author: Daniel Grumberg
Date: 2024-08-29T10:02:01+01:00
New Revision: b9f4afa1674fe6f101b298d4893cde2ab2d16877

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

LOG: [clang][ExtractAPI] Fix iteration order of TopLevelRecords (#106411)

Fixes #106355

Added: 


Modified: 
clang/include/clang/ExtractAPI/API.h
clang/lib/ExtractAPI/API.cpp

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 188e35b72117b5..4f34fcc575e807 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -23,7 +23,7 @@
 #include "clang/AST/RawCommentList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
-#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/TargetParser/Triple.h"
@@ -1420,9 +1420,8 @@ class APISet {
   typename std::enable_if_t, RecordTy> *
   createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
 
-  auto getTopLevelRecords() const {
-return llvm::iterator_range(
-TopLevelRecords);
+  ArrayRef getTopLevelRecords() const {
+return TopLevelRecords;
   }
 
   void removeRecord(StringRef USR);
@@ -1455,7 +1454,7 @@ class APISet {
   // lives in the BumpPtrAllocator.
   using APIRecordStoredPtr = std::unique_ptr;
   llvm::DenseMap USRBasedLookupTable;
-  llvm::SmallPtrSet TopLevelRecords;
+  llvm::SmallVector TopLevelRecords;
 
 public:
   const std::string ProductName;
@@ -1481,7 +1480,7 @@ APISet::createRecord(StringRef USR, StringRef Name,
 dyn_cast_if_present(Record->Parent.Record))
   ParentContext->addToRecordChain(Record);
 else
-  TopLevelRecords.insert(Record);
+  TopLevelRecords.push_back(Record);
   } else {
 Record = dyn_cast(Result.first->second.get());
   }

diff  --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 9dbc023885c37f..a6ca0ae8d0d51d 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -150,11 +150,13 @@ void APISet::removeRecord(StringRef USR) {
   if (auto *RecordAsCtx = llvm::dyn_cast(Record))
 ParentCtx->stealRecordChain(*RecordAsCtx);
 } else {
-  TopLevelRecords.erase(Record);
+  auto *It = llvm::find(TopLevelRecords, Record);
+  if (It != TopLevelRecords.end())
+TopLevelRecords.erase(It);
   if (auto *RecordAsCtx = llvm::dyn_cast(Record)) {
 for (const auto *Child = RecordAsCtx->First; Child != nullptr;
  Child = Child->getNextInContext())
-  TopLevelRecords.insert(Child);
+  TopLevelRecords.push_back(Child);
   }
 }
 USRBasedLookupTable.erase(Result);



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


[clang] [clang][ExtractAPI] Fix iteration order of TopLevelRecords (PR #106411)

2024-08-29 Thread Daniel Grumberg via cfe-commits

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


[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-29 Thread via cfe-commits

https://github.com/kiran-isaac updated 
https://github.com/llvm/llvm-project/pull/102896

>From eb7551e83618d8452f5dadae1be4aff8f6c9d23c Mon Sep 17 00:00:00 2001
From: Kiran 
Date: Thu, 8 Aug 2024 13:07:24 +0100
Subject: [PATCH 1/4] [ARM] musttail fixes

Backend:
- Caller and callee arguments no longer have to match, just to take up the same 
space, as they can be changed before the call
- Allowed tail calls if callee and callee both (or neither) use sret, wheras 
before it would be dissalowed if either used sret
- Allowed tail calls if byval args are used
- Added debug trace for IsEligibleForTailCallOptimisation

Frontend (clang):
- Do not generate extra alloca if sret is used with musttail, as the space for 
the sret is allocated already

Change-Id: Ic7f246a7eca43c06874922d642d7dc44bdfc98ec
---
 clang/lib/CodeGen/CGCall.cpp  |   2 +-
 llvm/include/llvm/CodeGen/CallingConvLower.h  |   2 +
 llvm/lib/CodeGen/CallingConvLower.cpp |  61 +++
 llvm/lib/Target/ARM/ARMISelLowering.cpp   | 141 ++
 .../ARM/2013-05-13-AAPCS-byval-padding.ll |  16 +-
 .../ARM/2013-05-13-AAPCS-byval-padding2.ll|  13 +-
 llvm/test/CodeGen/ARM/fp-arg-shuffle.ll   |  22 +
 llvm/test/CodeGen/ARM/fp16-vector-argument.ll |  41 +-
 llvm/test/CodeGen/ARM/struct_byval.ll | 455 --
 llvm/test/CodeGen/ARM/tail-call-float.ll  |  99 +++-
 10 files changed, 661 insertions(+), 191 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index ca2c79b51ac96b..05773f91f986ba 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5086,7 +5086,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   RawAddress SRetAlloca = RawAddress::invalid();
   llvm::Value *UnusedReturnSizePtr = nullptr;
   if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) {
-if (IsVirtualFunctionPointerThunk && RetAI.isIndirect()) {
+if ((IsVirtualFunctionPointerThunk || IsMustTail) && RetAI.isIndirect()) {
   SRetPtr = makeNaturalAddressForPointer(CurFn->arg_begin() +
  IRFunctionArgs.getSRetArgNo(),
  RetTy, 
CharUnits::fromQuantity(1));
diff --git a/llvm/include/llvm/CodeGen/CallingConvLower.h 
b/llvm/include/llvm/CodeGen/CallingConvLower.h
index d5a63c8dd627a0..12a6df16e279b4 100644
--- a/llvm/include/llvm/CodeGen/CallingConvLower.h
+++ b/llvm/include/llvm/CodeGen/CallingConvLower.h
@@ -540,6 +540,8 @@ class CCState {
});
   }
 
+  void dump() const;
+
 private:
   /// MarkAllocated - Mark a register and all of its aliases as allocated.
   void MarkAllocated(MCPhysReg Reg);
diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp 
b/llvm/lib/CodeGen/CallingConvLower.cpp
index b7152587a9fa05..7ba3ea83115db2 100644
--- a/llvm/lib/CodeGen/CallingConvLower.cpp
+++ b/llvm/lib/CodeGen/CallingConvLower.cpp
@@ -290,3 +290,64 @@ bool CCState::resultsCompatible(CallingConv::ID CalleeCC,
   return std::equal(RVLocs1.begin(), RVLocs1.end(), RVLocs2.begin(),
 RVLocs2.end(), AreCompatible);
 }
+
+void CCState::dump() const {
+  dbgs() << "CCState:\n";
+  for (const CCValAssign &Loc : Locs) {
+if (Loc.isRegLoc()) {
+  dbgs() << "  Reg " << TRI.getName(Loc.getLocReg());
+} else if (Loc.isMemLoc()) {
+  dbgs() << "  Mem " << Loc.getLocMemOffset();
+} else {
+  assert(Loc.isPendingLoc());
+  dbgs() << "  Pend " << Loc.getExtraInfo();
+}
+
+dbgs() << " ValVT:" << Loc.getValVT();
+dbgs() << " LocVT:" << Loc.getLocVT();
+
+if (Loc.needsCustom())
+  dbgs() << " custom";
+
+switch (Loc.getLocInfo()) {
+case CCValAssign::Full:
+  dbgs() << " Full";
+  break;
+case CCValAssign::SExt:
+  dbgs() << " SExt";
+  break;
+case CCValAssign::ZExt:
+  dbgs() << " ZExt";
+  break;
+case CCValAssign::AExt:
+  dbgs() << " AExt";
+  break;
+case CCValAssign::SExtUpper:
+  dbgs() << " SExtUpper";
+  break;
+case CCValAssign::ZExtUpper:
+  dbgs() << " ZExtUpper";
+  break;
+case CCValAssign::AExtUpper:
+  dbgs() << " AExtUpper";
+  break;
+case CCValAssign::BCvt:
+  dbgs() << " BCvt";
+  break;
+case CCValAssign::Trunc:
+  dbgs() << " Trunc";
+  break;
+case CCValAssign::VExt:
+  dbgs() << " VExt";
+  break;
+case CCValAssign::FPExt:
+  dbgs() << " FPExt";
+  break;
+case CCValAssign::Indirect:
+  dbgs() << " Indirect";
+  break;
+}
+
+dbgs() << "\n";
+  }
+}
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 853f54943eebf1..b5fdf630a8132d 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -2407,8 +2407,8 @@ 
ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 isTailCall = false;
 
   // For both t

[clang] [clang][bytecode] Properly diagnose non-const reads (PR #106514)

2024-08-29 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/106514

If the global variable is constant (but not constexpr), we need to diagnose, 
but keep evaluating.

>From e9e4774a38975de976793d7941b6eae68dde7711 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 29 Aug 2024 10:21:54 +0200
Subject: [PATCH] [clang][bytecode] Properly diagnose non-const reads

If the global variable is constant (but not constexpr), we need to
diagnose, but keep evaluating.
---
 clang/lib/AST/ByteCode/Interp.cpp  | 62 ++
 clang/test/AST/ByteCode/cxx11-pedantic.cpp | 13 +
 2 files changed, 52 insertions(+), 23 deletions(-)
 create mode 100644 clang/test/AST/ByteCode/cxx11-pedantic.cpp

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 09d3f4525138ed..0cd106b74d1504 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -323,36 +323,52 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
   assert(Desc);
 
-  auto IsConstType = [&S](const VarDecl *VD) -> bool {
-QualType T = VD->getType();
-
-if (T.isConstant(S.getASTContext()))
-  return true;
-
-if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11)
-  return (T->isSignedIntegerOrEnumerationType() ||
-  T->isUnsignedIntegerOrEnumerationType()) &&
- T.isConstQualified();
+  const auto *D = Desc->asVarDecl();
+  if (!D || !D->hasGlobalStorage())
+return true;
 
-if (T.isConstQualified())
-  return true;
+  if (D == S.EvaluatingDecl)
+return true;
 
-if (const auto *RT = T->getAs())
-  return RT->getPointeeType().isConstQualified();
+  if (D->isConstexpr())
+return true;
 
-if (const auto *PT = T->getAs())
-  return PT->getPointeeType().isConstQualified();
+  QualType T = D->getType();
+  bool IsConstant = T.isConstant(S.getASTContext());
+  if (T->isIntegralOrEnumerationType()) {
+if (!IsConstant) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
+  }
 
-return false;
-  };
+  if (IsConstant) {
+if (S.getLangOpts().CPlusPlus) {
+  S.CCEDiag(S.Current->getLocation(OpPC),
+S.getLangOpts().CPlusPlus11
+? diag::note_constexpr_ltor_non_constexpr
+: diag::note_constexpr_ltor_non_integral,
+1)
+  << D << T;
+  S.Note(D->getLocation(), diag::note_declared_at);
+} else {
+  S.CCEDiag(S.Current->getLocation(OpPC));
+}
+return true;
+  }
 
-  if (const auto *D = Desc->asVarDecl();
-  D && D->hasGlobalStorage() && D != S.EvaluatingDecl && !IsConstType(D)) {
-diagnoseNonConstVariable(S, OpPC, D);
-return false;
+  if (T->isPointerOrReferenceType()) {
+if (!T->getPointeeType().isConstant(S.getASTContext()) ||
+!S.getLangOpts().CPlusPlus11) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
   }
 
-  return true;
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
diff --git a/clang/test/AST/ByteCode/cxx11-pedantic.cpp 
b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
new file mode 100644
index 00..a51061431f87ad
--- /dev/null
+++ b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter 
-verify=both,expected -std=c++11 -pedantic %s
+// RUN: %clang_cc1 -verify=both,ref -std=c++11 -pedantic %s
+
+struct T { int n; };
+const T t = { 42 }; // both-note 2{{declared here}}
+struct S {
+  int m : t.n; // both-warning {{width of bit-field 'm' (42 bits)}} \
+   // both-warning {{expression is not an integral constant 
expression}} \
+   // both-note {{read of non-constexpr variable 't' is not 
allowed}}
+};
+
+static_assert(t.n == 42, ""); // both-error {{expression is not an integral 
constant expression}} \
+  // both-note {{read of non-constexpr variable 
't' is not allowed}}

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


[clang] [clang][bytecode] Properly diagnose non-const reads (PR #106514)

2024-08-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

If the global variable is constant (but not constexpr), we need to diagnose, 
but keep evaluating.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+39-23) 
- (added) clang/test/AST/ByteCode/cxx11-pedantic.cpp (+13) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 09d3f4525138ed..0cd106b74d1504 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -323,36 +323,52 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
   assert(Desc);
 
-  auto IsConstType = [&S](const VarDecl *VD) -> bool {
-QualType T = VD->getType();
-
-if (T.isConstant(S.getASTContext()))
-  return true;
-
-if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11)
-  return (T->isSignedIntegerOrEnumerationType() ||
-  T->isUnsignedIntegerOrEnumerationType()) &&
- T.isConstQualified();
+  const auto *D = Desc->asVarDecl();
+  if (!D || !D->hasGlobalStorage())
+return true;
 
-if (T.isConstQualified())
-  return true;
+  if (D == S.EvaluatingDecl)
+return true;
 
-if (const auto *RT = T->getAs())
-  return RT->getPointeeType().isConstQualified();
+  if (D->isConstexpr())
+return true;
 
-if (const auto *PT = T->getAs())
-  return PT->getPointeeType().isConstQualified();
+  QualType T = D->getType();
+  bool IsConstant = T.isConstant(S.getASTContext());
+  if (T->isIntegralOrEnumerationType()) {
+if (!IsConstant) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
+  }
 
-return false;
-  };
+  if (IsConstant) {
+if (S.getLangOpts().CPlusPlus) {
+  S.CCEDiag(S.Current->getLocation(OpPC),
+S.getLangOpts().CPlusPlus11
+? diag::note_constexpr_ltor_non_constexpr
+: diag::note_constexpr_ltor_non_integral,
+1)
+  << D << T;
+  S.Note(D->getLocation(), diag::note_declared_at);
+} else {
+  S.CCEDiag(S.Current->getLocation(OpPC));
+}
+return true;
+  }
 
-  if (const auto *D = Desc->asVarDecl();
-  D && D->hasGlobalStorage() && D != S.EvaluatingDecl && !IsConstType(D)) {
-diagnoseNonConstVariable(S, OpPC, D);
-return false;
+  if (T->isPointerOrReferenceType()) {
+if (!T->getPointeeType().isConstant(S.getASTContext()) ||
+!S.getLangOpts().CPlusPlus11) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
   }
 
-  return true;
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
diff --git a/clang/test/AST/ByteCode/cxx11-pedantic.cpp 
b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
new file mode 100644
index 00..a51061431f87ad
--- /dev/null
+++ b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter 
-verify=both,expected -std=c++11 -pedantic %s
+// RUN: %clang_cc1 -verify=both,ref -std=c++11 -pedantic %s
+
+struct T { int n; };
+const T t = { 42 }; // both-note 2{{declared here}}
+struct S {
+  int m : t.n; // both-warning {{width of bit-field 'm' (42 bits)}} \
+   // both-warning {{expression is not an integral constant 
expression}} \
+   // both-note {{read of non-constexpr variable 't' is not 
allowed}}
+};
+
+static_assert(t.n == 42, ""); // both-error {{expression is not an integral 
constant expression}} \
+  // both-note {{read of non-constexpr variable 
't' is not allowed}}

``




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


[clang] [clang] mangle placeholder for deduced type as a template-prefix (PR #106335)

2024-08-29 Thread via cfe-commits


@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | 
FileCheck %s
+
+template  class S>
+void create_unique()
+  requires (S{0}, true) {}
+
+template  struct A {
+  constexpr A(Fn) {};
+};
+
+template void create_unique();
+// CHECK: @_Z13create_uniqueI1AEvvQcmtlT_Li0EELb1E(

cor3ntin wrote:

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

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


[clang] [analyzer] Detect leaks of stack addresses via output params, indirect globals 3/3 (PR #105648)

2024-08-29 Thread Mikael Holmén via cfe-commits

mikaelholmen wrote:

Hello,

The following starts crashing with this patch:
```
clang -cc1 -analyze -analyzer-checker=core bbi-98571.c
```
Result:
```
bbi-98571.c:2:14: warning: expected ';' at end of declaration list
2 |   struct a *b
  |  ^
  |  ;
bbi-98571.c:5:8: warning: expected ';' at end of declaration list
5 |   int d
  |^
  |;
bbi-98571.c:11:4: warning: passing arguments to 'f' without a prototype is 
deprecated in all versions of C and is not supported in C23 
[-Wdeprecated-non-prototype]
   11 |   f(h);
  |^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: build-all/bin/clang -cc1 -analyze 
-analyzer-checker=core bbi-98571.c
1.   parser at end of file
2.  While analyzing stack: 
#0 Calling g
 #0 0x555c2d234d97 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(build-all/bin/clang+0x7f7cd97)
 #1 0x555c2d2328fe llvm::sys::RunSignalHandlers() 
(build-all/bin/clang+0x7f7a8fe)
 #2 0x555c2d23545f SignalHandler(int) Signals.cpp:0:0
 #3 0x7f49e8845cf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)
 #4 0x555c2f3124a8 clang::ento::MemRegion::getBaseRegion() const 
(build-all/bin/clang+0xa05a4a8)
 #5 0x555c2f0f5d82 (anonymous 
namespace)::StackAddrEscapeChecker::checkEndFunction(clang::ReturnStmt const*, 
clang::ento::CheckerContext&) 
const::CallBack::HandleBinding(clang::ento::StoreManager&, void const*, 
clang::ento::MemRegion const*, clang::ento::SVal) StackAddrEscapeChecker.cpp:0:0
 #6 0x555c2f351937 (anonymous 
namespace)::RegionStoreManager::iterBindings(void const*, 
clang::ento::StoreManager::BindingsHandler&) RegionStore.cpp:0:0
 #7 0x555c2f0f51c5 void 
clang::ento::check::EndFunction::_checkEndFunction<(anonymous 
namespace)::StackAddrEscapeChecker>(void*, clang::ReturnStmt const*, 
clang::ento::CheckerContext&) StackAddrEscapeChecker.cpp:0:0
 #8 0x555c2f29ee6a 
clang::ento::CheckerManager::runCheckersForEndFunction(clang::ento::NodeBuilderContext&,
 clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNode*, 
clang::ento::ExprEngine&, clang::ReturnStmt const*) 
(build-all/bin/clang+0x9fe6e6a)
 #9 0x555c2f2d3c96 
clang::ento::ExprEngine::processEndOfFunction(clang::ento::NodeBuilderContext&, 
clang::ento::ExplodedNode*, clang::ReturnStmt const*) 
(build-all/bin/clang+0xa01bc96)
#10 0x555c2f2a8e63 
clang::ento::CoreEngine::HandleBlockEdge(clang::BlockEdge const&, 
clang::ento::ExplodedNode*) (build-all/bin/clang+0x9ff0e63)
#11 0x555c2f2a870a 
clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, 
clang::ProgramPoint, clang::ento::WorkListUnit const&) 
(build-all/bin/clang+0x9ff070a)
#12 0x555c2f2a801a 
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, 
unsigned int, llvm::IntrusiveRefCntPtr) 
(build-all/bin/clang+0x9ff001a)
#13 0x555c2ee23955 (anonymous 
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, 
clang::ento::ExprEngine::InliningModes, llvm::DenseSet>*) AnalysisConsumer.cpp:0:0
#14 0x555c2edfc78b (anonymous 
namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) 
AnalysisConsumer.cpp:0:0
#15 0x555c2f3a7ea7 clang::ParseAST(clang::Sema&, bool, bool) 
(build-all/bin/clang+0xa0efea7)
#16 0x555c2def1e80 clang::FrontendAction::Execute() 
(build-all/bin/clang+0x8c39e80)
#17 0x555c2de5e5bf 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(build-all/bin/clang+0x8ba65bf)
#18 0x555c2dfdfa8e 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(build-all/bin/clang+0x8d27a8e)
#19 0x555c2aaa0576 cc1_main(llvm::ArrayRef, char const*, 
void*) (build-all/bin/clang+0x57e8576)
#20 0x555c2aa9cd1d ExecuteCC1Tool(llvm::SmallVectorImpl&, 
llvm::ToolContext const&) driver.cpp:0:0
#21 0x555c2aa9ba64 clang_main(int, char**, llvm::ToolContext const&) 
(build-all/bin/clang+0x57e3a64)
#22 0x555c2aaad347 main (build-all/bin/clang+0x57f5347)
#23 0x7f49e63ead85 __libc_start_main (/lib64/libc.so.6+0x3ad85)
#24 0x555c2aa9a62e _start (build-all/bin/clang+0x57e262e)
Segmentation fault (core dumped)
```
[bbi-98571.c.gz](https://github.com/user-attachments/files/16796839/bbi-98571.c.gz)


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


[clang-tools-extra] [clang-tidy] Extend `bugprone-sizeof-expression` with matching `P +- sizeof(T)` and `P +- N */ sizeof(T)` cases, add `cert-arr39-c` alias (PR #106061)

2024-08-29 Thread via cfe-commits

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


[clang] [clang][HLSL] Add sign intrinsic part 3 (PR #101989)

2024-08-29 Thread Tim Gymnich via cfe-commits

tgymnich wrote:

@farzonl This PR requires the SPIRV part 
(https://github.com/llvm/llvm-project/pull/101987) to be merged.

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


[clang] [llvm] [AArch64] Implement intrinsics for SVE FAMIN/FAMAX (PR #99042)

2024-08-29 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov updated 
https://github.com/llvm/llvm-project/pull/99042

>From aa74d04751558f3ab47d566c91fb8ad178df0dce Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Tue, 16 Jul 2024 13:37:34 +0100
Subject: [PATCH 1/2] [AArch64] Implement intrinsics for SVE FAMIN/FAMAX

This patch implements the following intrinsics:

* Floating-point absolute maximum (predicated)

  svfloat16_t svamax[_f16]_m(svbool_t, svfloat16_t, svfloat16_t);
  svfloat16_t svamax[_f16]_x(svbool_t, svfloat16_t, svfloat16_t);
  svfloat16_t svamax[_f16]_z(svbool_t, svfloat16_t, svfloat16_t);

  svfloat16_t svamax[_n_f16]_m(svbool_t, svfloat16_t, float16_t);
  svfloat16_t svamax[_n_f16]_x(svbool_t, svfloat16_t, float16_t);
  svfloat16_t svamax[_n_f16]_z(svbool_t, svfloat16_t, float16_t);

* Floating-point absolute minimum (predicated)

  svfloat16_t svmin[_f16]_m(svbool_t, svfloat16_t, svfloat16_t);
  svfloat16_t svmin[_f16]_x(svbool_t, svfloat16_t, svfloat16_t);
  svfloat16_t svmin[_f16]_z(svbool_t, svfloat16_t, svfloat16_t);

  svfloat16_t svmin[_n_f16]_m(svbool_t, svfloat16_t, float16_t);
  svfloat16_t svmin[_n_f16]_x(svbool_t, svfloat16_t, float16_t);
  svfloat16_t svmin[_n_f16]_z(svbool_t, svfloat16_t, float16_t);

All the intrinsics have also variants for `f32` and `f64`, and have
the `__arm_streaming` attribute.

(cf. https://github.com/ARM-software/acle/pull/324)
---
 clang/include/clang/Basic/arm_sve.td  |   5 +
 .../acle_sve2_faminmax.c  | 775 ++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   7 +
 .../Target/AArch64/AArch64ISelLowering.cpp|   8 +
 llvm/lib/Target/AArch64/AArch64ISelLowering.h |   2 +
 .../lib/Target/AArch64/AArch64SVEInstrInfo.td |  14 +-
 .../AArch64/sve2-intrinsics-faminmax.ll   | 266 ++
 7 files changed, 1075 insertions(+), 2 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_faminmax.c
 create mode 100644 llvm/test/CodeGen/AArch64/sve2-intrinsics-faminmax.ll

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 078373823a3b6f..b40ce9b4d11b56 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -2401,3 +2401,8 @@ let SVETargetGuard = "sve2p1", SMETargetGuard = "sme2" in 
{
   def SVBFMLSLB_LANE : SInst<"svbfmlslb_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslb_lane", [IsOverloadNone, VerifyRuntimeMode], [ImmCheck<3, 
ImmCheck0_7>]>;
   def SVBFMLSLT_LANE : SInst<"svbfmlslt_lane[_{d}]", "dd$$i", "f", MergeNone, 
"aarch64_sve_bfmlslt_lane", [IsOverloadNone, VerifyRuntimeMode], [ImmCheck<3, 
ImmCheck0_7>]>;
 }
+
+let SVETargetGuard = "sve2,faminmax", SMETargetGuard = "sme2,faminmax" in {
+  defm SVAMIN : SInstZPZZ<"svamin", "hfd", "aarch64_sve_famin", 
"aarch64_sve_famin_u">;
+  defm SVAMAX : SInstZPZZ<"svamax", "hfd", "aarch64_sve_famax", 
"aarch64_sve_famax_u">;
+}
diff --git a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_faminmax.c 
b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_faminmax.c
new file mode 100644
index 00..3cf7d99d606f32
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_faminmax.c
@@ -0,0 +1,775 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2 -target-feature +faminmax -O1 -Werror -Wall -emit-llvm -o 
- %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +faminmax -O1 -Werror -Wall -emit-llvm -o 
- %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +sve2 -target-feature +faminmax -O1 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2 -target-feature +faminmax -O1 -Werror -Wall -emit-llvm -o 
- %s | FileCheck %s -check-prefix CHECK-CPP
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +faminmax -O1 -Werror -Wall -emit-llvm -o 
- %s | FileCheck %s -check-prefix CHECK-CPP
+// RUN: %clang_cc1 -x c++ -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -target-feature +sve2 
-target-feature +faminmax -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s 
-check-prefix CHECK-CPP
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2 -target-feature +faminmax -S -disable-O0-optnone -Werror 
-Wall -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +faminmax -S -disable-O0-optnone -Werror 
-Wall -o /dev/null %s
+
+// REQUIRES: aarch64-registered-target
+
+#ifdef __ARM_FEATURE_SME
+#include "arm_sme.h"
+#else
+#include "arm_sve.h"
+#

[clang] [clang][bytecode] Properly diagnose non-const reads (PR #106514)

2024-08-29 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/106514

>From a8eaf58bcae529a3629dbd1b84df58e9557dde5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 29 Aug 2024 10:21:54 +0200
Subject: [PATCH] [clang][bytecode] Properly diagnose non-const reads

If the global variable is constant (but not constexpr), we need to
diagnose, but keep evaluating.
---
 clang/lib/AST/ByteCode/Interp.cpp  | 62 ++
 clang/test/AST/ByteCode/cxx11-pedantic.cpp | 13 +
 2 files changed, 52 insertions(+), 23 deletions(-)
 create mode 100644 clang/test/AST/ByteCode/cxx11-pedantic.cpp

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 09d3f4525138ed..0cd106b74d1504 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -323,36 +323,52 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
   assert(Desc);
 
-  auto IsConstType = [&S](const VarDecl *VD) -> bool {
-QualType T = VD->getType();
-
-if (T.isConstant(S.getASTContext()))
-  return true;
-
-if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11)
-  return (T->isSignedIntegerOrEnumerationType() ||
-  T->isUnsignedIntegerOrEnumerationType()) &&
- T.isConstQualified();
+  const auto *D = Desc->asVarDecl();
+  if (!D || !D->hasGlobalStorage())
+return true;
 
-if (T.isConstQualified())
-  return true;
+  if (D == S.EvaluatingDecl)
+return true;
 
-if (const auto *RT = T->getAs())
-  return RT->getPointeeType().isConstQualified();
+  if (D->isConstexpr())
+return true;
 
-if (const auto *PT = T->getAs())
-  return PT->getPointeeType().isConstQualified();
+  QualType T = D->getType();
+  bool IsConstant = T.isConstant(S.getASTContext());
+  if (T->isIntegralOrEnumerationType()) {
+if (!IsConstant) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
+  }
 
-return false;
-  };
+  if (IsConstant) {
+if (S.getLangOpts().CPlusPlus) {
+  S.CCEDiag(S.Current->getLocation(OpPC),
+S.getLangOpts().CPlusPlus11
+? diag::note_constexpr_ltor_non_constexpr
+: diag::note_constexpr_ltor_non_integral,
+1)
+  << D << T;
+  S.Note(D->getLocation(), diag::note_declared_at);
+} else {
+  S.CCEDiag(S.Current->getLocation(OpPC));
+}
+return true;
+  }
 
-  if (const auto *D = Desc->asVarDecl();
-  D && D->hasGlobalStorage() && D != S.EvaluatingDecl && !IsConstType(D)) {
-diagnoseNonConstVariable(S, OpPC, D);
-return false;
+  if (T->isPointerOrReferenceType()) {
+if (!T->getPointeeType().isConstant(S.getASTContext()) ||
+!S.getLangOpts().CPlusPlus11) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
   }
 
-  return true;
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
diff --git a/clang/test/AST/ByteCode/cxx11-pedantic.cpp 
b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
new file mode 100644
index 00..8779a2826c50db
--- /dev/null
+++ b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter 
-verify=both,expected -std=c++11 -triple x86_64-linux -pedantic %s
+// RUN: %clang_cc1 -verify=both,ref -std=c++11 -triple x86_64-linux -pedantic 
%s
+
+struct T { int n; };
+const T t = { 42 }; // both-note 2{{declared here}}
+struct S {
+  int m : t.n; // both-warning {{width of bit-field 'm' (42 bits)}} \
+   // both-warning {{expression is not an integral constant 
expression}} \
+   // both-note {{read of non-constexpr variable 't' is not 
allowed}}
+};
+
+static_assert(t.n == 42, ""); // both-error {{expression is not an integral 
constant expression}} \
+  // both-note {{read of non-constexpr variable 
't' is not allowed}}

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


[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits


@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclarationOrFunctionDefinition(
   // Add an enclosing time trace scope for a bunch of small scopes with
   // "EvaluateAsConstExpr".
   llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() 
{
-return Tok.getLocation().printToString(
-Actions.getASTContext().getSourceManager());
+llvm::TimeTraceMetadata M;
+const SourceManager &SM = Actions.getASTContext().getSourceManager();
+auto Loc = SM.getExpansionLoc(Tok.getLocation());

usx95 wrote:

I went ahead and did this PR.
I do not have a great home for such a function, went ahead with SourceManager.

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


[clang] [CodeGen] Apply 'readonly' to 'this' pointer argument. (PR #106499)

2024-08-29 Thread Zhijin Zeng via cfe-commits

zengdage wrote:

Sorry, I misunderstand the 'readonly' meaning. So this pr is wrong.

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


[clang] [CodeGen] Apply 'readonly' to 'this' pointer argument. (PR #106499)

2024-08-29 Thread Zhijin Zeng via cfe-commits

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


[clang] [CodeGen] Apply 'readonly' to 'this' pointer argument. (PR #106499)

2024-08-29 Thread Nikita Popov via cfe-commits

nikic wrote:

> > I'm very confused. `readonly` means that the memory behind `this` cannot be 
> > changed, not that the pointer cannot be changed.
> 
> Out of curiosity, it looks not same in https://llvm.org/docs/LangRef.html:
> 
> > This attribute indicates that the function does not write through this 
> > pointer argument, even though it may write to the memory that the pointer 
> > points to.
> > If a function writes to a readonly pointer argument, the behavior is 
> > undefined.
> 
> My understanding for ` it may write to the memory that the pointer points 
> to.` is what you said. Or do we need to update the document?

The distinction in LangRef is about a write through the pointer vs a write 
through an alias of the pointer to the same memory. Only the former is 
forbidden.

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


[clang] Adding optin.taint.TaintedDiv checker (PR #106389)

2024-08-29 Thread Donát Nagy via cfe-commits


@@ -48,8 +52,14 @@ static const Expr *getDenomExpr(const ExplodedNode *N) {
 
 void DivZeroChecker::reportBug(StringRef Msg, ProgramStateRef StateZero,
CheckerContext &C) const {
+  if (!ChecksEnabled[CK_DivZeroChecker])
+return;
+  if (!BugTypes[CK_DivZeroChecker])
+BugTypes[CK_DivZeroChecker].reset(
+new BugType(CheckNames[CK_DivZeroChecker], "Division by zero"));

NagyDonat wrote:

It's a pity that we need this lazy dynamic initialization 
:face_with_diagonal_mouth:. We should really introduce a clear framework to 
avoid this. 

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


[clang] Adding optin.taint.TaintedDiv checker (PR #106389)

2024-08-29 Thread Donát Nagy via cfe-commits

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


[clang] Adding optin.taint.TaintedDiv checker (PR #106389)

2024-08-29 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat commented:

LGTM overall, I added some minor inline remarks.

Also consider adding a few simple testcases to distinguish the effects of 
DivideZero and TaintedDiv. It would also be interesting to highlight what 
happens in situations like

```c
int test(void) {
  int x = getchar(); // or any other taint source
  if (!x)
return 5 / x;
  return 8;
}
```
(I presume that in this case core.DivideZero will create a bug report, but the 
new TaintedDiv checker won't.)


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


[clang] Adding optin.taint.TaintedDiv checker (PR #106389)

2024-08-29 Thread Donát Nagy via cfe-commits


@@ -113,9 +130,28 @@ void DivZeroChecker::checkPreStmt(const BinaryOperator *B,
 }
 
 void ento::registerDivZeroChecker(CheckerManager &mgr) {
-  mgr.registerChecker();
+  DivZeroChecker *checker = mgr.registerChecker();
+  ;

NagyDonat wrote:

Delete this empty statement.

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


[clang] Adding optin.taint.TaintedDiv checker (PR #106389)

2024-08-29 Thread Donát Nagy via cfe-commits


@@ -25,16 +25,20 @@ using namespace ento;
 using namespace taint;
 
 namespace {
-class DivZeroChecker : public Checker< check::PreStmt > {
-  const BugType BT{this, "Division by zero"};
-  const BugType TaintBT{this, "Division by zero", categories::TaintedData};
+class DivZeroChecker : public Checker> {
   void reportBug(StringRef Msg, ProgramStateRef StateZero,
  CheckerContext &C) const;
   void reportTaintBug(StringRef Msg, ProgramStateRef StateZero,
   CheckerContext &C,
   llvm::ArrayRef TaintedSyms) const;
 
 public:
+  /// This checker class implements multiple user facing checker
+  enum CheckKind { CK_DivZeroChecker, CK_TaintedDivChecker, CK_NumCheckKinds };

NagyDonat wrote:

Please use `DivideZero` instead of `DivZero` in the name of the `CheckKind` to 
be consistent with the name of the `core.DivideZero` checker. (The name of 
source file and the checker class may stay `DivZero`, because they are no 
longer in 1:1 correspondence with the checker. It's unfortunate that we have 
these inconsistencies, they are really annoying during the development.)

Also I'd omit the `Checker` suffix from these enum constants -- it doesn't 
provide any added information.

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


[clang] Adding optin.taint.TaintedDiv checker (PR #106389)

2024-08-29 Thread Donát Nagy via cfe-commits


@@ -58,8 +68,15 @@ void DivZeroChecker::reportBug(StringRef Msg, 
ProgramStateRef StateZero,
 void DivZeroChecker::reportTaintBug(
 StringRef Msg, ProgramStateRef StateZero, CheckerContext &C,
 llvm::ArrayRef TaintedSyms) const {
+  if (!ChecksEnabled[CK_TaintedDivChecker])
+return;
+  if (!BugTypes[CK_TaintedDivChecker])
+BugTypes[CK_TaintedDivChecker].reset(
+new BugType(CheckNames[CK_TaintedDivChecker], "Division by zero",
+categories::TaintedData));
   if (ExplodedNode *N = C.generateErrorNode(StateZero)) {

NagyDonat wrote:

Consider using a  non-fatal error node here and in other taint bugs. (Perhaps 
in a follow-up commit?)

When the analyzer finds a taint bug, it only says that "this _may_ cause a 
problem" so it's relevant to know that later something is _definitely_ 
problematic. 

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


[clang] `__noop` not marked as constexpr #102064 (PR #105983)

2024-08-29 Thread via cfe-commits

https://github.com/ofAlpaca updated 
https://github.com/llvm/llvm-project/pull/105983

>From 7f13ff52821a6c2ba58236fe363fb9a3a378c33b Mon Sep 17 00:00:00 2001
From: ofAlpaca 
Date: Sun, 25 Aug 2024 17:02:11 +0800
Subject: [PATCH 1/5] Fix for GH102064

---
 clang/include/clang/Basic/Builtins.td | 2 +-
 clang/lib/AST/ExprConstant.cpp| 4 
 clang/test/SemaCXX/GH102064.cpp   | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/GH102064.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index f5b15cf90d1f83..b42f7ea1d9de68 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -2516,7 +2516,7 @@ def IsoVolatileStore : MSLangBuiltin, 
Int8_16_32_64Template {
 
 def Noop : MSLangBuiltin {
   let Spellings = ["__noop"];
-  let Attributes = [NoThrow];
+  let Attributes = [NoThrow, Constexpr];
   let Prototype = "int(...)";
 }
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5af712dd7257b1..d505346bccd9b3 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12586,6 +12586,10 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 return false;
   }
 
+  case Builtin::BI__noop:
+  // __noop always evaluates successfully
+return true;
+
   case Builtin::BI__builtin_is_constant_evaluated: {
 const auto *Callee = Info.CurrentCall->getCallee();
 if (Info.InConstantContext && !Info.CheckingPotentialConstantExpression &&
diff --git a/clang/test/SemaCXX/GH102064.cpp b/clang/test/SemaCXX/GH102064.cpp
new file mode 100644
index 00..52213b66e9eccc
--- /dev/null
+++ b/clang/test/SemaCXX/GH102064.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++20 -fms-extensions %s
+// expected-no-diagnostics
+constexpr int x = []{ __noop; return 0; }();
\ No newline at end of file

>From 676b1b352d7e3279c6e3681466605e88b81dfdde Mon Sep 17 00:00:00 2001
From: ofAlpaca 
Date: Sun, 25 Aug 2024 20:03:19 +0800
Subject: [PATCH 2/5] Add release note

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 971df672b6ca1e..e60407061ccd3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -861,6 +861,8 @@ Bug Fixes to Compiler Builtins
 - Clang now allows pointee types of atomic builtin arguments to be complete 
template types
   that was not instantiated elsewhere.
 
+- Fix ``__noop`` not marked as constexpr. (#GH102064)
+
 Bug Fixes to Attribute Support
 ^^
 

>From 9730d9c50033c44766b370ccc92de6575c1eca29 Mon Sep 17 00:00:00 2001
From: ofAlpaca 
Date: Sun, 25 Aug 2024 20:13:48 +0800
Subject: [PATCH 3/5] Update testcase for end of file newline

---
 clang/test/SemaCXX/GH102064.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/SemaCXX/GH102064.cpp b/clang/test/SemaCXX/GH102064.cpp
index 52213b66e9eccc..0ed930439e3d75 100644
--- a/clang/test/SemaCXX/GH102064.cpp
+++ b/clang/test/SemaCXX/GH102064.cpp
@@ -1,3 +1,3 @@
 // RUN: %clang_cc1 -std=c++20 -fms-extensions %s
 // expected-no-diagnostics
-constexpr int x = []{ __noop; return 0; }();
\ No newline at end of file
+constexpr int x = []{ __noop; return 0; }();

>From 1a9a0740a1360443bf5f2ba42f7d263fdf06fdc7 Mon Sep 17 00:00:00 2001
From: ofAlpaca 
Date: Wed, 28 Aug 2024 00:48:44 +0800
Subject: [PATCH 4/5] Update ReleaseNotes.rst and testcase

---
 clang/docs/ReleaseNotes.rst | 2 +-
 clang/test/SemaCXX/GH102064.cpp | 3 ---
 clang/test/SemaCXX/builtins.cpp | 7 +++
 3 files changed, 8 insertions(+), 4 deletions(-)
 delete mode 100644 clang/test/SemaCXX/GH102064.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e60407061ccd3b..e458c1ba1550f8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -861,7 +861,7 @@ Bug Fixes to Compiler Builtins
 - Clang now allows pointee types of atomic builtin arguments to be complete 
template types
   that was not instantiated elsewhere.
 
-- Fix ``__noop`` not marked as constexpr. (#GH102064)
+- ``__noop`` can now be used in a constant expression. (#GH102064)
 
 Bug Fixes to Attribute Support
 ^^
diff --git a/clang/test/SemaCXX/GH102064.cpp b/clang/test/SemaCXX/GH102064.cpp
deleted file mode 100644
index 0ed930439e3d75..00
--- a/clang/test/SemaCXX/GH102064.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -fms-extensions %s
-// expected-no-diagnostics
-constexpr int x = []{ __noop; return 0; }();
diff --git a/clang/test/SemaCXX/builtins.cpp b/clang/test/SemaCXX/builtins.cpp
index 080b4476c7eec1..da4023fd467065 100644
--- a/clang/test/SemaCXX/builtins.cpp
+++ b/clang/test/SemaCXX/builtins.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 -fcxx-exceptions
 // RUN: %clang_cc1 %s -fsyntax-only -verify -st

[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-08-29 Thread via cfe-commits


@@ -19,6 +19,9 @@ The check implements the following rules from the CERT C 
Coding Standard:
 Unsafe functions
 
 
+The following functions are reported if `ReportDefaultFunctions
+`_ is enabled.
+

whisperity wrote:

Instead of the automatically generated label which might break apart if the 
template is changed, try to use a reference label in the RST with a proper 
identifier and refer that instead.

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


[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-08-29 Thread via cfe-commits


@@ -136,6 +128,15 @@ class MatchesAnyListedNameMatcher
 }
   };
 
+  bool matches(
+  const NamedDecl &Node, ast_matchers::internal::ASTMatchFinder *Finder,
+  ast_matchers::internal::BoundNodesTreeBuilder *Builder) const override {
+return llvm::any_of(NameMatchers, [&Node](const NameMatcher &NM) {
+  return NM.match(Node);
+});
+  }
+
+private:

whisperity wrote:

Why was this change needed? The other changes in the code do not indicate this 
function getting called anywhere.

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


[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-08-29 Thread via cfe-commits

whisperity wrote:

High-level design question: Why is `CustomAnnexKFunctions` a thing?

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


[clang] [analyzer] [MallocChecker] suspect all release functions as candite for supression (PR #104599)

2024-08-29 Thread Pavel Skripkin via cfe-commits

pskrgag wrote:

seems patch got lost 
CC: @steakhal @NagyDonat 

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


[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-08-29 Thread via cfe-commits


@@ -136,6 +128,15 @@ class MatchesAnyListedNameMatcher
 }
   };
 
+  bool matches(
+  const NamedDecl &Node, ast_matchers::internal::ASTMatchFinder *Finder,
+  ast_matchers::internal::BoundNodesTreeBuilder *Builder) const override {
+return llvm::any_of(NameMatchers, [&Node](const NameMatcher &NM) {
+  return NM.match(Node);
+});
+  }
+
+private:

Discookie wrote:

The diff here highlights the wrong part of the change:
https://github.com/llvm/llvm-project/pull/106350/commits/47c1a5694fed5769bb6bbc437e31276efe41d520

I made the contained NameMatcher class public, but the diff considered the 
other function to be moved.

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


[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-08-29 Thread via cfe-commits

Discookie wrote:

`CustomAnnexKFunctions` exists because the checker has two different internal 
matching modes for whether AnnexK is enabled or not. This both depends on 
`__STDC_LIB_EXT1__` (defined by system) `__STDC_WANT_LIB_EXT1__` (defined by 
the user), so it's reasonable to expect that a project could have differing 
availability of AnnexK.

I could rename CustomNormalFunctions to CustomFunctions or something to make it 
clearer that it's always available.

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


[clang-tools-extra] [clang-tidy] Extend `bugprone-sizeof-expression` with matching `P +- sizeof(T)` and `P +- N */ sizeof(T)` cases, add `cert-arr39-c` alias (PR #106061)

2024-08-29 Thread via cfe-commits

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


[clang] [llvm] [AArch64] Implement intrinsics for SVE FAMIN/FAMAX (PR #99042)

2024-08-29 Thread Paul Walker via cfe-commits

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


[clang] [llvm] [AArch64] Implement intrinsics for SVE FAMIN/FAMAX (PR #99042)

2024-08-29 Thread Paul Walker via cfe-commits

https://github.com/paulwalker-arm approved this pull request.

A couple of suggestions but otherwise this looks good to me.

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


[clang] [llvm] [AArch64] Implement intrinsics for SVE FAMIN/FAMAX (PR #99042)

2024-08-29 Thread Paul Walker via cfe-commits


@@ -0,0 +1,115 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc -mattr=+sve2 < %s | FileCheck %s
+; RUN: llc -mattr=+sme2 -force-streaming < %s | FileCheck %s
+
+target triple = "aarch64-linux"
+
+define  @famin_f16( %pg,  %a,  %b) #0 {
+; CHECK-LABEL: famin_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:famin z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+%r = call  @llvm.aarch64.sve.famin.nxv8f16( %pg,  %a,  %b)
+ret  %r
+}
+
+define  @famin_f32( %pg,  %a,  %b) #0 {
+; CHECK-LABEL: famin_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:famin z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT:ret
+%r = call  @llvm.aarch64.sve.famin.nxv4f32( %pg,  %a,  %b)
+ret  %r
+}
+
+define  @famin_f64( %pg,  %a,  %b) #0 {
+; CHECK-LABEL: famin_f64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:famin z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT:ret
+%r = call  @llvm.aarch64.sve.famin.nxv2f64( %pg,  %a,  %b)
+ret  %r
+}
+
+define  @famin_u_f16( %pg,  %a,  %b) #0 {
+; CHECK-LABEL: famin_u_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:famin z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+%r = call  @llvm.aarch64.sve.famin.u.nxv8f16( %pg,  %a,  %b)

paulwalker-arm wrote:

Up to you but it might be worth switching `%a` and `%b` for the calls in the 
`_u_` functions.  The output should be unchanged, which shows the significance 
of the `.u.` in that it frees the register allocator to reuse the second 
operand.

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


[clang] [llvm] [AArch64] Implement intrinsics for SVE FAMIN/FAMAX (PR #99042)

2024-08-29 Thread Paul Walker via cfe-commits


@@ -717,6 +717,11 @@ let Predicates = [HasSVEorSME] in {
   defm FDIV_ZPZZ   : sve_fp_bin_pred_hfd;
 } // End HasSVEorSME
 
+let Predicates = [HasSVE2orSME2, HasFAMINMAX] in {
+  defm FAMAX_ZPZZ : sve_fp_bin_pred_hfd;
+  defm FAMIN_ZPZZ : sve_fp_bin_pred_hfd;
+}
+

paulwalker-arm wrote:

It doesn't make sense for the pseudo instructions patterns to be so far away 
from the definitions of the real instructions.  Please move them just below the 
defs for FAMIN_ZPmZ/FAMAX_ZPmZ.

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


[clang] [clang][bytecode] Diagnose member calls on deleted blocks (PR #106529)

2024-08-29 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/106529

This requires a bit of restructuring of ctor calls when checking for a 
potential constant expression.

>From 86f776e9de9ddee4bb5c35f6f6cd7959795bea8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 29 Aug 2024 12:54:10 +0200
Subject: [PATCH] [clang][bytecode] Diagnose member calls on deleted blocks

This requires a bit of restructuring of ctor calls when checking for a
potential constant expression.
---
 clang/lib/AST/ByteCode/Interp.cpp  | 16 ++--
 clang/lib/AST/ByteCode/Interp.h|  6 +-
 clang/lib/AST/ByteCode/InterpBlock.cpp |  2 ++
 clang/lib/AST/ByteCode/Pointer.h   |  8 
 clang/test/AST/ByteCode/new-delete.cpp |  7 +++
 clang/test/AST/ByteCode/unions.cpp | 20 
 6 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 09d3f4525138ed..51490cf46790b7 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -305,14 +305,18 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 
   if (!Ptr.isLive()) {
 const auto &Src = S.Current->getSource(OpPC);
-bool IsTemp = Ptr.isTemporary();
 
-S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
+if (Ptr.isDynamic()) {
+  S.FFDiag(Src, diag::note_constexpr_access_deleted_object) << AK;
+} else {
+  bool IsTemp = Ptr.isTemporary();
+  S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
 
-if (IsTemp)
-  S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
-else
-  S.Note(Ptr.getDeclLoc(), diag::note_declared_at);
+  if (IsTemp)
+S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
+  else
+S.Note(Ptr.getDeclLoc(), diag::note_declared_at);
+}
 
 return false;
   }
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 242532a3f0544e..ea868e21159c69 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2623,7 +2623,11 @@ inline bool Call(InterpState &S, CodePtr OpPC, const 
Function *Func,
   if (!CheckCallable(S, OpPC, Func))
 return false;
 
-  if (Func->hasThisPointer() && S.checkingPotentialConstantExpression())
+  // FIXME: The isConstructor() check here is not always right. The current
+  // constant evaluator is somewhat inconsistent in when it allows a function
+  // call when checking for a constant expression.
+  if (Func->hasThisPointer() && S.checkingPotentialConstantExpression() &&
+  !Func->isConstructor())
 return false;
 
   if (!CheckCallDepth(S, OpPC))
diff --git a/clang/lib/AST/ByteCode/InterpBlock.cpp 
b/clang/lib/AST/ByteCode/InterpBlock.cpp
index 7a3962290edb4e..0ce88ca7e52365 100644
--- a/clang/lib/AST/ByteCode/InterpBlock.cpp
+++ b/clang/lib/AST/ByteCode/InterpBlock.cpp
@@ -110,6 +110,8 @@ DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
   Prev = nullptr;
   Root = this;
 
+  B.IsDynamic = Blk->IsDynamic;
+
   // Transfer pointers.
   B.Pointers = Blk->Pointers;
   for (Pointer *P = Blk->Pointers; P; P = P->Next)
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 27ac33616f5a8b..ef90e6e0dd7bd1 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -491,6 +491,14 @@ class Pointer {
 }
 return false;
   }
+  /// Checks if the storage has been dynamically allocated.
+  bool isDynamic() const {
+if (isBlockPointer()) {
+  assert(asBlockPointer().Pointee);
+  return asBlockPointer().Pointee->isDynamic();
+}
+return false;
+  }
   /// Checks if the storage is a static temporary.
   bool isStaticTemporary() const { return isStatic() && isTemporary(); }
 
diff --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index d733e3182fd59c..145bb366710f9b 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -579,6 +579,13 @@ namespace CastedDelete {
  // expected-note {{in call to}}
 }
 
+constexpr void use_after_free_2() { // both-error {{never produces a constant 
expression}}
+  struct X { constexpr void f() {} };
+  X *p = new X;
+  delete p;
+  p->f(); // both-note {{member call on heap allocated object that has been 
deleted}}
+}
+
 #else
 /// Make sure we reject this prior to C++20
 constexpr int a() { // both-error {{never produces a constant expression}}
diff --git a/clang/test/AST/ByteCode/unions.cpp 
b/clang/test/AST/ByteCode/unions.cpp
index 35b4a520baa269..7b39bb1bb9316e 100644
--- a/clang/test/AST/ByteCode/unions.cpp
+++ b/clang/test/AST/ByteCode/unions.cpp
@@ -86,7 +86,7 @@ namespace DefaultInit {
 
 #if __cplusplus >= 202002L
 namespace SimpleActivate {
-  constexpr int foo() { // ref-error {{never produces a cons

[clang] [clang][bytecode] Diagnose member calls on deleted blocks (PR #106529)

2024-08-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

This requires a bit of restructuring of ctor calls when checking for a 
potential constant expression.

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


6 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+10-6) 
- (modified) clang/lib/AST/ByteCode/Interp.h (+5-1) 
- (modified) clang/lib/AST/ByteCode/InterpBlock.cpp (+2) 
- (modified) clang/lib/AST/ByteCode/Pointer.h (+8) 
- (modified) clang/test/AST/ByteCode/new-delete.cpp (+7) 
- (modified) clang/test/AST/ByteCode/unions.cpp (+8-12) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 09d3f4525138ed..51490cf46790b7 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -305,14 +305,18 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 
   if (!Ptr.isLive()) {
 const auto &Src = S.Current->getSource(OpPC);
-bool IsTemp = Ptr.isTemporary();
 
-S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
+if (Ptr.isDynamic()) {
+  S.FFDiag(Src, diag::note_constexpr_access_deleted_object) << AK;
+} else {
+  bool IsTemp = Ptr.isTemporary();
+  S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
 
-if (IsTemp)
-  S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
-else
-  S.Note(Ptr.getDeclLoc(), diag::note_declared_at);
+  if (IsTemp)
+S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
+  else
+S.Note(Ptr.getDeclLoc(), diag::note_declared_at);
+}
 
 return false;
   }
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 242532a3f0544e..ea868e21159c69 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2623,7 +2623,11 @@ inline bool Call(InterpState &S, CodePtr OpPC, const 
Function *Func,
   if (!CheckCallable(S, OpPC, Func))
 return false;
 
-  if (Func->hasThisPointer() && S.checkingPotentialConstantExpression())
+  // FIXME: The isConstructor() check here is not always right. The current
+  // constant evaluator is somewhat inconsistent in when it allows a function
+  // call when checking for a constant expression.
+  if (Func->hasThisPointer() && S.checkingPotentialConstantExpression() &&
+  !Func->isConstructor())
 return false;
 
   if (!CheckCallDepth(S, OpPC))
diff --git a/clang/lib/AST/ByteCode/InterpBlock.cpp 
b/clang/lib/AST/ByteCode/InterpBlock.cpp
index 7a3962290edb4e..0ce88ca7e52365 100644
--- a/clang/lib/AST/ByteCode/InterpBlock.cpp
+++ b/clang/lib/AST/ByteCode/InterpBlock.cpp
@@ -110,6 +110,8 @@ DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
   Prev = nullptr;
   Root = this;
 
+  B.IsDynamic = Blk->IsDynamic;
+
   // Transfer pointers.
   B.Pointers = Blk->Pointers;
   for (Pointer *P = Blk->Pointers; P; P = P->Next)
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 27ac33616f5a8b..ef90e6e0dd7bd1 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -491,6 +491,14 @@ class Pointer {
 }
 return false;
   }
+  /// Checks if the storage has been dynamically allocated.
+  bool isDynamic() const {
+if (isBlockPointer()) {
+  assert(asBlockPointer().Pointee);
+  return asBlockPointer().Pointee->isDynamic();
+}
+return false;
+  }
   /// Checks if the storage is a static temporary.
   bool isStaticTemporary() const { return isStatic() && isTemporary(); }
 
diff --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index d733e3182fd59c..145bb366710f9b 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -579,6 +579,13 @@ namespace CastedDelete {
  // expected-note {{in call to}}
 }
 
+constexpr void use_after_free_2() { // both-error {{never produces a constant 
expression}}
+  struct X { constexpr void f() {} };
+  X *p = new X;
+  delete p;
+  p->f(); // both-note {{member call on heap allocated object that has been 
deleted}}
+}
+
 #else
 /// Make sure we reject this prior to C++20
 constexpr int a() { // both-error {{never produces a constant expression}}
diff --git a/clang/test/AST/ByteCode/unions.cpp 
b/clang/test/AST/ByteCode/unions.cpp
index 35b4a520baa269..7b39bb1bb9316e 100644
--- a/clang/test/AST/ByteCode/unions.cpp
+++ b/clang/test/AST/ByteCode/unions.cpp
@@ -86,7 +86,7 @@ namespace DefaultInit {
 
 #if __cplusplus >= 202002L
 namespace SimpleActivate {
-  constexpr int foo() { // ref-error {{never produces a constant expression}}
+  constexpr int foo() { // both-error {{never produces a constant expression}}
 union {
   int a;
   int b;
@@ -94,8 +94,7 @@ namespace SimpleActivate {
 
 Z.a = 10;
 Z.b = 20;
-return Z.a; // both-note {{read of member 'a' of unio

[clang] [llvm] [AArch64] Split FeatureLS64 to LS64_ACCDATA and LS64_V. (PR #101712)

2024-08-29 Thread Alexandros Lamprineas via cfe-commits


@@ -305,9 +305,17 @@ def FeatureWFxT : ExtensionWithMArch<"wfxt", "WFxT", 
"FEAT_WFxT",
 def FeatureHCX : Extension<"hcx", "HCX", "FEAT_HCX",
   "Enable Armv8.7-A HCRX_EL2 system register">;
 
-def FeatureLS64 : ExtensionWithMArch<"ls64", "LS64",
-  "FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA",
-  "Enable Armv8.7-A LD64B/ST64B Accelerator Extension">;
+def FeatureLS64 : Extension<"ls64", "LS64", "FEAT_LS64",

labrinea wrote:

I do think this will create confusion. I would prefer something like 
"ls64_no_status_result", which is also ugly but more informative. I think it is 
not worth maintaining backwards compatibility at the expense of code 
maintainability in cases like this. I consider the IR metadata to be more 
volatile than the command line or anything user facing like the .archextension 
in assembler.

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


[clang] [llvm] [AArch64] Split FeatureLS64 to LS64_ACCDATA and LS64_V. (PR #101712)

2024-08-29 Thread Alexandros Lamprineas via cfe-commits


@@ -305,9 +305,17 @@ def FeatureWFxT : ExtensionWithMArch<"wfxt", "WFxT", 
"FEAT_WFxT",
 def FeatureHCX : Extension<"hcx", "HCX", "FEAT_HCX",
   "Enable Armv8.7-A HCRX_EL2 system register">;
 
-def FeatureLS64 : ExtensionWithMArch<"ls64", "LS64",
-  "FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA",
-  "Enable Armv8.7-A LD64B/ST64B Accelerator Extension">;
+def FeatureLS64 : Extension<"ls64", "LS64", "FEAT_LS64",
+  "Enable single-copy atomic 64-byte loads and stores without status result">;
+
+def FeatureLS64_V : Extension<"ls64_v", "LS64_V", "FEAT_LS64_V",
+  "Enable single-copy atomic 64-byte stores with status result",
+  [FeatureLS64]>;
+
+let UserVisibleName = "ls64" in
+def FeatureLS64_ACCDATA : ExtensionWithMArch<"ls64_accdata", "LS64_ACCDATA", 
"FEAT_LS64_ACCDATA",

labrinea wrote:

Same here. The name `ls64` is less informative and having it alongside 
`ls64only` (or whichever name we decide) is just confusing than anything else 
in my opinion.

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


[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-29 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet updated 
https://github.com/llvm/llvm-project/pull/106241

From f8fb04379255a783f1fbdcd07cfff5846d253d32 Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Tue, 27 Aug 2024 17:56:47 +0200
Subject: [PATCH] [clang] Cleanup IncludeLocMap

CompilerInstance can re-use same SourceManager across multiple
frontendactions. During this process it calls
`SourceManager::clearIDTables` to reset any caches based on FileIDs.

It didn't reset IncludeLocMap, resulting in wrong include locations for
workflows that triggered multiple frontend-actions through same
CompilerInstance.
---
 clang/lib/Basic/SourceManager.cpp   |  1 +
 clang/unittests/Basic/SourceManagerTest.cpp | 56 +
 2 files changed, 57 insertions(+)

diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index b0256a8ce9ed04..d6ec26af80aadd 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -350,6 +350,7 @@ void SourceManager::clearIDTables() {
   LastLineNoContentCache = nullptr;
   LastFileIDLookup = FileID();
 
+  IncludedLocMap.clear();
   if (LineTable)
 LineTable->clear();
 
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp 
b/clang/unittests/Basic/SourceManagerTest.cpp
index 45840f5188cdcd..8d6e6e789cc057 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -20,6 +20,7 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Process.h"
 #include "gtest/gtest.h"
 #include 
@@ -453,6 +454,61 @@ TEST_F(SourceManagerTest, 
loadedSLocEntryIsInTheSameTranslationUnit) {
 
 #if defined(LLVM_ON_UNIX)
 
+TEST_F(SourceManagerTest, ResetsIncludeLocMap) {
+  auto ParseFile = [&] {
+TrivialModuleLoader ModLoader;
+HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+Diags, LangOpts, &*Target);
+Preprocessor PP(std::make_shared(), Diags, LangOpts,
+SourceMgr, HeaderInfo, ModLoader,
+/*IILookup =*/nullptr,
+/*OwnsHeaderSearch =*/false);
+PP.Initialize(*Target);
+PP.EnterMainSourceFile();
+PP.LexTokensUntilEOF();
+EXPECT_FALSE(Diags.hasErrorOccurred());
+  };
+
+  auto Buf = llvm::MemoryBuffer::getMemBuffer("");
+  FileEntryRef HeaderFile = FileMgr.getVirtualFileRef(
+  "/foo.h", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(HeaderFile, std::move(Buf));
+
+  Buf = llvm::MemoryBuffer::getMemBuffer(R"cpp(#include "/foo.h")cpp");
+  FileEntryRef BarFile = FileMgr.getVirtualFileRef(
+  "/bar.h", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(BarFile, std::move(Buf));
+  SourceMgr.createFileID(BarFile, {}, clang::SrcMgr::C_User);
+
+  Buf = llvm::MemoryBuffer::getMemBuffer(R"cpp(#include "/foo.h")cpp");
+  FileID MFID = SourceMgr.createFileID(std::move(Buf));
+  SourceMgr.setMainFileID(MFID);
+
+  ParseFile();
+  auto FooFID = SourceMgr.getOrCreateFileID(HeaderFile, clang::SrcMgr::C_User);
+  auto IncFID = SourceMgr.getDecomposedIncludedLoc(FooFID).first;
+  EXPECT_EQ(IncFID, MFID);
+
+  // Clean up source-manager state before we start next parse.
+  SourceMgr.clearIDTables();
+
+  // Set up a new main file.
+  Buf = llvm::MemoryBuffer::getMemBuffer(R"cpp(
+  // silly comment 42
+  #include "/bar.h")cpp");
+  MFID = SourceMgr.createFileID(std::move(Buf));
+  SourceMgr.setMainFileID(MFID);
+
+  ParseFile();
+  // Make sure foo.h got the same file-id in both runs.
+  EXPECT_EQ(FooFID,
+SourceMgr.getOrCreateFileID(HeaderFile, clang::SrcMgr::C_User));
+  auto BarFID = SourceMgr.getOrCreateFileID(BarFile, clang::SrcMgr::C_User);
+  IncFID = SourceMgr.getDecomposedIncludedLoc(FooFID).first;
+  // Check that includer is bar.h during this run.
+  EXPECT_EQ(IncFID, BarFID);
+}
+
 TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
   const char *header =
 "#define FM(x,y) x\n";

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


[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-29 Thread kadir çetinkaya via cfe-commits


@@ -350,6 +350,7 @@ void SourceManager::clearIDTables() {
   LastLineNoContentCache = nullptr;
   LastFileIDLookup = FileID();
 
+  IncludedLocMap.clear();

kadircet wrote:

done

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


[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-29 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff fdca2c33a1f33f4886d969ea0f0219764c7b6b59 
f8fb04379255a783f1fbdcd07cfff5846d253d32 --extensions cpp -- 
clang/lib/Basic/SourceManager.cpp clang/unittests/Basic/SourceManagerTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp 
b/clang/unittests/Basic/SourceManagerTest.cpp
index 8d6e6e789c..7e48cb5313 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -470,13 +470,13 @@ TEST_F(SourceManagerTest, ResetsIncludeLocMap) {
   };
 
   auto Buf = llvm::MemoryBuffer::getMemBuffer("");
-  FileEntryRef HeaderFile = FileMgr.getVirtualFileRef(
-  "/foo.h", Buf->getBufferSize(), 0);
+  FileEntryRef HeaderFile =
+  FileMgr.getVirtualFileRef("/foo.h", Buf->getBufferSize(), 0);
   SourceMgr.overrideFileContents(HeaderFile, std::move(Buf));
 
   Buf = llvm::MemoryBuffer::getMemBuffer(R"cpp(#include "/foo.h")cpp");
-  FileEntryRef BarFile = FileMgr.getVirtualFileRef(
-  "/bar.h", Buf->getBufferSize(), 0);
+  FileEntryRef BarFile =
+  FileMgr.getVirtualFileRef("/bar.h", Buf->getBufferSize(), 0);
   SourceMgr.overrideFileContents(BarFile, std::move(Buf));
   SourceMgr.createFileID(BarFile, {}, clang::SrcMgr::C_User);
 

``




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


[clang] [C++20] [Modules] Embed all source files for C++20 Modules (PR #102444)

2024-08-29 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> > Was this discussed/reviewed/motivated? There are drawbacks to this approach 
> > outlined in #72383
> > @iains @jyknight @AaronBallman @Bigcheese
> 
> The motivation is in #72383 and I comment in [#72383 
> (comment)](https://github.com/llvm/llvm-project/issues/72383#issuecomment-2275135890)
> 
> This is not reviewed. I wait for several weeks but got no response. And I 
> think it is good. So I choose to land it.

Thank you for the link! (FWIW, there's no problems with these changes having 
been landed; @ChuanqiXu9 is the code owner for modules and the PR was up for 
three weeks without discussion. This is just typical post-commit review 
feedback.)

There's a fair amount of discussion on that thread in opposition to this 
approach, and a comment thread on an issue is not really visible to many 
people. I think this warrants an RFC for a broader discussion, so I'd 
appreciate temporarily reverting this patch.

Some thoughts for the RFC discussion:

* Given that this is not the default behavior for MSVC, should `clang-cl` 
behave differently than `clang`?
* What are the impacts on other tooling (debugger, 3rd party static analysis, 
etc)?
* Is this the correct default when considering intellectual property security 
(will people expect their full, original source to be something that can be 
pulled from these artifacts)?

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


[clang] cb608cc - [clang][bytecode] Properly diagnose non-const reads (#106514)

2024-08-29 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-08-29T13:44:59+02:00
New Revision: cb608cc5f62baa01fe106a14ef41971337c2c030

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

LOG: [clang][bytecode] Properly diagnose non-const reads (#106514)

If the global variable is constant (but not constexpr), we need to
diagnose, but keep evaluating.

Added: 
clang/test/AST/ByteCode/cxx11-pedantic.cpp

Modified: 
clang/lib/AST/ByteCode/Interp.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 09d3f4525138ed..0cd106b74d1504 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -323,36 +323,52 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr,
 bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
   assert(Desc);
 
-  auto IsConstType = [&S](const VarDecl *VD) -> bool {
-QualType T = VD->getType();
-
-if (T.isConstant(S.getASTContext()))
-  return true;
-
-if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11)
-  return (T->isSignedIntegerOrEnumerationType() ||
-  T->isUnsignedIntegerOrEnumerationType()) &&
- T.isConstQualified();
+  const auto *D = Desc->asVarDecl();
+  if (!D || !D->hasGlobalStorage())
+return true;
 
-if (T.isConstQualified())
-  return true;
+  if (D == S.EvaluatingDecl)
+return true;
 
-if (const auto *RT = T->getAs())
-  return RT->getPointeeType().isConstQualified();
+  if (D->isConstexpr())
+return true;
 
-if (const auto *PT = T->getAs())
-  return PT->getPointeeType().isConstQualified();
+  QualType T = D->getType();
+  bool IsConstant = T.isConstant(S.getASTContext());
+  if (T->isIntegralOrEnumerationType()) {
+if (!IsConstant) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
+  }
 
-return false;
-  };
+  if (IsConstant) {
+if (S.getLangOpts().CPlusPlus) {
+  S.CCEDiag(S.Current->getLocation(OpPC),
+S.getLangOpts().CPlusPlus11
+? diag::note_constexpr_ltor_non_constexpr
+: diag::note_constexpr_ltor_non_integral,
+1)
+  << D << T;
+  S.Note(D->getLocation(), diag::note_declared_at);
+} else {
+  S.CCEDiag(S.Current->getLocation(OpPC));
+}
+return true;
+  }
 
-  if (const auto *D = Desc->asVarDecl();
-  D && D->hasGlobalStorage() && D != S.EvaluatingDecl && !IsConstType(D)) {
-diagnoseNonConstVariable(S, OpPC, D);
-return false;
+  if (T->isPointerOrReferenceType()) {
+if (!T->getPointeeType().isConstant(S.getASTContext()) ||
+!S.getLangOpts().CPlusPlus11) {
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
+}
+return true;
   }
 
-  return true;
+  diagnoseNonConstVariable(S, OpPC, D);
+  return false;
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {

diff  --git a/clang/test/AST/ByteCode/cxx11-pedantic.cpp 
b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
new file mode 100644
index 00..8779a2826c50db
--- /dev/null
+++ b/clang/test/AST/ByteCode/cxx11-pedantic.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter 
-verify=both,expected -std=c++11 -triple x86_64-linux -pedantic %s
+// RUN: %clang_cc1 -verify=both,ref -std=c++11 -triple x86_64-linux -pedantic 
%s
+
+struct T { int n; };
+const T t = { 42 }; // both-note 2{{declared here}}
+struct S {
+  int m : t.n; // both-warning {{width of bit-field 'm' (42 bits)}} \
+   // both-warning {{expression is not an integral constant 
expression}} \
+   // both-note {{read of non-constexpr variable 't' is not 
allowed}}
+};
+
+static_assert(t.n == 42, ""); // both-error {{expression is not an integral 
constant expression}} \
+  // both-note {{read of non-constexpr variable 
't' is not allowed}}



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


[clang] [clang][bytecode] Properly diagnose non-const reads (PR #106514)

2024-08-29 Thread Timm Baeder via cfe-commits

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


[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits


@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclarationOrFunctionDefinition(
   // Add an enclosing time trace scope for a bunch of small scopes with
   // "EvaluateAsConstExpr".
   llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() 
{
-return Tok.getLocation().printToString(
-Actions.getASTContext().getSourceManager());
+llvm::TimeTraceMetadata M;

usx95 wrote:

Added column information as well. The source range (begin and end column) might 
also be interesting for EvaluateExpr* thing but I am omitting them as of now.

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


[clang] [clang-tools-extra] [clang] Hide the `DiagnosticOptions` pointer from `CompilerInvocation` (PR #106274)

2024-08-29 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

yes turning diagnosticoptions to be a ThreadSafeRefCountedBase pointer should 
ensure we have similar guarantees. so LG from clangd side, but I am not sure 
about implications on using thread-aware structs in core parts of clang. so it 
might be worthwhile to get some opinions from clang maintainers as well.

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


[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits


@@ -223,15 +223,15 @@ Frontend (test.cc)
 | | | | EvaluateAsRValue ()
 | | | EvaluateAsBooleanCondition ()
 | | | | EvaluateAsRValue ()
-| ParseDeclarationOrFunctionDefinition (test.cc:16:1)
+| ParseDeclarationOrFunctionDefinition (test.cc:16)
 | | ParseFunctionDefinition (slow_test)
 | | | EvaluateAsInitializer (slow_value)
 | | | EvaluateAsConstantExpr ()

usx95 wrote:

Changed all of them to same structure

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


[clang-tools-extra] [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit (PR #106430)

2024-08-29 Thread Haojian Wu via cfe-commits

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


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


[clang-tools-extra] [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit (PR #106430)

2024-08-29 Thread Haojian Wu via cfe-commits


@@ -203,7 +203,7 @@ class ASTWalker : public RecursiveASTVisitor {
   bool VisitUsingDecl(UsingDecl *UD) {
 for (const auto *Shadow : UD->shadows()) {
   auto *TD = Shadow->getTargetDecl();
-  auto IsUsed = TD->isUsed() || TD->isReferenced();
+  auto IsUsed = TD->isUsed() || TD->isReferenced() || !TD->getAsFunction();

hokein wrote:

The connection between usedness and `!TD->getAsFunction()` wasn’t immediately 
obvious to me. With the newly-added comment, it's much clearer now, everything 
looks good, thanks.

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


[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread via cfe-commits

https://github.com/ivanaivanovska updated 
https://github.com/llvm/llvm-project/pull/103039

>From 6d3e4470dfe21f8f3832a2d38b4c4327aa7422a3 Mon Sep 17 00:00:00 2001
From: Ivana Ivanovska 
Date: Tue, 13 Aug 2024 10:30:34 +
Subject: [PATCH 1/3] Added instant events and marking defered templated
 instantiation.

---
 clang/lib/Sema/SemaExpr.cpp   | 18 ++
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  | 17 +
 clang/unittests/Support/TimeProfilerTest.cpp  | 51 ++-
 llvm/include/llvm/Support/TimeProfiler.h  | 19 +-
 llvm/lib/Support/TimeProfiler.cpp | 64 +--
 5 files changed, 145 insertions(+), 24 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 95f53dfefbcc52..9e88fe5a94289d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -64,6 +65,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/SaveAndRestore.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/TypeSize.h"
 #include 
 
@@ -18046,6 +18048,22 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, 
FunctionDecl *Func,
 std::make_pair(Func, PointOfInstantiation));
 // Notify the consumer that a function was implicitly instantiated.
 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
+
+llvm::TimeTraceScope TimeScope(
+"DeferInstantiation",
+[&]() {
+  llvm::TimeTraceMetadata M;
+  llvm::raw_string_ostream OS(M.Detail);
+  Func->getNameForDiagnostic(OS, getPrintingPolicy(),
+ /*Qualified=*/true);
+  if (llvm::isTimeTraceVerbose()) {
+auto Loc = SourceMgr.getExpansionLoc(Func->getLocation());
+M.File = SourceMgr.getFilename(Loc);
+M.Line = SourceMgr.getExpansionLineNumber(Loc);
+  }
+  return M;
+},
+llvm::TimeTraceEventType::InstantEvent);
   }
 }
   } else {
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0e064be2391838..191f46ed00b7cc 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4983,6 +4983,23 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
   Function->setInstantiationIsPending(true);
   PendingInstantiations.push_back(
 std::make_pair(Function, PointOfInstantiation));
+
+  llvm::TimeTraceScope TimeScope(
+  "DeferInstantiation",
+  [&]() {
+llvm::TimeTraceMetadata M;
+llvm::raw_string_ostream OS(M.Detail);
+Function->getNameForDiagnostic(OS, getPrintingPolicy(),
+   /*Qualified=*/true);
+if (llvm::isTimeTraceVerbose()) {
+  auto Loc = SourceMgr.getExpansionLoc(Function->getLocation());
+  M.File = SourceMgr.getFilename(Loc);
+  M.Line = SourceMgr.getExpansionLineNumber(Loc);
+}
+return M;
+  },
+  llvm::TimeTraceEventType::InstantEvent);
+
 } else if (TSK == TSK_ImplicitInstantiation) {
   if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
   !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) {
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index f53fe71d630bf5..ccda12e943dd73 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -238,13 +238,55 @@ Frontend (test.cc)
 buildTraceGraph(Json));
 }
 
+TEST(TimeProfilerTest, ClassTemplateInstantiations) {
+  std::string Code = R"(
+template
+struct S
+{
+  void foo() {}
+  void bar();
+};
+
+template struct S; // explicit instantiation of S
+
+void user() {
+  S a; // implicit instantiation of S
+  S* b;
+  b->foo(); // implicit instatiation of S and S::foo()
+}
+  )";
+
+  setupProfiler();
+  ASSERT_TRUE(compileFromString(Code, "-std=c++20", "test.cc"));
+  std::string Json = teardownProfiler();
+  ASSERT_EQ(R"(
+Frontend (test.cc)
+| ParseClass (S)
+| InstantiateClass (S, test.cc:9)
+| InstantiateFunction (S::foo, test.cc:5)
+| ParseDeclarationOrFunctionDefinition (test.cc:11:5)
+| | ParseFunctionDefinition (user)
+| | | InstantiateClass (S, test.cc:3)
+| | | InstantiateClass (S, test.cc:3)
+| | | DeferInstantiatio

[clang] [Clang] prevent assertion failure when converting vectors to int/float with invalid expressions (PR #105727)

2024-08-29 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/105727

>From d8bed3f4db8056a6afa9bd7eae5d4a8361f83086 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Thu, 22 Aug 2024 23:25:31 +0300
Subject: [PATCH 1/2] [Clang] prevent assertion failure when converting vectors
 to int/float with invalid expressions

---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaExpr.cpp   |  6 ++
 clang/test/SemaCXX/vector.cpp | 14 ++
 3 files changed, 21 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 12a924acc14331..27aac987011dea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -296,6 +296,7 @@ Bug Fixes to C++ Support
   template depth than the friend function template. (#GH98258)
 - Clang now rebuilds the template parameters of out-of-line declarations and 
specializations in the context
   of the current instantiation in all cases.
+- Fixed an assertion failure when converting vectors to int/float with invalid 
expressions. (#GH105486)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c67183df335dd5..58825ef89213d2 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9889,6 +9889,9 @@ static ExprResult convertVector(Expr *E, QualType 
ElementType, Sema &S) {
 /// IntTy without losing precision.
 static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
   QualType OtherIntTy) {
+  if (Int->get()->isValueDependent())
+return false;
+
   QualType IntTy = Int->get()->getType().getUnqualifiedType();
 
   // Reject cases where the value of the Int is unknown as that would
@@ -9927,6 +9930,9 @@ static bool canConvertIntToOtherIntTy(Sema &S, ExprResult 
*Int,
 /// FloatTy without losing precision.
 static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int,
  QualType FloatTy) {
+  if (Int->get()->isValueDependent())
+return false;
+
   QualType IntTy = Int->get()->getType().getUnqualifiedType();
 
   // Determine if the integer constant can be expressed as a floating point
diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp
index 7c8ee89814e578..808bdb679b09cd 100644
--- a/clang/test/SemaCXX/vector.cpp
+++ b/clang/test/SemaCXX/vector.cpp
@@ -772,3 +772,17 @@ void test_scoped_enum_vector(EnumClass ea, v2u v2ua) {
 }
 #endif
 }
+
+namespace GH105486 {
+__attribute__((__vector_size__(sizeof(double double a;
+double b = a - (long)(*0); // expected-error {{indirection requires pointer 
operand ('int' invalid)}} \
+   // expected-error {{cannot initialize a variable of 
type 'double' with an rvalue of type '__attribute__((__vector_size__(1 * 
sizeof(double double' (vector of 1 'double' value)}}
+
+__attribute__((__vector_size__(sizeof(long long c;
+long d = c - (long)(*0); // expected-error {{indirection requires pointer 
operand ('int' invalid)}} \
+ // expected-error {{cannot initialize a variable of 
type 'long' with an rvalue of type '__attribute__((__vector_size__(1 * 
sizeof(long long' (vector of 1 'long' value)}}
+
+const long long e = *0; // expected-error {{indirection requires pointer 
operand ('int' invalid)}}
+double f = a - e;   // expected-error {{cannot initialize a variable of 
type 'double' with an rvalue of type '__attribute__((__vector_size__(1 * 
sizeof(double double' (vector of 1 'double' value)}}
+int h = c - e;  // expected-error {{cannot initialize a variable of 
type 'int' with an rvalue of type '__attribute__((__vector_size__(1 * 
sizeof(long long' (vector of 1 'long' value)}}
+}

>From 3a3832464269585858b384b61c9f879050774be4 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Tue, 27 Aug 2024 18:58:09 +0300
Subject: [PATCH 2/2] use containsErrors

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

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e419606ab96753..de316f30e9523d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9888,7 +9888,7 @@ static ExprResult convertVector(Expr *E, QualType 
ElementType, Sema &S) {
 /// IntTy without losing precision.
 static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
   QualType OtherIntTy) {
-  if (Int->get()->isValueDependent())
+  if (Int->get()->containsErrors())
 return false;
 
   QualType IntTy = Int->get()->getType().getUnqualifiedType();
@@ -9929,7 +9929,7 @@ static bool canConvertIntToOtherIntTy(Sema &S, ExprResult 
*Int,
 /// FloatTy without losing precision.
 static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int,
  QualType FloatTy) {
-  if (Int->get()->isValueDependent())
+  if (Int->get()->containsErrors())
 return false;
 
   QualType 

[clang-tools-extra] acff429 - [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit (#106430)

2024-08-29 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2024-08-29T14:23:57+02:00
New Revision: acff429191a27a164a0941346ce0c73e953d4638

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

LOG: [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit 
(#106430)

We were reporting ambigious references from using declarations as user
can be depending on different overloads of a function just because they
are visible in the TU.
This doesn't apply to records, or primary templates as declaration being
referenced in such cases is unambigious, the ambiguity applies to
specializations though.

Hence this patch returns an explicit reference to record decls and
primary templates of those.

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index 598484d09712e5..f7a2ebd5260681 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -203,7 +203,12 @@ class ASTWalker : public RecursiveASTVisitor {
   bool VisitUsingDecl(UsingDecl *UD) {
 for (const auto *Shadow : UD->shadows()) {
   auto *TD = Shadow->getTargetDecl();
-  auto IsUsed = TD->isUsed() || TD->isReferenced();
+  // For function-decls, we might have overloads brought in due to
+  // transitive dependencies. Hence we only want to report explicit
+  // references for those if they're used.
+  // But for record decls, spelling of the type always refers to primary
+  // decl non-ambiguously. Hence spelling is already a use.
+  auto IsUsed = TD->isUsed() || TD->isReferenced() || !TD->getAsFunction();
   report(UD->getLocation(), TD,
  IsUsed ? RefType::Explicit : RefType::Ambiguous);
 

diff  --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index 6c8eacbff1cea3..9286758cab081c 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -255,7 +255,7 @@ TEST(WalkAST, TemplateSpecializationsFromUsingDecl) {
   // Class templates
   testWalk(R"cpp(
 namespace ns {
-template class $ambiguous^Z {};  // primary template
+template class $explicit^Z {};  // primary template
 template class $ambiguous^Z {};  // partial specialization
 template<> class $ambiguous^Z {};// full specialization
 }
@@ -265,7 +265,7 @@ template<> class $ambiguous^Z {};// full 
specialization
   // Var templates
   testWalk(R"cpp(
 namespace ns {
-template T $ambiguous^foo;  // primary template
+template T $explicit^foo;  // primary template
 template T $ambiguous^foo;  // partial specialization
 template<> int* $ambiguous^foo; // full specialization
 }
@@ -335,7 +335,12 @@ TEST(WalkAST, Using) {
   testWalk(R"cpp(
 namespace ns {
   template
-  class $ambiguous^Y {};
+  class $explicit^Y {};
+})cpp",
+   "using ns::^Y;");
+  testWalk(R"cpp(
+namespace ns {
+  class $explicit^Y {};
 })cpp",
"using ns::^Y;");
   testWalk(R"cpp(



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


[clang-tools-extra] [include-cleaner] Mark RecordDecls referenced in UsingDecls as explicit (PR #106430)

2024-08-29 Thread kadir çetinkaya via cfe-commits

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


[clang] [clang] Output location info in separate fields for -ftime-trace (PR #106277)

2024-08-29 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/106277

>From b2bb29ec61f4e9a7b3b7f9bcd0f5b7a12c844d14 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 27 Aug 2024 19:44:34 +
Subject: [PATCH 1/3] [clang] Properly set file and line info for -ftime-trace

---
 clang/lib/Parse/Parser.cpp |  9 +++--
 ...-trace-ParseDeclarationOrFunctionDefinition.cpp |  3 ++-
 clang/unittests/Support/TimeProfilerTest.cpp   | 14 +++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 5ebe71e496a2e8..cc16a9d98d0ca6 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclarationOrFunctionDefinition(
   // Add an enclosing time trace scope for a bunch of small scopes with
   // "EvaluateAsConstExpr".
   llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() 
{
-return Tok.getLocation().printToString(
-Actions.getASTContext().getSourceManager());
+llvm::TimeTraceMetadata M;
+const SourceManager &SM = Actions.getASTContext().getSourceManager();
+auto Loc = SM.getExpansionLoc(Tok.getLocation());
+M.File = SM.getFilename(Loc);
+M.Line = SM.getExpansionLineNumber(Loc);
+return M;
   });
 
   if (DS) {
diff --git 
a/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp 
b/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp
index f854cddadbfcc1..8a1127752b325b 100644
--- 
a/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp
+++ 
b/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp
@@ -4,7 +4,8 @@
 // RUN:   | FileCheck %s
 
 // CHECK-DAG: "name": "ParseDeclarationOrFunctionDefinition"
-// CHECK-DAG: "detail": 
"{{.*}}check-time-trace-ParseDeclarationOrFunctionDefinition.cpp:15:1"
+// CHECK-DAG: "file": 
"{{.*}}check-time-trace-ParseDeclarationOrFunctionDefinition.cpp"
+// CHECK-DAG: "line": 16
 // CHECK-DAG: "name": "ParseFunctionDefinition"
 // CHECK-DAG: "detail": "foo"
 // CHECK-DAG: "name": "ParseFunctionDefinition"
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index f53fe71d630bf5..6d8b4e0453294f 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -210,8 +210,8 @@ constexpr int slow_init_list[] = {1, 1, 2, 3, 5, 8, 13, 
21}; // 25th line
   std::string Json = teardownProfiler();
   ASSERT_EQ(R"(
 Frontend (test.cc)
-| ParseDeclarationOrFunctionDefinition (test.cc:2:1)
-| ParseDeclarationOrFunctionDefinition (test.cc:6:1)
+| ParseDeclarationOrFunctionDefinition (test.cc:2)
+| ParseDeclarationOrFunctionDefinition (test.cc:6)
 | | ParseFunctionDefinition (slow_func)
 | | | EvaluateAsRValue ()
 | | | EvaluateForOverflow ()
@@ -223,15 +223,15 @@ Frontend (test.cc)
 | | | | EvaluateAsRValue ()
 | | | EvaluateAsBooleanCondition ()
 | | | | EvaluateAsRValue ()
-| ParseDeclarationOrFunctionDefinition (test.cc:16:1)
+| ParseDeclarationOrFunctionDefinition (test.cc:16)
 | | ParseFunctionDefinition (slow_test)
 | | | EvaluateAsInitializer (slow_value)
 | | | EvaluateAsConstantExpr ()
 | | | EvaluateAsConstantExpr ()
-| ParseDeclarationOrFunctionDefinition (test.cc:22:1)
+| ParseDeclarationOrFunctionDefinition (test.cc:22)
 | | EvaluateAsConstantExpr ()
 | | EvaluateAsRValue ()
-| ParseDeclarationOrFunctionDefinition (test.cc:25:1)
+| ParseDeclarationOrFunctionDefinition (test.cc:25)
 | | EvaluateAsInitializer (slow_init_list)
 | PerformPendingInstantiations
 )",
@@ -270,7 +270,7 @@ Frontend (test.cc)
 | ParseFunctionDefinition (fooB)
 | ParseFunctionDefinition (fooMTA)
 | ParseFunctionDefinition (fooA)
-| ParseDeclarationOrFunctionDefinition (test.cc:3:5)
+| ParseDeclarationOrFunctionDefinition (test.cc:3)
 | | ParseFunctionDefinition (user)
 | PerformPendingInstantiations
 | | InstantiateFunction (fooA, a.h:7)
@@ -292,7 +292,7 @@ struct {
   std::string Json = teardownProfiler();
   ASSERT_EQ(R"(
 Frontend (test.c)
-| ParseDeclarationOrFunctionDefinition (test.c:2:1)
+| ParseDeclarationOrFunctionDefinition (test.c:2)
 | | isIntegerConstantExpr ()
 | | EvaluateKnownConstIntCheckOverflow ()
 | PerformPendingInstantiations

>From 126fbc39d71d1ae674cfa2a0b23f994c7420ad9b Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 27 Aug 2024 20:03:42 +
Subject: [PATCH 2/3] Add release notes

---
 clang/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b165f6e65636d9

  1   2   3   4   5   >