[clang] ece5dd1 - [clang] Stop including llvm/ADT/StringMap.h (NFC)

2023-10-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-10-13T21:34:23-07:00
New Revision: ece5dd101c7e4dc2fd23428abd312f75fd3d3eaf

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

LOG: [clang] Stop including llvm/ADT/StringMap.h (NFC)

These source files do not use StringMap.h.

Added: 


Modified: 
clang/lib/ASTMatchers/GtestMatchers.cpp
clang/lib/Basic/Sarif.cpp
clang/lib/Driver/Multilib.cpp
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/GtestMatchers.cpp 
b/clang/lib/ASTMatchers/GtestMatchers.cpp
index 6e4c12f319692fa..a556d8ef2da0665 100644
--- a/clang/lib/ASTMatchers/GtestMatchers.cpp
+++ b/clang/lib/ASTMatchers/GtestMatchers.cpp
@@ -21,7 +21,6 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {

diff  --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp
index bef948181ec014b..3476103cc39d408 100644
--- a/clang/lib/Basic/Sarif.cpp
+++ b/clang/lib/Basic/Sarif.cpp
@@ -20,7 +20,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/JSON.h"

diff  --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index a37dffc8a6f1d2c..ba466af39e2dcaf 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -10,7 +10,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"

diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index 66e9a501c348eb5..268fc742f050fe6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -32,7 +32,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp 
b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index c105db434dc43c9..597ee194fc8d4b1 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -10,7 +10,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/ErrorHandling.h"

diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 90c475e541f4c33..7ad6c19482b11de 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -19,7 +19,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/ArchiveWriter.h"



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


[clang] 18d1991 - Stop including llvm/ADT/STLFunctionalExtras.h (NFC)

2023-10-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-10-13T20:50:58-07:00
New Revision: 18d199116fe2150549110da68ac0ca8cfd80f9c8

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

LOG: Stop including llvm/ADT/STLFunctionalExtras.h (NFC)

These source files do not use function_ref.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/Formula.h
clang/lib/ExtractAPI/API.cpp
llvm/include/llvm/IRReader/IRReader.h
llvm/include/llvm/Support/ThreadSafeAllocator.h
llvm/tools/llvm-readobj/ObjDumper.h
openmp/libomptarget/include/Utilities.h

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 5126fda8440..9a6c6d2b2f45f58 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -13,7 +13,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
-#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/raw_ostream.h"
 #include 

diff  --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 2973a31345c9b2d..71c655ba5b5b32c 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -17,7 +17,6 @@
 #include "clang/AST/CommentLexer.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/Index/USRGeneration.h"
-#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 

diff  --git a/llvm/include/llvm/IRReader/IRReader.h 
b/llvm/include/llvm/IRReader/IRReader.h
index 644fea82bfbe056..4d690dcaf1c43e3 100644
--- a/llvm/include/llvm/IRReader/IRReader.h
+++ b/llvm/include/llvm/IRReader/IRReader.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_IRREADER_IRREADER_H
 #define LLVM_IRREADER_IRREADER_H
 
-#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include 

diff  --git a/llvm/include/llvm/Support/ThreadSafeAllocator.h 
b/llvm/include/llvm/Support/ThreadSafeAllocator.h
index 3092287e691f754..8c56bb6e5803d5f 100644
--- a/llvm/include/llvm/Support/ThreadSafeAllocator.h
+++ b/llvm/include/llvm/Support/ThreadSafeAllocator.h
@@ -10,7 +10,6 @@
 #define LLVM_SUPPORT_THREADSAFEALLOCATOR_H
 
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/Support/Allocator.h"
 #include 
 

diff  --git a/llvm/tools/llvm-readobj/ObjDumper.h 
b/llvm/tools/llvm-readobj/ObjDumper.h
index a44fa42b85c9b0e..fe588047e962cd9 100644
--- a/llvm/tools/llvm-readobj/ObjDumper.h
+++ b/llvm/tools/llvm-readobj/ObjDumper.h
@@ -13,7 +13,6 @@
 #include 
 #include 
 
-#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"

diff  --git a/openmp/libomptarget/include/Utilities.h 
b/openmp/libomptarget/include/Utilities.h
index 7f2884ed7ea06ff..82593e206e4d032 100644
--- a/openmp/libomptarget/include/Utilities.h
+++ b/openmp/libomptarget/include/Utilities.h
@@ -14,7 +14,6 @@
 #ifndef OPENMP_LIBOMPTARGET_INCLUDE_UTILITIES_H
 #define OPENMP_LIBOMPTARGET_INCLUDE_UTILITIES_H
 
-#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 



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


[clang] [clang] Additional FP classification functions (PR #69041)

2023-10-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Serge Pavlov (spavloff)


Changes

C language standard defined library functions `iszero`, `issignaling` and 
`issubnormal`, which did not have counterparts among clang builtin functions. 
This change adds new functions:

__builtin_iszero
__builtin_issubnormal
__builtin_issignaling

They provide builtin implementation for the missing standard functions.

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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/Builtins.def (+3) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+24) 
- (modified) clang/test/CodeGen/builtins.c (+15) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2d918967e7f0b02..2453804cd7735be 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -621,6 +621,8 @@ Floating Point Support in Clang
 - Add ``__builtin_exp10``, ``__builtin_exp10f``,
   ``__builtin_exp10f16``, ``__builtin_exp10l`` and
   ``__builtin_exp10f128`` builtins.
+- Add ``__builtin_iszero``, ``__builtin_issignaling`` and
+  ``__builtin_issubnormal``.
 
 AST Matchers
 
diff --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 6ea8484606cfd5d..ebcb5b45e5bdc23 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -494,6 +494,9 @@ BUILTIN(__builtin_isinf,  "i.", "FnctE")
 BUILTIN(__builtin_isinf_sign, "i.", "FnctE")
 BUILTIN(__builtin_isnan,  "i.", "FnctE")
 BUILTIN(__builtin_isnormal,   "i.", "FnctE")
+BUILTIN(__builtin_issubnormal,"i.", "FnctE")
+BUILTIN(__builtin_iszero, "i.", "FnctE")
+BUILTIN(__builtin_issignaling,"i.", "FnctE")
 BUILTIN(__builtin_isfpclass,  "i.", "nctE")
 
 // FP signbit builtins
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8cb7943df9a7822..5d3946a84b6c34a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3287,6 +3287,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
ConvertType(E->getType(;
   }
 
+  case Builtin::BI__builtin_issignaling: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+Value *V = EmitScalarExpr(E->getArg(0));
+return RValue::get(
+Builder.CreateZExt(Builder.createIsFPClass(V, FPClassTest::fcSNan),
+   ConvertType(E->getType(;
+  }
+
   case Builtin::BI__builtin_isinf: {
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 Value *V = EmitScalarExpr(E->getArg(0));
@@ -3321,6 +3329,22 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
ConvertType(E->getType(;
   }
 
+  case Builtin::BI__builtin_issubnormal: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+Value *V = EmitScalarExpr(E->getArg(0));
+return RValue::get(
+Builder.CreateZExt(Builder.createIsFPClass(V, 
FPClassTest::fcSubnormal),
+   ConvertType(E->getType(;
+  }
+
+  case Builtin::BI__builtin_iszero: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+Value *V = EmitScalarExpr(E->getArg(0));
+return RValue::get(
+Builder.CreateZExt(Builder.createIsFPClass(V, FPClassTest::fcZero),
+   ConvertType(E->getType(;
+  }
+
   case Builtin::BI__builtin_isfpclass: {
 Expr::EvalResult Result;
 if (!E->getArg(1)->EvaluateAsInt(Result, CGM.getContext()))
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 1b1b2cd6413a344..ce1182b724dcc21 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -64,6 +64,9 @@ int main(void) {
   P(isinf_sign, (1.));
   P(isnan, (1.));
   P(isfinite, (1.));
+  P(iszero, (1.));
+  P(issubnormal, (1.));
+  P(issignaling, (1.));
   P(isfpclass, (1., 1));
 
   // Bitwise & Numeric Functions
@@ -270,6 +273,18 @@ void test_float_builtins(__fp16 *H, float F, double D, 
long double LD) {
   // CHECK: [[TMP:%.*]] = call i1 @llvm.is.fpclass.f32(float {{.*}}, i32 264)
   // CHECK: zext i1 [[TMP]] to i32
 
+  res = __builtin_issubnormal(F);
+  // CHECK: [[TMP:%.*]] = call i1 @llvm.is.fpclass.f32(float {{.*}}, i32 144)
+  // CHECK: zext i1 [[TMP]] to i32
+
+  res = __builtin_iszero(F);
+  // CHECK: [[TMP:%.*]] = call i1 @llvm.is.fpclass.f32(float {{.*}}, i32 96)
+  // CHECK: zext i1 [[TMP]] to i32
+
+  res = __builtin_issignaling(F);
+  // CHECK: [[TMP:%.*]] = call i1 @llvm.is.fpclass.f32(float {{.*}}, i32 1)
+  // CHECK: zext i1 [[TMP]] to i32
+
   res = __builtin_flt_rounds();
   // CHECK: call i32 @llvm.get.rounding(
 }

``




https://github.com/llvm/llvm-project/pull/69041
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] [clang] Additional FP classification functions (PR #69041)

2023-10-13 Thread Serge Pavlov via cfe-commits

https://github.com/spavloff created 
https://github.com/llvm/llvm-project/pull/69041

C language standard defined library functions `iszero`, `issignaling` and 
`issubnormal`, which did not have counterparts among clang builtin functions. 
This change adds new functions:

__builtin_iszero
__builtin_issubnormal
__builtin_issignaling

They provide builtin implementation for the missing standard functions.

>From 1374e323198d7188e688845eb951df4148a1dfd8 Mon Sep 17 00:00:00 2001
From: Serge Pavlov 
Date: Wed, 11 Oct 2023 14:27:26 +0700
Subject: [PATCH] [clang] Additional FP classification functions

C language standard defined library functions `iszero`, `issignaling`
and `issubnormal`, which did not have counterparts among clang
builtin functions. This change adds new functions:

__builtin_iszero
__builtin_issubnormal
__builtin_issignaling

They provide builtin implementation for the missing standard functions.
---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/include/clang/Basic/Builtins.def |  3 +++
 clang/lib/CodeGen/CGBuiltin.cpp| 24 
 clang/test/CodeGen/builtins.c  | 15 +++
 4 files changed, 44 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2d918967e7f0b02..2453804cd7735be 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -621,6 +621,8 @@ Floating Point Support in Clang
 - Add ``__builtin_exp10``, ``__builtin_exp10f``,
   ``__builtin_exp10f16``, ``__builtin_exp10l`` and
   ``__builtin_exp10f128`` builtins.
+- Add ``__builtin_iszero``, ``__builtin_issignaling`` and
+  ``__builtin_issubnormal``.
 
 AST Matchers
 
diff --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 6ea8484606cfd5d..ebcb5b45e5bdc23 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -494,6 +494,9 @@ BUILTIN(__builtin_isinf,  "i.", "FnctE")
 BUILTIN(__builtin_isinf_sign, "i.", "FnctE")
 BUILTIN(__builtin_isnan,  "i.", "FnctE")
 BUILTIN(__builtin_isnormal,   "i.", "FnctE")
+BUILTIN(__builtin_issubnormal,"i.", "FnctE")
+BUILTIN(__builtin_iszero, "i.", "FnctE")
+BUILTIN(__builtin_issignaling,"i.", "FnctE")
 BUILTIN(__builtin_isfpclass,  "i.", "nctE")
 
 // FP signbit builtins
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8cb7943df9a7822..5d3946a84b6c34a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3287,6 +3287,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
ConvertType(E->getType(;
   }
 
+  case Builtin::BI__builtin_issignaling: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+Value *V = EmitScalarExpr(E->getArg(0));
+return RValue::get(
+Builder.CreateZExt(Builder.createIsFPClass(V, FPClassTest::fcSNan),
+   ConvertType(E->getType(;
+  }
+
   case Builtin::BI__builtin_isinf: {
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 Value *V = EmitScalarExpr(E->getArg(0));
@@ -3321,6 +3329,22 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
ConvertType(E->getType(;
   }
 
+  case Builtin::BI__builtin_issubnormal: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+Value *V = EmitScalarExpr(E->getArg(0));
+return RValue::get(
+Builder.CreateZExt(Builder.createIsFPClass(V, 
FPClassTest::fcSubnormal),
+   ConvertType(E->getType(;
+  }
+
+  case Builtin::BI__builtin_iszero: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+Value *V = EmitScalarExpr(E->getArg(0));
+return RValue::get(
+Builder.CreateZExt(Builder.createIsFPClass(V, FPClassTest::fcZero),
+   ConvertType(E->getType(;
+  }
+
   case Builtin::BI__builtin_isfpclass: {
 Expr::EvalResult Result;
 if (!E->getArg(1)->EvaluateAsInt(Result, CGM.getContext()))
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 1b1b2cd6413a344..ce1182b724dcc21 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -64,6 +64,9 @@ int main(void) {
   P(isinf_sign, (1.));
   P(isnan, (1.));
   P(isfinite, (1.));
+  P(iszero, (1.));
+  P(issubnormal, (1.));
+  P(issignaling, (1.));
   P(isfpclass, (1., 1));
 
   // Bitwise & Numeric Functions
@@ -270,6 +273,18 @@ void test_float_builtins(__fp16 *H, float F, double D, 
long double LD) {
   // CHECK: [[TMP:%.*]] = call i1 @llvm.is.fpclass.f32(float {{.*}}, i32 264)
   // CHECK: zext i1 [[TMP]] to i32
 
+  res = __builtin_issubnormal(F);
+  // CHECK: [[TMP:%.*]] = call i1 @llvm.is.fpclass.f32(float {{.*}}, i32 144)
+  // CHECK: zext i1 [[TMP]] to i32
+
+  res = __builtin_iszero(F);
+  // CHECK: [[TMP:%.*]] = call i1 

[clang] 3743c53 - [clang] Remove unused using decls (NFC)

2023-10-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-10-13T20:09:32-07:00
New Revision: 3743c53dd19fd2f935dfd4dec17ca1b1f7911ddb

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

LOG: [clang] Remove unused using decls (NFC)

Identified with misc-unused-using-decls.

Added: 


Modified: 
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
clang/unittests/Format/FormatTestRawStrings.cpp
clang/unittests/Tooling/RangeSelectorTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 325c585e0e1164f..1dc314eafc4eff4 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -24,7 +24,6 @@ namespace clang {
 namespace ast_matchers {
 
 using internal::Matcher;
-using internal::BindableMatcher;
 
 static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) {
   QualType Ty = FD->getFriendType()->getType().getCanonicalType();

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index 2425bb8711bdbaf..edd87b798198b12 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -47,7 +47,6 @@ using namespace test;
 using namespace ast_matchers;
 using llvm::IsStringMapEntry;
 using ::testing::DescribeMatcher;
-using ::testing::ElementsAre;
 using ::testing::IsEmpty;
 using ::testing::NotNull;
 using ::testing::Test;

diff  --git a/clang/unittests/Format/FormatTestRawStrings.cpp 
b/clang/unittests/Format/FormatTestRawStrings.cpp
index 6f9a0d650ba2dc9..10f341cc8f799ed 100644
--- a/clang/unittests/Format/FormatTestRawStrings.cpp
+++ b/clang/unittests/Format/FormatTestRawStrings.cpp
@@ -17,9 +17,6 @@
 
 #define DEBUG_TYPE "format-test"
 
-using clang::tooling::ReplacementTest;
-using clang::tooling::toReplacements;
-
 namespace clang {
 namespace format {
 namespace {

diff  --git a/clang/unittests/Tooling/RangeSelectorTest.cpp 
b/clang/unittests/Tooling/RangeSelectorTest.cpp
index cbb8e25bb92f24a..03ab66235e43c63 100644
--- a/clang/unittests/Tooling/RangeSelectorTest.cpp
+++ b/clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -28,7 +28,6 @@ using ::llvm::HasValue;
 using ::llvm::StringError;
 using ::testing::AllOf;
 using ::testing::HasSubstr;
-using ::testing::Property;
 
 using MatchResult = MatchFinder::MatchResult;
 



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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsSubrangeIt = requires(Iter1 first1, Sent1 last1, Iter2 
first2, Sent2 last2) {
+  std::ranges::contains_subrange(first1, last1, first2, last2);
+};
+
+static_assert(HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt); // not indirectly 
comparable
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+
+template >
+concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
+  std::ranges::contains_subrange(std::forward(range1), 
std::forward(range2)); };
+
+static_assert(HasContainsSubrangeR>);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR, 
UncheckedRange>); // not indirectly comparable
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotDerivedFrom>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotIncrementable>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelSemiregular>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelEqualityComparableWith>);
+
+template 
+constexpr void test_iterators() {
+  {  // simple tests
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 5};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+  std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret = 
std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // no match
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // range consists of just one element
+int a[]   = {3};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 1)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // subrange consists of just one element
+int a[]   = {23, 1, 20, 3, 54, 2};
+int p[]   = {3};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 1)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // range has zero length
+int a[]   = {};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), 

[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"

var-const wrote:

Is this header used?

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

https://github.com/var-const requested changes to this pull request.

Thank you for the patch!

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 

var-const wrote:

Nit: `` seems unused.

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsSubrangeIt = requires(Iter1 first1, Sent1 last1, Iter2 
first2, Sent2 last2) {
+  std::ranges::contains_subrange(first1, last1, first2, last2);
+};
+
+static_assert(HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt); // not indirectly 
comparable
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+
+template >
+concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
+  std::ranges::contains_subrange(std::forward(range1), 
std::forward(range2)); };
+
+static_assert(HasContainsSubrangeR>);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR, 
UncheckedRange>); // not indirectly comparable
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotDerivedFrom>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotIncrementable>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelSemiregular>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelEqualityComparableWith>);
+
+template 
+constexpr void test_iterators() {
+  {  // simple tests
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 5};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+  std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret = 
std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // no match
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // range consists of just one element
+int a[]   = {3};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 1)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // subrange consists of just one element
+int a[]   = {23, 1, 20, 3, 54, 2};
+int p[]   = {3};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 1)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // range has zero length
+int a[]   = {};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), 

[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -214,6 +214,19 @@ namespace ranges {
 constexpr ranges::minmax_element_result>
   minmax_element(R&& r, Comp comp = {}, Proj proj = {});   
   // since C++20
 
+  template S1, forward_iterator I2,
+sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity,
+class Proj2 = identity>
+requires indirectly_comparable
+constexpr bool ranges::contains_subrange(I1 first1, S1 last1, I2 first2,

var-const wrote:

Nit: please remove `ranges::` (this code block in synopsis is already within 
`namespace ranges`).

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsSubrangeIt = requires(Iter1 first1, Sent1 last1, Iter2 
first2, Sent2 last2) {
+  std::ranges::contains_subrange(first1, last1, first2, last2);
+};
+
+static_assert(HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt); // not indirectly 
comparable
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+
+template >
+concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
+  std::ranges::contains_subrange(std::forward(range1), 
std::forward(range2)); };
+
+static_assert(HasContainsSubrangeR>);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR, 
UncheckedRange>); // not indirectly comparable
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotDerivedFrom>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotIncrementable>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelSemiregular>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelEqualityComparableWith>);
+
+template 
+constexpr void test_iterators() {
+  {  // simple tests
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 5};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =

var-const wrote:

I think this `[[maybe_unused]]` is unnecessary because `ret` is being asserted 
on below.

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


[clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsSubrangeIt = requires(Iter1 first1, Sent1 last1, Iter2 
first2, Sent2 last2) {
+  std::ranges::contains_subrange(first1, last1, first2, last2);
+};
+
+static_assert(HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt); // not indirectly 
comparable
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+
+template >
+concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
+  std::ranges::contains_subrange(std::forward(range1), 
std::forward(range2)); };
+
+static_assert(HasContainsSubrangeR>);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR, 
UncheckedRange>); // not indirectly comparable
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotDerivedFrom>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotIncrementable>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelSemiregular>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelEqualityComparableWith>);
+
+template 
+constexpr void test_iterators() {
+  {  // simple tests
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 5};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+  std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret = 
std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // no match
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // range consists of just one element
+int a[]   = {3};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 1)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // subrange consists of just one element
+int a[]   = {23, 1, 20, 3, 54, 2};
+int p[]   = {3};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 1)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // range has zero length
+int a[]   = {};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), 

[clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

https://github.com/var-const requested changes to this pull request.

Thank you for the patch!

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


[clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 

var-const wrote:

Nit: `` seems unused.

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


[clang] f3cfd38 - [AST] Stop including llvm/ADT/StringMap.h (NFC)

2023-10-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-10-13T18:22:42-07:00
New Revision: f3cfd3812b4a721fcf1be0e242a31d547c908459

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

LOG: [AST] Stop including llvm/ADT/StringMap.h (NFC)

The last use of StringMap was removed by:

  commit 20157410862d376c624cc24bffd9730290a16142
  Author: Vince Bridgers 
  Date:   Thu Jul 16 12:55:32 2020 -0500

Added: 


Modified: 
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 393ed44de3f1831..325c585e0e1164f 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -12,7 +12,6 @@
 
 #include "clang/AST/RecordLayout.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/SmallVectorMemoryBuffer.h"
 
 #include "clang/AST/DeclContextInternals.h"
@@ -26,7 +25,6 @@ namespace ast_matchers {
 
 using internal::Matcher;
 using internal::BindableMatcher;
-using llvm::StringMap;
 
 static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) {
   QualType Ty = FD->getFriendType()->getType().getCanonicalType();



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


[clang] [libcxx] Unifying __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (PR #68642)

2023-10-13 Thread Louis Dionne via cfe-commits


@@ -41,13 +42,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_CONSTEXPR_SINCE_CXX20 boo
   return true;
 }
 
-template <
-class _Tp,
-class _Up,
-class _BinaryPredicate,
-__enable_if_t<__is_trivial_equality_predicate<_BinaryPredicate, _Tp, 
_Up>::value && !is_volatile<_Tp>::value &&
-  !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
-  int> = 0>
+template < class _Tp,
+   class _Up,
+   class _BinaryPredicate,
+   __enable_if_t<__desugars_to<_BinaryPredicate, equal_to<_Tp> 
>::value && !is_volatile<_Tp>::value &&

ldionne wrote:

I think it is pretty important to say `__desugars_to<_BinaryPredicate, 
equal_to >::value` here. `equal_to` represents the "transparent" 
version of `equal_to`, i.e. the one that does `x == y` without any conversion 
involved. If you use `__desugars_to<_BinaryPredicate, equal_to<_Tp> >::value`, 
it means that if `_Up` and `_Tp` are different but they happen to be trivially 
equality-comparable, we would skip this optimization.

You should be able to check that this optimization gets disabled if you use 
something like [this](https://godbolt.org/z/hGq57j5jM):

```
#include 

using T = int*;
using U = void*;

bool f(T* first1, T* last1, U* first2, U* last2) {
return std::equal(first1, last1, first2);
}
```

```
f(int**, int**, void**, void**):   # @f(int**, int**, 
void**, void**)
pushrax
mov rax, rsi
sub rax, rdi
mov rsi, rdx
mov rdx, rax
callbcmp@PLT
testeax, eax
seteal
pop rcx
ret
```

This is good, if there's no `bcmp` or `memcmp` in the output then the 
optimization was disabled. Since we don't have access to FileCheck in the 
libc++ test suite, however, it's going to be really hard to add a test for 
this. But it would be great if you can validate it manually at least. You can 
do something like this:

```
ninja -C build cxx-test-depends

cat <

using T = int*;
using U = void*;

bool f(T* first1, T* last1, U* first2, U* last2) {
return std::equal(first1, last1, first2);
}
EOF
```

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


[clang] [Bazel][Clang Tidy] Include builtin headers with clang-tidy (PR #67626)

2023-10-13 Thread via cfe-commits

https://github.com/jathu updated https://github.com/llvm/llvm-project/pull/67626

>From 20d9ca99fbf11868a5816df217b2aad09e079fb6 Mon Sep 17 00:00:00 2001
From: jathu 
Date: Wed, 27 Sep 2023 18:01:19 -0700
Subject: [PATCH] [clang-tidy][bazel] Include builtin headers with clang-tidy

---
 .../clang-tools-extra/BUILD.bazel | 21 +++
 .../clang-tools-extra/clang-tidy/BUILD.bazel  |  1 +
 .../clang-tools-extra/defs.bzl| 26 +++
 .../llvm-project-overlay/clang/BUILD.bazel| 12 ++---
 .../bazel/llvm-project-overlay/clang/defs.bzl |  5 
 5 files changed, 61 insertions(+), 4 deletions(-)
 create mode 100644 
utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel
 create mode 100644 utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl
 create mode 100644 utils/bazel/llvm-project-overlay/clang/defs.bzl

diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel
new file mode 100644
index 000..d7559a376698583
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel
@@ -0,0 +1,21 @@
+# This file is licensed 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
+
+load("//:vars.bzl", "LLVM_VERSION_MAJOR")
+load("//clang:defs.bzl", "BUILTIN_HEADERS_GEN_DIR")
+load("defs.bzl", "symlink")
+
+package(
+default_visibility = ["//visibility:public"],
+features = ["layering_check"],
+)
+
+licenses(["notice"])
+
+symlink(
+name = "builtin_headers",
+srcs = ["//clang:builtin_headers_gen"],
+destination = "lib/clang/{0}/include".format(LLVM_VERSION_MAJOR),
+partition = BUILTIN_HEADERS_GEN_DIR,
+)
diff --git 
a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel
index bbabc5397e98937..257c9e875d0133b 100644
--- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel
@@ -370,6 +370,7 @@ cc_library(
 cc_binary(
 name = "clang-tidy",
 srcs = ["tool/ClangTidyToolMain.cpp"],
+data = ["//clang-tools-extra:builtin_headers"],
 stamp = 0,
 deps = [":tool"],
 )
diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl 
b/utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl
new file mode 100644
index 000..fd992c052b0f055
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl
@@ -0,0 +1,26 @@
+# This file is licensed 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
+
+load("@bazel_skylib//lib:paths.bzl", "paths")
+
+def _symlink_impl(ctx):
+copied_files = []
+for input_file in ctx.files.srcs:
+(_, _, relative_filename) = 
input_file.path.rpartition(ctx.attr.partition)
+output_file = 
ctx.actions.declare_file(paths.join(ctx.attr.destination, relative_filename))
+ctx.actions.symlink(
+target_file = input_file,
+output = output_file,
+)
+copied_files.append(output_file)
+return DefaultInfo(files = depset(copied_files))
+
+symlink = rule(
+implementation = _symlink_impl,
+attrs = {
+"destination": attr.string(mandatory = True),
+"partition": attr.string(mandatory = True),
+"srcs": attr.label_list(allow_files = True),
+},
+)
diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index cac8ec120929a37..02f0f6076c6fddd 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -14,6 +14,7 @@ load(
 "LLVM_VERSION_MINOR",
 "LLVM_VERSION_PATCH",
 )
+load("defs.bzl", "BUILTIN_HEADERS_GEN_DIR")
 
 package(
 default_visibility = ["//visibility:public"],
@@ -1696,14 +1697,17 @@ builtin_headers = glob(
 genrule(
 name = "builtin_headers_gen",
 srcs = builtin_headers,
-outs = [hdr.replace("lib/Headers/", "staging/include/") for hdr in 
builtin_headers],
+outs = [
+header.replace("lib/Headers/", BUILTIN_HEADERS_GEN_DIR)
+for header in builtin_headers
+],
 cmd = """
for src in $(SRCS); do
- relsrc=$${src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers}
- target=$(@D)/staging/include/$$relsrc
+ relsrc=$${{src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers}}
+ target=$(@D)/{resource_dir}$$relsrc
  mkdir -p $$(dirname $$target)
  cp $$src $$target
-   done""",
+   done""".format(resource_dir = BUILTIN_HEADERS_GEN_DIR),
 output_to_bindir = 1,
 toolchains = [
 ":workspace_root",
diff 

[clang-tools-extra] Adding Separate OpenMP Offloading Backend to `libcxx/include/__algorithm/pstl_backends` (PR #66968)

2023-10-13 Thread Louis Dionne via cfe-commits


@@ -0,0 +1,33 @@
+//===--===//
+//
+// 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 _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+
+#include <__algorithm/any_of.h>
+#include <__algorithm/pstl_backends/cpu_backends/backend.h>
+#include <__algorithm/pstl_backends/openmp/backend.h>
+#include <__config>
+#include <__type_traits/is_execution_policy.h>
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template 
+_LIBCPP_HIDE_FROM_ABI bool
+__pstl_any_of(__omp_backend_tag, _ForwardIterator __first, _ForwardIterator 
__last, _Predicate __pred) {

ldionne wrote:

You should look at the updated documentation for backend functions in 
`libcxx/include/__algorithm/pstl_backend.h`. They now return `optional`.

The `optional`s are used to represent whether the implementation failed to run 
the algorithm due to a setup issue. For example in the CPU backends we 
sometimes need to allocate memory and that can fail. When that fails, we return 
an empty optional and the front-end of the PSTL will then throw 
`std::bad_alloc` for us.

In your case I think there's nothing that can throw or fail so far, so you 
should always return an engaged optional.

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


[clang] Adding Separate OpenMP Offloading Backend to `libcxx/include/__algorithm/pstl_backends` (PR #66968)

2023-10-13 Thread Louis Dionne via cfe-commits


@@ -0,0 +1,33 @@
+//===--===//
+//
+// 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 _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+
+#include <__algorithm/any_of.h>
+#include <__algorithm/pstl_backends/cpu_backends/backend.h>
+#include <__algorithm/pstl_backends/openmp/backend.h>
+#include <__config>
+#include <__type_traits/is_execution_policy.h>
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template 
+_LIBCPP_HIDE_FROM_ABI bool
+__pstl_any_of(__omp_backend_tag, _ForwardIterator __first, _ForwardIterator 
__last, _Predicate __pred) {

ldionne wrote:

You should look at the updated documentation for backend functions in 
`libcxx/include/__algorithm/pstl_backend.h`. They now return `optional`.

The `optional`s are used to represent whether the implementation failed to run 
the algorithm due to a setup issue. For example in the CPU backends we 
sometimes need to allocate memory and that can fail. When that fails, we return 
an empty optional and the front-end of the PSTL will then throw 
`std::bad_alloc` for us.

In your case I think there's nothing that can throw or fail so far, so you 
should always return an engaged optional.

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


[clang] [clang][modules] Use file name as requested (PR #68957)

2023-10-13 Thread Jan Svoboda via cfe-commits


@@ -1384,10 +1384,10 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
   SmallVector ModMaps(AdditionalModMaps->begin(),
AdditionalModMaps->end());
   llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
-return A.getName() < B.getName();
+return A.getNameAsRequested() < B.getNameAsRequested();
   });
   for (FileEntryRef F : ModMaps)
-AddPath(F.getName(), Record);
+AddPath(F.getNameAsRequested(), Record);

jansvoboda11 wrote:

Done in the two new commits.

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


[clang] [clang][modules] Use file name as requested (PR #68957)

2023-10-13 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/68957

>From 4f60df88e1623733a64896ef332fd9a31e5b0e47 Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Thu, 12 Oct 2023 21:46:47 -0700
Subject: [PATCH 1/3] [clang][modules] Use file name as requested

This prevents redefinition errors due to having multiple paths for the same 
module map. (rdar://24116019)

Originally implemented and tested downstream by @bcardosolopes, I just made use 
of `FileEntryRef::getNameAsRequested()`.
---
 clang/lib/Lex/HeaderSearch.cpp|  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  4 +--
 .../Modules/Inputs/all-product-headers.yaml   | 33 +++
 clang/test/Modules/modulemap-collision.m  | 15 +
 4 files changed, 51 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Modules/Inputs/all-product-headers.yaml
 create mode 100644 clang/test/Modules/modulemap-collision.m

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 4c8b64a374b47d5..cf1c0cc5284f316 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1623,7 +1623,7 @@ bool HeaderSearch::findUsableModuleForHeader(
 ModuleMap::KnownHeader *SuggestedModule, bool IsSystemHeaderDir) {
   if (needModuleLookup(RequestingModule, SuggestedModule)) {
 // If there is a module that corresponds to this header, suggest it.
-hasModuleMap(File.getName(), Root, IsSystemHeaderDir);
+hasModuleMap(File.getNameAsRequested(), Root, IsSystemHeaderDir);
 return suggestModule(*this, File, RequestingModule, SuggestedModule);
   }
   return true;
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 27700c711d52fdd..0d216927d76260d 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1384,10 +1384,10 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
   SmallVector ModMaps(AdditionalModMaps->begin(),
AdditionalModMaps->end());
   llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
-return A.getName() < B.getName();
+return A.getNameAsRequested() < B.getNameAsRequested();
   });
   for (FileEntryRef F : ModMaps)
-AddPath(F.getName(), Record);
+AddPath(F.getNameAsRequested(), Record);
 } else {
   Record.push_back(0);
 }
diff --git a/clang/test/Modules/Inputs/all-product-headers.yaml 
b/clang/test/Modules/Inputs/all-product-headers.yaml
new file mode 100644
index 000..53d683f2ad2ecc0
--- /dev/null
+++ b/clang/test/Modules/Inputs/all-product-headers.yaml
@@ -0,0 +1,33 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "DUMMY_DIR/build/A.framework/PrivateHeaders"
+  'contents': [
+{
+  'type': 'file',
+  'name': "A.h",
+  'external-contents': "DUMMY_DIR/sources/A.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "DUMMY_DIR/build/A.framework/Modules"
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "DUMMY_DIR/build/module.modulemap"
+},
+{
+  'type': 'file',
+  'name': "module.private.modulemap",
+  'external-contents': "DUMMY_DIR/build/module.private.modulemap"
+}
+  ]
+}
+  ]
+}
diff --git a/clang/test/Modules/modulemap-collision.m 
b/clang/test/Modules/modulemap-collision.m
new file mode 100644
index 000..5ada45da3dae191
--- /dev/null
+++ b/clang/test/Modules/modulemap-collision.m
@@ -0,0 +1,15 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/sources %t/build
+// RUN: echo "// A.h" > %t/sources/A.h
+// RUN: echo "framework module A {}" > %t/sources/module.modulemap
+// RUN: echo "framework module A.Private { umbrella header \"A.h\" }" > 
%t/sources/module.private.modulemap
+// RUN: cp %t/sources/module.modulemap %t/build/module.modulemap
+// RUN: cp %t/sources/module.private.modulemap 
%t/build/module.private.modulemap
+
+// RUN: sed -e "s:DUMMY_DIR:%t:g" %S/Inputs/all-product-headers.yaml > 
%t/build/all-product-headers.yaml
+// RUN: %clang_cc1 -fsyntax-only -ivfsoverlay 
%t/build/all-product-headers.yaml -F%t/build -fmodules -fimplicit-module-maps 
-Wno-private-module -fmodules-cache-path=%t/cache -x objective-c %s -verify
+
+// expected-no-diagnostics
+#import 

>From 68a9858b1c4c8b2aaee4ebf6a72a9d3c081912fe Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Fri, 13 Oct 2023 17:23:47 -0700
Subject: [PATCH 2/3] [clang] Remove `PointerLikeTypeTraits`

---
 clang/include/clang/ARCMigrate/FileRemapper.h |  4 +-
 clang/include/clang/Basic/FileEntry.h | 31 ---
 clang/include/clang/Basic/Module.h| 12 ++--
 .../clang/Frontend/VerifyDiagnosticConsumer.h |  9 +--
 clang/include/clang/Lex/ModuleMap.h 

[clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2023-10-13 Thread Sami Tolvanen via cfe-commits


@@ -106,9 +111,14 @@ static void emitSCSEpilogue(MachineFunction , 
MachineBasicBlock ,
   CSI, [&](CalleeSavedInfo ) { return CSR.getReg() == RAReg; }))
 return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {

samitolvanen wrote:

> > Do we need an enable other than just the feature being in -march? The 
> > shadow stack pointer has to be set up when the application starts. Is this 
> > done by the kernel?
> > My concern is that if your -mcpu supports Zicfiss, but the kernel doesn't, 
> > this will generate code that doesn't work.
> 
> oh, that's good point...let me check how other target do

If the kernel doesn't support Zicfiss, it presumably also hasn't enabled the 
extension for U-mode. Therefore, my understanding is that the application 
loader can simply skip shadow stack setup for the program, including the 
`prctl` (which would fail with `-EINVAL`), and since the Zicfiss (Zimop) 
instructions are no-ops when the extension is disabled, the program would run 
normally, just without shadow stacks. Does this sound correct?

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


[clang] [time-trace] Add a new time trace scope variable named "ParseDeclarationOrFunctionDefinition". (PR #65268)

2023-10-13 Thread via cfe-commits


@@ -1224,6 +1225,9 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclOrFunctionDefInternal(
 Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition(
 ParsedAttributes , ParsedAttributes ,
 ParsingDeclSpec *DS, AccessSpecifier AS) {
+  // Add an enclosing time trace scope for a bunch of small scopes with
+  // "EvaluateAsConstExpr".
+  llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition");

MaggieYingYi wrote:

Good point, thanks. It is added in the commit 
https://github.com/llvm/llvm-project/pull/65268/commits/fa0503d3b7.

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


[clang] [time-trace] Add a new time trace scope variable named "ParseDeclarationOrFunctionDefinition". (PR #65268)

2023-10-13 Thread via cfe-commits

https://github.com/MaggieYingYi updated 
https://github.com/llvm/llvm-project/pull/65268

>From cc5cf9500cbdbb2fdd332c7de26c0516e49594bf Mon Sep 17 00:00:00 2001
From: Ying Yi 
Date: Fri, 1 Sep 2023 15:30:44 +0100
Subject: [PATCH 1/3] Add a new time trace scope variable named
 "ParseDeclarationOrFunctionDefinition".

When profiling code using `-ftime-trace` with the default 
`time-trace-granularity` value (500 microseconds), in some code there is a 
large empty timeline in the flame chart profiling view (using Chrome Tracing 
view).  If you pass `-ftime-trace-granularity=0` in order to show all time 
traces, the empty timeline consists of a large number of small time scopes 
named `EvaluateAsConstExpr`.  This change adds an enclosing time trace scope 
for the function `Parser::ParseDeclarationOrFunctionDefinition` to record the 
time spent parsing  the function's declaration or definition.
---
 clang/lib/Parse/Parser.cpp|  6 ++-
 ...e-ParseDeclarationOrFunctionDefinition.cpp | 10 +
 clang/unittests/Support/TimeProfilerTest.cpp  | 42 +++
 3 files changed, 39 insertions(+), 19 deletions(-)
 create mode 100644 
clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp

diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 0f930248e77174b..ef0d98d60746f9c 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -13,8 +13,8 @@
 #include "clang/Parse/Parser.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ASTLambda.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
@@ -22,6 +22,7 @@
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/TimeProfiler.h"
 using namespace clang;
 
 
@@ -1229,6 +1230,9 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclOrFunctionDefInternal(
 Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition(
 ParsedAttributes , ParsedAttributes ,
 ParsingDeclSpec *DS, AccessSpecifier AS) {
+  // Add an enclosing time trace scope for a bunch of small scopes with
+  // "EvaluateAsConstExpr".
+  llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition");
   if (DS) {
 return ParseDeclOrFunctionDefInternal(Attrs, DeclSpecAttrs, *DS, AS);
   } else {
diff --git 
a/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp 
b/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp
new file mode 100644
index 000..be1cc51cc6669f3
--- /dev/null
+++ 
b/clang/test/Driver/check-time-trace-ParseDeclarationOrFunctionDefinition.cpp
@@ -0,0 +1,10 @@
+// RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -o 
%T/check-time-trace-ParseDeclarationOrFunctionDefinition %s
+// RUN: cat %T/check-time-trace-ParseDeclarationOrFunctionDefinition.json \
+// RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+
+// CHECK: "name": "ParseDeclarationOrFunctionDefinition"
+
+template 
+void foo(T) {}
+void bar() { foo(0); }
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp 
b/clang/unittests/Support/TimeProfilerTest.cpp
index a7ca2bf91e474ef..62b37ab5c5e6424 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -177,22 +177,27 @@ constexpr int slow_init_list[] = {1, 1, 2, 3, 5, 8, 13, 
21}; // 25th line
   std::string TraceGraph = buildTraceGraph(Json);
   ASSERT_TRUE(TraceGraph == R"(
 Frontend
-| EvaluateAsRValue ()
-| EvaluateForOverflow ()
-| EvaluateForOverflow ()
-| EvaluateAsRValue ()
-| EvaluateForOverflow ()
-| isPotentialConstantExpr (slow_namespace::slow_func)
-| EvaluateAsBooleanCondition ()
-| | EvaluateAsRValue ()
-| EvaluateAsBooleanCondition ()
-| | EvaluateAsRValue ()
-| EvaluateAsInitializer (slow_value)
-| EvaluateAsConstantExpr ()
-| EvaluateAsConstantExpr ()
-| EvaluateAsConstantExpr ()
-| EvaluateAsRValue ()
-| EvaluateAsInitializer (slow_init_list)
+| ParseDeclarationOrFunctionDefinition
+| ParseDeclarationOrFunctionDefinition
+| | EvaluateAsRValue ()
+| | EvaluateForOverflow ()
+| | EvaluateForOverflow ()
+| | EvaluateAsRValue ()
+| | EvaluateForOverflow ()
+| | isPotentialConstantExpr (slow_namespace::slow_func)
+| | EvaluateAsBooleanCondition ()
+| | | EvaluateAsRValue ()
+| | EvaluateAsBooleanCondition ()
+| | | EvaluateAsRValue ()
+| ParseDeclarationOrFunctionDefinition
+| | EvaluateAsInitializer (slow_value)
+| | EvaluateAsConstantExpr ()
+| | EvaluateAsConstantExpr ()
+| | EvaluateAsConstantExpr ()
+| ParseDeclarationOrFunctionDefinition
+| | EvaluateAsRValue ()
+| ParseDeclarationOrFunctionDefinition
+| | EvaluateAsInitializer (slow_init_list)
 | PerformPendingInstantiations
 )");
 
@@ 

[clang] [clang][modules] Use file name as requested (PR #68957)

2023-10-13 Thread Jan Svoboda via cfe-commits


@@ -1384,10 +1384,10 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
   SmallVector ModMaps(AdditionalModMaps->begin(),
AdditionalModMaps->end());
   llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
-return A.getName() < B.getName();
+return A.getNameAsRequested() < B.getNameAsRequested();
   });
   for (FileEntryRef F : ModMaps)
-AddPath(F.getName(), Record);
+AddPath(F.getNameAsRequested(), Record);

jansvoboda11 wrote:

Yeah, this is a bit suspicious. This test started failing downstream after 
de85739ded2 and this change appeared to be required to fix things.

Turns out `llvm::SmallPtrSet` determines equality of elements 
based on the equality of their `void *` representation, not based on 
`FileEntryRef::operator==()`. This means that when we find the module map 
through a VFS, but serialize the on-disk path, we aren't able to correctly 
match them together in `ASTReader`.

I don't want to go messing with the `SmallPtrSet` implementation, so I'll 
probably just revert [D154905](https://reviews.llvm.org/D154905) (making the 
types unusable in `SmallPtrSet`) and switch from 
`llvm::SmallPtrSet` to  `llvm::DenseMap`.

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


[clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

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


[clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

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


[clang-tools-extra] [libc++] Implement ranges::contains_subrange (PR #66963)

2023-10-13 Thread Konstantin Varlamov via cfe-commits

var-const wrote:

> > Please make sure you add a description to your PR. This is what usually 
> > goes into the git log and we want those entries to be as descriptive and 
> > helpful for folks who read the git logs, thank you.
> 
> Do you have any specific suggestions what should be in the message? The 
> libc++ "I implement something" patches are most of the time quite 
> straight-forward, since you can look at the standard and know what's going 
> on. It's also the best source, since it's the authoritative document here, 
> and is also what anybody who cares to actually look at the patch should check 
> against for correctness.

+1 -- I'm in favor of descriptive commit messages in general, but in this case 
I'm not sure what would be useful to add beyond "Implement 
ranges::contains_subrange".

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


[clang-tools-extra] [libcxx] Unifying __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (PR #68642)

2023-10-13 Thread Anton Rydahl via cfe-commits

https://github.com/AntonRydahl updated 
https://github.com/llvm/llvm-project/pull/68642

>From f0d93cc6a5cd485c654ab38221691db038bacc7d Mon Sep 17 00:00:00 2001
From: AntonRydahl 
Date: Mon, 9 Oct 2023 15:13:22 -0700
Subject: [PATCH 1/3] Merged __is_trivial_equality_predicate and
 __is_trivial_plus_operation into __desugars_to

---
 libcxx/include/CMakeLists.txt |  1 -
 libcxx/include/__algorithm/comp.h |  7 ++---
 libcxx/include/__algorithm/equal.h| 22 
 .../cpu_backends/transform_reduce.h   | 23 
 libcxx/include/__functional/operations.h  | 15 +--
 .../include/__functional/ranges_operations.h  |  7 ++---
 .../include/__numeric/pstl_transform_reduce.h |  2 +-
 .../include/__type_traits/operation_traits.h  |  4 +--
 .../include/__type_traits/predicate_traits.h  | 26 ---
 libcxx/include/module.modulemap.in|  1 -
 10 files changed, 40 insertions(+), 68 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/predicate_traits.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 340353f8ebb41c4..7eb09a06ccd482e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -813,7 +813,6 @@ set(files
   __type_traits/negation.h
   __type_traits/noexcept_move_assign_container.h
   __type_traits/operation_traits.h
-  __type_traits/predicate_traits.h
   __type_traits/promote.h
   __type_traits/rank.h
   __type_traits/remove_all_extents.h
diff --git a/libcxx/include/__algorithm/comp.h 
b/libcxx/include/__algorithm/comp.h
index 9474536615ffb67..0993c37cce36a6b 100644
--- a/libcxx/include/__algorithm/comp.h
+++ b/libcxx/include/__algorithm/comp.h
@@ -10,8 +10,9 @@
 #define _LIBCPP___ALGORITHM_COMP_H
 
 #include <__config>
+#include <__functional/operations.h>
 #include <__type_traits/integral_constant.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -26,8 +27,8 @@ struct __equal_to {
   }
 };
 
-template 
-struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
+template <>
+struct __desugars_to<__equal_to, std::equal_to<>> : true_type {};
 
 // The definition is required because __less is part of the ABI, but it's empty
 // because all comparisons should be transparent.
diff --git a/libcxx/include/__algorithm/equal.h 
b/libcxx/include/__algorithm/equal.h
index b69aeff92bb9289..35e82da15e4d058 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -15,6 +15,7 @@
 #include <__config>
 #include <__functional/identity.h>
 #include <__functional/invoke.h>
+#include <__functional/operations.h>
 #include <__iterator/distance.h>
 #include <__iterator/iterator_traits.h>
 #include <__string/constexpr_c_functions.h>
@@ -23,7 +24,7 @@
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_equality_comparable.h>
 #include <__type_traits/is_volatile.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 #include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -41,13 +42,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_CONSTEXPR_SINCE_CXX20 boo
   return true;
 }
 
-template <
-class _Tp,
-class _Up,
-class _BinaryPredicate,
-__enable_if_t<__is_trivial_equality_predicate<_BinaryPredicate, _Tp, 
_Up>::value && !is_volatile<_Tp>::value &&
-  !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
-  int> = 0>
+template < class _Tp,
+   class _Up,
+   class _BinaryPredicate,
+   __enable_if_t<__desugars_to<_BinaryPredicate, 
std::equal_to<>>::value && !is_volatile<_Tp>::value &&
+ !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
+ int> = 0>
 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool
 __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, 
_BinaryPredicate&) {
   return std::__constexpr_memcmp_equal(__first1, __first2, 
__element_count(__last1 - __first1));
@@ -94,12 +94,12 @@ template ::value && __is_identity<_Proj1>::value &&
+  __enable_if_t<__desugars_to<_Pred, std::equal_to<>>::value && 
__is_identity<_Proj1>::value &&
 __is_identity<_Proj2>::value && 
!is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
 __libcpp_is_trivially_equality_comparable<_Tp, 
_Up>::value,
 int> = 0>
-_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool __equal_impl(
-_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, 
_Proj2&) {
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool

[clang] [libcxx] Unifying __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (PR #68642)

2023-10-13 Thread Anton Rydahl via cfe-commits

https://github.com/AntonRydahl updated 
https://github.com/llvm/llvm-project/pull/68642

>From f0d93cc6a5cd485c654ab38221691db038bacc7d Mon Sep 17 00:00:00 2001
From: AntonRydahl 
Date: Mon, 9 Oct 2023 15:13:22 -0700
Subject: [PATCH 1/3] Merged __is_trivial_equality_predicate and
 __is_trivial_plus_operation into __desugars_to

---
 libcxx/include/CMakeLists.txt |  1 -
 libcxx/include/__algorithm/comp.h |  7 ++---
 libcxx/include/__algorithm/equal.h| 22 
 .../cpu_backends/transform_reduce.h   | 23 
 libcxx/include/__functional/operations.h  | 15 +--
 .../include/__functional/ranges_operations.h  |  7 ++---
 .../include/__numeric/pstl_transform_reduce.h |  2 +-
 .../include/__type_traits/operation_traits.h  |  4 +--
 .../include/__type_traits/predicate_traits.h  | 26 ---
 libcxx/include/module.modulemap.in|  1 -
 10 files changed, 40 insertions(+), 68 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/predicate_traits.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 340353f8ebb41c4..7eb09a06ccd482e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -813,7 +813,6 @@ set(files
   __type_traits/negation.h
   __type_traits/noexcept_move_assign_container.h
   __type_traits/operation_traits.h
-  __type_traits/predicate_traits.h
   __type_traits/promote.h
   __type_traits/rank.h
   __type_traits/remove_all_extents.h
diff --git a/libcxx/include/__algorithm/comp.h 
b/libcxx/include/__algorithm/comp.h
index 9474536615ffb67..0993c37cce36a6b 100644
--- a/libcxx/include/__algorithm/comp.h
+++ b/libcxx/include/__algorithm/comp.h
@@ -10,8 +10,9 @@
 #define _LIBCPP___ALGORITHM_COMP_H
 
 #include <__config>
+#include <__functional/operations.h>
 #include <__type_traits/integral_constant.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -26,8 +27,8 @@ struct __equal_to {
   }
 };
 
-template 
-struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
+template <>
+struct __desugars_to<__equal_to, std::equal_to<>> : true_type {};
 
 // The definition is required because __less is part of the ABI, but it's empty
 // because all comparisons should be transparent.
diff --git a/libcxx/include/__algorithm/equal.h 
b/libcxx/include/__algorithm/equal.h
index b69aeff92bb9289..35e82da15e4d058 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -15,6 +15,7 @@
 #include <__config>
 #include <__functional/identity.h>
 #include <__functional/invoke.h>
+#include <__functional/operations.h>
 #include <__iterator/distance.h>
 #include <__iterator/iterator_traits.h>
 #include <__string/constexpr_c_functions.h>
@@ -23,7 +24,7 @@
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_equality_comparable.h>
 #include <__type_traits/is_volatile.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 #include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -41,13 +42,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_CONSTEXPR_SINCE_CXX20 boo
   return true;
 }
 
-template <
-class _Tp,
-class _Up,
-class _BinaryPredicate,
-__enable_if_t<__is_trivial_equality_predicate<_BinaryPredicate, _Tp, 
_Up>::value && !is_volatile<_Tp>::value &&
-  !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
-  int> = 0>
+template < class _Tp,
+   class _Up,
+   class _BinaryPredicate,
+   __enable_if_t<__desugars_to<_BinaryPredicate, 
std::equal_to<>>::value && !is_volatile<_Tp>::value &&
+ !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
+ int> = 0>
 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool
 __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, 
_BinaryPredicate&) {
   return std::__constexpr_memcmp_equal(__first1, __first2, 
__element_count(__last1 - __first1));
@@ -94,12 +94,12 @@ template ::value && __is_identity<_Proj1>::value &&
+  __enable_if_t<__desugars_to<_Pred, std::equal_to<>>::value && 
__is_identity<_Proj1>::value &&
 __is_identity<_Proj2>::value && 
!is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
 __libcpp_is_trivially_equality_comparable<_Tp, 
_Up>::value,
 int> = 0>
-_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool __equal_impl(
-_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, 
_Proj2&) {
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool

[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread David Li via cfe-commits


@@ -202,6 +202,18 @@ static cl::opt
  cl::desc("Path to the profile remapping file."),
  cl::Hidden);
 
+static cl::opt PGOColdFuncAttr(
+"pgo-cold-func-attr", cl::init(PGOOptions::ColdFuncAttr::None), cl::Hidden,

david-xl wrote:

pgo-cold-func-opt

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


[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread David Li via cfe-commits


@@ -0,0 +1,65 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Transforms/Instrumentation/MarkColdFunctions.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/ProfileSummaryInfo.h"
+#include "llvm/IR/PassManager.h"
+
+using namespace llvm;
+
+PreservedAnalyses MarkColdFunctionsPass::run(Module ,

david-xl wrote:

why not just mark those function with 'cold' attribute, and have one global 
option to determine the optimization strategy of cold attributed functions? 
These functions are not different from functions annotated by a developer.

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


[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread David Li via cfe-commits


@@ -27,10 +27,12 @@ class FileSystem;
 struct PGOOptions {
   enum PGOAction { NoAction, IRInstr, IRUse, SampleUse };
   enum CSPGOAction { NoCSAction, CSIRInstr, CSIRUse };
+  enum class ColdFuncAttr { None, OptSize, MinSize, OptNone };

david-xl wrote:

None --> Default

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


[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread David Li via cfe-commits


@@ -44,6 +46,7 @@ struct PGOOptions {
   std::string MemoryProfile;
   PGOAction Action;
   CSPGOAction CSAction;
+  ColdFuncAttr ColdType;

david-xl wrote:

ColdType --> ColdOptType

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


[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread David Li via cfe-commits


@@ -27,10 +27,12 @@ class FileSystem;
 struct PGOOptions {
   enum PGOAction { NoAction, IRInstr, IRUse, SampleUse };
   enum CSPGOAction { NoCSAction, CSIRInstr, CSIRUse };
+  enum class ColdFuncAttr { None, OptSize, MinSize, OptNone };

david-xl wrote:

Even though the optimization directive is implemented as a function attribute, 
it might be better to express the real intention is to decide 'optimization 
strategy', so perhaps ColdFuncOpt as name or ColdFuncOptAttr? ColdFuncAttr 
feels too broad.

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


[clang-tools-extra] Adding Separate OpenMP Offloading Backend to `libcxx/include/__algorithm/pstl_backends` (PR #66968)

2023-10-13 Thread Anton Rydahl via cfe-commits


@@ -0,0 +1,33 @@
+//===--===//
+//
+// 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 _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+
+#include <__algorithm/any_of.h>
+#include <__algorithm/pstl_backends/cpu_backends/backend.h>
+#include <__algorithm/pstl_backends/openmp/backend.h>
+#include <__config>
+#include <__type_traits/is_execution_policy.h>
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template 
+_LIBCPP_HIDE_FROM_ABI bool
+__pstl_any_of(__omp_backend_tag, _ForwardIterator __first, _ForwardIterator 
__last, _Predicate __pred) {

AntonRydahl wrote:

Here is the full error for one of the tests that fail if I do not make a 
placeholder for any_of:
```
 TEST 'llvm-libc++-shared.cfg.in :: 
std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp' FAILED 

Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
/dev/shm/rydahl1/LLVM/build/./bin/clang++ 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp
 -pthread --target=x86_64-unknown-linux-gnu -nostdinc++ -I 
/dev/shm/rydahl1/LLVM/build/include/c++/v1 -I 
/dev/shm/rydahl1/LLVM/build/include/x86_64-unknown-linux-gnu/c++/v1 -I 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/support -std=c++26 -Werror 
-Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-Werror=thread-safety -Wuser-defined-warnings  -lc++experimental -nostdlib++ -L 
/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu 
-Wl,-rpath,/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu -lc++ -o 
/dev/shm/rydahl1/LLVM/build/runtimes/runtimes-bins/test/std/algorithms/alg.modifying.operations/alg.fill/Output/pstl.fill_n.pass.cpp.dir/t.tmp.exe
# executed command: /dev/shm/rydahl1/LLVM/build/./bin/clang++ 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp
 -pthread --target=x86_64-unknown-linux-gnu -nostdinc++ -I 
/dev/shm/rydahl1/LLVM/build/include/c++/v1 -I 
/dev/shm/rydahl1/LLVM/build/include/x86_64-unknown-linux-gnu/c++/v1 -I 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/support -std=c++26 -Werror 
-Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L 
/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu 
-Wl,-rpath,/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu -lc++ -o 
/dev/shm/rydahl1/LLVM/build/runtimes/runtimes-bins/test/std/algorithms/alg.modifying.operations/alg.fill/Output/pstl.fill_n.pass.cpp.dir/t.tmp.exe
# .---command stderr
# | In file included from 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp:19:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/algorithm:1827:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_any_all_none_of.h:12:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_find.h:14:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_backend.h:12:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_backends/cpu_backend.h:58:
# | In file included from 

[clang] Adding Separate OpenMP Offloading Backend to `libcxx/include/__algorithm/pstl_backends` (PR #66968)

2023-10-13 Thread Anton Rydahl via cfe-commits


@@ -0,0 +1,33 @@
+//===--===//
+//
+// 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 _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_OPENMP_BACKEND_ANY_OF_H
+
+#include <__algorithm/any_of.h>
+#include <__algorithm/pstl_backends/cpu_backends/backend.h>
+#include <__algorithm/pstl_backends/openmp/backend.h>
+#include <__config>
+#include <__type_traits/is_execution_policy.h>
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template 
+_LIBCPP_HIDE_FROM_ABI bool
+__pstl_any_of(__omp_backend_tag, _ForwardIterator __first, _ForwardIterator 
__last, _Predicate __pred) {

AntonRydahl wrote:

Here is the full error for one of the tests that fail if I do not make a 
placeholder for any_of:
```
 TEST 'llvm-libc++-shared.cfg.in :: 
std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp' FAILED 

Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
/dev/shm/rydahl1/LLVM/build/./bin/clang++ 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp
 -pthread --target=x86_64-unknown-linux-gnu -nostdinc++ -I 
/dev/shm/rydahl1/LLVM/build/include/c++/v1 -I 
/dev/shm/rydahl1/LLVM/build/include/x86_64-unknown-linux-gnu/c++/v1 -I 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/support -std=c++26 -Werror 
-Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-Werror=thread-safety -Wuser-defined-warnings  -lc++experimental -nostdlib++ -L 
/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu 
-Wl,-rpath,/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu -lc++ -o 
/dev/shm/rydahl1/LLVM/build/runtimes/runtimes-bins/test/std/algorithms/alg.modifying.operations/alg.fill/Output/pstl.fill_n.pass.cpp.dir/t.tmp.exe
# executed command: /dev/shm/rydahl1/LLVM/build/./bin/clang++ 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp
 -pthread --target=x86_64-unknown-linux-gnu -nostdinc++ -I 
/dev/shm/rydahl1/LLVM/build/include/c++/v1 -I 
/dev/shm/rydahl1/LLVM/build/include/x86_64-unknown-linux-gnu/c++/v1 -I 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/support -std=c++26 -Werror 
-Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L 
/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu 
-Wl,-rpath,/dev/shm/rydahl1/LLVM/build/./lib/x86_64-unknown-linux-gnu -lc++ -o 
/dev/shm/rydahl1/LLVM/build/runtimes/runtimes-bins/test/std/algorithms/alg.modifying.operations/alg.fill/Output/pstl.fill_n.pass.cpp.dir/t.tmp.exe
# .---command stderr
# | In file included from 
/g/g92/rydahl1/LLVM_FORK/llvm-project/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp:19:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/algorithm:1827:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_any_all_none_of.h:12:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_find.h:14:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_backend.h:12:
# | In file included from 
/dev/shm/rydahl1/LLVM/build/include/c++/v1/__algorithm/pstl_backends/cpu_backend.h:58:
# | In file included from 

[PATCH] D149800: [WIP][PGO] Add ability to mark cold functions as optsize/minsize/optnone

2023-10-13 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks abandoned this revision.
aeubanks added a comment.

reworked into https://github.com/llvm/llvm-project/pull/69030


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149800

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


[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-lto

Author: Arthur Eubanks (aeubanks)


Changes

The performance of cold functions shouldn't matter too much, so if we care 
about binary sizes, add an option to mark cold functions as optsize/minsize for 
binary size, or optnone for compile times [1]. Clang patch will be in a future 
patch

Initial version: https://reviews.llvm.org/D149800

[1] 
https://discourse.llvm.org/t/rfc-new-feature-proposal-de-optimizing-cold-functions-using-pgo-info/56388


---

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


13 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+12-6) 
- (modified) llvm/include/llvm/Support/PGOOptions.h (+3) 
- (added) llvm/include/llvm/Transforms/Instrumentation/MarkColdFunctions.h 
(+28) 
- (modified) llvm/lib/LTO/LTOBackend.cpp (+8-4) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+2-1) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+12) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1) 
- (modified) llvm/lib/Support/PGOOptions.cpp (+4-3) 
- (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1) 
- (added) llvm/lib/Transforms/Instrumentation/MarkColdFunctions.cpp (+65) 
- (added) llvm/test/Transforms/MarkColdFunctions/basic.ll (+97) 
- (modified) llvm/tools/opt/NewPMDriver.cpp (+19-5) 
- (modified) 
llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn (+1) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index d066819871dfde3..f0c9b9d4daf08b5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -770,7 +770,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
 "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling,
+PGOOptions::NoCSAction, PGOOptions::ColdFuncAttr::None,
+CodeGenOpts.DebugInfoForProfiling,
 /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
@@ -779,28 +780,32 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 PGOOpt = PGOOptions(
 CodeGenOpts.ProfileInstrumentUsePath, "",
 CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, 
VFS,
-PGOOptions::IRUse, CSAction, CodeGenOpts.DebugInfoForProfiling);
+PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncAttr::None,
+CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
 PGOOpt = PGOOptions(
 CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
 CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse,
-PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling,
-CodeGenOpts.PseudoProbeForProfiling);
+PGOOptions::NoCSAction, PGOOptions::ColdFuncAttr::None,
+CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
 // -fmemory-profile-use (without any of the above options)
 PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
+PGOOptions::ColdFuncAttr::None,
 CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
 // -fpseudo-probe-for-profiling
 PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
+PGOOptions::ColdFuncAttr::None,
 CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
 // -fdebug-info-for-profiling
 PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
-PGOOptions::NoAction, PGOOptions::NoCSAction, true);
+PGOOptions::NoAction, PGOOptions::NoCSAction,
+PGOOptions::ColdFuncAttr::None, true);
 
   // Check to see if we want to generate a CS profile.
   if (CodeGenOpts.hasProfileCSIRInstr()) {
@@ -823,7 +828,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
  ? getDefaultProfileGenName()
  : CodeGenOpts.InstrProfileOutput,
  "", /*MemoryProfile=*/"", nullptr, PGOOptions::NoAction,
- PGOOptions::CSIRInstr, CodeGenOpts.DebugInfoForProfiling);
+ PGOOptions::CSIRInstr, PGOOptions::ColdFuncAttr::None,
+ CodeGenOpts.DebugInfoForProfiling);
   }
   if (TM)
 TM->setPGOOption(PGOOpt);
diff --git 

[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

still need to do measurements with this new approach, but lmk if this makes 
sense

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


[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

2023-10-13 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks created 
https://github.com/llvm/llvm-project/pull/69030

The performance of cold functions shouldn't matter too much, so if we care 
about binary sizes, add an option to mark cold functions as optsize/minsize for 
binary size, or optnone for compile times [1]. Clang patch will be in a future 
patch

Initial version: https://reviews.llvm.org/D149800

[1] 
https://discourse.llvm.org/t/rfc-new-feature-proposal-de-optimizing-cold-functions-using-pgo-info/56388


>From 81083bddc68864a96f265910019b519d28601e60 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Fri, 13 Oct 2023 14:40:28 -0700
Subject: [PATCH] [PGO] Add ability to mark cold functions as
 optsize/minsize/optnone

The performance of cold functions shouldn't matter too much, so if we care 
about binary sizes, add an option to mark cold functions as optsize/minsize for 
binary size, or optnone for compile times [1]. Clang patch will be in a future 
patch

Initial version: https://reviews.llvm.org/D149800

[1] 
https://discourse.llvm.org/t/rfc-new-feature-proposal-de-optimizing-cold-functions-using-pgo-info/56388
---
 clang/lib/CodeGen/BackendUtil.cpp | 18 ++--
 llvm/include/llvm/Support/PGOOptions.h|  3 +
 .../Instrumentation/MarkColdFunctions.h   | 28 ++
 llvm/lib/LTO/LTOBackend.cpp   | 12 ++-
 llvm/lib/Passes/PassBuilder.cpp   |  3 +-
 llvm/lib/Passes/PassBuilderPipelines.cpp  | 12 +++
 llvm/lib/Passes/PassRegistry.def  |  1 +
 llvm/lib/Support/PGOOptions.cpp   |  7 +-
 .../Transforms/Instrumentation/CMakeLists.txt |  1 +
 .../Instrumentation/MarkColdFunctions.cpp | 65 +
 .../Transforms/MarkColdFunctions/basic.ll | 97 +++
 llvm/tools/opt/NewPMDriver.cpp| 24 -
 .../lib/Transforms/Instrumentation/BUILD.gn   |  1 +
 13 files changed, 253 insertions(+), 19 deletions(-)
 create mode 100644 
llvm/include/llvm/Transforms/Instrumentation/MarkColdFunctions.h
 create mode 100644 llvm/lib/Transforms/Instrumentation/MarkColdFunctions.cpp
 create mode 100644 llvm/test/Transforms/MarkColdFunctions/basic.ll

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index d066819871dfde3..f0c9b9d4daf08b5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -770,7 +770,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
 "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling,
+PGOOptions::NoCSAction, PGOOptions::ColdFuncAttr::None,
+CodeGenOpts.DebugInfoForProfiling,
 /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
@@ -779,28 +780,32 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 PGOOpt = PGOOptions(
 CodeGenOpts.ProfileInstrumentUsePath, "",
 CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, 
VFS,
-PGOOptions::IRUse, CSAction, CodeGenOpts.DebugInfoForProfiling);
+PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncAttr::None,
+CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
 PGOOpt = PGOOptions(
 CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
 CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse,
-PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling,
-CodeGenOpts.PseudoProbeForProfiling);
+PGOOptions::NoCSAction, PGOOptions::ColdFuncAttr::None,
+CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
 // -fmemory-profile-use (without any of the above options)
 PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
+PGOOptions::ColdFuncAttr::None,
 CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
 // -fpseudo-probe-for-profiling
 PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
+PGOOptions::ColdFuncAttr::None,
 CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
 // -fdebug-info-for-profiling
 PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
-PGOOptions::NoAction, PGOOptions::NoCSAction, true);
+PGOOptions::NoAction, PGOOptions::NoCSAction,
+   

[clang-tools-extra] [bolt] Add cmake c, cxx, asm, linker flags (PR #68358)

2023-10-13 Thread via cfe-commits

https://github.com/hiraditya updated 
https://github.com/llvm/llvm-project/pull/68358

>From 1e90114dd6ca671671d66460378de9ebf5b4dda0 Mon Sep 17 00:00:00 2001
From: AdityaK <1894981+hiradi...@users.noreply.github.com>
Date: Thu, 5 Oct 2023 11:41:21 -0700
Subject: [PATCH] Add cmake c,cxx,asm,linker flags

Fixes: #68356
---
 bolt/CMakeLists.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt
index f163d45342874d0..0d07cb43eea82b7 100644
--- a/bolt/CMakeLists.txt
+++ b/bolt/CMakeLists.txt
@@ -97,7 +97,11 @@ if (BOLT_ENABLE_RUNTIME)
 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
 BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins
 CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+   -DCMAKE_ASM_FLAGS=${CMAKE_ASM_FLAGS}
+   -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
+   -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+   -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}

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


[PATCH] D151479: [clang] Use IgnoreParensSingleStep in more places

2023-10-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151479

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


[clang] e220398 - [MSVC, ARM64] Add __prefetch intrinsic (#67174)

2023-10-13 Thread via cfe-commits

Author: Amy Huang
Date: 2023-10-13T13:34:15-07:00
New Revision: e220398cc3aea0c23752594aa3d8437c13bf4c71

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

LOG: [MSVC, ARM64] Add __prefetch intrinsic (#67174)

Implement __prefetch intrinsic. 

MSVC docs:
https://learn.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

Bug: https://github.com/llvm/llvm-project/issues/65405

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/intrin.h
clang/test/CodeGen/arm64-microsoft-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 12c7a371e0fbdb9..82a1ba3c82ad358 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -283,6 +283,8 @@ TARGET_HEADER_BUILTIN(_CountLeadingZeros64, "UiULLi", "nh", 
INTRIN_H, ALL_MS_LAN
 TARGET_HEADER_BUILTIN(_CountOneBits, "UiUNi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_CountOneBits64, "UiULLi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(__prefetch, "vv*", "nh", INTRIN_H, ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8cb7943df9a7822..c05e69eff43704f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10842,6 +10842,15 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 return Result;
   }
 
+  if (BuiltinID == AArch64::BI__prefetch) {
+Value *Address = EmitScalarExpr(E->getArg(0));
+Value *RW = llvm::ConstantInt::get(Int32Ty, 0);
+Value *Locality = ConstantInt::get(Int32Ty, 3);
+Value *Data = llvm::ConstantInt::get(Int32Ty, 1);
+Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
+return Builder.CreateCall(F, {Address, RW, Locality, Data});
+  }
+
   // Handle MSVC intrinsics before argument evaluation to prevent double
   // evaluation.
   if (std::optional MsvcIntId =

diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 4678c527bfaab5a..9ebaea9fee94214 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -586,6 +586,8 @@ unsigned int _CountLeadingZeros(unsigned long);
 unsigned int _CountLeadingZeros64(unsigned _int64);
 unsigned int _CountOneBits(unsigned long);
 unsigned int _CountOneBits64(unsigned __int64);
+
+void __cdecl __prefetch(void *);
 #endif
 
 
/**\

diff  --git a/clang/test/CodeGen/arm64-microsoft-intrinsics.c 
b/clang/test/CodeGen/arm64-microsoft-intrinsics.c
index b15defb0894e92e..44b2ee28fe56814 100644
--- a/clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ b/clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -402,6 +402,16 @@ unsigned int check_CountOneBits64(unsigned __int64 arg1) {
 // CHECK-MSCOMPAT: ret i32 %[[VAR2]]
 // CHECK-LINUX: error: call to undeclared function '_CountOneBits64'
 
+void check__prefetch(void *arg1) {
+  return __prefetch(arg1);
+}
+
+// CHECK-MSCOMPAT: %[[ARG1:.*]].addr = alloca ptr, align 8
+// CHECK-MSCOMPAT: store ptr %[[ARG1]], ptr %[[ARG1]].addr, align 8
+// CHECK-MSCOMPAT: %[[VAR0:.*]] = load ptr, ptr %[[ARG1]].addr, align 8
+// CHECK-MSCOMPAT: call void @llvm.prefetch.p0(ptr %[[VAR0]], i32 0, i32 3, 
i32 1)
+// CHECK-MSCOMPAT: ret void
+
 
 // CHECK-MSCOMPAT: ![[MD2]] = !{!"x18"}
 // CHECK-MSCOMPAT: ![[MD3]] = !{!"sp"}



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


[clang] [MSVC, ARM64] Add __prefetch intrinsic (PR #67174)

2023-10-13 Thread Amy Huang via cfe-commits

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


[clang] [clang][modules] Use file name as requested (PR #68957)

2023-10-13 Thread Ben Langmuir via cfe-commits


@@ -1384,10 +1384,10 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
   SmallVector ModMaps(AdditionalModMaps->begin(),
AdditionalModMaps->end());
   llvm::sort(ModMaps, [](FileEntryRef A, FileEntryRef B) {
-return A.getName() < B.getName();
+return A.getNameAsRequested() < B.getNameAsRequested();
   });
   for (FileEntryRef F : ModMaps)
-AddPath(F.getName(), Record);
+AddPath(F.getNameAsRequested(), Record);

benlangmuir wrote:

How does this relate to the header search part of the change?

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


[clang] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -289,13 +306,38 @@ TargetPointerResultTy DeviceTy::getTargetPointer(
 // In addition to the mapping rules above, the close map modifier forces 
the
 // mapping of the variable to the device.
 if (Size) {
-  DP("Return HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "
- "memory\n",
- DPxPTR((uintptr_t)HstPtrBegin), Size);
-  LR.TPR.Flags.IsPresent = false;
+  LR.TPR.Flags.IsNewEntry = true;
+  assert(TgtPadding == 0 && "TgtPadding must always be zero in USM mode");
+  uintptr_t TgtPtrBegin = (uintptr_t)HstPtrBegin + TgtPadding;
+  LR.TPR.setEntry(
+  HDTTMap
+  ->emplace(new HostDataToTargetTy(
+  (uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
+  (uintptr_t)HstPtrBegin + Size, (uintptr_t)HstPtrBegin,
+  TgtPtrBegin, HasHoldModifier, HstPtrName))
+  .first->HDTT);
+  INFO(OMP_INFOTYPE_MAPPING_CHANGED, DeviceID,
+   "Creating new map entry ONLY with HstPtrBase=" DPxMOD
+   ", HstPtrBegin=" DPxMOD ", TgtAllocBegin=" DPxMOD
+   ", TgtPtrBegin=" DPxMOD
+   ", Size=%ld, DynRefCount=%s, HoldRefCount=%s, Name=%s\n",
+   DPxPTR(HstPtrBase), DPxPTR(HstPtrBegin), DPxPTR(HstPtrBegin),
+   DPxPTR(TgtPtrBegin), Size,
+   LR.TPR.getEntry()->dynRefCountToStr().c_str(),
+   LR.TPR.getEntry()->holdRefCountToStr().c_str(),
+   (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
   LR.TPR.Flags.IsHostPointer = true;
+
+  // The following assert should catch any case in which the pointers
+  // do not match to understand if this case can ever happen.
+  assert((uintptr_t)HstPtrBegin == TgtPtrBegin &&
+ "Pointers must always match");
+
+  // If the above assert is ever hit the following should be changed to =
+  // TgtPtrBegin
   LR.TPR.TargetPointer = HstPtrBegin;
 }
+LR.TPR.Flags.IsPresent = false;

carlobertolli wrote:

How do we implement omp_target_is_present()?
If we implement it by checking if the input pointer is contained within 
previously mapped memory, then we might want to change this to "true".

Here's a reminder of the definition of the API above:

> The omp_target_is_present routine tests whether a host pointer refers to 
> storage that is
> mapped to a given device.

Under unified_shared_memory, mapping memory should mean the same as in non 
unified_shared_memory: not that memory is being allocated and copied on some 
physical storage device, but that the device data environment contains that 
memory, which in this case it does (and it is accessed via the host pointer).
I believe omp_target_is_present implementation has been discussed in the 
context of OpenMP acceleration subcommittee, so we may want to check on what 
TR11 and any "in fieri" document requires about this.

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


[clang-tools-extra] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -289,13 +306,38 @@ TargetPointerResultTy DeviceTy::getTargetPointer(
 // In addition to the mapping rules above, the close map modifier forces 
the
 // mapping of the variable to the device.
 if (Size) {
-  DP("Return HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "
- "memory\n",
- DPxPTR((uintptr_t)HstPtrBegin), Size);
-  LR.TPR.Flags.IsPresent = false;
+  LR.TPR.Flags.IsNewEntry = true;
+  assert(TgtPadding == 0 && "TgtPadding must always be zero in USM mode");
+  uintptr_t TgtPtrBegin = (uintptr_t)HstPtrBegin + TgtPadding;
+  LR.TPR.setEntry(
+  HDTTMap
+  ->emplace(new HostDataToTargetTy(
+  (uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
+  (uintptr_t)HstPtrBegin + Size, (uintptr_t)HstPtrBegin,
+  TgtPtrBegin, HasHoldModifier, HstPtrName))
+  .first->HDTT);
+  INFO(OMP_INFOTYPE_MAPPING_CHANGED, DeviceID,
+   "Creating new map entry ONLY with HstPtrBase=" DPxMOD
+   ", HstPtrBegin=" DPxMOD ", TgtAllocBegin=" DPxMOD
+   ", TgtPtrBegin=" DPxMOD
+   ", Size=%ld, DynRefCount=%s, HoldRefCount=%s, Name=%s\n",
+   DPxPTR(HstPtrBase), DPxPTR(HstPtrBegin), DPxPTR(HstPtrBegin),
+   DPxPTR(TgtPtrBegin), Size,
+   LR.TPR.getEntry()->dynRefCountToStr().c_str(),
+   LR.TPR.getEntry()->holdRefCountToStr().c_str(),
+   (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
   LR.TPR.Flags.IsHostPointer = true;
+
+  // The following assert should catch any case in which the pointers
+  // do not match to understand if this case can ever happen.
+  assert((uintptr_t)HstPtrBegin == TgtPtrBegin &&
+ "Pointers must always match");
+
+  // If the above assert is ever hit the following should be changed to =
+  // TgtPtrBegin
   LR.TPR.TargetPointer = HstPtrBegin;
 }
+LR.TPR.Flags.IsPresent = false;

carlobertolli wrote:

How do we implement omp_target_is_present()?
If we implement it by checking if the input pointer is contained within 
previously mapped memory, then we might want to change this to "true".

Here's a reminder of the definition of the API above:

> The omp_target_is_present routine tests whether a host pointer refers to 
> storage that is
> mapped to a given device.

Under unified_shared_memory, mapping memory should mean the same as in non 
unified_shared_memory: not that memory is being allocated and copied on some 
physical storage device, but that the device data environment contains that 
memory, which in this case it does (and it is accessed via the host pointer).
I believe omp_target_is_present implementation has been discussed in the 
context of OpenMP acceleration subcommittee, so we may want to check on what 
TR11 and any "in fieri" document requires about this.

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


[libunwind] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -289,13 +306,38 @@ TargetPointerResultTy DeviceTy::getTargetPointer(
 // In addition to the mapping rules above, the close map modifier forces 
the
 // mapping of the variable to the device.
 if (Size) {
-  DP("Return HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "
- "memory\n",
- DPxPTR((uintptr_t)HstPtrBegin), Size);
-  LR.TPR.Flags.IsPresent = false;
+  LR.TPR.Flags.IsNewEntry = true;
+  assert(TgtPadding == 0 && "TgtPadding must always be zero in USM mode");
+  uintptr_t TgtPtrBegin = (uintptr_t)HstPtrBegin + TgtPadding;
+  LR.TPR.setEntry(

carlobertolli wrote:

As you are changing the behavior of getTargetPointer under 
unified_shared_memory, please update the comment on the declaration of 
getTargetPointer in device.h.

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


[libunwind] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -268,6 +268,23 @@ TargetPointerResultTy DeviceTy::getTargetPointer(
  LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction,
  (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
 LR.TPR.TargetPointer = (void *)Ptr;
+
+if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
+!HasCloseModifier && !LR.TPR.Flags.IsHostPointer) {
+  // This is a host pointer and is not present if the pointers match:
+  if (LR.TPR.getEntry()->TgtPtrBegin == LR.TPR.getEntry()->HstPtrBegin) {
+LR.TPR.Flags.IsPresent = false;
+LR.TPR.Flags.IsHostPointer = true;
+  }
+
+  // Catch the case where incmoing HstPtrBegin is not consistent with the

carlobertolli wrote:

incmoing->incoming

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


[clang] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -0,0 +1,158 @@
+// RUN: %libomptarget-compilexx-generic && env HSA_XNACK=1 LIBOMPTARGET_INFO=-1
+// %libomptarget-run-generic 2>&1 | %fcheck-generic
+
+// UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
+
+// REQUIRES: amdgcn-amd-amdhsa
+
+#include 
+#include 
+
+#pragma omp requires unified_shared_memory
+
+#define N 1024
+
+int main(int argc, char *argv[]) {
+  int fails;
+  void *host_alloc, *device_alloc;
+  void *host_data, *device_data;
+  int *alloc = (int *)malloc(N * sizeof(int));
+  int data[N];
+
+  for (int i = 0; i < N; ++i) {
+alloc[i] = 10;
+data[i] = 1;
+  }
+
+  host_data = [0];
+  host_alloc = [0];
+
+// CHECK: Creating new map entry ONLY with
+// HstPtrBase=[[DEVICE_DATA_HST_PTR:0x.*]], 
HstPtrBegin=[[DEVICE_DATA_HST_PTR]],
+// TgtAllocBegin=[[DEVICE_DATA_HST_PTR]], TgtPtrBegin=[[DEVICE_DATA_HST_PTR]],
+// Size=8, DynRefCount=1, HoldRefCount=0 CHECK: Creating new map entry ONLY 
with
+// HstPtrBase=[[DATA_HST_PTR:0x.*]], HstPtrBegin=[[DATA_HST_PTR]],
+// TgtAllocBegin=[[DATA_HST_PTR]], TgtPtrBegin=[[DATA_HST_PTR]], Size=4096,
+// DynRefCount=1, HoldRefCount=0 CHECK: Creating new map entry ONLY with
+// HstPtrBase=[[DEVICE_ALLOC_HST_PTR:0x.*]],
+// HstPtrBegin=[[DEVICE_ALLOC_HST_PTR]], 
TgtAllocBegin=[[DEVICE_ALLOC_HST_PTR]],
+// TgtPtrBegin=[[DEVICE_ALLOC_HST_PTR]], Size=8, DynRefCount=1, HoldRefCount=0
+
+// CHECK: Mapping exists with HstPtrBegin=[[DEVICE_DATA_HST_PTR]],
+// TgtPtrBegin=[[DEVICE_DATA_HST_PTR]], Size=8, DynRefCount=1 (update
+// suppressed), HoldRefCount=0 CHECK: Mapping exists with
+// HstPtrBegin=[[DATA_HST_PTR]], TgtPtrBegin=[[DATA_HST_PTR]], Size=4096,
+// DynRefCount=1 (update suppressed), HoldRefCount=0 CHECK: Mapping exists with
+// HstPtrBegin=[[DEVICE_ALLOC_HST_PTR]], TgtPtrBegin=[[DEVICE_ALLOC_HST_PTR]],
+// Size=8, DynRefCount=1 (update suppressed), HoldRefCount=0
+
+// CHECK: Launching kernel __omp_offloading_{{.*}}_main_l{{.*}} with 1 blocks
+// and 256 threads in Generic mode
+
+// CHECK: Mapping exists with HstPtrBegin=[[DEVICE_ALLOC_HST_PTR]],
+// TgtPtrBegin=[[DEVICE_ALLOC_HST_PTR]], Size=8, DynRefCount=0 (decremented,
+// delayed deletion), HoldRefCount=0 CHECK: Mapping exists with
+// HstPtrBegin=[[DATA_HST_PTR]], TgtPtrBegin=[[DATA_HST_PTR]], Size=4096,
+// DynRefCount=0 (decremented, delayed deletion), HoldRefCount=0 CHECK: Mapping
+// exists with HstPtrBegin=[[DEVICE_DATA_HST_PTR]],
+// TgtPtrBegin=[[DEVICE_DATA_HST_PTR]], Size=8, DynRefCount=0 (decremented,
+// delayed deletion), HoldRefCount=0
+
+// CHECK: Removing map entry with HstPtrBegin=[[DEVICE_ALLOC_HST_PTR]]{{.*}}
+// Size=8 CHECK: Removing map entry with HstPtrBegin=[[DATA_HST_PTR]]{{.*}}
+// Size=4096 CHECK: Removing map entry with
+// HstPtrBegin=[[DEVICE_DATA_HST_PTR]]{{.*}} Size=8
+
+// implicit mapping of data
+#pragma omp target map(tofrom : device_data, device_alloc)
+  {
+device_data = [0];
+device_alloc = [0];
+
+for (int i = 0; i < N; i++) {
+  alloc[i] += 1;
+  data[i] += 1;
+}
+  }
+
+  if (device_alloc == host_alloc)
+printf("Address of alloc on device matches host address.\n");
+
+  if (device_data == host_data)
+printf("Address of data on device matches host address.\n");
+
+  // On the host, check that the arrays have been updated.
+  fails = 0;
+  for (int i = 0; i < N; i++) {
+if (alloc[i] != 11)
+  fails++;
+  }
+  printf("Alloc device values updated: %s\n",
+ (fails == 0) ? "Succeeded" : "Failed");
+
+  fails = 0;
+  for (int i = 0; i < N; i++) {
+if (data[i] != 2)
+  fails++;
+  }
+  printf("Data device values updated: %s\n",
+ (fails == 0) ? "Succeeded" : "Failed");
+
+  //
+  // Test that updates on the host snd on the device are both visible.

carlobertolli wrote:

snd-->and

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


[clang] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -268,6 +268,23 @@ TargetPointerResultTy DeviceTy::getTargetPointer(
  LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction,
  (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
 LR.TPR.TargetPointer = (void *)Ptr;
+
+if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
+!HasCloseModifier && !LR.TPR.Flags.IsHostPointer) {
+  // This is a host pointer and is not present if the pointers match:
+  if (LR.TPR.getEntry()->TgtPtrBegin == LR.TPR.getEntry()->HstPtrBegin) {
+LR.TPR.Flags.IsPresent = false;
+LR.TPR.Flags.IsHostPointer = true;
+  }
+
+  // Catch the case where incmoing HstPtrBegin is not consistent with the

carlobertolli wrote:

incmoing->incoming

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


[libunwind] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -444,6 +486,29 @@ DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size, 
bool UpdateRefCount,
  LR.TPR.getEntry()->dynRefCountToStr().c_str(), DynRefCountAction,
  LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction);
 LR.TPR.TargetPointer = (void *)TP;
+
+// If this entry is not marked as being host pointer (the way the
+// implementation works today this is never true, mistake?) then we
+// have to check if this is a host pointer or not. This is a host pointer
+// if the host address matches the target address.
+if ((PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) &&
+!LR.TPR.Flags.IsHostPointer) {
+  // If addresses match it means that we are dealing with a host pointer
+  // which has to be marked as one and present flag reset:
+  if (LR.TPR.getEntry()->TgtPtrBegin == LR.TPR.getEntry()->HstPtrBegin) {
+LR.TPR.Flags.IsPresent = false;

carlobertolli wrote:

Again, still odd: do we not always use getTargetPointer to add a new entry and 
before calling getTgtPtrBegin? Again, it might be that I do not understand how 
these APIs are used. 

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


[clang-tools-extra] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -444,6 +486,29 @@ DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size, 
bool UpdateRefCount,
  LR.TPR.getEntry()->dynRefCountToStr().c_str(), DynRefCountAction,
  LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction);
 LR.TPR.TargetPointer = (void *)TP;
+
+// If this entry is not marked as being host pointer (the way the
+// implementation works today this is never true, mistake?) then we
+// have to check if this is a host pointer or not. This is a host pointer
+// if the host address matches the target address.
+if ((PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) &&
+!LR.TPR.Flags.IsHostPointer) {

carlobertolli wrote:

This is odd: you set IsHostPointer on the new entry under unified_shared_memory 
in getTargetPointer.
I am expecting this to be reflected in getTgtPtrBegin, no? Maybe I am 
misunderstanding how getTgtPtrBegin is really used. I see you are perplexed by 
this behavior too...?

Can you write a test that reproduces this? Like

```
#pragma opm requires unified_shared_memory

void foo() {
  int a[10];
  #pragma omp target enter data map(to:a[10])

  #pragma omp target  \\ should this call getTgtPtrBegin?
 {
a[0] = 1;
  }
}
```


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


[clang-tools-extra] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread via cfe-commits


@@ -268,6 +268,23 @@ TargetPointerResultTy DeviceTy::getTargetPointer(
  LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction,
  (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
 LR.TPR.TargetPointer = (void *)Ptr;
+
+if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
+!HasCloseModifier && !LR.TPR.Flags.IsHostPointer) {
+  // This is a host pointer and is not present if the pointers match:
+  if (LR.TPR.getEntry()->TgtPtrBegin == LR.TPR.getEntry()->HstPtrBegin) {
+LR.TPR.Flags.IsPresent = false;
+LR.TPR.Flags.IsHostPointer = true;
+  }
+
+  // Catch the case where incmoing HstPtrBegin is not consistent with the

carlobertolli wrote:

incmoing->incoming

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


[clang-tools-extra] [libcxx] Unifying __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (PR #68642)

2023-10-13 Thread Anton Rydahl via cfe-commits

https://github.com/AntonRydahl updated 
https://github.com/llvm/llvm-project/pull/68642

>From f0d93cc6a5cd485c654ab38221691db038bacc7d Mon Sep 17 00:00:00 2001
From: AntonRydahl 
Date: Mon, 9 Oct 2023 15:13:22 -0700
Subject: [PATCH 1/2] Merged __is_trivial_equality_predicate and
 __is_trivial_plus_operation into __desugars_to

---
 libcxx/include/CMakeLists.txt |  1 -
 libcxx/include/__algorithm/comp.h |  7 ++---
 libcxx/include/__algorithm/equal.h| 22 
 .../cpu_backends/transform_reduce.h   | 23 
 libcxx/include/__functional/operations.h  | 15 +--
 .../include/__functional/ranges_operations.h  |  7 ++---
 .../include/__numeric/pstl_transform_reduce.h |  2 +-
 .../include/__type_traits/operation_traits.h  |  4 +--
 .../include/__type_traits/predicate_traits.h  | 26 ---
 libcxx/include/module.modulemap.in|  1 -
 10 files changed, 40 insertions(+), 68 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/predicate_traits.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 340353f8ebb41c4..7eb09a06ccd482e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -813,7 +813,6 @@ set(files
   __type_traits/negation.h
   __type_traits/noexcept_move_assign_container.h
   __type_traits/operation_traits.h
-  __type_traits/predicate_traits.h
   __type_traits/promote.h
   __type_traits/rank.h
   __type_traits/remove_all_extents.h
diff --git a/libcxx/include/__algorithm/comp.h 
b/libcxx/include/__algorithm/comp.h
index 9474536615ffb67..0993c37cce36a6b 100644
--- a/libcxx/include/__algorithm/comp.h
+++ b/libcxx/include/__algorithm/comp.h
@@ -10,8 +10,9 @@
 #define _LIBCPP___ALGORITHM_COMP_H
 
 #include <__config>
+#include <__functional/operations.h>
 #include <__type_traits/integral_constant.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -26,8 +27,8 @@ struct __equal_to {
   }
 };
 
-template 
-struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
+template <>
+struct __desugars_to<__equal_to, std::equal_to<>> : true_type {};
 
 // The definition is required because __less is part of the ABI, but it's empty
 // because all comparisons should be transparent.
diff --git a/libcxx/include/__algorithm/equal.h 
b/libcxx/include/__algorithm/equal.h
index b69aeff92bb9289..35e82da15e4d058 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -15,6 +15,7 @@
 #include <__config>
 #include <__functional/identity.h>
 #include <__functional/invoke.h>
+#include <__functional/operations.h>
 #include <__iterator/distance.h>
 #include <__iterator/iterator_traits.h>
 #include <__string/constexpr_c_functions.h>
@@ -23,7 +24,7 @@
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_equality_comparable.h>
 #include <__type_traits/is_volatile.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 #include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -41,13 +42,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_CONSTEXPR_SINCE_CXX20 boo
   return true;
 }
 
-template <
-class _Tp,
-class _Up,
-class _BinaryPredicate,
-__enable_if_t<__is_trivial_equality_predicate<_BinaryPredicate, _Tp, 
_Up>::value && !is_volatile<_Tp>::value &&
-  !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
-  int> = 0>
+template < class _Tp,
+   class _Up,
+   class _BinaryPredicate,
+   __enable_if_t<__desugars_to<_BinaryPredicate, 
std::equal_to<>>::value && !is_volatile<_Tp>::value &&
+ !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
+ int> = 0>
 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool
 __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, 
_BinaryPredicate&) {
   return std::__constexpr_memcmp_equal(__first1, __first2, 
__element_count(__last1 - __first1));
@@ -94,12 +94,12 @@ template ::value && __is_identity<_Proj1>::value &&
+  __enable_if_t<__desugars_to<_Pred, std::equal_to<>>::value && 
__is_identity<_Proj1>::value &&
 __is_identity<_Proj2>::value && 
!is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
 __libcpp_is_trivially_equality_comparable<_Tp, 
_Up>::value,
 int> = 0>
-_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool __equal_impl(
-_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, 
_Proj2&) {
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool

[clang] [libcxx] Unifying __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (PR #68642)

2023-10-13 Thread Anton Rydahl via cfe-commits

https://github.com/AntonRydahl updated 
https://github.com/llvm/llvm-project/pull/68642

>From f0d93cc6a5cd485c654ab38221691db038bacc7d Mon Sep 17 00:00:00 2001
From: AntonRydahl 
Date: Mon, 9 Oct 2023 15:13:22 -0700
Subject: [PATCH 1/2] Merged __is_trivial_equality_predicate and
 __is_trivial_plus_operation into __desugars_to

---
 libcxx/include/CMakeLists.txt |  1 -
 libcxx/include/__algorithm/comp.h |  7 ++---
 libcxx/include/__algorithm/equal.h| 22 
 .../cpu_backends/transform_reduce.h   | 23 
 libcxx/include/__functional/operations.h  | 15 +--
 .../include/__functional/ranges_operations.h  |  7 ++---
 .../include/__numeric/pstl_transform_reduce.h |  2 +-
 .../include/__type_traits/operation_traits.h  |  4 +--
 .../include/__type_traits/predicate_traits.h  | 26 ---
 libcxx/include/module.modulemap.in|  1 -
 10 files changed, 40 insertions(+), 68 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/predicate_traits.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 340353f8ebb41c4..7eb09a06ccd482e 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -813,7 +813,6 @@ set(files
   __type_traits/negation.h
   __type_traits/noexcept_move_assign_container.h
   __type_traits/operation_traits.h
-  __type_traits/predicate_traits.h
   __type_traits/promote.h
   __type_traits/rank.h
   __type_traits/remove_all_extents.h
diff --git a/libcxx/include/__algorithm/comp.h 
b/libcxx/include/__algorithm/comp.h
index 9474536615ffb67..0993c37cce36a6b 100644
--- a/libcxx/include/__algorithm/comp.h
+++ b/libcxx/include/__algorithm/comp.h
@@ -10,8 +10,9 @@
 #define _LIBCPP___ALGORITHM_COMP_H
 
 #include <__config>
+#include <__functional/operations.h>
 #include <__type_traits/integral_constant.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -26,8 +27,8 @@ struct __equal_to {
   }
 };
 
-template 
-struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
+template <>
+struct __desugars_to<__equal_to, std::equal_to<>> : true_type {};
 
 // The definition is required because __less is part of the ABI, but it's empty
 // because all comparisons should be transparent.
diff --git a/libcxx/include/__algorithm/equal.h 
b/libcxx/include/__algorithm/equal.h
index b69aeff92bb9289..35e82da15e4d058 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -15,6 +15,7 @@
 #include <__config>
 #include <__functional/identity.h>
 #include <__functional/invoke.h>
+#include <__functional/operations.h>
 #include <__iterator/distance.h>
 #include <__iterator/iterator_traits.h>
 #include <__string/constexpr_c_functions.h>
@@ -23,7 +24,7 @@
 #include <__type_traits/is_constant_evaluated.h>
 #include <__type_traits/is_equality_comparable.h>
 #include <__type_traits/is_volatile.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
 #include <__utility/move.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -41,13 +42,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_CONSTEXPR_SINCE_CXX20 boo
   return true;
 }
 
-template <
-class _Tp,
-class _Up,
-class _BinaryPredicate,
-__enable_if_t<__is_trivial_equality_predicate<_BinaryPredicate, _Tp, 
_Up>::value && !is_volatile<_Tp>::value &&
-  !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
-  int> = 0>
+template < class _Tp,
+   class _Up,
+   class _BinaryPredicate,
+   __enable_if_t<__desugars_to<_BinaryPredicate, 
std::equal_to<>>::value && !is_volatile<_Tp>::value &&
+ !is_volatile<_Up>::value && 
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
+ int> = 0>
 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool
 __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, 
_BinaryPredicate&) {
   return std::__constexpr_memcmp_equal(__first1, __first2, 
__element_count(__last1 - __first1));
@@ -94,12 +94,12 @@ template ::value && __is_identity<_Proj1>::value &&
+  __enable_if_t<__desugars_to<_Pred, std::equal_to<>>::value && 
__is_identity<_Proj1>::value &&
 __is_identity<_Proj2>::value && 
!is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
 __libcpp_is_trivially_equality_comparable<_Tp, 
_Up>::value,
 int> = 0>
-_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool __equal_impl(
-_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, 
_Proj2&) {
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 
bool

[clang] Use the correct namespace for looking up matching operator!= (PR #68922)

2023-10-13 Thread Richard Smith via cfe-commits

zygoloid wrote:

> > Does this work for function-scope operator declarations?
> 
> @zygoloid I am not sure I follow. Could you please give an example.

Sure:

```c++
struct X { operator int(); };

bool f(X x) {
  bool operator==(X, int);
  return x == x;
}


bool g(X x) {
  bool operator==(X, int);
  bool operator!=(X, int);
  return x == x;
}

bool operator!=(X, int);

bool h(X x) {
  bool operator==(X, int);
  return x == x;
}


bool i(X x) {
  bool operator==(X, int);
  bool operator!=(X, int);
  return x == x;
}
```

Based on the standard's rules, it looks like `f` and `g` should be invalid due 
to ambiguity, but `h` and `i` should be valid. (Which I think is a pretty 
surprising outcome, but that's what the rules say.)

If there's not already something like that in our test suite, it'd be good to 
add it.

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits


@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(datasizeof, LangOpts.CPlusPlus)

philnik777 wrote:

Yeah, that's what we'd have to fall back to - or just live with using the 
fallback when changing warning flags (!?).

Not really relevant for this patch, but I'm not sure the behaviour actually 
makes that much sense. There are a few things that make it somewhat weird IMO.
1) `-pedantic-errors` disables `__has_extension`, but `-Werror=pedantic` 
doesn't. These are clearly distinct flags, but for a user they look like 
aliases, since they interact with warnings identically (AFAIK).
2) If you use `__has_extension` you almost always want to know whether the 
compiler accepts some code, and if not you generate an error that you don't 
support the compiler or use some fallback implementation. (At least that's my 
interpretation)
3) Changing diagnostic flags shouldn't influence anything other than the 
behaviour of the diagnostics engine. The code shouldn't compile differently, 
you should just get different diagnostics.


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


[clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2023-10-13 Thread Kito Cheng via cfe-commits


@@ -106,9 +111,14 @@ static void emitSCSEpilogue(MachineFunction , 
MachineBasicBlock ,
   CSI, [&](CalleeSavedInfo ) { return CSR.getReg() == RAReg; }))
 return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {

kito-cheng wrote:

> Do we need an enable other than just the feature being in -march? The shadow 
> stack pointer has to be set up when the application starts. Is this done by 
> the kernel?
>
> My concern is that if your -mcpu supports Zicfiss, but the kernel doesn't, 
> this will generate code that doesn't work.

oh, that's good point...let me check how other target do

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


[clang] [clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes (PR #68379)

2023-10-13 Thread Erich Keane via cfe-commits

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


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


[clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2023-10-13 Thread Kito Cheng via cfe-commits


@@ -106,9 +111,14 @@ static void emitSCSEpilogue(MachineFunction , 
MachineBasicBlock ,
   CSI, [&](CalleeSavedInfo ) { return CSR.getReg() == RAReg; }))
 return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {

kito-cheng wrote:

> I believe that setting up this memory and initializing the SCS reg would fall 
> under activate the use of Zicfiss..., but I could be wrong.

That suppose initialize SCS register by kernel, more precisely is user space 
will invoke some prctl system call to enable SCS and the kernel will allocate 
SCS page and then initialize the SCS register then back to user space.

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


[clang] [DebugMetadata][DwarfDebug] Clone uniqued function-local types after metadata loading (PR #68986)

2023-10-13 Thread David Blaikie via cfe-commits

dwblaikie wrote:

FWIW, I think we also saw, internally at Google, some significant and 
surprising (growth in sections, like .debug_loclists and 
.debug_gnu_pubnames/types) that were a bit surprising/not what I'd have 
expected of the original committed/reverted patch.

Could you run a clang build with/without this patch, and compare the two files 
using `bloaty` ( https://github.com/google/bloaty ) or similar - some 
comparison of the % growth of each section to see how these patches are 
affecting debug info size?

(patch itself sounds OK/looks good)

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


[clang] Reland "[mlir][arith] Canonicalization patterns for `arith.select` (#67809)" (PR #68941)

2023-10-13 Thread Han-Chung Wang via cfe-commits

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


[clang] [clang][Sema] Use original template pattern when declaring implicit deduction guides for nested template classes (PR #68379)

2023-10-13 Thread via cfe-commits

antangelo wrote:

Friendly ping

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


[clang] a8896e5 - [clang-format][NFC] Annotate control statement r_braces (#68621)

2023-10-13 Thread via cfe-commits

Author: Björn Schäpers
Date: 2023-10-13T21:07:33+02:00
New Revision: a8896e57f150abf57b4e70ba1f6bfbd4c2d24ff6

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

LOG: [clang-format][NFC] Annotate control statement r_braces (#68621)

Annotating switch braces for the first time.

Also in preparation of #67906.

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 527f1d744a58089..606e9e790ad833b 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -52,6 +52,7 @@ namespace format {
   TYPE(ConflictStart)  
\
   /* l_brace of if/for/while */
\
   TYPE(ControlStatementLBrace) 
\
+  TYPE(ControlStatementRBrace) 
\
   TYPE(CppCastLParen)  
\
   TYPE(CSharpGenericTypeConstraint)
\
   TYPE(CSharpGenericTypeConstraintColon)   
\
@@ -67,6 +68,7 @@ namespace format {
   TYPE(DesignatedInitializerPeriod)
\
   TYPE(DictLiteral)
\
   TYPE(ElseLBrace) 
\
+  TYPE(ElseRBrace) 
\
   TYPE(EnumLBrace) 
\
   TYPE(EnumRBrace) 
\
   TYPE(FatArrow)   
\

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 3275d7b6a71aaa0..82a812fc8bcc610 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -640,6 +640,14 @@ void UnwrappedLineParser::calculateBraceTypes(bool 
ExpectClassBody) {
   FormatTok = Tokens->setPosition(StoredPosition);
 }
 
+// Sets the token type of the directly previous right brace.
+void UnwrappedLineParser::setPreviousRBraceType(TokenType Type) {
+  if (auto Prev = FormatTok->getPreviousNonComment();
+  Prev && Prev->is(tok::r_brace)) {
+Prev->setFinalizedType(Type);
+  }
+}
+
 template 
 static inline void hash_combine(std::size_t , const T ) {
   std::hash hasher;
@@ -2756,6 +2764,7 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
 CompoundStatementIndenter Indenter(this, Style, Line->Level);
 parseBlock(/*MustBeDeclaration=*/false, /*AddLevels=*/1u,
/*MunchSemi=*/true, KeepIfBraces, );
+setPreviousRBraceType(TT_ControlStatementRBrace);
 if (Style.BraceWrapping.BeforeElse)
   addUnwrappedLine();
 else
@@ -2794,6 +2803,7 @@ FormatToken 
*UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
   FormatToken *IfLBrace =
   parseBlock(/*MustBeDeclaration=*/false, /*AddLevels=*/1u,
  /*MunchSemi=*/true, KeepElseBraces, );
+  setPreviousRBraceType(TT_ElseRBrace);
   if (FormatTok->is(tok::kw_else)) {
 KeepElseBraces = KeepElseBraces ||
  ElseBlockKind == IfStmtKind::IfOnly ||
@@ -3057,12 +3067,12 @@ void UnwrappedLineParser::parseLoopBody(bool 
KeepBraces, bool WrapRightBrace) {
   keepAncestorBraces();
 
   if (isBlockBegin(*FormatTok)) {
-if (!KeepBraces)
-  FormatTok->setFinalizedType(TT_ControlStatementLBrace);
+FormatTok->setFinalizedType(TT_ControlStatementLBrace);
 FormatToken *LeftBrace = FormatTok;
 CompoundStatementIndenter Indenter(this, Style, Line->Level);
 parseBlock(/*MustBeDeclaration=*/false, /*AddLevels=*/1u,
/*MunchSemi=*/true, KeepBraces);
+setPreviousRBraceType(TT_ControlStatementRBrace);
 if (!KeepBraces) {
   assert(!NestedTooDeep.empty());
   if (!NestedTooDeep.back())
@@ -3196,7 +3206,9 @@ void UnwrappedLineParser::parseSwitch() {
 
   if (FormatTok->is(tok::l_brace)) {
 CompoundStatementIndenter Indenter(this, Style, Line->Level);
+FormatTok->setFinalizedType(TT_ControlStatementLBrace);
 parseBlock();
+setPreviousRBraceType(TT_ControlStatementRBrace);
 addUnwrappedLine();
   } else {
 addUnwrappedLine();
@@ -3713,10 +3725,7 @@ bool UnwrappedLineParser::parseEnum() {
   nextToken();
 addUnwrappedLine();
   }
-  if (auto Prev = 

[clang] [clang-format][NFC] Annotate control statement r_braces (PR #68621)

2023-10-13 Thread Björn Schäpers via cfe-commits

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


[clang] [Clang] Implement the 'counted_by' attribute (PR #68750)

2023-10-13 Thread Bill Wendling via cfe-commits

bwendling wrote:

@nickdesaulniers and @alexfh Any comments? :-)

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(datasizeof, LangOpts.CPlusPlus)

AaronBallman wrote:

Oh my. That behavior makes sense, but is really not helpful in this case.

You could use compiler version macro checks instead of `__has_extension`. 
That's pretty gross and likely easy to forget, but would it be a viable 
workaround?

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


[clang] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

2023-10-13 Thread Gheorghe-Teodor Bercea via cfe-commits

https://github.com/doru1004 updated 
https://github.com/llvm/llvm-project/pull/69005

>From cb4121c466a0fc357d6ca129bfdd4e7c5e2d11ee Mon Sep 17 00:00:00 2001
From: Doru Bercea 
Date: Wed, 16 Nov 2022 17:23:48 -0600
Subject: [PATCH 1/2] Fix declare target implementation to support enter.

---
 clang/include/clang/Basic/Attr.td |  4 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 12 -
 clang/lib/AST/AttrImpl.cpp|  2 +-
 clang/lib/CodeGen/CGExpr.cpp  | 12 +++--
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 24 ++---
 clang/lib/CodeGen/CodeGenModule.cpp   |  6 ++-
 clang/lib/Parse/ParseOpenMP.cpp   | 39 ++
 clang/lib/Sema/SemaOpenMP.cpp | 10 ++--
 .../test/OpenMP/declare_target_ast_print.cpp  | 53 +++
 9 files changed, 130 insertions(+), 32 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 16cf932c3760bd3..eaf4a6db3600e07 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3749,8 +3749,8 @@ def OMPDeclareTargetDecl : InheritableAttr {
   let Documentation = [OMPDeclareTargetDocs];
   let Args = [
 EnumArgument<"MapType", "MapTypeTy",
- [ "to", "link" ],
- [ "MT_To", "MT_Link" ]>,
+ [ "to", "enter", "link" ],
+ [ "MT_To", "MT_Enter", "MT_Link" ]>,
 EnumArgument<"DevType", "DevTypeTy",
  [ "host", "nohost", "any" ],
  [ "DT_Host", "DT_NoHost", "DT_Any" ]>,
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 674d6bd34fc544f..27cd3da1f191c3d 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1383,12 +1383,22 @@ def note_omp_assumption_clause_continue_here
 : Note<"the ignored tokens spans until here">;
 def err_omp_declare_target_unexpected_clause: Error<
   "unexpected '%0' clause, only %select{'device_type'|'to' or 'link'|'to', 
'link' or 'device_type'|'device_type', 'indirect'|'to', 'link', 'device_type' 
or 'indirect'}1 clauses expected">;
+def err_omp_declare_target_unexpected_clause_52: Error<
+  "unexpected '%0' clause, only %select{'device_type'|'enter' or 
'link'|'enter', 'link' or 'device_type'|'device_type', 'indirect'|'enter', 
'link', 'device_type' or 'indirect'}1 clauses expected">;
 def err_omp_begin_declare_target_unexpected_implicit_to_clause: Error<
   "unexpected '(', only 'to', 'link' or 'device_type' clauses expected for 
'begin declare target' directive">;
-def err_omp_declare_target_unexpected_clause_after_implicit_to: Error<
+def err_omp_declare_target_wrong_clause_after_implicit_to: Error<
   "unexpected clause after an implicit 'to' clause">;
+def err_omp_declare_target_wrong_clause_after_implicit_enter: Error<
+  "unexpected clause after an implicit 'enter' clause">;
 def err_omp_declare_target_missing_to_or_link_clause: Error<
   "expected at least one %select{'to' or 'link'|'to', 'link' or 'indirect'}0 
clause">;
+def err_omp_declare_target_missing_enter_or_link_clause: Error<
+  "expected at least one %select{'enter' or 'link'|'enter', 'link' or 
'indirect'}0 clause">;
+def err_omp_declare_target_unexpected_to_clause: Error<
+  "unexpected 'to' clause, use 'enter' instead">;
+def err_omp_declare_target_unexpected_enter_clause: Error<
+  "unexpected 'enter' clause, use 'to' instead">;
 def err_omp_declare_target_multiple : Error<
   "%0 appears multiple times in clauses on the same declare target directive">;
 def err_omp_declare_target_indirect_device_type: Error<
diff --git a/clang/lib/AST/AttrImpl.cpp b/clang/lib/AST/AttrImpl.cpp
index cecbd703ac61e8c..da842f6b190e74d 100644
--- a/clang/lib/AST/AttrImpl.cpp
+++ b/clang/lib/AST/AttrImpl.cpp
@@ -137,7 +137,7 @@ void OMPDeclareTargetDeclAttr::printPrettyPragma(
   // Use fake syntax because it is for testing and debugging purpose only.
   if (getDevType() != DT_Any)
 OS << " device_type(" << ConvertDevTypeTyToStr(getDevType()) << ")";
-  if (getMapType() != MT_To)
+  if (getMapType() != MT_To && getMapType() != MT_Enter)
 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
   if (Expr *E = getIndirectExpr()) {
 OS << " indirect(";
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index ee09a8566c3719e..77085ff34fca233 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2495,14 +2495,16 @@ static Address 
emitDeclTargetVarDeclLValue(CodeGenFunction ,
const VarDecl *VD, QualType T) {
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
-  // Return an invalid address if variable is MT_To and unified
-  // memory is not enabled. For all other cases: MT_Link and
-  // MT_To with unified memory, return a valid address.
-  if (!Res || (*Res 

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits


@@ -1016,4 +1016,7 @@ def warn_unpacked_field
 def warn_unaligned_access : Warning<
   "field %1 within %0 is less aligned than %2 and is usually due to %0 being "
   "packed, which can lead to unaligned accesses">, InGroup, 
DefaultIgnore;
+
+def err_cannot_mangle_expression : Error<
+  "cannot yet mangle %0 expression">;

philnik777 wrote:

Sounds good!

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


[libunwind] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread Louis Dionne via cfe-commits

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


[clang] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread Louis Dionne via cfe-commits

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


[clang] [clang-format][NFC] Annotate control statement r_braces (PR #68621)

2023-10-13 Thread Owen Pan via cfe-commits

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


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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -1016,4 +1016,7 @@ def warn_unpacked_field
 def warn_unaligned_access : Warning<
   "field %1 within %0 is less aligned than %2 and is usually due to %0 being "
   "packed, which can lead to unaligned accesses">, InGroup, 
DefaultIgnore;
+
+def err_cannot_mangle_expression : Error<
+  "cannot yet mangle %0 expression">;

AaronBallman wrote:

Ah, so the "obvious" may be more obvious to people used to working with Clang's 
diagnostics and not so obvious to folks not as well-versed. Good feedback!

I'm okay with the changes but I have a preference for doing this in two steps. 
Step 1: your patch w/custom diagnostics engine, Step 2: replace all custom 
diagnostics with the regular diagnostic in one go. (This makes code archeology 
easier because the changes are kind of orthogonal to one another.) Would you be 
okay with splitting it up despite the extra work?

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits


@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(datasizeof, LangOpts.CPlusPlus)

philnik777 wrote:

The problem is that `-pedantic-errors` makes `__has_extension` useless: 
https://godbolt.org/z/7TfMjf5h6

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


[libunwind] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread Martin Storsjö via cfe-commits


@@ -642,18 +642,8 @@ get_sanitizer_flags(SANITIZER_FLAGS 
"${LLVM_USE_SANITIZER}")
 
 # Link system libraries ===
 function(cxx_link_system_libraries target)
-
-# In order to remove just libc++ from the link step
-# we need to use -nostdlib++ whenever it is supported.
-# Unfortunately this cannot be used universally because for example g++ 
supports
-# only -nodefaultlibs in which case all libraries will be removed and
-# all libraries but c++ have to be added in manually.
-  if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++")
-  else()
-target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs")
-target_add_compile_flags_if_supported(${target} PRIVATE "/Zl")
-target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib")

mstorsjo wrote:

Yeah I think it's totally ok to remove. Whatever the setup was when those might 
have been needed on MSVC-like setups, they're not needed (or usable) currently 
- and our CI coverage is fairly good at the moment, I would say. So if this 
patch works, just go ahead!

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


[clang] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread Martin Storsjö via cfe-commits


@@ -642,18 +642,8 @@ get_sanitizer_flags(SANITIZER_FLAGS 
"${LLVM_USE_SANITIZER}")
 
 # Link system libraries ===
 function(cxx_link_system_libraries target)
-
-# In order to remove just libc++ from the link step
-# we need to use -nostdlib++ whenever it is supported.
-# Unfortunately this cannot be used universally because for example g++ 
supports
-# only -nodefaultlibs in which case all libraries will be removed and
-# all libraries but c++ have to be added in manually.
-  if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++")
-  else()
-target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs")
-target_add_compile_flags_if_supported(${target} PRIVATE "/Zl")
-target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib")

mstorsjo wrote:

Yeah I think it's totally ok to remove. Whatever the setup was when those might 
have been needed on MSVC-like setups, they're not needed (or usable) currently 
- and our CI coverage is fairly good at the moment, I would say. So if this 
patch works, just go ahead!

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(datasizeof, LangOpts.CPlusPlus)

AaronBallman wrote:

Yeah, but we still need to diagnose it as an extension because that's what 
it is. (We should not add extensions that we do not diagnose under `-pedantic` 
-- we have been inconsistent in the past but we've gotten better in the past 
several years.)

Pedantic warnings aren't triggered in system headers, so I think I'm failing to 
see the concern: https://godbolt.org/z/nn7TdKrcv

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


[clang] Reland "[mlir][arith] Canonicalization patterns for `arith.select` (#67809)" (PR #68941)

2023-10-13 Thread Han-Chung Wang via cfe-commits

hanhanW wrote:

thanks for the review!

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


[clang] Reland "[mlir][arith] Canonicalization patterns for `arith.select` (#67809)" (PR #68941)

2023-10-13 Thread Markus Böck via cfe-commits

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


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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits


@@ -1016,4 +1016,7 @@ def warn_unpacked_field
 def warn_unaligned_access : Warning<
   "field %1 within %0 is less aligned than %2 and is usually due to %0 being "
   "packed, which can lead to unaligned accesses">, InGroup, 
DefaultIgnore;
+
+def err_cannot_mangle_expression : Error<
+  "cannot yet mangle %0 expression">;

philnik777 wrote:

I think a `// FIXME` would make that a lot more obvious than using the custom 
diagnostics engine. To me it wasn't obvious that these should be FIXMES, which 
is the reason I replaced them with a normal diagnostic.

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits


@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(datasizeof, LangOpts.CPlusPlus)

philnik777 wrote:

The problem with `EXTENSION` is that it's influenced by `-pedantic-errors`, 
which makes it pretty much useless for standard libraries.

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


[clang] Reland "[mlir][arith] Canonicalization patterns for `arith.select` (#67809)" (PR #68941)

2023-10-13 Thread via cfe-commits

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


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


[clang] [AST] Add dump() method to TypeLoc (PR #65484)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -415,9 +443,55 @@ class ASTNodeTraverser
 if (!T->isSugared())
   Visit(T->getPattern());
   }
+  void VisitAutoType(const AutoType *T) {
+for (const auto  : T->getTypeConstraintArguments())
+  Visit(Arg);
+  }
   // FIXME: ElaboratedType, DependentNameType,
   // DependentTemplateSpecializationType, ObjCObjectType
 
+  // For TypeLocs, we automatically visit the inner type loc (pointee type 
etc).
+  // We must explicitly visit other lexically-nested nodes.
+  void VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {

AaronBallman wrote:

>>another test with a lambda expression
> I'm not sure what such a test should do.
> `[](){}` doesn't really have meaningful TypeLocs, and `[]()->int{}` just has 
> the BuiltinTypeLoc for int.
> Do you want a dump of the (implicit) call operator's typeloc?

Ah, I was thinking of the trailing return type and the types in the parameter 
list, but I think I confused myself there (the `FunctionProtoTypeLoc` wouldn't 
be for the lambda but for its call operator, which we already have coverage 
for).

Thank you for the additional test coverage!

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


[clang] [AST] Add dump() method to TypeLoc (PR #65484)

2023-10-13 Thread Aaron Ballman via cfe-commits

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

LGTM, but please add a release note so users know about the improvement.

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


[clang] [AST] Add dump() method to TypeLoc (PR #65484)

2023-10-13 Thread Aaron Ballman via cfe-commits

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


[clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

2023-10-13 Thread Paul Kirth via cfe-commits


@@ -106,9 +111,14 @@ static void emitSCSEpilogue(MachineFunction , 
MachineBasicBlock ,
   CSI, [&](CalleeSavedInfo ) { return CSR.getReg() == RAReg; }))
 return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {

ilovepi wrote:

I think this is probably handled by the loader. Its how it is currently handled 
for platforms like Fuchsia and Android when SCS is enabled. I'm not totally 
sure on the new spec, but the linked document above makes me think that is the 
case with this text:

```
The dynamic loader should activate the use of Zicfiss extension for an 
application only if all executables (the application and the dependent 
dynamically linked libraries) used by that application use the Zicfiss 
extension.

An application that has the Zicfiss extension active may request the dynamic 
loader at runtime to load a new dynamic shared object (using dlopen() for 
example). If the requested object does not have the Zicfiss attribute then the 
dynamic loader, based on its policy (e.g, established by the operating system 
or the administrator) configuration, could either deny the request or 
deactivate the Zicfiss extension for the application. It is strongly 
recommended that the policy enforces a strict security posture and denies the 
request.
```

I believe that setting up this memory and initializing the SCS reg would fall 
under `activate the use of Zicfiss...`, but I could be wrong.

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -1016,4 +1016,7 @@ def warn_unpacked_field
 def warn_unaligned_access : Warning<
   "field %1 within %0 is less aligned than %2 and is usually due to %0 being "
   "packed, which can lead to unaligned accesses">, InGroup, 
DefaultIgnore;
+
+def err_cannot_mangle_expression : Error<
+  "cannot yet mangle %0 expression">;

AaronBallman wrote:

All of the other "cannot yet mangle" diagnostics are done with a custom 
diagnostic, as in 
https://github.com/llvm/llvm-project/blob/475e154331af19f175ec082b08547b155bba1577/clang/lib/AST/ItaniumMangle.cpp#L5116
 -- I think we can drop this diagnostic and do the same (that helps make it 
more obvious in the code that the diagnostic is really a fixme issue rather 
than a diagnostic we intend to keep long-term). WDYT?

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-gnu -verify %s

AaronBallman wrote:

We should also show it's strange behavior with VLAs in C++:
```
int n = 12;
__datasizeof(int[n++]); // Surprise, n is incremented, you're welcome
```
and with templates:
```
template 
constexpr int data_size_of() { return __datasizeof(Ty); }

static_assert(data_size_of() == sizeof(int)); // etc
```
and I suppose with not-yet-complete types:
```
struct S {
  int i = __datasizeof(S);
  float f;
  char c;
}; // Test that i is the full class size, not the size at the point of parsing
```

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

I think this is a reasonable minor extension, but it should come with 
documentation in `clang/docs/LanguageExtensions.rst` and release note in 
`clang/docs/ReleaseNotes.rst` before we're done.

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -5038,19 +5039,19 @@ void CXXNameMangler::mangleExpression(const Expr *E, 
unsigned Arity,
   Out << 'a';
   MangleAlignofSizeofArg();
   break;
+case UETT_DataSizeOf: {
+  Context.getDiags().Report(diag::err_cannot_mangle_expression)
+  << "__datasizeof";
+  return;
+}
 case UETT_VecStep: {
-  DiagnosticsEngine  = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
- "cannot yet mangle vec_step expression");
-  Diags.Report(DiagID);
+  Context.getDiags().Report(diag::err_cannot_mangle_expression)
+  << "vec_step";
   return;
 }
 case UETT_OpenMPRequiredSimdAlign: {
-  DiagnosticsEngine  = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "cannot yet mangle __builtin_omp_required_simd_align expression");
-  Diags.Report(DiagID);
+  Context.getDiags().Report(diag::err_cannot_mangle_expression)

AaronBallman wrote:

I think we should keep the more verbose form as it's more of a clear signal to 
the reader "this is weird and needs to be fixed". (These diagnostics are also 
strange in that they're not associated with a source location, which looks like 
a bug but isn't really one because we expect these diagnostics to go away at 
some point.)

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits

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


[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits


@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(datasizeof, LangOpts.CPlusPlus)

AaronBallman wrote:

`FEATURE` is for standards features, this should be exposed under `EXTENSION` 
instead.

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


[libunwind] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread via cfe-commits


@@ -108,22 +97,18 @@ if(WIN32 AND NOT MINGW)
   # TODO(compnerd) do we want to support an emulation layer that allows for the
   # use of pthread-win32 or similar libraries to emulate pthreads on Windows?
   set(LIBCXX_HAS_PTHREAD_LIB NO)
-  set(LIBCXX_HAS_M_LIB NO)
   set(LIBCXX_HAS_RT_LIB NO)
   set(LIBCXX_HAS_ATOMIC_LIB NO)
 elseif(APPLE)
   set(LIBCXX_HAS_PTHREAD_LIB NO)
-  set(LIBCXX_HAS_M_LIB NO)
   set(LIBCXX_HAS_RT_LIB NO)
   set(LIBCXX_HAS_ATOMIC_LIB NO)
 elseif(FUCHSIA)
-  set(LIBCXX_HAS_M_LIB NO)

EricWF wrote:

Thanks for checking!

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


[libunwind] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread via cfe-commits

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


[clang] [libc++] Use -nostdlib++ on GCC unconditionally (PR #68832)

2023-10-13 Thread via cfe-commits


@@ -108,22 +97,18 @@ if(WIN32 AND NOT MINGW)
   # TODO(compnerd) do we want to support an emulation layer that allows for the
   # use of pthread-win32 or similar libraries to emulate pthreads on Windows?
   set(LIBCXX_HAS_PTHREAD_LIB NO)
-  set(LIBCXX_HAS_M_LIB NO)
   set(LIBCXX_HAS_RT_LIB NO)
   set(LIBCXX_HAS_ATOMIC_LIB NO)
 elseif(APPLE)
   set(LIBCXX_HAS_PTHREAD_LIB NO)
-  set(LIBCXX_HAS_M_LIB NO)
   set(LIBCXX_HAS_RT_LIB NO)
   set(LIBCXX_HAS_ATOMIC_LIB NO)
 elseif(FUCHSIA)
-  set(LIBCXX_HAS_M_LIB NO)

EricWF wrote:

Thanks for checking!

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


  1   2   3   4   >