[llvm-branch-commits] [clang] [llvm] [clang] Define ptrauth_string_discriminator builtin. (PR #93903)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 commented:

@ahmedbougacha After the latest force-push, the PR seems to contain 
SipHash-related changes from PRs 93902, 94393 and 94394. Could you please limit 
the changes only to those which are actually being intended to be merged as a 
part of this PR and resolve merge conflicts with the base branch?

I'd like to take one more look at this since there were updates since my latest 
feedback, but with different changes mixed, it's a bit messy.

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


[llvm-branch-commits] [clang] [llvm] [clang] Define ptrauth_string_discriminator builtin. (PR #93903)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -328,6 +328,21 @@ be done in a single instruction with an immediate integer.
 ``pointer`` must have pointer type, and ``integer`` must have integer type. The
 result has type ``ptrauth_extra_data_t``.
 
+``ptrauth_string_discriminator``
+
+
+.. code-block:: c
+
+  ptrauth_string_discriminator(string)
+
+Produce a discriminator value for the given string.  ``string`` must be
+a string literal of ``char`` character type.  The result has type
+``ptrauth_extra_data_t``.
+
+The result is always a constant expression.  The result value is never zero and
+always within range for both the ``__ptrauth`` qualifier and

kovdan01 wrote:

Since we are talking about ranges here, it would be nice to have these ranges 
explicitly described in corresponding parts of docs. As far as I understand, 
different implementations are allowed to have different constraints on 
discriminator. It would be nice to somewhere describe actual figures for some 
specific implementation, e.g. arm64e. Please let me know if there is already a 
place for that which I've missed.

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


[llvm-branch-commits] [clang] [llvm] [clang] Define ptrauth_string_discriminator builtin. (PR #93903)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -112,6 +135,17 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
 #define ptrauth_auth_data(__value, __old_key, __old_data)  
\
   __builtin_ptrauth_auth(__value, __old_key, __old_data)
 
+/* Compute a constant discriminator from the given string.
+
+   The result can be used as the second argument to
+   ptrauth_blend_discriminator or the third argument to the
+   __ptrauth qualifier.  It has type size_t.

kovdan01 wrote:

> It has type size_t.

Is it actually size_t? I suppose this should be `ptrauth_extra_data_t` (and in 
clang/docs/PointerAuthentication.rst, we have `ptrauth_extra_data_t`).

One more thought (also applies to #93904, #93906 and any other PRs touching 
both the rst docs and ptrauth.h header) - can we just use the exact same text 
for the rst docs and for the comments in the header?

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


[llvm-branch-commits] [clang] [llvm] [clang] Define ptrauth_string_discriminator builtin. (PR #93903)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 edited 
https://github.com/llvm/llvm-project/pull/93903
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [DAGCombiner] In mergeTruncStore, make sure we aren't storing shifted in bits. (#90939) (PR #91038)

2024-06-10 Thread via llvm-branch-commits

https://github.com/AtariDreams closed 
https://github.com/llvm/llvm-project/pull/91038
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] [llvm] release/18.x: [lld] Fix -ObjC load behavior with LTO (#92162) (PR #92478)

2024-06-10 Thread via llvm-branch-commits

https://github.com/AtariDreams closed 
https://github.com/llvm/llvm-project/pull/92478
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 300a496 - Revert "[Misc] Use `LLVM_ENABLE_ABI_BREAKING_CHECKS` correctly (#94212)"

2024-06-10 Thread via llvm-branch-commits

Author: paperchalice
Date: 2024-06-10T22:08:51+08:00
New Revision: 300a496d4cfec331b080b597cd2f99d5ffc3c6e7

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

LOG: Revert "[Misc] Use `LLVM_ENABLE_ABI_BREAKING_CHECKS` correctly (#94212)"

This reverts commit 291b415c6c39156c82c7cdefd7a6a67657fb6927.

Added: 


Modified: 
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/include/llvm/Support/GenericDomTreeConstruction.h
llvm/include/llvm/Transforms/Scalar/JumpThreading.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Removed: 




diff  --git a/llvm/include/llvm/Passes/StandardInstrumentations.h 
b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 9de8ba5b8bf51..84d1b541171bf 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -171,7 +171,7 @@ class PreservedCFGCheckerInstrumentation {
 FunctionAnalysisManager::Invalidator &);
   };
 
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
   SmallVector PassStack;
 #endif
 

diff  --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h 
b/llvm/include/llvm/Support/GenericDomTreeConstruction.h
index b9d398fee2b74..29b5f9159c68e 100644
--- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -638,7 +638,7 @@ struct SemiNCAInfo {
 Bucket;
 SmallDenseSet Visited;
 SmallVector Affected;
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
 SmallVector VisitedUnaffected;
 #endif
   };
@@ -913,7 +913,7 @@ struct SemiNCAInfo {
 LLVM_DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
   << BlockNamePrinter(To) << "\n");
 
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
 // Ensure that the edge was in fact deleted from the CFG before informing
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.

diff  --git a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h 
b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
index 290e5a1cc337f..65d43775bdc1d 100644
--- a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
+++ b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
@@ -88,7 +88,7 @@ class JumpThreadingPass : public 
PassInfoMixin {
   std::optional BPI;
   bool ChangedSinceLastAnalysisUpdate = false;
   bool HasGuards = false;
-#if !LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
   SmallPtrSet LoopHeaders;
 #else
   SmallSet, 16> LoopHeaders;

diff  --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h 
b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 227f6dfb8362c..6aab1f98e6781 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -286,7 +286,7 @@ class LPMUpdater {
   }
 
   void setParentLoop(Loop *L) {
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
 ParentL = L;
 #endif
   }
@@ -377,7 +377,7 @@ class LPMUpdater {
   const bool LoopNestMode;
   bool LoopNestChanged;
 
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
   // In debug builds we also track the parent loop to implement asserts even in
   // the face of loop deletion.
   Loop *ParentL;

diff  --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h 
b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
index 468b50092efcf..62c1e15a9a60e 100644
--- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
+++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
@@ -167,7 +167,7 @@ class SCEVExpander : public SCEVVisitor {
   /// consistent when instructions are moved.
   SmallVector InsertPointGuards;
 
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
   const char *DebugType;
 #endif
 
@@ -183,7 +183,7 @@ class SCEVExpander : public SCEVVisitor {
 Builder(se.getContext(), InstSimplifyFolder(DL),
 IRBuilderCallbackInserter(
 [this](Instruction *I) { rememberInstruction(I); })) {
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
 DebugType = "";
 #endif
   }
@@ -193,7 +193,7 @@ class SCEVExpander : public SCEVVisitor {
 assert(InsertPointGuards.empty());
   }
 
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
   void setDebugType(const char *s) { DebugType = s; }
 #endif
 

d

[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -354,6 +354,23 @@ Given that ``signedPointer`` matches the layout for signed 
pointers signed with
 the given key, extract the raw pointer from it.  This operation does not trap
 and cannot fail, even if the pointer is not validly signed.
 
+``ptrauth_sign_constant``
+^
+
+.. code-block:: c
+
+  ptrauth_sign_constant(pointer, key, discriminator)
+
+Return a signed pointer for a constant address in a manner which guarantees
+a non-attackable sequence.
+
+``pointer`` must be a constant expression of pointer type which evaluates to
+a non-null pointer.  The result will have the same type as ``discriminator``.

kovdan01 wrote:

> The result will have the same type as ``discriminator``

Will it? I suppose this should have the same type as `pointer`, shouldn't it? 
See also ptrauth.h:

> The result will have the same type as the original value.

And see also a comment 
https://github.com/llvm/llvm-project/pull/93903#discussion_r1633197979

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits

https://github.com/kovdan01 edited 
https://github.com/llvm/llvm-project/pull/93904
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2030,8 +2030,25 @@ bool Sema::checkConstantPointerAuthKey(Expr *Arg, 
unsigned &Result) {
   return false;
 }
 
+static std::pair
+findConstantBaseAndOffset(Sema &S, Expr *E) {
+  // Must evaluate as a pointer.
+  Expr::EvalResult Result;
+  if (!E->EvaluateAsRValue(Result, S.Context) || !Result.Val.isLValue())
+return std::make_pair(nullptr, CharUnits());
+
+  // Base must be a declaration and can't be weakly imported.

kovdan01 wrote:

Is there a test for this case?

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2030,8 +2030,25 @@ bool Sema::checkConstantPointerAuthKey(Expr *Arg, 
unsigned &Result) {
   return false;
 }
 
+static std::pair
+findConstantBaseAndOffset(Sema &S, Expr *E) {
+  // Must evaluate as a pointer.
+  Expr::EvalResult Result;
+  if (!E->EvaluateAsRValue(Result, S.Context) || !Result.Val.isLValue())
+return std::make_pair(nullptr, CharUnits());

kovdan01 wrote:

Feel free to ignore: use of `std::make_pair` is not required in this context, 
so you can just write the following:

```suggestion
return {nullptr, CharUnits()};
```

Also applies to a couple of usages of `std::make_pair` below.

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-intrinsics -emit-llvm %s  
-o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-elf -fptrauth-intrinsics -emit-llvm %s  
-o - | FileCheck %s
+
+extern int external;
+
+// CHECK: @ptr1 = global ptr ptrauth (ptr @external, i32 0, i64 26)
+void *ptr1 = __builtin_ptrauth_sign_constant(&external, 0, 26);
+
+// CHECK: @ptr2 = global ptr ptrauth (ptr @external, i32 2, i64 26, ptr @ptr2)
+void *ptr2 = __builtin_ptrauth_sign_constant(&external, 2, 
__builtin_ptrauth_blend_discriminator(&ptr2, 26));
+
+// CHECK: @ptr3 = global ptr null
+void *ptr3;

kovdan01 wrote:

Feel free to ignore: probably worth adding test for smth like

```
void *ptr4 = __builtin_ptrauth_sign_constant(&external, 0, NULL);
```

This doesn't bring that much value over testing a non-null constant integer 
discriminator, but:
1. In docs, having null pointer as a discriminator is listed as a separate 
option
   > This is a constant expression if the extra data is an integer or
   null pointer constant. 
2. With `NULL` defined as `#define NULL ((void*) 0)`, we'll explicitly test 
having a constant pointer, not an integer, value as a discriminator

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2061,6 +2071,58 @@ ConstantLValueEmitter::VisitCallExpr(const CallExpr *E) {
   }
 }
 
+ConstantLValue
+ConstantLValueEmitter::emitPointerAuthSignConstant(const CallExpr *E) {
+  llvm::Constant *UnsignedPointer = emitPointerAuthPointer(E->getArg(0));
+  unsigned Key = emitPointerAuthKey(E->getArg(1));
+  llvm::Constant *StorageAddress;
+  llvm::Constant *OtherDiscriminator;
+  std::tie(StorageAddress, OtherDiscriminator) =

kovdan01 wrote:

Maybe just use a structured binding declaration like this?

```
  auto [StorageAddress, OtherDiscriminator] =
  emitPointerAuthDiscriminator(E->getArg(2));
```

Or do you want to have separate declarations with explicitly set types?

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits

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


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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2061,6 +2071,58 @@ ConstantLValueEmitter::VisitCallExpr(const CallExpr *E) {
   }
 }
 
+ConstantLValue
+ConstantLValueEmitter::emitPointerAuthSignConstant(const CallExpr *E) {
+  llvm::Constant *UnsignedPointer = emitPointerAuthPointer(E->getArg(0));
+  unsigned Key = emitPointerAuthKey(E->getArg(1));
+  llvm::Constant *StorageAddress;
+  llvm::Constant *OtherDiscriminator;
+  std::tie(StorageAddress, OtherDiscriminator) =
+  emitPointerAuthDiscriminator(E->getArg(2));
+
+  llvm::Constant *SignedPointer = CGM.getConstantSignedPointer(
+  UnsignedPointer, Key, StorageAddress, OtherDiscriminator);
+  return SignedPointer;
+}
+
+llvm::Constant *ConstantLValueEmitter::emitPointerAuthPointer(const Expr *E) {
+  Expr::EvalResult Result;
+  bool Succeeded = E->EvaluateAsRValue(Result, CGM.getContext());
+  assert(Succeeded);
+  (void)Succeeded;
+
+  // The assertions here are all checked by Sema.
+  assert(Result.Val.isLValue());
+  return ConstantEmitter(CGM, Emitter.CGF)
+  .emitAbstract(E->getExprLoc(), Result.Val, E->getType());
+}
+
+unsigned ConstantLValueEmitter::emitPointerAuthKey(const Expr *E) {
+  return E->EvaluateKnownConstInt(CGM.getContext()).getZExtValue();
+}
+
+std::pair
+ConstantLValueEmitter::emitPointerAuthDiscriminator(const Expr *E) {
+  E = E->IgnoreParens();
+
+  if (auto *Call = dyn_cast(E)) {
+if (Call->getBuiltinCallee() ==
+Builtin::BI__builtin_ptrauth_blend_discriminator) {
+  llvm::Constant *Pointer = ConstantEmitter(CGM).emitAbstract(
+  Call->getArg(0), Call->getArg(0)->getType());
+  llvm::Constant *Extra = ConstantEmitter(CGM).emitAbstract(
+  Call->getArg(1), Call->getArg(1)->getType());
+  return {Pointer, Extra};
+}
+  }
+
+  llvm::Constant *Result = ConstantEmitter(CGM).emitAbstract(E, E->getType());
+  if (Result->getType()->isPointerTy())
+return {Result, nullptr};
+  else

kovdan01 wrote:

Do not use else after return

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -938,6 +938,11 @@ class CodeGenModule : public CodeGenTypeCache {
   // Return the function body address of the given function.
   llvm::Constant *GetFunctionStart(const ValueDecl *Decl);
 
+  llvm::Constant *getConstantSignedPointer(llvm::Constant *Pointer,
+   unsigned Key,
+   llvm::Constant *StorageAddress,
+   llvm::Constant *ExtraDiscrim);

kovdan01 wrote:

Here, this is called `ExtraDiscrim`, in clang/lib/CodeGen/CGPointerAuth.cpp - 
`OtherDiscriminator`. I suppose that for exact same function its argument names 
should be the same in the declaration and the definition. I actually suggest to 
unify this naming all over the pauth-related changes - having one term for a 
thing is better than mixing several ones for ease of understanding and also 
helps grepping. Or do I miss smth and extra discriminator is somehow different 
from other discriminator?

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -354,6 +354,23 @@ Given that ``signedPointer`` matches the layout for signed 
pointers signed with
 the given key, extract the raw pointer from it.  This operation does not trap
 and cannot fail, even if the pointer is not validly signed.
 
+``ptrauth_sign_constant``
+^
+
+.. code-block:: c
+
+  ptrauth_sign_constant(pointer, key, discriminator)
+
+Return a signed pointer for a constant address in a manner which guarantees
+a non-attackable sequence.
+
+``pointer`` must be a constant expression of pointer type which evaluates to
+a non-null pointer.  The result will have the same type as ``discriminator``.

kovdan01 wrote:

`key` type is not described here (should be `ptrauth_key` as in comments in 
ptrauth.h)

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2074,16 +2091,91 @@ static bool checkPointerAuthValue(Sema &S, Expr *&Arg,
   if (convertArgumentToType(S, Arg, ExpectedTy))
 return true;
 
-  // Warn about null pointers for non-generic sign and auth operations.
-  if ((OpKind == PAO_Sign || OpKind == PAO_Auth) &&
-  Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) {
-S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign
-  ? diag::warn_ptrauth_sign_null_pointer
-  : diag::warn_ptrauth_auth_null_pointer)
-<< Arg->getSourceRange();
+  if (!RequireConstant) {
+// Warn about null pointers for non-generic sign and auth operations.
+if ((OpKind == PAO_Sign || OpKind == PAO_Auth) &&
+Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) 
{
+  S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign
+? diag::warn_ptrauth_sign_null_pointer
+: diag::warn_ptrauth_auth_null_pointer)
+  << Arg->getSourceRange();
+}
+
+return false;
   }
 
-  return false;
+  // Perform special checking on the arguments to ptrauth_sign_constant.
+
+  // The main argument.
+  if (OpKind == PAO_Sign) {
+// Require the value we're signing to have a special form.
+auto BaseOffsetPair = findConstantBaseAndOffset(S, Arg);

kovdan01 wrote:

Wouldn't this become easier to read if you use structured bindings declaration 
like this:

```suggestion
auto [BaseDecl, Offset] = findConstantBaseAndOffset(S, Arg);
```

And below use `BaseDecl` instead of `BaseOffsetPair.first` and `Offset` instead 
of `BaseOffsetPair.second`? You do not use the pair itself, only its individual 
members, so just initializing them and having their names short and descriptive 
looks preferable to me.

Also applies to other usage of `findConstantBaseAndOffset` below.

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -354,6 +354,23 @@ Given that ``signedPointer`` matches the layout for signed 
pointers signed with
 the given key, extract the raw pointer from it.  This operation does not trap
 and cannot fail, even if the pointer is not validly signed.
 
+``ptrauth_sign_constant``
+^
+
+.. code-block:: c
+
+  ptrauth_sign_constant(pointer, key, discriminator)
+
+Return a signed pointer for a constant address in a manner which guarantees
+a non-attackable sequence.

kovdan01 wrote:

It would be nice to have this term described more deeply. Do you mean an 
absence of a signing oracle when talking about a non-attackable sequence?

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2074,16 +2091,91 @@ static bool checkPointerAuthValue(Sema &S, Expr *&Arg,
   if (convertArgumentToType(S, Arg, ExpectedTy))
 return true;
 
-  // Warn about null pointers for non-generic sign and auth operations.
-  if ((OpKind == PAO_Sign || OpKind == PAO_Auth) &&
-  Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) {
-S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign
-  ? diag::warn_ptrauth_sign_null_pointer
-  : diag::warn_ptrauth_auth_null_pointer)
-<< Arg->getSourceRange();
+  if (!RequireConstant) {
+// Warn about null pointers for non-generic sign and auth operations.
+if ((OpKind == PAO_Sign || OpKind == PAO_Auth) &&
+Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) 
{
+  S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign
+? diag::warn_ptrauth_sign_null_pointer
+: diag::warn_ptrauth_auth_null_pointer)
+  << Arg->getSourceRange();
+}
+
+return false;
   }
 
-  return false;
+  // Perform special checking on the arguments to ptrauth_sign_constant.
+
+  // The main argument.
+  if (OpKind == PAO_Sign) {
+// Require the value we're signing to have a special form.
+auto BaseOffsetPair = findConstantBaseAndOffset(S, Arg);
+bool Invalid;
+
+// Must be rooted in a declaration reference.
+if (!BaseOffsetPair.first) {
+  Invalid = true;

kovdan01 wrote:

It's probably out of scope of this patch and may be just considered (or maybe 
not :) ) as a TODO for future enhancements - it's probably worth having 
separate error messages for different `Invalid = true` cases. This applies to 
both `err_ptrauth_bad_constant_discriminator` and 
`err_ptrauth_bad_constant_pointer`. Feel free to ignore though.

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-intrinsics -emit-llvm %s  
-o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-elf -fptrauth-intrinsics -emit-llvm %s  
-o - | FileCheck %s
+
+extern int external;
+
+// CHECK: @ptr1 = global ptr ptrauth (ptr @external, i32 0, i64 26)
+void *ptr1 = __builtin_ptrauth_sign_constant(&external, 0, 26);
+
+// CHECK: @ptr2 = global ptr ptrauth (ptr @external, i32 2, i64 26, ptr @ptr2)
+void *ptr2 = __builtin_ptrauth_sign_constant(&external, 2, 
__builtin_ptrauth_blend_discriminator(&ptr2, 26));
+
+// CHECK: @ptr3 = global ptr null
+void *ptr3;
+
+void test_sign_constant_code() {

kovdan01 wrote:

It's probably worth to have the exact same tests for global and function-local 
variables to ensure that everything is OK in both contexts.

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


[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

2024-06-10 Thread Daniil Kovalev via llvm-branch-commits


@@ -2074,16 +2091,91 @@ static bool checkPointerAuthValue(Sema &S, Expr *&Arg,
   if (convertArgumentToType(S, Arg, ExpectedTy))
 return true;
 
-  // Warn about null pointers for non-generic sign and auth operations.
-  if ((OpKind == PAO_Sign || OpKind == PAO_Auth) &&
-  Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) {
-S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign
-  ? diag::warn_ptrauth_sign_null_pointer
-  : diag::warn_ptrauth_auth_null_pointer)
-<< Arg->getSourceRange();
+  if (!RequireConstant) {
+// Warn about null pointers for non-generic sign and auth operations.
+if ((OpKind == PAO_Sign || OpKind == PAO_Auth) &&
+Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) 
{
+  S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign
+? diag::warn_ptrauth_sign_null_pointer
+: diag::warn_ptrauth_auth_null_pointer)
+  << Arg->getSourceRange();
+}
+
+return false;
   }
 
-  return false;
+  // Perform special checking on the arguments to ptrauth_sign_constant.
+
+  // The main argument.
+  if (OpKind == PAO_Sign) {
+// Require the value we're signing to have a special form.
+auto BaseOffsetPair = findConstantBaseAndOffset(S, Arg);
+bool Invalid;
+
+// Must be rooted in a declaration reference.
+if (!BaseOffsetPair.first) {
+  Invalid = true;
+
+  // If it's a function declaration, we can't have an offset.
+} else if (isa(BaseOffsetPair.first)) {
+  Invalid = !BaseOffsetPair.second.isZero();
+
+  // Otherwise we're fine.
+} else {
+  Invalid = false;
+}
+
+if (Invalid) {

kovdan01 wrote:

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

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


[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)

2024-06-10 Thread via llvm-branch-commits

EricWF wrote:

> @EricWF When switching to `__libcpp_operator_{new,delete}` everything gets 
> compiled exactly the same on my system. Could you disclose which test you 
> used for this code? You also claim that the `__pointer_int_pair` causes the 
> optimizer to lose track of the function pointer causing the call to not be 
> elided, but I can't see any calls other than `new` and `delete` in the code 
> you posted either.

I meant `__libcpp_allocate` and `__libcpp_deallocate`.  That's my mistake.

I may have misread the assembly earlier, it's possible there's some other issue 
causing the compiler to fail to optimize your code away in the same way the 
compiler optimizes the implementation I provided. 

@philnik777 I would encourage you to read about the importance of learning to 
"kill your darlings". The saying comes from creating writing, but is equally 
important here.



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


[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)

2024-06-10 Thread via llvm-branch-commits


@@ -0,0 +1,233 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// This header is unguarded on purpose. This header is an implementation 
detail of move_only_function.h
+// and generates multiple versions of std::move_only_function
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/move_only_function_common.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <__utility/exchange.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/pointer_int_pair.h>
+#include <__utility/small_buffer.h>
+#include <__utility/swap.h>
+#include 
+#include 
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H
+#  error This header should only be included from move_only_function.h
+#endif
+
+#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_CV
+#endif
+
+#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_REF
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS 
_LIBCPP_MOVE_ONLY_FUNCTION_CV&
+#else
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS 
_LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF
+#endif
+
+#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false
+#endif
+
+#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV 
_LIBCPP_MOVE_ONLY_FUNCTION_REF
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]]
+#else
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI
+#endif
+
+template 
+class move_only_function;
+
+template 
+class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT(
+_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF 
noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> {
+private:
+  static constexpr size_t __buffer_size_  = 3 * sizeof(void*);
+  static constexpr size_t __buffer_alignment_ = alignof(void*);
+  using _BufferT  = __small_buffer<__buffer_size_, 
__buffer_alignment_>;
+
+  using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, 
_ArgTypes...>;
+  using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, 
_ReturnT, _ArgTypes...>;
+
+  template 
+  static constexpr _TrivialVTable __trivial_vtable_ = {
+  .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) 
noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT {
+return std::invoke_r<_ReturnT>(
+static_cast<_Functor 
_LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()),
+std::forward<_ArgTypes>(__args)...);
+  }};
+
+  template 
+  static constexpr _NonTrivialVTable __non_trivial_vtable_{
+  __trivial_vtable_<_Functor>,
+  [](_BufferT& __buffer) noexcept -> void {
+std::destroy_at(__buffer.__get<_Functor>());
+__buffer.__dealloc<_Functor>();
+  },
+  };
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair 
__get_vptr() {
+if constexpr (_BufferT::__fits_in_buffer<_Functor> && 
is_trivially_destructible_v<_Functor>) {
+  return {&__trivial_vtable_<_Functor>, false};
+} else {
+  return {&__non_trivial_vtable_<_Functor>, true};
+}
+  }
+
+  template 
+  static constexpr bool __is_callable_from = [] {
+using _DVT = decay_t<_VT>;
+if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) {
+  return is_nothrow_invocable_r_v<_ReturnT, _DVT 
_LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> &&
+ is_nothrow_invocable_r_v<_ReturnT, _DVT 
_LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>;
+} else {
+  return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, 
_ArgTypes...> &&
+ is_invocable_r_v<_ReturnT, _DVT 
_LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>;
+}
+  }();
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) {
+static_assert(is_constructible_v, _Func>);
+
+using _StoredFunc = decay_t<_Func>;
+__vtable_ = __get_vptr<_StoredFunc>();
+__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void __reset() {
+if (__vtable_.__get_value())

EricWF wrote:

There's other cost here. 

There's complexity, there's ABI risk. To speak on the ABI risk.:

 From my investigations Clang has trouble optimizing around this, where it 
doesn't have trouble optimizing around what @huixie90 is suggesting, which I've 
implemented and tested

[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)

2024-06-10 Thread Nikolas Klauser via llvm-branch-commits


@@ -0,0 +1,233 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// This header is unguarded on purpose. This header is an implementation 
detail of move_only_function.h
+// and generates multiple versions of std::move_only_function
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/move_only_function_common.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <__utility/exchange.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <__utility/pointer_int_pair.h>
+#include <__utility/small_buffer.h>
+#include <__utility/swap.h>
+#include 
+#include 
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H
+#  error This header should only be included from move_only_function.h
+#endif
+
+#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_CV
+#endif
+
+#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_REF
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS 
_LIBCPP_MOVE_ONLY_FUNCTION_CV&
+#else
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS 
_LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF
+#endif
+
+#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false
+#endif
+
+#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV 
_LIBCPP_MOVE_ONLY_FUNCTION_REF
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]]
+#else
+#  define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI
+#endif
+
+template 
+class move_only_function;
+
+template 
+class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT(
+_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF 
noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> {
+private:
+  static constexpr size_t __buffer_size_  = 3 * sizeof(void*);
+  static constexpr size_t __buffer_alignment_ = alignof(void*);
+  using _BufferT  = __small_buffer<__buffer_size_, 
__buffer_alignment_>;
+
+  using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, 
_ArgTypes...>;
+  using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, 
_ReturnT, _ArgTypes...>;
+
+  template 
+  static constexpr _TrivialVTable __trivial_vtable_ = {
+  .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) 
noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT {
+return std::invoke_r<_ReturnT>(
+static_cast<_Functor 
_LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()),
+std::forward<_ArgTypes>(__args)...);
+  }};
+
+  template 
+  static constexpr _NonTrivialVTable __non_trivial_vtable_{
+  __trivial_vtable_<_Functor>,
+  [](_BufferT& __buffer) noexcept -> void {
+std::destroy_at(__buffer.__get<_Functor>());
+__buffer.__dealloc<_Functor>();
+  },
+  };
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair 
__get_vptr() {
+if constexpr (_BufferT::__fits_in_buffer<_Functor> && 
is_trivially_destructible_v<_Functor>) {
+  return {&__trivial_vtable_<_Functor>, false};
+} else {
+  return {&__non_trivial_vtable_<_Functor>, true};
+}
+  }
+
+  template 
+  static constexpr bool __is_callable_from = [] {
+using _DVT = decay_t<_VT>;
+if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) {
+  return is_nothrow_invocable_r_v<_ReturnT, _DVT 
_LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> &&
+ is_nothrow_invocable_r_v<_ReturnT, _DVT 
_LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>;
+} else {
+  return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, 
_ArgTypes...> &&
+ is_invocable_r_v<_ReturnT, _DVT 
_LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>;
+}
+  }();
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) {
+static_assert(is_constructible_v, _Func>);
+
+using _StoredFunc = decay_t<_Func>;
+__vtable_ = __get_vptr<_StoredFunc>();
+__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void __reset() {
+if (__vtable_.__get_value())

philnik777 wrote:

Then provide the fucking evidence.

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

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-10 Thread Anton Korobeynikov via llvm-branch-commits

asl wrote:

> @asl It would be nice if you submit the next round of review as a single 
> review, instead of 29 individual comments.

Oh, strange. I thought it was a single review...

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


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95010

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

>From 5fd96e63fab22b5d809c837eaaa5f0db0ae5449b Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  67 +-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 107 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 180 +
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 191 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 113 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 121 +++
 .../zoned_time_duration2.pass.cpp |  92 +
 libcxx/test/support/test_offset_time_zone.h   |   9 +
 14 files changed, 1318 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  const

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

---

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


14 Files Affected:

- (modified) libcxx/docs/Status/Cxx20Issues.csv (+2-2) 
- (modified) libcxx/include/__chrono/zoned_time.h (+64-3) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 (+82) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 (+107) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 (+82) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 (+180) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 (+191) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 (+80) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 (+109) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 (+86) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 (+113) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 (+121) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp
 (+92) 
- (modified) libcxx/test/support/test_offset_time_zone.h (+9) 


``diff
diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","|Complete|","19.0","|chrono|"
 "`3233 `__","Broken requirements for 
``shared_ptr``\  converting constructors","Prague","|Complete|","19.0"
 "`3237 `__","LWG 3038 and 3190 have inconsistent 
PRs","Prague","|Complete|","16.0"
 "`3238 `__","Insufficiently-defined behavior of 
``std::function``\  deduction guides","Prague","|Nothing To Do|",""
diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index f7510c9121a59..02945270cec7c 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -56,6 +56,10 @@ class zoned_time {
   static_assert(__is_duration<_Duration>::value,
 "the program is ill-formed since _Dura

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From fc3076706f093903ab298fc934d848e9dd58bf51 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  70 ++-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 105 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 177 +
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 188 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 112 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 118 +++
 .../zoned_time_duration2.pass.cpp |  89 +
 libcxx/test/support/test_offset_time_zone.h   |   9 +
 14 files changed, 1306 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","

[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)

2024-06-10 Thread Anton Korobeynikov via llvm-branch-commits


@@ -1,185 +1,149 @@
-/*
-   SipHash reference C implementation
-
-   Copyright (c) 2012-2022 Jean-Philippe Aumasson
-   
-   Copyright (c) 2012-2014 Daniel J. Bernstein 
-
-   To the extent possible under law, the author(s) have dedicated all copyright
-   and related and neighboring rights to this software to the public domain
-   worldwide. This software is distributed without any warranty.
-
-   You should have received a copy of the CC0 Public Domain Dedication along
-   with
-   this software. If not, see
-   .
- */
-
-#include "siphash.h"
-#include 
-#include 
-#include 
-
-/* default: SipHash-2-4 */
-#ifndef cROUNDS
-#define cROUNDS 2
-#endif
-#ifndef dROUNDS
-#define dROUNDS 4
-#endif
+//===--- SipHash.cpp - An ABI-stable string hash 
--===//
+//
+// 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
+//
+//===--===//
 
-#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b
+#include "llvm/Support/Compiler.h"
+#include 
 
-#define U32TO8_LE(p, v)
\
-(p)[0] = (uint8_t)((v));   
\
-(p)[1] = (uint8_t)((v) >> 8);  
\
-(p)[2] = (uint8_t)((v) >> 16); 
\
-(p)[3] = (uint8_t)((v) >> 24);
+// Lightly adapted from the SipHash reference C implementation:
+//   https://github.com/veorq/SipHash
+// by Jean-Philippe Aumasson and Daniel J. Bernstein
 
-#define U64TO8_LE(p, v)
\
-U32TO8_LE((p), (uint32_t)((v)));   
\
-U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
+#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b

asl wrote:

Maybe we can use function call instead of macros?

E.g. (as in xxhash):
```c++
static uint64_t rotl64(uint64_t X, size_t R) {
  return (X << R) | (X >> (64 - R));
}
```

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


[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)

2024-06-10 Thread Anton Korobeynikov via llvm-branch-commits


@@ -1,185 +1,149 @@
-/*
-   SipHash reference C implementation
-
-   Copyright (c) 2012-2022 Jean-Philippe Aumasson
-   
-   Copyright (c) 2012-2014 Daniel J. Bernstein 
-
-   To the extent possible under law, the author(s) have dedicated all copyright
-   and related and neighboring rights to this software to the public domain
-   worldwide. This software is distributed without any warranty.
-
-   You should have received a copy of the CC0 Public Domain Dedication along
-   with
-   this software. If not, see
-   .
- */
-
-#include "siphash.h"
-#include 
-#include 
-#include 
-
-/* default: SipHash-2-4 */
-#ifndef cROUNDS
-#define cROUNDS 2
-#endif
-#ifndef dROUNDS
-#define dROUNDS 4
-#endif
+//===--- SipHash.cpp - An ABI-stable string hash 
--===//
+//
+// 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
+//
+//===--===//
 
-#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b
+#include "llvm/Support/Compiler.h"
+#include 
 
-#define U32TO8_LE(p, v)
\
-(p)[0] = (uint8_t)((v));   
\
-(p)[1] = (uint8_t)((v) >> 8);  
\
-(p)[2] = (uint8_t)((v) >> 16); 
\
-(p)[3] = (uint8_t)((v) >> 24);
+// Lightly adapted from the SipHash reference C implementation:
+//   https://github.com/veorq/SipHash
+// by Jean-Philippe Aumasson and Daniel J. Bernstein
 
-#define U64TO8_LE(p, v)
\
-U32TO8_LE((p), (uint32_t)((v)));   
\
-U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
+#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b
 
 #define U8TO64_LE(p)   
\

asl wrote:

Use `endian::read64le` instead this

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


[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)

2024-06-10 Thread Anton Korobeynikov via llvm-branch-commits


@@ -1,185 +1,149 @@
-/*
-   SipHash reference C implementation
-
-   Copyright (c) 2012-2022 Jean-Philippe Aumasson
-   
-   Copyright (c) 2012-2014 Daniel J. Bernstein 
-
-   To the extent possible under law, the author(s) have dedicated all copyright
-   and related and neighboring rights to this software to the public domain
-   worldwide. This software is distributed without any warranty.
-
-   You should have received a copy of the CC0 Public Domain Dedication along
-   with
-   this software. If not, see
-   .
- */
-
-#include "siphash.h"
-#include 
-#include 
-#include 
-
-/* default: SipHash-2-4 */
-#ifndef cROUNDS
-#define cROUNDS 2
-#endif
-#ifndef dROUNDS
-#define dROUNDS 4
-#endif
+//===--- SipHash.cpp - An ABI-stable string hash 
--===//
+//
+// 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
+//
+//===--===//
 
-#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b
+#include "llvm/Support/Compiler.h"
+#include 
 
-#define U32TO8_LE(p, v)
\
-(p)[0] = (uint8_t)((v));   
\
-(p)[1] = (uint8_t)((v) >> 8);  
\
-(p)[2] = (uint8_t)((v) >> 16); 
\
-(p)[3] = (uint8_t)((v) >> 24);
+// Lightly adapted from the SipHash reference C implementation:
+//   https://github.com/veorq/SipHash
+// by Jean-Philippe Aumasson and Daniel J. Bernstein
 
-#define U64TO8_LE(p, v)
\
-U32TO8_LE((p), (uint32_t)((v)));   
\
-U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
+#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b
 
 #define U8TO64_LE(p)   
\
-(((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) |
\
- ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | 
\
- ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | 
\
- ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
+  (((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) |  
\
+   ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) |   
\
+   ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) |   
\
+   ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
 
 #define SIPROUND   
\
-do {   
\
-v0 += v1;  
\
-v1 = ROTL(v1, 13); 
\
-v1 ^= v0;  
\
-v0 = ROTL(v0, 32); 
\
-v2 += v3;  
\
-v3 = ROTL(v3, 16); 
\
-v3 ^= v2;  
\
-v0 += v3;  
\
-v3 = ROTL(v3, 21); 
\
-v3 ^= v0;  
\
-v2 += v1;  
\
-v1 = ROTL(v1, 17); 
\
-v1 ^= v2;  
\
-v2 = ROTL(v2, 32); 
\
-} while (0)
-
-#ifdef DEBUG_SIPHASH
-#include 
-
-#define TRACE  
\
-do {   
\
-printf("(%3zu) v0 %016" PRIx64 "\n", inlen, v0);   
\
-printf("(%3zu) v1 %016" PRIx64 "\n", inlen, v1);   
\
-printf("(%3zu) v2 %016" PRIx64 "\n", inlen, v2);   
\
-printf("(%3zu) v3 %016" PRIx64 "\n", inlen, v3);   
\
-} while (0)
-#else
-#define TRACE
-#endif
-
-/*
-Computes a SipHash value
-*in: pointer to input data (read-only)
-inlen: input data length in bytes (any size_t value)
-*k: pointer to the key data (read-only), must be 16 bytes 
-*out: pointer to output data (write-only), outlen bytes must be allocated
-o

[llvm-branch-commits] [hwasan] Distinguish overflow and underflow (PR #76131)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka converted_to_draft 
https://github.com/llvm/llvm-project/pull/76131
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From edac5048367b80622007cbd199483cc2eda29efb Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  70 ++-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 105 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 177 +
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 188 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 ++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 112 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 118 +++
 .../zoned_time_duration2.pass.cpp |  89 +
 libcxx/test/support/test_offset_time_zone.h   |  10 +
 14 files changed, 1307 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time constructors. (PR #95010)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95010

>From e374d900e2b3524b466013d61b9c3911c862c8fa Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time constructors.

Completes
- LWG3225 zoned_time converting constructor shall not be noexcept
- LWG3226 zoned_time constructor from string_view should accept 
zoned_time

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/docs/Status/Cxx20Issues.csv|   4 +-
 libcxx/include/__chrono/zoned_time.h  |  70 ++-
 .../string_view_local_time.pass.cpp   |  82 
 .../string_view_local_time_choose.pass.cpp| 105 ++
 .../string_view_sys_time.pass.cpp |  82 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 174 
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 185 ++
 .../time_zone_pointer_local_time.pass.cpp |  80 
 ...me_zone_pointer_local_time_choose.pass.cpp | 109 +++
 .../time_zone_pointer_sys_time.pass.cpp   |  86 
 ...ned_time_duration2_time_zone_ptr2.pass.cpp | 109 +++
 ...e_duration2_time_zone_ptr2_choose.pass.cpp | 115 +++
 .../zoned_time_duration2.pass.cpp |  86 
 libcxx/test/support/test_offset_time_zone.h   |  10 +
 14 files changed, 1292 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/string_view_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_local_time_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_pointer_sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/time_zone_ptr_zoned_time_duration2_time_zone_ptr2_choose.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.ctor/zoned_time_duration2.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index d4db7876cb2ef..5051a2089c98e 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -162,7 +162,7 @@
 "`3209 `__","Expression in ``year::ok()``\  returns 
clause is ill-formed","Cologne","|Complete|",""
 "","","","","",""
 "`3231 `__","``year_month_day_last::day``\  
specification does not cover ``!ok()``\  values","Belfast","|Nothing To Do|",""
-"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|"
+"`3225 `__","``zoned_time``\  converting 
constructor shall not be ``noexcept``\ 
","Belfast","|Complete|","19.0","|chrono|"
 "`3190 `__","``std::allocator::allocate``\  
sometimes returns too little storage","Belfast","|Complete|","14.0"
 "`3218 `__","Modifier for ``%d``\  parse flag does 
not match POSIX and ``format``\  specification","Belfast","","","|chrono| 
|format|"
 "`3224 `__","``zoned_time``\  constructor from 
``TimeZonePtr``\  does not specify initialization of ``tp_``\ 
","Belfast","|Complete|","19.0","|chrono|"
@@ -199,7 +199,7 @@
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","|Complete|","13.0"
 "`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
-"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","","","|chrono|"
+"`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","|

[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Florian Mayer via llvm-branch-commits


@@ -3357,6 +3357,37 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  Value *convertBlendvToSelectMask(IRBuilder<> &IRB, Value *C) {

fmayer wrote:

should these two be `static`?

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


[llvm-branch-commits] [NFC][msan] Extract `handleSelectLikeInst` (PR #94881)

2024-06-10 Thread Florian Mayer via llvm-branch-commits

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


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


[llvm-branch-commits] [NFC][msan] Extract `handleSelectLikeInst` (PR #94881)

2024-06-10 Thread Thurston Dang via llvm-branch-commits

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


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


[llvm-branch-commits] [NFC][msan] Prepare function to extract main logic (PR #94880)

2024-06-10 Thread Thurston Dang via llvm-branch-commits

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


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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94875


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


[llvm-branch-commits] [NFC][msan] Prepare function to extract main logic (PR #94880)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94880


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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94875


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


[llvm-branch-commits] [NFC][msan] Prepare function to extract main logic (PR #94880)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94880


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


[llvm-branch-commits] [NFC][msan] Extract `handleSelectLikeInst` (PR #94881)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94881


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


[llvm-branch-commits] [NFC][msan] Extract `handleSelectLikeInst` (PR #94881)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94881


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


[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94882


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


[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94882


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


[llvm-branch-commits] [llvm] 0491cea - Revert "[MC][NFC] Make ELFUniquingMap a StringMap (#95006)"

2024-06-10 Thread via llvm-branch-commits

Author: aengelke
Date: 2024-06-10T20:57:30+02:00
New Revision: 0491cea05e65c0f2fac9c268df01de65f437c2ba

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

LOG: Revert "[MC][NFC] Make ELFUniquingMap a StringMap (#95006)"

This reverts commit 2f9a80b7343606f62b3e907b888a8e9d17c0c551.

Added: 


Modified: 
llvm/include/llvm/MC/MCContext.h
llvm/lib/MC/MCContext.cpp

Removed: 




diff  --git a/llvm/include/llvm/MC/MCContext.h 
b/llvm/include/llvm/MC/MCContext.h
index b2a52b4297e60..b0ac432a065bf 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -252,6 +252,31 @@ class MCContext {
   /// A collection of MCPseudoProbe in the current module
   MCPseudoProbeTable PseudoProbeTable;
 
+  // Sections are 
diff erentiated by the quadruple (section_name, group_name,
+  // unique_id, link_to_symbol_name). Sections sharing the same quadruple are
+  // combined into one section.
+  struct ELFSectionKey {
+std::string SectionName;
+StringRef GroupName;
+StringRef LinkedToName;
+unsigned UniqueID;
+
+ELFSectionKey(StringRef SectionName, StringRef GroupName,
+  StringRef LinkedToName, unsigned UniqueID)
+: SectionName(SectionName), GroupName(GroupName),
+  LinkedToName(LinkedToName), UniqueID(UniqueID) {}
+
+bool operator<(const ELFSectionKey &Other) const {
+  if (SectionName != Other.SectionName)
+return SectionName < Other.SectionName;
+  if (GroupName != Other.GroupName)
+return GroupName < Other.GroupName;
+  if (int O = LinkedToName.compare(Other.LinkedToName))
+return O < 0;
+  return UniqueID < Other.UniqueID;
+}
+  };
+
   struct COFFSectionKey {
 std::string SectionName;
 StringRef GroupName;
@@ -325,8 +350,8 @@ class MCContext {
   };
 
   StringMap MachOUniquingMap;
+  std::map ELFUniquingMap;
   std::map COFFUniquingMap;
-  StringMap ELFUniquingMap;
   std::map GOFFUniquingMap;
   std::map WasmUniquingMap;
   std::map XCOFFUniquingMap;

diff  --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index d5bde2bcb7301..771ca9c6006ca 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -44,7 +44,6 @@
 #include "llvm/MC/SectionKind.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/EndianStream.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -549,42 +548,16 @@ MCSectionELF *MCContext::getELFSection(const Twine 
&Section, unsigned Type,
   if (GroupSym)
 Group = GroupSym->getName();
   assert(!(LinkedToSym && LinkedToSym->getName().empty()));
+  // Do the lookup, if we have a hit, return it.
+  auto IterBool = ELFUniquingMap.insert(std::make_pair(
+  ELFSectionKey{Section.str(), Group,
+LinkedToSym ? LinkedToSym->getName() : "", UniqueID},
+  nullptr));
+  auto &Entry = *IterBool.first;
+  if (!IterBool.second)
+return Entry.second;
 
-  // Sections are 
diff erentiated by the quadruple (section_name, group_name,
-  // unique_id, link_to_symbol_name). Sections sharing the same quadruple are
-  // combined into one section. As an optimization, non-unique sections without
-  // group or linked-to symbol have a shorter unique-ing key.
-  std::pair::iterator, bool> EntryNewPair;
-  // Length of the section name, which are the first SectionLen bytes of the 
key
-  unsigned SectionLen;
-  if (GroupSym || LinkedToSym || UniqueID != MCSection::NonUniqueID) {
-SmallString<128> Buffer;
-Section.toVector(Buffer);
-SectionLen = Buffer.size();
-Buffer.push_back(0); // separator which cannot occur in the name
-if (GroupSym)
-  Buffer.append(GroupSym->getName());
-Buffer.push_back(0); // separator which cannot occur in the name
-if (LinkedToSym)
-  Buffer.append(LinkedToSym->getName());
-support::endian::write(Buffer, UniqueID, endianness::native);
-StringRef UniqueMapKey = StringRef(Buffer);
-EntryNewPair = ELFUniquingMap.insert(std::make_pair(UniqueMapKey, 
nullptr));
-  } else if (!Section.isSingleStringRef()) {
-SmallString<128> Buffer;
-SectionLen = Buffer.size();
-StringRef UniqueMapKey = Section.toStringRef(Buffer);
-EntryNewPair = ELFUniquingMap.insert(std::make_pair(UniqueMapKey, 
nullptr));
-  } else {
-SectionLen = Section.getSingleStringRef().size();
-StringRef UniqueMapKey = Section.getSingleStringRef();
-EntryNewPair = ELFUniquingMap.insert(std::make_pair(UniqueMapKey, 
nullptr));
-  }
-
-  if (!EntryNewPair.second)
-return EntryNewPair.first->second;
-
-  StringRef CachedName = EntryNewPair.first->getKey().take_front(SectionLen);
+  StringRef CachedName = Entry.first.SectionName;
 

[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Florian Mayer via llvm-branch-commits


@@ -3287,6 +3287,76 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  // Convert `Mask` into ``.
+  Constant *createDppMask(unsigned Width, unsigned Mask) {
+SmallVector R;
+R.assign(Width, ConstantInt::getFalse(F.getContext()));
+for (auto &M : R) {
+  if (Mask & 1)
+M = ConstantInt::getTrue(F.getContext());

fmayer wrote:

wouldn't this bge more readable as

```
M = ConstantInt::getBool(F.getContext(), Mask & 1)
```

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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Florian Mayer via llvm-branch-commits


@@ -3287,6 +3287,76 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  // Convert `Mask` into ``.
+  Constant *createDppMask(unsigned Width, unsigned Mask) {
+SmallVector R;
+R.assign(Width, ConstantInt::getFalse(F.getContext()));
+for (auto &M : R) {
+  if (Mask & 1)
+M = ConstantInt::getTrue(F.getContext());
+  Mask >>= 1;
+}
+return ConstantVector::get(R);
+  }
+
+  // Calculate output shadow as array of booleans ``, assuming if any

fmayer wrote:

"assuming" is a bit weird. Isn't that how the poison should propagate, not an 
assumption?

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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Florian Mayer via llvm-branch-commits


@@ -3287,6 +3287,76 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  // Convert `Mask` into ``.
+  Constant *createDppMask(unsigned Width, unsigned Mask) {
+SmallVector R;
+R.assign(Width, ConstantInt::getFalse(F.getContext()));
+for (auto &M : R) {
+  if (Mask & 1)
+M = ConstantInt::getTrue(F.getContext());
+  Mask >>= 1;
+}
+return ConstantVector::get(R);
+  }
+
+  // Calculate output shadow as array of booleans ``, assuming if any
+  // arg is poisoned, entire dot product is poisoned.
+  Value *makeDppShadowI1(IRBuilder<> &IRB, Value *S, unsigned SrcMask,

fmayer wrote:

What does `I1` stand for?

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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer edited https://github.com/llvm/llvm-project/pull/94875
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/95026

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could be 
if the object caches the local_time assigned. However this does not seem to 
intended. The current implementation matches MSVC STL and libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

>From 368f0d443a91c6671fd913e1e475a43fe1a84f1d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time member functions.

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could
be if the object caches the local_time assigned. However this does not
seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h  |  21 ++
 .../diagnostics/chrono.nodiscard.verify.cpp   |  12 +-
 .../assign.local_time.pass.cpp| 245 ++
 .../assign.sys_time.pass.cpp  | 134 ++
 .../get_info.pass.cpp |  49 
 .../get_local_time.pass.cpp   | 131 ++
 .../operator_local_time.pass.cpp  | 133 ++
 .../operator_sys_time.pass.cpp| 123 +
 8 files changed, 846 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index bf8e04b6407ef..e59f527f4d825 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -146,8 +146,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning 

[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-06-10 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could be 
if the object caches the local_time assigned. However this does not seem to 
intended. The current implementation matches MSVC STL and libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones

---

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


8 Files Affected:

- (modified) libcxx/include/__chrono/zoned_time.h (+21) 
- (modified) libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp (+10-2) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 (+245) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 (+134) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 (+49) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 (+131) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 (+133) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp
 (+123) 


``diff
diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index bf8e04b6407ef..e59f527f4d825 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -146,8 +146,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_sys_time();   // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_info();   // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
   }
 }
diff --git 
a/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
new file mode 100644
index 0..e5f2e5d92e71a
--- /dev/null
+++ 
b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
@@ -0,0 +1,245 @@
+//===--

[llvm-branch-commits] [flang] [flang] Lower REDUCE intrinsic with DIM argument (PR #94771)

2024-06-10 Thread Valentin Clement バレンタイン クレメン via llvm-branch-commits

https://github.com/clementval updated 
https://github.com/llvm/llvm-project/pull/94771

>From 87a01d458650f4c6fd9b0456acbca51094bd127b Mon Sep 17 00:00:00 2001
From: Valentin Clement 
Date: Thu, 6 Jun 2024 14:17:44 -0700
Subject: [PATCH] [flang] Lower REDUCE intrinsic with DIM argument

---
 .../Optimizer/Builder/Runtime/Reduction.h |   7 +
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp |  12 +-
 .../Optimizer/Builder/Runtime/Reduction.cpp   | 204 
 flang/test/Lower/Intrinsics/reduce.f90| 221 ++
 4 files changed, 443 insertions(+), 1 deletion(-)

diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h 
b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h
index 27652208b524e..fedf453a6dc8d 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h
@@ -240,6 +240,13 @@ mlir::Value genReduce(fir::FirOpBuilder &builder, 
mlir::Location loc,
   mlir::Value maskBox, mlir::Value identity,
   mlir::Value ordered);
 
+/// Generate call to `Reduce` intrinsic runtime routine. This is the version
+/// that takes arrays of any rank with a dim argument specified.
+void genReduceDim(fir::FirOpBuilder &builder, mlir::Location loc,
+  mlir::Value arrayBox, mlir::Value operation, mlir::Value dim,
+  mlir::Value maskBox, mlir::Value identity,
+  mlir::Value ordered, mlir::Value resultBox);
+
 } // namespace fir::runtime
 
 #endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_REDUCTION_H
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp 
b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 0e29849a57688..e250a476b5802 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -5790,7 +5790,17 @@ IntrinsicLibrary::genReduce(mlir::Type resultType,
 return fir::runtime::genReduce(builder, loc, array, operation, mask,
identity, ordered);
   }
-  TODO(loc, "reduce with array result");
+  // Handle cases that have an array result.
+  // Create mutable fir.box to be passed to the runtime for the result.
+  mlir::Type resultArrayType = builder.getVarLenSeqTy(resultType, rank - 1);
+  fir::MutableBoxValue resultMutableBox =
+  fir::factory::createTempMutableBox(builder, loc, resultArrayType);
+  mlir::Value resultIrBox =
+  fir::factory::getMutableIRBox(builder, loc, resultMutableBox);
+  mlir::Value dim = fir::getBase(args[2]);
+  fir::runtime::genReduceDim(builder, loc, array, operation, dim, mask,
+ identity, ordered, resultIrBox);
+  return readAndAddCleanUp(resultMutableBox, resultType, "REDUCE");
 }
 
 // REPEAT
diff --git a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp 
b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
index a7cd53328d69a..9b035e6b4dd06 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
@@ -486,6 +486,50 @@ struct ForcedReduceReal16 {
   }
 };
 
+/// Placeholder for DIM real*10 version of Reduce Intrinsic
+struct ForcedReduceReal10Dim {
+  static constexpr const char *name =
+  ExpandAndQuoteKey(RTNAME(ReduceReal10Dim));
+  static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
+return [](mlir::MLIRContext *ctx) {
+  auto ty = mlir::FloatType::getF80(ctx);
+  auto boxTy =
+  fir::runtime::getModel()(ctx);
+  auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, ty);
+  auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
+  auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
+  auto refTy = fir::ReferenceType::get(ty);
+  auto refBoxTy = fir::ReferenceType::get(boxTy);
+  auto i1Ty = mlir::IntegerType::get(ctx, 1);
+  return mlir::FunctionType::get(
+  ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, 
i1Ty},
+  {});
+};
+  }
+};
+
+/// Placeholder for DIM real*16 version of Reduce Intrinsic
+struct ForcedReduceReal16Dim {
+  static constexpr const char *name =
+  ExpandAndQuoteKey(RTNAME(ReduceReal16Dim));
+  static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
+return [](mlir::MLIRContext *ctx) {
+  auto ty = mlir::FloatType::getF128(ctx);
+  auto boxTy =
+  fir::runtime::getModel()(ctx);
+  auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, ty);
+  auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
+  auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
+  auto refTy = fir::ReferenceType::get(ty);
+  auto refBoxTy = fir::ReferenceType::get(boxTy);
+  auto i1Ty = mlir::IntegerType::get(ctx, 1);
+  return mlir::FunctionType::get(
+  ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, 
i1Ty},
+  {});
+};
+  }
+};
+
 /// Placeholder for integer

[llvm-branch-commits] [NFC][msan] Prepare function to extract main logic (PR #94880)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94880


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


[llvm-branch-commits] [NFC][msan] Prepare function to extract main logic (PR #94880)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94880


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


[llvm-branch-commits] [libcxx] [libc++][TZDB] Finishes zoned_time member functions. (PR #95026)

2024-06-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/95026

>From ad83e31016100fede20971e7ac16dbdd8137504d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Finishes zoned_time member functions.

Note the implementation of
  zoned_time& operator=(const local_time& lt);
is not correct; however the wording cannot be easily implemented. It could
be if the object caches the local_time assigned. However this does not
seem to intended. The current implementation matches MSVC STL and
libstdc++.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h  |  22 ++
 .../diagnostics/chrono.nodiscard.verify.cpp   |  12 +-
 .../assign.local_time.pass.cpp| 245 ++
 .../assign.sys_time.pass.cpp  | 134 ++
 .../get_info.pass.cpp |  49 
 .../get_local_time.pass.cpp   | 131 ++
 .../operator_local_time.pass.cpp  | 133 ++
 .../operator_sys_time.pass.cpp| 123 +
 8 files changed, 847 insertions(+), 2 deletions(-)
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/assign.sys_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/get_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_local_time.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.members/operator_sys_time.pass.cpp

diff --git a/libcxx/include/__chrono/zoned_time.h 
b/libcxx/include/__chrono/zoned_time.h
index bf8e04b6407ef..169efb8e9d6f3 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -18,6 +18,7 @@
 
 #  include <__chrono/calendar.h>
 #  include <__chrono/duration.h>
+#  include <__chrono/sys_info.h>
 #  include <__chrono/system_clock.h>
 #  include <__chrono/time_zone.h>
 #  include <__chrono/tzdb_list.h>
@@ -146,8 +147,29 @@ class zoned_time {
 } && is_convertible_v, sys_time<_Duration>>)
   : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
 
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) 
{
+__tp_ = __tp;
+return *this;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& 
__tp) {
+// TODO TZDB This seems wrong.
+// Assigning a non-existant or abiguous time will throw and not satisfy
+// the post condition. This seems quite odd; I constructed an object with
+// choose::earliest and that choice is not respected.
+// what did LEWG do with this.
+// MSVC STL and libstdc++ behave the same
+__tp_ = __zone_->to_sys(__tp);
+return *this;
+  }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time() const { 
return get_sys_time(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time() 
const { return get_local_time(); }
+
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { 
return __zone_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time get_local_time() 
const { return __zone_->to_local(__tp_); }
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time get_sys_time() const 
{ return __tp_; }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return 
__zone_->get_info(__tp_); }
 
 private:
   _TimeZonePtr __zone_;
diff --git a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp 
b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
index e8337cb33822e..32a67dc4dc9c4 100644
--- a/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp
@@ -81,7 +81,15 @@ void test() {
 
   {
 std::chrono::zoned_time zt;
-zt.get_time_zone(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
-zt.get_sys_time();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+// expected-warning@+1 {{ignoring return value of function declared with 
'nodiscard' attribute}}
+static_cast(zt);
+
+zt.get_time_zone();  // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_local_time(); // expected-warning {{ignoring return value of 
function declared with 'nodiscard' attribute}}
+zt.get_sys_time();   // expected-warning {{ignoring return value 

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-10 Thread Oliver Hunt via llvm-branch-commits


@@ -7037,8 +7036,64 @@ void ItaniumMangleContextImpl::mangleCXXDtorComdat(const 
CXXDestructorDecl *D,
   Mangler.mangle(GlobalDecl(D, Dtor_Comdat));
 }
 
+static void mangleOverrideDiscrimination(CXXNameMangler &mangler,
+ ASTContext &context,
+ const ThunkInfo &thunk) {
+  auto &langOpts = context.getLangOpts();
+  auto thisType = thunk.ThisType;
+  auto thisRecord = thisType->getPointeeCXXRecordDecl();
+  auto ptrauthClassRecord = context.baseForVTableAuthentication(thisRecord);
+  unsigned typedDiscriminator =
+  context.getPointerAuthVTablePointerDiscriminator(thisRecord);
+  mangler.mangleVendorQualifier("__vtptrauth");
+  auto &manglerStream = mangler.getStream();
+  manglerStream << "I";
+  if (auto explicitAuth =
+  ptrauthClassRecord->getAttr()) {
+manglerStream << "Lj" << explicitAuth->getKey();

ojhunt wrote:

I'll see what I can find

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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits


@@ -3287,6 +3287,76 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  // Convert `Mask` into ``.
+  Constant *createDppMask(unsigned Width, unsigned Mask) {
+SmallVector R;
+R.assign(Width, ConstantInt::getFalse(F.getContext()));
+for (auto &M : R) {
+  if (Mask & 1)
+M = ConstantInt::getTrue(F.getContext());
+  Mask >>= 1;
+}
+return ConstantVector::get(R);
+  }
+
+  // Calculate output shadow as array of booleans ``, assuming if any

vitalybuka wrote:

Not exactly. Input bits can affect particular output bits.
E.g. argument with single uninitialized bit can be multiplied by initialized 
zero.
So it's approximation, but better checking will be expensive.

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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Florian Mayer via llvm-branch-commits


@@ -3287,6 +3287,76 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  // Convert `Mask` into ``.
+  Constant *createDppMask(unsigned Width, unsigned Mask) {
+SmallVector R;
+R.assign(Width, ConstantInt::getFalse(F.getContext()));
+for (auto &M : R) {
+  if (Mask & 1)
+M = ConstantInt::getTrue(F.getContext());
+  Mask >>= 1;
+}
+return ConstantVector::get(R);
+  }
+
+  // Calculate output shadow as array of booleans ``, assuming if any

fmayer wrote:

Ah, ok. Please add a comment. I guess these instructions are beyond the reach 
of the C++ standard, so there is no proper definition for "undefined bits" that 
would say whether multiplying one by zero is UB or not?

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


[llvm-branch-commits] [msan] Implement shadow propagation for _mm_dp_pd, _mm_dp_ps, _mm256_dp_ps (PR #94875)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits


@@ -3287,6 +3287,76 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  // Convert `Mask` into ``.
+  Constant *createDppMask(unsigned Width, unsigned Mask) {
+SmallVector R;
+R.assign(Width, ConstantInt::getFalse(F.getContext()));
+for (auto &M : R) {
+  if (Mask & 1)
+M = ConstantInt::getTrue(F.getContext());
+  Mask >>= 1;
+}
+return ConstantVector::get(R);
+  }
+
+  // Calculate output shadow as array of booleans ``, assuming if any
+  // arg is poisoned, entire dot product is poisoned.
+  Value *makeDppShadowI1(IRBuilder<> &IRB, Value *S, unsigned SrcMask,

vitalybuka wrote:

`i1` type of shadow elements

renamed the function

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


[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits


@@ -3357,6 +3357,37 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  Value *convertBlendvToSelectMask(IRBuilder<> &IRB, Value *C) {

vitalybuka wrote:

CreateAppToShadowCast can't be static

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


[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits


@@ -3357,6 +3357,37 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setOriginForNaryOp(I);
   }
 
+  Value *convertBlendvToSelectMask(IRBuilder<> &IRB, Value *C) {

vitalybuka wrote:

they are member of MemorySanitizerVisitor:: and access some fields

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


[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94882


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


[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)

2024-06-10 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/94882


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


[llvm-branch-commits] [clang] 809adec - Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights…"

2024-06-10 Thread via llvm-branch-commits

Author: Paul Kirth
Date: 2024-06-10T16:43:14-07:00
New Revision: 809adec88edb2cdca5c97d612865c9789233d3c3

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

LOG: Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of 
weights…"

This reverts commit c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8.

Added: 


Modified: 
clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
llvm/docs/BranchWeightMetadata.rst
llvm/include/llvm/IR/MDBuilder.h
llvm/include/llvm/IR/ProfDataUtils.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/MDBuilder.cpp
llvm/lib/IR/Metadata.cpp
llvm/lib/IR/ProfDataUtils.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/LoopPeel.cpp
llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll
llvm/test/Transforms/LowerExpectIntrinsic/expect_nonboolean.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_merge.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_or.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_tern.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_unexpect.ll
llvm/test/Transforms/PhaseOrdering/AArch64/hoist-runtime-checks.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp 
b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
index 81d9334356520..fb236aeb982e0 100644
--- a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
+++ b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
@@ -221,5 +221,5 @@ void tu2(int &i) {
   }
 }
 
-// CHECK: [[BW_LIKELY]] = !{!"branch_weights", !"expected", i32 2000, i32 1}
-// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", !"expected", i32 1, i32 2000}
+// CHECK: [[BW_LIKELY]] = !{!"branch_weights", i32 2000, i32 1}
+// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", i32 1, i32 2000}

diff  --git a/llvm/docs/BranchWeightMetadata.rst 
b/llvm/docs/BranchWeightMetadata.rst
index 62204753e29b0..522f37cdad4fc 100644
--- a/llvm/docs/BranchWeightMetadata.rst
+++ b/llvm/docs/BranchWeightMetadata.rst
@@ -28,14 +28,11 @@ Supported Instructions
 
 Metadata is only assigned to the conditional branches. There are two extra
 operands for the true and the false branch.
-We optionally track if the metadata was added by ``__builtin_expect`` or
-``__builtin_expect_with_probability`` with an optional field ``!"expected"``.
 
 .. code-block:: none
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 ,
 i32 
   }
@@ -50,7 +47,6 @@ is always case #0).
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -64,7 +60,6 @@ Branch weights are assigned to every destination.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -80,7 +75,6 @@ block and entry counts which may not be accurate with 
sampling.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
   }
 
@@ -101,7 +95,6 @@ is used.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ]
   }

diff  --git a/llvm/include/llvm/IR/MDBuilder.h 
b/llvm/include/llvm/IR/MDBuilder.h
index e02ec8f5a3d8b..3265589b7c8df 100644
--- a/llvm/include/llvm/IR/MDBuilder.h
+++ b/llvm/include/llvm/IR/MDBuilder.h
@@ -59,11 +59,7 @@ class MDBuilder {
   //===--===//
 
   /// Return metadata containing two branch weights.
-  /// @param TrueWeight the weight of the true branch
-  /// @param FalseWeight the weight of the false branch
-  /// @param Do these weights come from __builtin_expect*
-  MDNode *createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight,
-  bool IsExpected = false);
+  MDNode *createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight);
 
   /// Return metadata containing two branch weights, with significant bias
   /// towards `true` destination.
@@ -74,10 +70,7 @@ class MDBuilder {
   MDNode *createUnlikelyBranchWeights();
 
   /// Return metadata containing a number of branch weights.
-  /// @param Weights the weights of all the branches

[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)

2024-06-10 Thread Pengcheng Wang via llvm-branch-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/94313

>From 6e3d6329300e27a23481df3e6e01b9763a34d9d2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Thu, 6 Jun 2024 15:05:20 +0800
Subject: [PATCH 1/2] Address comments

Created using spr 1.3.6-beta.1
---
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp   | 17 +++--
 llvm/test/MC/RISCV/rvv/vsetvl.s |  6 +++---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 4091f9d5e9f8a..49f21e46f34ea 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2160,10 +2160,9 @@ bool RISCVAsmParser::parseVTypeToken(const AsmToken 
&Tok, VTypeState &State,
   unsigned ELEN = STI->hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32;
   unsigned MinLMUL = ELEN / 8;
   if (Lmul > MinLMUL)
-Warning(
-Tok.getLoc(),
-Twine("The use of vtype encodings with LMUL < SEWMIN/ELEN == mf") +
-Twine(MinLMUL) + Twine(" is reserved"));
+Warning(Tok.getLoc(),
+"use of vtype encodings with LMUL < SEWMIN/ELEN == mf" +
+Twine(MinLMUL) + " is reserved");
 }
 
 State = VTypeState_TailPolicy;
@@ -2228,12 +2227,10 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector 
&Operands) {
   unsigned MaxSEW = ELEN / Lmul;
   // If MaxSEW < 8, we should have printed warning about reserved LMUL.
   if (MaxSEW >= 8 && Sew > MaxSEW)
-Warning(
-SEWLoc,
-Twine("The use of vtype encodings with SEW > ") + Twine(MaxSEW) +
-Twine(" and LMUL == ") + Twine(Fractional ? "mf" : "m") +
-Twine(Lmul) +
-Twine(" may not be compatible with all RVV implementations"));
+Warning(SEWLoc,
+"use of vtype encodings with SEW > " + Twine(MaxSEW) +
+" and LMUL == " + (Fractional ? "mf" : "m") + Twine(Lmul) +
+" may not be compatible with all RVV implementations");
 }
 
 unsigned VTypeI =
diff --git a/llvm/test/MC/RISCV/rvv/vsetvl.s b/llvm/test/MC/RISCV/rvv/vsetvl.s
index 207daf392bd50..2741def0eeff2 100644
--- a/llvm/test/MC/RISCV/rvv/vsetvl.s
+++ b/llvm/test/MC/RISCV/rvv/vsetvl.s
@@ -73,21 +73,21 @@ vsetvli a2, a0, e32, m8, ta, ma
 
 vsetvli a2, a0, e32, mf2, ta, ma
 # CHECK-INST: vsetvli a2, a0, e32, mf2, ta, ma
-# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW 
> 16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}}
+# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 
16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}}
 # CHECK-ENCODING: [0x57,0x76,0x75,0x0d]
 # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for 
Application Processors), 'Zve32x' (Vector Extensions for Embedded 
Processors){{$}}
 # CHECK-UNKNOWN: 0d757657 
 
 vsetvli a2, a0, e32, mf4, ta, ma
 # CHECK-INST: vsetvli a2, a0, e32, mf4, ta, ma
-# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW 
> 8 and LMUL == mf4 may not be compatible with all RVV implementations{{$}}
+# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 8 
and LMUL == mf4 may not be compatible with all RVV implementations{{$}}
 # CHECK-ENCODING: [0x57,0x76,0x65,0x0d]
 # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for 
Application Processors), 'Zve32x' (Vector Extensions for Embedded 
Processors){{$}}
 # CHECK-UNKNOWN: 0d657657 
 
 vsetvli a2, a0, e32, mf8, ta, ma
 # CHECK-INST: vsetvli a2, a0, e32, mf8, ta, ma
-# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: The use of vtype encodings with 
LMUL < SEWMIN/ELEN == mf4 is reserved{{$}}
+# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: use of vtype encodings with LMUL < 
SEWMIN/ELEN == mf4 is reserved{{$}}
 # CHECK-ENCODING: [0x57,0x76,0x55,0x0d]
 # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for 
Application Processors), 'Zve32x' (Vector Extensions for Embedded 
Processors){{$}}
 # CHECK-UNKNOWN: 0d557657 

>From 6b44742cfcc24a07408bbe20070f57ebaa4e9066 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Fri, 7 Jun 2024 11:27:13 +0800
Subject: [PATCH 2/2] Remove Fractional

Created using spr 1.3.6-beta.1
---
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 49f21e46f34ea..ca11d155ec7c6 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2229,7 +2229,7 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector 
&Operands) {
   if (MaxSEW >= 8 && Sew > MaxSEW)

[llvm-branch-commits] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)

2024-06-10 Thread Pengcheng Wang via llvm-branch-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/94313

>From 6e3d6329300e27a23481df3e6e01b9763a34d9d2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Thu, 6 Jun 2024 15:05:20 +0800
Subject: [PATCH 1/2] Address comments

Created using spr 1.3.6-beta.1
---
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp   | 17 +++--
 llvm/test/MC/RISCV/rvv/vsetvl.s |  6 +++---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 4091f9d5e9f8a..49f21e46f34ea 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2160,10 +2160,9 @@ bool RISCVAsmParser::parseVTypeToken(const AsmToken 
&Tok, VTypeState &State,
   unsigned ELEN = STI->hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32;
   unsigned MinLMUL = ELEN / 8;
   if (Lmul > MinLMUL)
-Warning(
-Tok.getLoc(),
-Twine("The use of vtype encodings with LMUL < SEWMIN/ELEN == mf") +
-Twine(MinLMUL) + Twine(" is reserved"));
+Warning(Tok.getLoc(),
+"use of vtype encodings with LMUL < SEWMIN/ELEN == mf" +
+Twine(MinLMUL) + " is reserved");
 }
 
 State = VTypeState_TailPolicy;
@@ -2228,12 +2227,10 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector 
&Operands) {
   unsigned MaxSEW = ELEN / Lmul;
   // If MaxSEW < 8, we should have printed warning about reserved LMUL.
   if (MaxSEW >= 8 && Sew > MaxSEW)
-Warning(
-SEWLoc,
-Twine("The use of vtype encodings with SEW > ") + Twine(MaxSEW) +
-Twine(" and LMUL == ") + Twine(Fractional ? "mf" : "m") +
-Twine(Lmul) +
-Twine(" may not be compatible with all RVV implementations"));
+Warning(SEWLoc,
+"use of vtype encodings with SEW > " + Twine(MaxSEW) +
+" and LMUL == " + (Fractional ? "mf" : "m") + Twine(Lmul) +
+" may not be compatible with all RVV implementations");
 }
 
 unsigned VTypeI =
diff --git a/llvm/test/MC/RISCV/rvv/vsetvl.s b/llvm/test/MC/RISCV/rvv/vsetvl.s
index 207daf392bd50..2741def0eeff2 100644
--- a/llvm/test/MC/RISCV/rvv/vsetvl.s
+++ b/llvm/test/MC/RISCV/rvv/vsetvl.s
@@ -73,21 +73,21 @@ vsetvli a2, a0, e32, m8, ta, ma
 
 vsetvli a2, a0, e32, mf2, ta, ma
 # CHECK-INST: vsetvli a2, a0, e32, mf2, ta, ma
-# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW 
> 16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}}
+# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 
16 and LMUL == mf2 may not be compatible with all RVV implementations{{$}}
 # CHECK-ENCODING: [0x57,0x76,0x75,0x0d]
 # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for 
Application Processors), 'Zve32x' (Vector Extensions for Embedded 
Processors){{$}}
 # CHECK-UNKNOWN: 0d757657 
 
 vsetvli a2, a0, e32, mf4, ta, ma
 # CHECK-INST: vsetvli a2, a0, e32, mf4, ta, ma
-# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: The use of vtype encodings with SEW 
> 8 and LMUL == mf4 may not be compatible with all RVV implementations{{$}}
+# CHECK-ZVE32X: :[[#@LINE-2]]:17: warning: use of vtype encodings with SEW > 8 
and LMUL == mf4 may not be compatible with all RVV implementations{{$}}
 # CHECK-ENCODING: [0x57,0x76,0x65,0x0d]
 # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for 
Application Processors), 'Zve32x' (Vector Extensions for Embedded 
Processors){{$}}
 # CHECK-UNKNOWN: 0d657657 
 
 vsetvli a2, a0, e32, mf8, ta, ma
 # CHECK-INST: vsetvli a2, a0, e32, mf8, ta, ma
-# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: The use of vtype encodings with 
LMUL < SEWMIN/ELEN == mf4 is reserved{{$}}
+# CHECK-ZVE32X: :[[#@LINE-2]]:22: warning: use of vtype encodings with LMUL < 
SEWMIN/ELEN == mf4 is reserved{{$}}
 # CHECK-ENCODING: [0x57,0x76,0x55,0x0d]
 # CHECK-ERROR: instruction requires the following: 'V' (Vector Extension for 
Application Processors), 'Zve32x' (Vector Extensions for Embedded 
Processors){{$}}
 # CHECK-UNKNOWN: 0d557657 

>From 6b44742cfcc24a07408bbe20070f57ebaa4e9066 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Fri, 7 Jun 2024 11:27:13 +0800
Subject: [PATCH 2/2] Remove Fractional

Created using spr 1.3.6-beta.1
---
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 49f21e46f34ea..ca11d155ec7c6 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2229,7 +2229,7 @@ ParseStatus RISCVAsmParser::parseVTypeI(OperandVector 
&Operands) {
   if (MaxSEW >= 8 && Sew > MaxSEW)