[clang-tools-extra] [clang-tidy][docs] improve documentation on cppcoreguidelines-narrowing-conversions (#111510) (PR #118209)

2024-12-02 Thread Jonas Toth via cfe-commits


@@ -27,6 +27,29 @@ This check will flag:
  - All applications of binary operators with a narrowing conversions.
For example: ``int i; i+= 0.1;``.
 
+Note that arithmetic with integer types may perform implicit conversions if 
the used integer types are smaller than ``int``.
+These rules are documented under `"Integral Promotion" on this 
cppreference.com 
`_
+page. The following example demonstrates this behavior and can be explored 
with `cppinsights.io `_.
+
+.. code-block:: c++
+
+   // The following function definition demonstrates usage of arithmetic with 
integer types smaller than `int`
+   // and how the narrowing conversion happens implicitly.
+   void computation(short argument1, short argument2) {
+ // Arithmetic written by humans:
+ short result = argument1 + argument2;
+ // Arithmetic actually performed by C++:
+ short result = static_cast(static_cast(argument1) + 
static_cast(argument2));
+   }
+
+   void recommended_with_gsl(short argument1, short argument2) {

JonasToth wrote:

The coreguidelines recommend `narrow_cast<>` of course,  so i wanted it to 
stand out.
Solving this with `static_cast<>` is the example above. I will clarify that 
those are both ways to deal with warning if casting is used.

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


[clang] c1dcf75 - [clang][bytecode] Implement __builtin_reduce_mul (#118287)

2024-12-02 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-12-02T14:03:53+01:00
New Revision: c1dcf75a7cf8840ddf20b622148c4ab0c3b16943

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

LOG: [clang][bytecode] Implement __builtin_reduce_mul (#118287)

Added: 


Modified: 
clang/lib/AST/ByteCode/Integral.h
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/test/AST/ByteCode/builtin-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Integral.h 
b/clang/lib/AST/ByteCode/Integral.h
index ca3674263aef4f..cb81b5a6989240 100644
--- a/clang/lib/AST/ByteCode/Integral.h
+++ b/clang/lib/AST/ByteCode/Integral.h
@@ -123,7 +123,9 @@ template  class Integral final {
   APSInt toAPSInt() const {
 return APSInt(APInt(Bits, static_cast(V), Signed), !Signed);
   }
-  APSInt toAPSInt(unsigned BitWidth) const { return APSInt(toAPInt(BitWidth)); 
}
+  APSInt toAPSInt(unsigned BitWidth) const {
+return APSInt(toAPInt(BitWidth), !Signed);
+  }
   APInt toAPInt(unsigned BitWidth) const {
 if constexpr (Signed)
   return APInt(Bits, static_cast(V), Signed)

diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 8ede6717db0463..b35b90e55e5155 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1695,32 +1695,42 @@ static bool interp__builtin_vector_reduce(InterpState 
&S, CodePtr OpPC,
   assert(Arg.getFieldDesc()->isPrimitiveArray());
 
   unsigned ID = Func->getBuiltinID();
-  if (ID == Builtin::BI__builtin_reduce_add) {
-QualType ElemType = Arg.getFieldDesc()->getElemQualType();
-assert(Call->getType() == ElemType);
-PrimType ElemT = *S.getContext().classify(ElemType);
-unsigned NumElems = Arg.getNumElems();
-
-INT_TYPE_SWITCH(ElemT, {
-  T Sum = Arg.atIndex(0).deref();
-  unsigned BitWidth = Sum.bitWidth();
-  for (unsigned I = 1; I != NumElems; ++I) {
-T Elem = Arg.atIndex(I).deref();
-if (T::add(Sum, Elem, BitWidth, &Sum)) {
+  QualType ElemType = Arg.getFieldDesc()->getElemQualType();
+  assert(Call->getType() == ElemType);
+  PrimType ElemT = *S.getContext().classify(ElemType);
+  unsigned NumElems = Arg.getNumElems();
+
+  INT_TYPE_SWITCH(ElemT, {
+T Result = Arg.atIndex(0).deref();
+unsigned BitWidth = Result.bitWidth();
+for (unsigned I = 1; I != NumElems; ++I) {
+  T Elem = Arg.atIndex(I).deref();
+  T PrevResult = Result;
+
+  if (ID == Builtin::BI__builtin_reduce_add) {
+if (T::add(Result, Elem, BitWidth, &Result)) {
   unsigned OverflowBits = BitWidth + 1;
-  (void)handleOverflow(
-  S, OpPC,
-  (Sum.toAPSInt(OverflowBits) + Elem.toAPSInt(OverflowBits)));
+  (void)handleOverflow(S, OpPC,
+   (PrevResult.toAPSInt(OverflowBits) +
+Elem.toAPSInt(OverflowBits)));
   return false;
 }
+  } else if (ID == Builtin::BI__builtin_reduce_mul) {
+if (T::mul(Result, Elem, BitWidth, &Result)) {
+  unsigned OverflowBits = BitWidth * 2;
+  (void)handleOverflow(S, OpPC,
+   (PrevResult.toAPSInt(OverflowBits) *
+Elem.toAPSInt(OverflowBits)));
+  return false;
+}
+  } else {
+llvm_unreachable("Unhandled vector reduce builtin");
   }
-  pushInteger(S, Sum, Call->getType());
-});
-
-return true;
-  }
+}
+pushInteger(S, Result, Call->getType());
+  });
 
-  llvm_unreachable("Unsupported vector reduce builtin");
+  return true;
 }
 
 static bool interp__builtin_memcpy(InterpState &S, CodePtr OpPC,
@@ -2195,6 +2205,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
 
   case Builtin::BI__builtin_reduce_add:
+  case Builtin::BI__builtin_reduce_mul:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;

diff  --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 78b692b819a0ab..e59b7616ac5ab9 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1035,6 +1035,35 @@ namespace RecuceAdd {
 #endif
 }
 
+namespace ReduceMul {
+  static_assert(__builtin_reduce_mul((vector4char){}) == 0);
+  static_assert(__builtin_reduce_mul((vector4char){1, 2, 3, 4}) == 24);
+  static_assert(__builtin_reduce_mul((vector4short){1, 2, 30, 40}) == 2400);
+#ifndef __AVR__
+  static_assert(__builtin_reduce_mul((vector4int){10, 20, 300, 400}) == 
24'000'000);
+#endif
+  static_assert(__builtin_reduce_mul((vector4long){1000L, 2000L, 3000L, 
4000L}) == 24'000'000'000'000L);
+  constexpr int reduceMulInt1 = _

[clang] [clang][bytecode] Implement __builtin_reduce_mul (PR #118287)

2024-12-02 Thread Timm Baeder via cfe-commits

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


[clang] [clang][bytecode] Implement __builtin_reduce_and (PR #118289)

2024-12-02 Thread Timm Baeder via cfe-commits

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

None

>From 3b59280cae47010df112ae9aff091e3fc0708686 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 2 Dec 2024 14:03:16 +0100
Subject: [PATCH] [clang][bytecode] Implement __builtin_reduce_and

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  |  6 +-
 clang/test/AST/ByteCode/builtin-functions.cpp | 14 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index b35b90e55e5155..a4e1126bbfa8ae 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1700,7 +1700,7 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
   PrimType ElemT = *S.getContext().classify(ElemType);
   unsigned NumElems = Arg.getNumElems();
 
-  INT_TYPE_SWITCH(ElemT, {
+  INT_TYPE_SWITCH_NO_BOOL(ElemT, {
 T Result = Arg.atIndex(0).deref();
 unsigned BitWidth = Result.bitWidth();
 for (unsigned I = 1; I != NumElems; ++I) {
@@ -1723,6 +1723,9 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
 Elem.toAPSInt(OverflowBits)));
   return false;
 }
+
+  } else if (ID == Builtin::BI__builtin_reduce_and) {
+(void)T::bitAnd(Result, Elem, BitWidth, &Result);
   } else {
 llvm_unreachable("Unhandled vector reduce builtin");
   }
@@ -2206,6 +2209,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 
   case Builtin::BI__builtin_reduce_add:
   case Builtin::BI__builtin_reduce_mul:
+  case Builtin::BI__builtin_reduce_and:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e59b7616ac5ab9..1699bb8c3abc2a 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1064,6 +1064,20 @@ namespace ReduceMul {
   static_assert(__builtin_reduce_mul((vector4ulong){~0ULL, 1, 1, 2}) == ~0ULL 
- 1);
 }
 
+namespace ReduceAnd {
+  static_assert(__builtin_reduce_and((vector4char){}) == 0);
+  static_assert(__builtin_reduce_and((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == 0);
+  static_assert(__builtin_reduce_and((vector4short){(short)0x, 
(short)0x, (short)0x, (short)0x}) == 0);
+  static_assert(__builtin_reduce_and((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == 0);
+  static_assert(__builtin_reduce_and((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == 0L);
+  static_assert(__builtin_reduce_and((vector4char){(char)-1, (char)~0x22, 
(char)~0x44, (char)~0x88}) == 0x11);
+  static_assert(__builtin_reduce_and((vector4short){(short)~0x, (short)-1, 
(short)~0x, (short)~0x}) == 0x);
+  static_assert(__builtin_reduce_and((vector4int){(int)~0x, 
(int)~0x, (int)-1, (int)~0x}) == 0x);
+  static_assert(__builtin_reduce_and((vector4long){(long 
long)~0xL, (long long)~0xL, (long 
long)~0xL, (long long)-1}) == 0xL);
+  static_assert(__builtin_reduce_and((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0U);
+  static_assert(__builtin_reduce_and((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 0L);
+}
+
 namespace BuiltinMemcpy {
   constexpr int simple() {
 int a = 12;

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


[clang] [clang][bytecode] Implement __builtin_reduce_and (PR #118289)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+5-1) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+14) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index b35b90e55e5155..a4e1126bbfa8ae 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1700,7 +1700,7 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
   PrimType ElemT = *S.getContext().classify(ElemType);
   unsigned NumElems = Arg.getNumElems();
 
-  INT_TYPE_SWITCH(ElemT, {
+  INT_TYPE_SWITCH_NO_BOOL(ElemT, {
 T Result = Arg.atIndex(0).deref();
 unsigned BitWidth = Result.bitWidth();
 for (unsigned I = 1; I != NumElems; ++I) {
@@ -1723,6 +1723,9 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
 Elem.toAPSInt(OverflowBits)));
   return false;
 }
+
+  } else if (ID == Builtin::BI__builtin_reduce_and) {
+(void)T::bitAnd(Result, Elem, BitWidth, &Result);
   } else {
 llvm_unreachable("Unhandled vector reduce builtin");
   }
@@ -2206,6 +2209,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 
   case Builtin::BI__builtin_reduce_add:
   case Builtin::BI__builtin_reduce_mul:
+  case Builtin::BI__builtin_reduce_and:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e59b7616ac5ab9..1699bb8c3abc2a 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1064,6 +1064,20 @@ namespace ReduceMul {
   static_assert(__builtin_reduce_mul((vector4ulong){~0ULL, 1, 1, 2}) == ~0ULL 
- 1);
 }
 
+namespace ReduceAnd {
+  static_assert(__builtin_reduce_and((vector4char){}) == 0);
+  static_assert(__builtin_reduce_and((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == 0);
+  static_assert(__builtin_reduce_and((vector4short){(short)0x, 
(short)0x, (short)0x, (short)0x}) == 0);
+  static_assert(__builtin_reduce_and((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == 0);
+  static_assert(__builtin_reduce_and((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == 0L);
+  static_assert(__builtin_reduce_and((vector4char){(char)-1, (char)~0x22, 
(char)~0x44, (char)~0x88}) == 0x11);
+  static_assert(__builtin_reduce_and((vector4short){(short)~0x, (short)-1, 
(short)~0x, (short)~0x}) == 0x);
+  static_assert(__builtin_reduce_and((vector4int){(int)~0x, 
(int)~0x, (int)-1, (int)~0x}) == 0x);
+  static_assert(__builtin_reduce_and((vector4long){(long 
long)~0xL, (long long)~0xL, (long 
long)~0xL, (long long)-1}) == 0xL);
+  static_assert(__builtin_reduce_and((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0U);
+  static_assert(__builtin_reduce_and((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 0L);
+}
+
 namespace BuiltinMemcpy {
   constexpr int simple() {
 int a = 12;

``




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


[clang] [clang][bytecode] Implement __builtin_reduce_and (PR #118289)

2024-12-02 Thread via cfe-commits

graphite-app[bot] wrote:

## Your org has enabled the Graphite merge queue for merging into main

Add the label “FP Bundles” to the PR and Graphite will automatically add it to 
the merge queue when it’s ready to merge.

You must have a Graphite account and log in to Graphite in order to use the 
merge queue. Sign up using [this 
link](https://app.graphite.dev/invite/github/llvm?ref=merge-queue-instructions-comment&prId=5671411547).

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


[clang] [ExprConst] Handle floating- and char literals in FastEvaluateAsRValue (PR #118294)

2024-12-02 Thread via cfe-commits

https://github.com/Sirraide commented:

Seems fine, though I wonder at what point we might want to rewrite this to be a 
switch statement on the StmtClass because we’re checking for like 5 different 
expressions here at this point

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


[clang] [clang][Driver] Use shared_ptr in the Compilation class (PR #116406)

2024-12-02 Thread David Truby via cfe-commits


@@ -63,41 +56,39 @@ Compilation::getArgsForToolChain(const ToolChain *TC, 
StringRef BoundArch,
   if (!TC)
 TC = &DefaultToolChain;
 
-  DerivedArgList *&Entry = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
+  std::shared_ptr &Entry =
+  TCArgs[{TC, BoundArch, DeviceOffloadKind}];
   if (!Entry) {
 SmallVector AllocatedArgs;
-DerivedArgList *OpenMPArgs = nullptr;
+std::shared_ptr OpenMPArgs;

DavidTruby wrote:

```suggestion
std::unique_ptr OpenMPArgs;
```

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


[clang] [clang][Driver] Use shared_ptr in the Compilation class (PR #116406)

2024-12-02 Thread David Truby via cfe-commits

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


[clang] [llvm] AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins (PR #118297)

2024-12-02 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/118297

>From 10bece71d7a36fa70c10c5a4ccd0962b293ee642 Mon Sep 17 00:00:00 2001
From: Sirish Pande 
Date: Thu, 18 Jul 2024 14:27:57 -0500
Subject: [PATCH] AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins

Co-authored-by: Sirish Pande 
---
 clang/include/clang/Basic/BuiltinsAMDGPU.def  |  2 +
 clang/lib/CodeGen/CGBuiltin.cpp   |  4 ++
 .../builtins-amdgcn-gfx950-read-tr.cl | 23 
 llvm/lib/Target/AMDGPU/DSInstructions.td  |  2 +
 .../UniformityAnalysis/AMDGPU/intrinsics.ll   | 22 
 .../AMDGPU/llvm.amdgcn.ds.read.tr.gfx950.ll   | 52 +++
 6 files changed, 105 insertions(+)

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 752a751a25a0c7..4758f6053ccb6d 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -467,6 +467,8 @@ TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr4_b64_v2i32, 
"V2iV2i*3", "nc", "gfx950
 TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr6_b96_v3i32, "V3iV3i*3", "nc", 
"gfx950-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr8_b64_v2i32, "V2iV2i*3", "nc", 
"gfx950-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr16_b64_v4i16, "V4sV4s*3", "nc", 
"gfx950-insts")
+TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr16_b64_v4f16, "V4hV4h*3", "nc", 
"gfx950-insts")
+TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr16_b64_v4bf16, "V4yV4y*3", "nc", 
"gfx950-insts")
 
 TARGET_BUILTIN(__builtin_amdgcn_ashr_pk_i8_i32, "UsUiUiUi", "nc", 
"ashr-pk-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ashr_pk_u8_i32, "UsUiUiUi", "nc", 
"ashr-pk-insts")
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index cb9c23b8e0a0d0..8d162d3b8add40 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19726,6 +19726,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr4_b64_v2i32:
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr8_b64_v2i32:
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr6_b96_v3i32:
+  case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4f16:
+  case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4bf16:
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4i16: {
 Intrinsic::ID IID;
 switch (BuiltinID) {
@@ -19751,6 +19753,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   IID = Intrinsic::amdgcn_ds_read_tr6_b96;
   break;
 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4i16:
+case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4f16:
+case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4bf16:
   IID = Intrinsic::amdgcn_ds_read_tr16_b64;
   break;
 }
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl
index 39fa46d5845f42..91e04430d4973a 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl
@@ -4,6 +4,8 @@
 typedef intv2i   __attribute__((ext_vector_type(2)));
 typedef intv3i   __attribute__((ext_vector_type(3)));
 typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef __bf16 v4y   __attribute__((ext_vector_type(4)));
 
 // GFX950-LABEL: define dso_local <2 x i32> 
@test_amdgcn_ds_read_b64_tr_b4_v2i32(
 // GFX950-SAME: ptr addrspace(3) nocapture noundef readonly [[INPTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
@@ -48,3 +50,24 @@ v4s test_amdgcn_ds_read_b64_tr_b16_v2i16(local v4s* inptr)
 {
   return __builtin_amdgcn_ds_read_tr16_b64_v4i16(inptr);
 }
+
+// GFX950-LABEL: define dso_local <4 x half> 
@test_amdgcn_ds_read_b64_tr_b16_v2f16(
+// GFX950-SAME: ptr addrspace(3) nocapture noundef readonly [[INPTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// GFX950-NEXT:  entry:
+// GFX950-NEXT:[[TMP0:%.*]] = tail call <4 x half> 
@llvm.amdgcn.ds.read.tr16.b64.v4f16(ptr addrspace(3) [[INPTR]])
+// GFX950-NEXT:ret <4 x half> [[TMP0]]
+//
+v4h test_amdgcn_ds_read_b64_tr_b16_v2f16(local v4h* inptr)
+{
+  return __builtin_amdgcn_ds_read_tr16_b64_v4f16(inptr);
+}
+
+// GFX950-LABEL: define dso_local <4 x bfloat> 
@test_amdgcn_ds_read_b64_tr_b16_v2bf16(
+// GFX950-SAME: ptr addrspace(3) nocapture noundef readonly [[INPTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// GFX950-NEXT:  entry:
+// GFX950-NEXT:[[TMP0:%.*]] = tail call <4 x bfloat> 
@llvm.amdgcn.ds.read.tr16.b64.v4bf16(ptr addrspace(3) [[INPTR]])
+// GFX950-NEXT:ret <4 x bfloat> [[TMP0]]
+v4y test_amdgcn_ds_read_b64_tr_b16_v2bf16(local v4y* inptr)
+{
+  return __builtin_amdgcn_ds_read_tr16_b64_v4bf16(inptr);
+}
diff --git a/llvm/lib/Target/AMDGPU/DSInstructions.td 
b/llvm/lib/Target/AMDGPU/DSInstructions.td
index 7cbd6d2dc62097..ef618727258cf2 100644
--- a/llvm/lib/Target/AMDGPU/DSInstr

[clang] [clang][bytecode] Implement __builtin_reduce_xor (PR #118299)

2024-12-02 Thread Timm Baeder via cfe-commits

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

None

>From ef14e182caffbd2f4f2e6470fdb53efd00910eb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 2 Dec 2024 14:51:03 +0100
Subject: [PATCH] [clang][bytecode] Implement __builtin_reduce_xor

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  |  3 +++
 clang/test/AST/ByteCode/builtin-functions.cpp | 12 
 2 files changed, 15 insertions(+)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 65fd1538595e5f..a217578e4936b4 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1730,6 +1730,8 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
 (void)T::bitAnd(Result, Elem, BitWidth, &Result);
   } else if (ID == Builtin::BI__builtin_reduce_or) {
 (void)T::bitOr(Result, Elem, BitWidth, &Result);
+  } else if (ID == Builtin::BI__builtin_reduce_xor) {
+(void)T::bitXor(Result, Elem, BitWidth, &Result);
   } else {
 llvm_unreachable("Unhandled vector reduce builtin");
   }
@@ -2215,6 +2217,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
   case Builtin::BI__builtin_reduce_mul:
   case Builtin::BI__builtin_reduce_and:
   case Builtin::BI__builtin_reduce_or:
+  case Builtin::BI__builtin_reduce_xor:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 81fed29a8c6c0f..61b78e8928df4c 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1096,6 +1096,18 @@ namespace ReduceOr {
 #endif
 }
 
+namespace ReduceXor {
+  static_assert(__builtin_reduce_xor((vector4char){}) == 0);
+  static_assert(__builtin_reduce_xor((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == (char)0xFF);
+  static_assert(__builtin_reduce_xor((vector4short){(short)0x, 
(short)0x, (short)0x, (short)0x}) == (short)0x);
+#if __INT_WIDTH__ == 32
+  static_assert(__builtin_reduce_xor((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == (int)0x);
+  static_assert(__builtin_reduce_xor((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == (long 
long)0xL);
+  static_assert(__builtin_reduce_xor((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0xU);
+  static_assert(__builtin_reduce_xor((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 
0xUL);
+#endif
+}
+
 namespace BuiltinMemcpy {
   constexpr int simple() {
 int a = 12;

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


[clang] [lld] [llvm] [Windows] Add support for emitting PGO/LTO magic strings in the Windows PE debug directory (PR #114260)

2024-12-02 Thread Mikołaj Piróg via cfe-commits

mikolaj-pirog wrote:

> As I'm not a Windows developer, I defer to other reviewers' expertise on 
> MSVC's PGO/LTO feature.
> 
> However, to be honest, I'm unsure about the value of porting the strings 
> given the large feature differences between Clang and MSVC on PGO and LTO. 
> `clang -flto -c` output is LLVM bitcode files, which are distinguishable on 
> their own. With LLVM LTO, you can have 1 bitcode file and 99 object files, or 
> 99 bitcode files and 1 object file. I am not sure identifying that LTO 
> happens is very useful.
> 
> There are many PGO flavors. If we add this, there could be some inconsistency 
> everytime someone adds a new flavor of PGO and does not port this piece of 
> code.

I agree that it's a little awkward to port this behavior to clang, since msvc 
does pgo/lto differently; the lto is enabled by default; it's impossible to do 
pgo without lto. The value of this patch, as I have seen when creating it, is 
the feature parity with msvc, accepting the awkwardness.




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


[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-12-02 Thread Justin Bogner via cfe-commits

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


[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-12-02 Thread Justin Bogner via cfe-commits


@@ -40,10 +40,42 @@ TEST(TypesTest, TargetExtType) {
   Type *A = TargetExtType::get(Context, "typea");
   Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1});
   Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1});
+
   // Opaque types with same parameters are identical...
   EXPECT_EQ(Aparam, Aparam2);
   // ... but just having the same name is not enough.
   EXPECT_NE(A, Aparam);
+
+  // ensure struct types in targest extension types
+  // only show the struct name, not the struct body
+  Type *Int32Type = Type::getInt32Ty(Context);
+  Type *FloatType = Type::getFloatTy(Context);
+  std::array Elements = {Int32Type, FloatType};
+
+  StructType *Struct = llvm::StructType::create(Context, Elements, "MyStruct",
+/*isPacked=*/false);
+  SmallVector TETV;
+  llvm::raw_svector_ostream TETStream(TETV);
+  Type *TargetExtensionType =
+  TargetExtType::get(Context, "structTET", {Struct}, {0, 1});
+  TargetExtensionType->print(TETStream);
+
+  EXPECT_STREQ(TETStream.str().str().data(),
+   "target(\"structTET\", %MyStruct, 0, 1)");
+
+  // ensure that literal structs in the target extension type print the struct
+  // body
+  StructType *OtherStruct =
+  StructType::get(Context, Struct->elements(), /*isPacked=*/false);
+
+  Type *OtherTargetExtensionType =
+  TargetExtType::get(Context, "structTET", {OtherStruct}, {0, 1});
+  SmallVector OtherTETV;
+  llvm::raw_svector_ostream OtherTETStream(OtherTETV);

bogner wrote:

It would be fine to reuse the variables from above here (`Struct`, 
`TargetExtensionType`, `TETV`, `TETStream`)

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


[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

2024-12-02 Thread Justin Bogner via cfe-commits

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

Looks good!

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


[clang] [Xtensa] Default to unsigned char (PR #115967)

2024-12-02 Thread Alexander Richardson via cfe-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/115967

>From e428a45e9638d0d310bd21e46acf4175b09815c9 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Tue, 12 Nov 2024 16:24:08 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 clang/lib/Driver/ToolChains/Clang.cpp | 1 +
 clang/test/Driver/xtensa-char.c   | 4 
 2 files changed, 5 insertions(+)
 create mode 100644 clang/test/Driver/xtensa-char.c

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0952262c360185..29954bfbc560c1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1347,6 +1347,7 @@ static bool isSignedCharDefault(const llvm::Triple 
&Triple) {
   case llvm::Triple::riscv64:
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
+  case llvm::Triple::xtensa:
 return false;
   }
 }
diff --git a/clang/test/Driver/xtensa-char.c b/clang/test/Driver/xtensa-char.c
new file mode 100644
index 00..13f8f67727e75d
--- /dev/null
+++ b/clang/test/Driver/xtensa-char.c
@@ -0,0 +1,4 @@
+/// Check that char is unsigned by default.
+// RUN: %clang -### %s --target=xtensa -c 2>&1 | FileCheck %s
+// CHECK: "-cc1" "-triple" "xtensa"
+// CHECK-SAME: "-fno-signed-char"

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


[clang] [Xtensa] Default to unsigned char (PR #115967)

2024-12-02 Thread Alexander Richardson via cfe-commits

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


[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Maksim Ivanov via cfe-commits

https://github.com/emaxx-google updated 
https://github.com/llvm/llvm-project/pull/118281

>From ffba96ae0b32a25b810c46c46e9c360c3eef400d Mon Sep 17 00:00:00 2001
From: Maksim Ivanov 
Date: Mon, 2 Dec 2024 10:03:25 +
Subject: [PATCH 1/3] [clang] Warn [[clang::lifetimebound]] misusages on types

Emit the "cannot be applied to types" warning instead of silently
ignoring the attribute when it's attempted to be used on a type (instead
of a function argument or the function definition).

Before this commit, the warning has been printed when the attribute was
(mis)used on a decl-specifier, but not in other places in a declarator.

Examples where the warning starts being emitted with this commit:

  int * [[clang::lifetimebound]] x;

  void f(int * [[clang::lifetimebound]] x);

  void g(int * [[clang::lifetimebound]]);

Note that the last example is the case of an unnamed function parameter.
While in theory Clang could've supported the [[clang::lifetimebound]],
it doesn't currently, so the commit at least makes the situation better
by highlighting this as a warning instead of a silent ignore.
---
 clang/lib/Sema/SemaType.cpp   |  3 +++
 clang/test/SemaCXX/attr-lifetimebound.cpp | 13 +++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index f32edc5ac06440..2cc083ff6689d6 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8612,7 +8612,10 @@ static void HandleLifetimeBoundAttr(TypeProcessingState 
&State,
 CurType = State.getAttributedType(
 createSimpleAttr(State.getSema().Context, Attr),
 CurType, CurType);
+return;
   }
+  State.getSema().Diag(Attr.getLoc(), diag::err_attribute_not_type_attr)
+  << Attr << Attr.isRegularKeywordAttribute();
 }
 
 static void HandleLifetimeCaptureByAttr(TypeProcessingState &State,
diff --git a/clang/test/SemaCXX/attr-lifetimebound.cpp 
b/clang/test/SemaCXX/attr-lifetimebound.cpp
index f89b556f5bba08..5f10dea97c29b4 100644
--- a/clang/test/SemaCXX/attr-lifetimebound.cpp
+++ b/clang/test/SemaCXX/attr-lifetimebound.cpp
@@ -9,11 +9,20 @@ namespace usage_invalid {
 ~A() [[clang::lifetimebound]]; // expected-error {{cannot be applied to a 
destructor}}
 static int *static_class_member() [[clang::lifetimebound]]; // 
expected-error {{static member function has no implicit object parameter}}
 int *explicit_object(this A&) [[clang::lifetimebound]]; // expected-error 
{{explicit object member function has no implicit object parameter}}
-int not_function [[clang::lifetimebound]]; // expected-error {{only 
applies to parameters and implicit object parameters}}
-int [[clang::lifetimebound]] also_not_function; // expected-error {{cannot 
be applied to types}}
+int attr_on_var [[clang::lifetimebound]]; // expected-error {{only applies 
to parameters and implicit object parameters}}
+int [[clang::lifetimebound]] attr_on_int; // expected-error {{cannot be 
applied to types}}
+int * [[clang::lifetimebound]] attr_on_int_ptr; // expected-error {{cannot 
be applied to types}}
+int * [[clang::lifetimebound]] * attr_on_int_ptr_ptr; // expected-error 
{{cannot be applied to types}}
+int (* [[clang::lifetimebound]] attr_on_func_ptr)(); // expected-error 
{{cannot be applied to types}}
 void void_return_member() [[clang::lifetimebound]]; // expected-error 
{{'lifetimebound' attribute cannot be applied to an implicit object parameter 
of a function that returns void; did you mean 'lifetime_capture_by(X)'}}
   };
   int *attr_with_param(int ¶m [[clang::lifetimebound(42)]]); // 
expected-error {{takes no arguments}}
+
+  void attr_on_ptr_arg(int * [[clang::lifetimebound]] ptr); // expected-error 
{{cannot be applied to types}}
+  static_assert((int [[clang::lifetimebound]]) 12); // expected-error {{cannot 
be applied to types}}
+  int* attr_on_unnamed_arg(const int& [[clang::lifetimebound]]); // 
expected-error {{cannot be applied to types}}
+  template 
+  int* attr_on_template_ptr_arg(T * [[clang::lifetimebound]] ptr); // 
expected-error {{cannot be applied to types}}
 }
 
 namespace usage_ok {

>From 8bd3f8db4c92a3c7f098dde65274590d6ee8592c Mon Sep 17 00:00:00 2001
From: Maksim Ivanov 
Date: Mon, 2 Dec 2024 15:47:08 +
Subject: [PATCH 2/3] change warning

---
 clang/lib/Sema/SemaType.cpp   |  5 +++--
 clang/test/SemaCXX/attr-lifetimebound.cpp | 12 ++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 2cc083ff6689d6..75130436282fbd 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8614,8 +8614,9 @@ static void HandleLifetimeBoundAttr(TypeProcessingState 
&State,
 CurType, CurType);
 return;
   }
-  State.getSema().Diag(Attr.getLoc(), diag::err_attribute_not_type_attr)
-  << Attr << Attr.isRegularKeywordAttribute();
+  State.getSema().Diag(Attr.getLoc(), diag::err_at

[clang] Revert [Clang] prevent errors for deduction guides using deduced type aliases (PR #118165)

2024-12-02 Thread Oleksandr T. via cfe-commits

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


[clang] [llvm] [SPIR-V] Fixup storage class for global private (PR #116636)

2024-12-02 Thread Nathan Gauër via cfe-commits

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


[clang] [clang] constexpr built-in elementwise bitreverse function. (PR #118177)

2024-12-02 Thread via cfe-commits


@@ -11322,9 +11323,18 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 
 for (unsigned EltNum = 0; EltNum < SourceLen; ++EltNum) {
   APSInt Elt = Source.getVectorElt(EltNum).getInt();
-  ResultElements.push_back(
-  APValue(APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), 
Elt.popcount()),
- DestEltTy->isUnsignedIntegerOrEnumerationType(;
+  switch (E->getBuiltinCallee()) {
+  case Builtin::BI__builtin_elementwise_popcount:
+ResultElements.push_back(APValue(
+APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), Elt.popcount()),
+   DestEltTy->isUnsignedIntegerOrEnumerationType(;
+break;
+  case Builtin::BI__builtin_elementwise_bitreverse:
+ResultElements.push_back(
+APValue(APSInt(Elt.reverseBits(),
+   DestEltTy->isUnsignedIntegerOrEnumerationType(;
+break;

c8ef wrote:

Done.

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


[clang-tools-extra] [NFC] Fix uninitialized data member in constructor. (PR #118324)

2024-12-02 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/118324

>From 4142b5bd36a4f7a554196687e191a09dba9e4dcf Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Mon, 2 Dec 2024 09:09:21 -0800
Subject: [PATCH 1/2] [NFC] Fix uninitialized data member in constructor.

---
 clang-tools-extra/clangd/index/dex/Dex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang-tools-extra/clangd/index/dex/Dex.h 
b/clang-tools-extra/clangd/index/dex/Dex.h
index 69e161d51135b6..f907c9a55b935b 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.h
+++ b/clang-tools-extra/clangd/index/dex/Dex.h
@@ -58,6 +58,7 @@ class Dex : public SymbolIndex {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
 this->BackingDataSize = BackingDataSize;
+this->IdxContents = IndexContents::All;
   }
 
   template From d93be0f1db9eb4cb4691c7b023bf6bc046d7 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Mon, 2 Dec 2024 10:54:41 -0800
Subject: [PATCH 2/2] Fix uninitialized scalar field in constructor.

---
 clang-tools-extra/clangd/index/MemIndex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang-tools-extra/clangd/index/MemIndex.h 
b/clang-tools-extra/clangd/index/MemIndex.h
index fba2c1a7120a2b..879d7750ac0480 100644
--- a/clang-tools-extra/clangd/index/MemIndex.h
+++ b/clang-tools-extra/clangd/index/MemIndex.h
@@ -43,6 +43,7 @@ class MemIndex : public SymbolIndex {
 KeepAlive = std::shared_ptr(
 std::make_shared(std::move(BackingData)), nullptr);
 this->BackingDataSize = BackingDataSize;
+this->IdxContents = IndexContents::All;
   }
 
   template https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AArch64] Implement FP8 SVE intrinsics for widening conversions (PR #118123)

2024-12-02 Thread via cfe-commits


@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: llc -mattr=+bf16,+sve2,+fp8 < %s | FileCheck %s

SpencerAbson wrote:

nit: I'm not sure we need `+bf16` in these.

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


[clang] f8b4182 - Revert "[SPIR-V] Fixup storage class for global private (#116636)" (#118312)

2024-12-02 Thread via cfe-commits

Author: Nathan Gauër
Date: 2024-12-02T17:32:54+01:00
New Revision: f8b4182f076f8fe55f9d5f617b5a25008a77b22f

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

LOG: Revert "[SPIR-V] Fixup storage class for global private (#116636)" 
(#118312)

This reverts commit aa7fe1c10e5d6d0d3aacdb345fed995de413e142.

Added: 


Modified: 
clang/include/clang/Basic/AddressSpaces.h
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/DirectX.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.h
clang/test/SemaTemplate/address_space-dependent.cpp
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
llvm/lib/Target/SPIRV/SPIRVUtils.cpp
llvm/lib/Target/SPIRV/SPIRVUtils.h
llvm/test/CodeGen/SPIRV/pointers/variables-storage-class.ll

Removed: 
llvm/test/CodeGen/SPIRV/pointers/global-addrspacecast.ll
llvm/test/CodeGen/SPIRV/pointers/variables-storage-class-vk.ll



diff  --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index 8563d373d87367..7b723d508fff17 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -58,7 +58,6 @@ enum class LangAS : unsigned {
 
   // HLSL specific address spaces.
   hlsl_groupshared,
-  hlsl_private,
 
   // Wasm specific address spaces.
   wasm_funcref,

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 1a273c76f71c41..7caebfb061a50b 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2553,8 +2553,6 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
 return "__funcref";
   case LangAS::hlsl_groupshared:
 return "groupshared";
-  case LangAS::hlsl_private:
-return "hlsl_private";
   default:
 return std::to_string(toTargetAddressSpace(AS));
   }

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 80aa212afc5c91..86befb1cbc74fc 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -47,7 +47,6 @@ static const LangASMap FakeAddrSpaceMap = {
 11, // ptr32_uptr
 12, // ptr64
 13, // hlsl_groupshared
-14, // hlsl_private
 20, // wasm_funcref
 };
 

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 6ef38fac6da280..68a8b1ebad8cde 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -44,7 +44,6 @@ static const unsigned ARM64AddrSpaceMap[] = {
 static_cast(AArch64AddrSpace::ptr32_uptr),
 static_cast(AArch64AddrSpace::ptr64),
 0, // hlsl_groupshared
-0, // hlsl_private
 // Wasm address space values for this target are dummy values,
 // as it is only enabled for Wasm targets.
 20, // wasm_funcref

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 83aac92e2ea3ca..99f8f2944e2796 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -59,7 +59,6 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_uptr
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
 llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
-llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_private
 };
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
@@ -84,7 +83,6 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_uptr
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
 llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
-llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_private
 
 };
 } // namespace targets

diff  --git a/clang/lib/Basic/Targets/DirectX.h 
b/clang/lib/Basic/Targets/DirectX.h
index 2cbb724386870e..ab22d1281a4df7 100644
--- a/clang/lib/Basic/Targets/DirectX.h
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -33,16 +33,15 @@ static const unsigned DirectXAddrSpaceMap[] = {
 0, // cuda_constant
 0, // cuda_shared
 // SYCL address space values for this map are dummy
-0,  // sycl_global
-0,  // sycl_global_device
-0,  // sycl_global_host
-0,  // sycl_local
-0,  // sycl_private
-0,  // ptr32_sptr
-0,  // ptr32_uptr
-0,  // ptr64
-3,  // hlsl_groupshared
-10, // hlsl_private
+0, // sycl_global
+0, // sycl_global_device
+0, // sycl_global_host
+0, // sycl_local
+0, // sycl_private
+0, // ptr32_sptr
+0, // ptr32_uptr
+0, // ptr64
+3, /

[clang] [clang][Driver] Use shared_ptr in the Compilation class (PR #116406)

2024-12-02 Thread David Truby via cfe-commits


@@ -63,41 +56,39 @@ Compilation::getArgsForToolChain(const ToolChain *TC, 
StringRef BoundArch,
   if (!TC)
 TC = &DefaultToolChain;
 
-  DerivedArgList *&Entry = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
+  std::shared_ptr &Entry =

DavidTruby wrote:

You can just use a reference to the unique_ptr here, since no ownership is 
being taken. 

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


[clang] [llvm] Revert "[SPIR-V] Fixup storage class for global private (#116636)" (PR #118312)

2024-12-02 Thread Nathan Gauër via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits


@@ -10264,6 +10264,10 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays compare their addresses and will be 
deprecated in c++20; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">;

AmrDeveloper wrote:

I think i misunderstood inlining diagnostic here, can you give me example about 
how inline it

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


[clang] [flang] [clang][driver] Special care for -l flags in config files (PR #117573)

2024-12-02 Thread David Truby via cfe-commits


@@ -0,0 +1 @@
+-ffast-math -Wl,--as-needed | -lm -Wl,-Bstatic -lhappy -Wl,-Bdynamic

DavidTruby wrote:

Could we just pick a character to prefix each argument with that indicates that 
that argument should come at the end? `$` maybe?
e.g. 
```
-ffast-math $-lm 
-Wl,--as-needed, $-Wl,-Bstatic 
$-lhappy $-Wl,-Bdynamic
```
It's a bit messy compared to your pipe idea but maybe easier to implement?

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


[clang-tools-extra] [NFC] Fix uninitialized data member in constructor. (PR #118324)

2024-12-02 Thread Zahira Ammarguellat via cfe-commits

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


[clang-tools-extra] [NFC] Fix uninitialized scalar field in constructor. (PR #118324)

2024-12-02 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [clang][Driver] Use shared_ptr in the Compilation class (PR #116406)

2024-12-02 Thread David Truby via cfe-commits


@@ -100,7 +100,7 @@ class Compilation {
   return false;
 }
   };
-  std::map TCArgs;
+  std::map> TCArgs;

DavidTruby wrote:

This can be a unique_ptr, as TCArgs owns the underlying DerivedArgList.

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


[clang] [HLSL] Add ByteAddressBuffer, RWByteAddressBuffer and RasterizerOrderedByteAddressBuffer definitions to HLSLExternalSemaSource #113477 (PR #116699)

2024-12-02 Thread via cfe-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/116699

>From 84c1c4dc168b4d20c9f0f0131548080d32f3f02b Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Sat, 9 Nov 2024 01:34:16 +
Subject: [PATCH 01/19] adding definition

---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 +
 .../test/AST/HLSL/ByteAddressBuffer-AST.hlsl  | 41 +++
 2 files changed, 51 insertions(+)
 create mode 100644 clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl

diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index 951375cc84ba82..4c428087ec55d2 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -939,6 +939,16 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
 .addDecrementCounterMethod()
 .completeDefinition();
   });
+
+  Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ByteAddressBuffer")
+ .Record;
+  onCompletion(Decl, [this](CXXRecordDecl *Decl) {
+setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
+/*IsROV=*/true,
+/*RawBuffer=*/true)
+.addArraySubscriptOperators()
+.completeDefinition();
+  });
 }
 
 void HLSLExternalSemaSource::onCompletion(CXXRecordDecl *Record,
diff --git a/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl 
b/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl
new file mode 100644
index 00..013974369d033a
--- /dev/null
+++ b/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY %s | FileCheck -check-prefix=EMPTY %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump %s 
| FileCheck %s
+
+
+// EMPTY: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit  class ByteAddressBuffer
+// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+
+// There should be no more occurrences of ByteAddressBuffer
+// EMPTY-NOT: {{[^[:alnum:]]}}ByteAddressBuffer
+
+#ifndef EMPTY
+
+ByteAddressBuffer Buffer;
+
+#endif
+
+// CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit referenced  class ByteAddressBuffer 
definition
+
+
+// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
+// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
+// CHECK-SAME{LITERAL}: [[hlsl::contained_type(char8_t)]]
+// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
RawBuffer
+
+// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'char8_t &const (unsigned int) const'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
+// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'char8_t' lvalue 
.e 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 'const 
hlsl::ByteAddressBuffer' lvalue implicit this
+// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
always_inline
+
+// CHECK-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  operator[] 'char8_t &(unsigned int)'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
+// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'char8_t' lvalue 
.e 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 
'hlsl::ByteAddressBuffer' lvalue implicit this
+// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
always_inline

>From a08103a27066729b4224a949c11c3fcc70e2ea3e Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Mon, 18 Nov 2024 21:11:47 +
Subject: [PATCH 02/19] adding tests

---
 clang/test/AST/HLSL/ByteAddressBuffer-AST.ll| 13 +
 .../CodeGenHLSL/builtins/ByteAddressBuffer.hlsl |  8 
 2 files changed, 21 insertions(+)
 create mode 100644 clang/test/AST/HLSL/ByteAddressBuffer-AST.ll
 create mode 100644 clang/test/CodeGenHLSL/builtins/ByteAddressBuffer.hlsl

diff --git a/clang/test/AST/HLSL/ByteAddressBuffer-AST.ll 
b/clang/test/AST/HLSL/ByteAddressBuffer-AST.ll
new file mode 100644
index 00..7df06100d69fe5
--- /dev/null
+++ b/clang/test/AST/HLSL/ByteAddressBuffer-AST.ll
@@ -0,0 +1,13 @@
+; ModuleID = 
'/workspace/llvm-project/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl'
+source_filename = 
"/workspace/llvm-project/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl"
+target datalayout = 
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxilv1.0-pc-shadermodel6.0-library"
+
+!llvm.module.flags = !{!0, !1}
+!dx.valver = !{!2}
+!llvm.ident = !{!3}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 4, !"dx.disable_optimizations", i32 1}
+!2 = !{i32 1, i32 8}
+!3 = !{!"clang ve

[clang] [flang] [clang][driver] Special care for -l flags in config files (PR #117573)

2024-12-02 Thread Paul Osmialowski via cfe-commits

https://github.com/pawosm-arm updated 
https://github.com/llvm/llvm-project/pull/117573

>From bc66202680198f0e5d1289c62f79ca5799e6f2ac Mon Sep 17 00:00:00 2001
From: Pawel Osmialowski 
Date: Mon, 25 Nov 2024 14:46:55 +
Subject: [PATCH] [clang][driver] Special care for -l and -Wl, flags in config
 files

Currently, if a -l (or -Wl,) flag is added into a config file
(e.g. clang.cfg), it is situated before any object file in the
effective command line. If the library requested by given -l flag is
static, its symbols will not be made visible to any of the object
files provided by the user. Also, the presence of any of the linker
flags in a config file confuses the driver whenever the user invokes
clang without any parameters.

This patch attempts to solve both of the problems, by allowing a split
of the arguments list into two parts. The head part of the list will
be used as before, but the tail part will be appended after the
command line flags provided by the user and only when it is known
that the linking should occur. The ^-prefixed arguments will be added
to the tail part.
---
 clang/include/clang/Driver/Driver.h   |  3 ++
 clang/lib/Driver/Driver.cpp   | 51 ++-
 clang/test/Driver/Inputs/config-l.cfg |  3 ++
 clang/test/Driver/config-file.c   | 26 ++
 flang/test/Driver/Inputs/config-l.cfg |  3 ++
 flang/test/Driver/config-file.f90 | 26 ++
 6 files changed, 104 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Driver/Inputs/config-l.cfg
 create mode 100644 flang/test/Driver/Inputs/config-l.cfg

diff --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 9177d56718ee77..b21606b6f54b77 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -297,6 +297,9 @@ class Driver {
   /// Object that stores strings read from configuration file.
   llvm::StringSaver Saver;
 
+  /// Linker inputs originated from configuration file.
+  std::unique_ptr CfgLinkerInputs;
+
   /// Arguments originated from configuration file.
   std::unique_ptr CfgOptions;
 
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7de8341b8d2d61..3265aca659681c 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1039,34 +1039,59 @@ bool Driver::readConfigFile(StringRef FileName,
   }
 
   // Try reading the given file.
-  SmallVector NewCfgArgs;
-  if (llvm::Error Err = ExpCtx.readConfigFile(FileName, NewCfgArgs)) {
+  SmallVector NewCfgFileArgs;
+  if (llvm::Error Err = ExpCtx.readConfigFile(FileName, NewCfgFileArgs)) {
 Diag(diag::err_drv_cannot_read_config_file)
 << FileName << toString(std::move(Err));
 return true;
   }
 
+  // Populate head and tail lists. The tail list is used only when linking.
+  SmallVector NewCfgHeadArgs, NewCfgTailArgs;
+  for (const char *Opt : NewCfgFileArgs) {
+// An ^-prefixed option should go to the tail list.
+if (Opt[0] == '^' && Opt[1])
+  NewCfgTailArgs.push_back(Opt + 1);
+else
+  NewCfgHeadArgs.push_back(Opt);
+  }
+
   // Read options from config file.
   llvm::SmallString<128> CfgFileName(FileName);
   llvm::sys::path::native(CfgFileName);
-  bool ContainErrors;
-  auto NewOptions = std::make_unique(
-  ParseArgStrings(NewCfgArgs, /*UseDriverMode=*/true, ContainErrors));
+  bool ContainErrors = false;
+  auto NewHeadOptions = std::make_unique(
+  ParseArgStrings(NewCfgHeadArgs, /*UseDriverMode=*/true, ContainErrors));
+  if (ContainErrors)
+return true;
+  auto NewTailOptions = std::make_unique(
+  ParseArgStrings(NewCfgTailArgs, /*UseDriverMode=*/true, ContainErrors));
   if (ContainErrors)
 return true;
 
   // Claim all arguments that come from a configuration file so that the driver
   // does not warn on any that is unused.
-  for (Arg *A : *NewOptions)
+  for (Arg *A : *NewHeadOptions)
+A->claim();
+  for (Arg *A : *NewTailOptions)
 A->claim();
 
   if (!CfgOptions)
-CfgOptions = std::move(NewOptions);
+CfgOptions = std::move(NewHeadOptions);
   else {
 // If this is a subsequent config file, append options to the previous one.
-for (auto *Opt : *NewOptions)
+for (auto *Opt : *NewHeadOptions)
   appendOneArg(*CfgOptions, Opt);
   }
+
+  if (!CfgLinkerInputs)
+CfgLinkerInputs = std::move(NewTailOptions);
+  else {
+// If this is a subsequent config file, append options to the previous one.
+for (auto *Opt : *NewTailOptions)
+  appendOneArg(*CfgLinkerInputs, Opt);
+  }
+
   ConfigFiles.push_back(std::string(CfgFileName));
   return false;
 }
@@ -1244,6 +1269,7 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   if (!ContainsError)
 ContainsError = loadConfigFiles();
   bool HasConfigFile = !ContainsError && (CfgOptions.get() != nullptr);
+  bool HasConfigLinkerIn = !ContainsError && CfgLinkerInputs;
 
   // All arguments, from both config file and command line.
   InputArgList Args 

[clang] [flang] [clang][driver] Special care for -l flags in config files (PR #117573)

2024-12-02 Thread Paul Osmialowski via cfe-commits

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


[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2024-12-02 Thread via cfe-commits

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


[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2024-12-02 Thread via cfe-commits


@@ -633,6 +633,50 @@ def Packed : DiagGroup<"packed", [PackedNonPod]>;
 def PaddedBitField : DiagGroup<"padded-bitfield">;
 def Padded : DiagGroup<"padded", [PaddedBitField]>;
 def UnalignedAccess : DiagGroup<"unaligned-access">;
+def MSBitfieldCompatibility : DiagGroup<"ms-bitfield-compatibility"> {
+  code Documentation = [{
+Under the MSVC ABI adjacemt bit-fields are not packed if the underlying 
type
+has a different storage size. This warning indicates that a pair of 
adjacent
+bit-fields may not pack in the same way due to this behavioural difference.
+
+This can occur when mixing different types explicitly:
+
+.. code-block:: c++
+
+  struct S {
+uint16_t field1 : 1;
+uint32_t field2 : 1;
+  };
+
+or more subtly through enums
+
+.. code-block:: c++
+
+  enum Enum1 { /* ... */ };
+  enum class Enum2 : unsigned char { /* ... */ };
+  struct S {
+Enum1 field1 : 1;
+Enum2 field2 : 1;
+  };
+
+In each of these cases under the MSVC ABI the second bit-field will not be
+packed with the preceding bit-field, and instead will be aligned as if the
+fields were each separately defined integer fields of their respective 
storage
+size. For binary compatibility this is obviously and observably 
incompatible,
+however where bit-fields are being used solely for memory use reduction 
this
+incomplete packing may silently increase the size of objects vs what is
+expected.
+
+This issue can be addressed by ensuring the storage type of each bit-field 
is
+the same, either by explicitly using the same integer type, or in the case 
of
+enum types declaring the enum types with the same storage size. For enum 
types
+where you cannot specify the underlying type, the options are to either 
switch
+to int sized storage for all specifiers or to resort to declaring the
+bit-fields with explicit integer storage types and cast in and out of the 
field.
+If such a solution is required the `preferred_type` attribute can be used 
to
+convey the actual field type to debuggers and other tooling.

Sirraide wrote:

Can we link to the documentation of that attribute here maybe?

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


[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2024-12-02 Thread via cfe-commits

https://github.com/Sirraide commented:

So I take it we decided not to enable it by default in `-fms-compatibility` 
mode then?

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


[clang] [clang] Fix non-deterministic infinite recursion... (PR #118288)

2024-12-02 Thread via cfe-commits

graphite-app[bot] wrote:

## Your org has enabled the Graphite merge queue for merging into main

Add the label “FP Bundles” to the PR and Graphite will automatically add it to 
the merge queue when it’s ready to merge.

You must have a Graphite account and log in to Graphite in order to use the 
merge queue. Sign up using [this 
link](https://app.graphite.dev/invite/github/llvm?ref=merge-queue-instructions-comment&prId=5671389591).

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


[clang] [clang] Fix non-deterministic infinite recursion... (PR #118288)

2024-12-02 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource created 
https://github.com/llvm/llvm-project/pull/118288

...in `ASTContext::getAutoTypeInternal`

Given

```cpp
template < typename >
concept C1 = true;

template < typename , auto >
concept C2 = true;

template < C1 auto V, C2< V > auto>
struct S;
```

Both `C1 auto V` and `C2 auto` end on the set `AutoType`, the former being a 
template parameter for the latter.

Since the hashing is not deterministic (i.e., pointers are hashed), every now 
and then, both will end on the same bucket. Given that `FoldingSet` recomputes 
the `FoldingSetID` for each node in the target bucket on lookup, this triggers 
an infinite recursion:

1. Look for `X` in `AutoTypes`
2. Let's assume it would be in bucket N, so it iterates over nodes in that 
bucket. Let's assume the first is `C2 auto`.
3. Computes the `FoldingSetID` for this one, which requires the profile of its 
template parameters, so they are visited.
4. In some frames below, we end on the same `FoldingSet`, and, by chance, `C1 
auto V` would be in bucket N too.
5. But the first node in the bucket is `C2 auto` for which we need to 
profile `C1 auto V`
6. ... stack overflow!

No step individually does anything wrong, but in general, `FoldingSet` seems 
not to be re-entrant, and this fact is hidden behind many nested calls.

With this change, we store the `AutoType`s inside a `DenseMap` instead. The 
`FoldingSetID` is computed once only and then kept as the map's key, avoiding 
the need to do recursive lookups.

We also now make sure the key for the inserted `AutoType` is the same as the 
key used for lookup. Before, this was not the case, and it caused also 
non-deterministic parsing errors.

Fixes https://github.com/llvm/llvm-project/issues/110231

From 998ea6184faa12f6137d5b20f0a5f9279b14623a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Mon, 2 Dec 2024 10:48:52 +0100
Subject: [PATCH] [clang] Fix non-deterministic infinite recursion...

...in `ASTContext::getAutoTypeInternal`

Given

```cpp
template < typename >
concept C1 = true;

template < typename , auto >
concept C2 = true;

template < C1 auto V, C2< V > auto>
struct S;
```

Both `C1 auto V` and `C2 auto` end on the set `AutoType`, the former
being a template parameter for the latter.

Since the hashing is not deterministic (i.e., pointers are hashed),
every now and then, both will end on the same bucket.
Given that `FoldingSet` recomputes the `FoldingSetID` for each node in
the target bucket on lookup, this triggers an infinite recursion:

1. Look for `X` in `AutoTypes`
2. Let's assume it would be in bucket N, so it iterates over nodes in
that bucket. Let's assume the first is `C2 auto`.
3. Computes the `FoldingSetID` for this one, which requires the profile
of its template parameters, so they are visited.
4. In some frames below, we end on the same `FoldingSet`, and, by
chance, `C1 auto V` would be in bucket N too.
5. But the first node in the bucket is `C2 auto` for which we need to
profile `C1 auto V`
6. ... stack overflow!

No step individually does anything wrong, but in general, `FoldingSet`
seems not to be re-entrant, and this fact is hidden behind many nested
calls.

With this change, we store the `AutoType`s inside a `DenseMap` instead.
The `FoldingSetID` is computed once only and then kept as the map's key,
avoiding the need to do recursive lookups.

We also now make sure the key for the inserted `AutoType` is the same as
the key used for lookup. Before, this was not the case, and it caused
also non-deterministic parsing errors.

Fixes https://github.com/llvm/llvm-project/issues/110231
---
 clang/include/clang/AST/ASTContext.h |  6 +++-
 clang/include/clang/AST/Type.h   |  2 +-
 clang/lib/AST/ASTContext.cpp | 43 +---
 clang/test/Parser/gh110231.cpp   | 12 
 4 files changed, 51 insertions(+), 12 deletions(-)
 create mode 100644 clang/test/Parser/gh110231.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 89fcb6789d880a..1e89a6805ce9c6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -245,7 +245,11 @@ class ASTContext : public RefCountedBase {
   mutable llvm::FoldingSet ObjCObjectPointerTypes;
   mutable llvm::FoldingSet
 DependentUnaryTransformTypes;
-  mutable llvm::ContextualFoldingSet AutoTypes;
+  // An AutoType can have a dependency on another AutoType via its template
+  // arguments. Since both dependent and dependency are on the same set,
+  // we can end up in an infinite recursion when looking for a node if we used
+  // a `FoldingSet`, since both could end up in the same bucket.
+  mutable llvm::DenseMap AutoTypes;
   mutable llvm::FoldingSet
 DeducedTemplateSpecializationTypes;
   mutable llvm::FoldingSet AtomicTypes;
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 90a52b1dcbf624..7a10aedbcb6437 100644
--- a/

[clang] [clang] Fix non-deterministic infinite recursion... (PR #118288)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alejandro Álvarez Ayllón (alejandro-alvarez-sonarsource)


Changes

...in `ASTContext::getAutoTypeInternal`

Given

```cpp
template < typename >
concept C1 = true;

template < typename , auto >
concept C2 = true;

template < C1 auto V, C2< V > auto>
struct S;
```

Both `C1 auto V` and `C2 auto` end on the set `AutoType`, the former 
being a template parameter for the latter.

Since the hashing is not deterministic (i.e., pointers are hashed), every now 
and then, both will end on the same bucket. Given that `FoldingSet` recomputes 
the `FoldingSetID` for each node in the target bucket on lookup, this triggers 
an infinite recursion:

1. Look for `X` in `AutoTypes`
2. Let's assume it would be in bucket N, so it iterates over nodes in that 
bucket. Let's assume the first is `C2 auto`.
3. Computes the `FoldingSetID` for this one, which requires the profile of its 
template parameters, so they are visited.
4. In some frames below, we end on the same `FoldingSet`, and, by chance, `C1 
auto V` would be in bucket N too.
5. But the first node in the bucket is `C2 auto` for which we need to 
profile `C1 auto V`
6. ... stack overflow!

No step individually does anything wrong, but in general, `FoldingSet` seems 
not to be re-entrant, and this fact is hidden behind many nested calls.

With this change, we store the `AutoType`s inside a `DenseMap` instead. The 
`FoldingSetID` is computed once only and then kept as the map's key, avoiding 
the need to do recursive lookups.

We also now make sure the key for the inserted `AutoType` is the same as the 
key used for lookup. Before, this was not the case, and it caused also 
non-deterministic parsing errors.

Fixes https://github.com/llvm/llvm-project/issues/110231

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


4 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+5-1) 
- (modified) clang/include/clang/AST/Type.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+33-10) 
- (added) clang/test/Parser/gh110231.cpp (+12) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 89fcb6789d880a..1e89a6805ce9c6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -245,7 +245,11 @@ class ASTContext : public RefCountedBase {
   mutable llvm::FoldingSet ObjCObjectPointerTypes;
   mutable llvm::FoldingSet
 DependentUnaryTransformTypes;
-  mutable llvm::ContextualFoldingSet AutoTypes;
+  // An AutoType can have a dependency on another AutoType via its template
+  // arguments. Since both dependent and dependency are on the same set,
+  // we can end up in an infinite recursion when looking for a node if we used
+  // a `FoldingSet`, since both could end up in the same bucket.
+  mutable llvm::DenseMap AutoTypes;
   mutable llvm::FoldingSet
 DeducedTemplateSpecializationTypes;
   mutable llvm::FoldingSet AtomicTypes;
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 90a52b1dcbf624..7a10aedbcb6437 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6551,7 +6551,7 @@ class DeducedType : public Type {
 
 /// Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained
 /// by a type-constraint.
-class AutoType : public DeducedType, public llvm::FoldingSetNode {
+class AutoType : public DeducedType {
   friend class ASTContext; // ASTContext creates these
 
   ConceptDecl *TypeConstraintConcept;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 80e8c5b9df58e7..f2cb9d3c57b5e9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -112,6 +112,27 @@ enum FloatingRank {
   Ibm128Rank
 };
 
+template <> struct llvm::DenseMapInfo {
+  static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; }
+
+  static FoldingSetNodeID getTombstoneKey() {
+FoldingSetNodeID id;
+for (size_t i = 0; i < sizeof(id) / sizeof(unsigned); ++i) {
+  id.AddInteger(std::numeric_limits::max());
+}
+return id;
+  }
+
+  static unsigned getHashValue(const FoldingSetNodeID &Val) {
+return Val.ComputeHash();
+  }
+
+  static bool isEqual(const FoldingSetNodeID &LHS,
+  const FoldingSetNodeID &RHS) {
+return LHS == RHS;
+  }
+};
+
 /// \returns The locations that are relevant when searching for Doc comments
 /// related to \p D.
 static SmallVector
@@ -899,7 +920,7 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager 
&SM,
   FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
   DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
   TemplateSpecializationTypes(this_()),
-  DependentTemplateSpecializationTypes(this_()), AutoTypes(this_()),
+  DependentTemplateSpecializationTypes(this_()),
   DependentBitIntTypes(this_()), SubstTemplateTemplateParmPacks(this_()),
   Ded

[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

2024-12-02 Thread via cfe-commits


@@ -570,27 +579,35 @@ void SVEType::applyTypespec(StringRef TS) {
   for (char I : TS) {
 switch (I) {
 case 'Q':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Svcount;
   break;
 case 'P':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Predicate;
   break;
 case 'U':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = UInt;
   break;
 case 'c':
+  Kind = isInvalid() ? SInt : Kind;

SpencerAbson wrote:

Sure.

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


[clang] [ExprConst] Handle floating- and char literals in FastEvaluateAsRValue (PR #118294)

2024-12-02 Thread Timm Baeder via cfe-commits

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

This is part of a three-patch series that results in some nice (but not 
substantial) compile-time improvements: 
http://llvm-compile-time-tracker.com/compare.php?from=fe1c4f0106fe4fd6d61c38ba46e71fda8f4d1573&to=0824d621b2c035a3befb564153b31309a9a79d97&stat=instructions%3Au

The results for just this patch are here: 
http://llvm-compile-time-tracker.com/compare.php?from=fe1c4f0106fe4fd6d61c38ba46e71fda8f4d1573&to=6f7f51b476a37dc7c80427fede077e6798a83be8&stat=instructions:u

>From 3cb35d11ee2be92ff4372c2c0802f409a6967ebc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 27 Nov 2024 09:57:27 +0100
Subject: [PATCH] [ExprConst] Handle floating- and char literals in
 FastEvaluateAsRValue

---
 clang/lib/AST/ExprConstant.cpp | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index bb5ab67328fbc6..fa0661f65fceaf 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -16473,7 +16473,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
  const ASTContext &Ctx, bool &IsConst) {
   // Fast-path evaluations of integer literals, since we sometimes see files
   // containing vast quantities of these.
-  if (const IntegerLiteral *L = dyn_cast(Exp)) {
+  if (const auto *L = dyn_cast(Exp)) {
 Result.Val = APValue(APSInt(L->getValue(),
 L->getType()->isUnsignedIntegerType()));
 IsConst = true;
@@ -16486,6 +16486,18 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
 return true;
   }
 
+  if (const auto *FL = dyn_cast(Exp)) {
+Result.Val = APValue(FL->getValue());
+IsConst = true;
+return true;
+  }
+
+  if (const auto *L = dyn_cast(Exp)) {
+Result.Val = APValue(Ctx.MakeIntValue(L->getValue(), L->getType()));
+IsConst = true;
+return true;
+  }
+
   if (const auto *CE = dyn_cast(Exp)) {
 if (CE->hasAPValueResult()) {
   APValue APV = CE->getAPValueResult();

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


[clang] [ExprConst] Handle floating- and char literals in FastEvaluateAsRValue (PR #118294)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

This is part of a three-patch series that results in some nice (but not 
substantial) compile-time improvements: 
http://llvm-compile-time-tracker.com/compare.php?from=fe1c4f0106fe4fd6d61c38ba46e71fda8f4d1573&to=0824d621b2c035a3befb564153b31309a9a79d97&stat=instructions%3Au

The results for just this patch are here: 
http://llvm-compile-time-tracker.com/compare.php?from=fe1c4f0106fe4fd6d61c38ba46e71fda8f4d1573&to=6f7f51b476a37dc7c80427fede077e6798a83be8&stat=instructions:u

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


1 Files Affected:

- (modified) clang/lib/AST/ExprConstant.cpp (+13-1) 


``diff
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index bb5ab67328fbc6..fa0661f65fceaf 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -16473,7 +16473,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
  const ASTContext &Ctx, bool &IsConst) {
   // Fast-path evaluations of integer literals, since we sometimes see files
   // containing vast quantities of these.
-  if (const IntegerLiteral *L = dyn_cast(Exp)) {
+  if (const auto *L = dyn_cast(Exp)) {
 Result.Val = APValue(APSInt(L->getValue(),
 L->getType()->isUnsignedIntegerType()));
 IsConst = true;
@@ -16486,6 +16486,18 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
 return true;
   }
 
+  if (const auto *FL = dyn_cast(Exp)) {
+Result.Val = APValue(FL->getValue());
+IsConst = true;
+return true;
+  }
+
+  if (const auto *L = dyn_cast(Exp)) {
+Result.Val = APValue(Ctx.MakeIntValue(L->getValue(), L->getType()));
+IsConst = true;
+return true;
+  }
+
   if (const auto *CE = dyn_cast(Exp)) {
 if (CE->hasAPValueResult()) {
   APValue APV = CE->getAPValueResult();

``




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


[clang] [AArch64][SME] Fix bug on SMELd1St1 (PR #118109)

2024-12-02 Thread Tulio Magno Quites Machado Filho via cfe-commits

tuliom wrote:

@wwwatermiao I noticed the author name in the commit is `unknown`.
Is that intentional? Would you like to change it?

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


[clang] [Clang] Permit noescape on non-pointer types (PR #117344)

2024-12-02 Thread Gábor Horváth via cfe-commits


@@ -1,7 +1,12 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
+// expected-no-diagnostics
+
 template
 void test1(T __attribute__((noescape)) arr, int size);
 
-// expected-warning@+1 {{'noescape' attribute only applies to pointer 
arguments}}
-void test2(int __attribute__((noescape)) arr, int size);
\ No newline at end of file
+void test2(int __attribute__((noescape)) arr, int size);
+
+#if !__has_feature(attribute_noescape_nonpointer)

Xazax-hun wrote:

This PR introduced this feature and the goal of this test to make sure feature 
testing works as expected. I am happy to remove the test if you find it 
redundant. 

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


[clang] [analyzer][Z3] Restore the original timeout of 15s (PR #118291)

2024-12-02 Thread Kristóf Umann via cfe-commits

Szelethus wrote:

I also have some just-in-case measurements cooking to confirm that we don't 
observe any nondeterminism with these values. Previous measurements of mine 
were made with _all_ configs set to 0. Our downstream release goes off with the 
patch totally reverted.

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


[clang] [clang] constexpr built-in elementwise bitreverse function. (PR #118177)

2024-12-02 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/118177

>From 69c3275b5119adc049821aacf2b9f01641d73aad Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Sun, 1 Dec 2024 00:10:58 +0800
Subject: [PATCH 1/3] constexpr elementwise bitreverse

---
 clang/docs/LanguageExtensions.rst |  2 +-
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/Basic/Builtins.td |  2 +-
 clang/lib/AST/ExprConstant.cpp| 22 ++-
 .../test/CodeGen/builtins-elementwise-math.c  |  2 +-
 clang/test/Sema/constant_builtins_vector.cpp  |  5 +
 6 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c053a5ab3c528c..52032e935928f1 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -648,7 +648,7 @@ elementwise to the input.
 Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = 
±infinity
 
 The integer elementwise intrinsics, including 
``__builtin_elementwise_popcount``,
-can be called in a ``constexpr`` context.
+``__builtin_elementwise_bitreverse``, can be called in a ``constexpr`` context.
 
 == 
== 
=
  Name   Operation  
   Supported element types
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e44aefa90ab386..7a4d58f170d297 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -402,6 +402,7 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
 - ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 - ``__builtin_elementwise_popcount`` function can now be used in constant 
expressions.
+- ``__builtin_elementwise_bitreverse`` function can now be used in constant 
expressions.
 
 New Compiler Flags
 --
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index db5cd73fba8ad1..f953f869d726bb 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1270,7 +1270,7 @@ def ElementwiseATan2 : Builtin {
 
 def ElementwiseBitreverse : Builtin {
   let Spellings = ["__builtin_elementwise_bitreverse"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index bb5ab67328fbc6..a99e91ff7b786e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11310,7 +11310,8 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   switch (E->getBuiltinCallee()) {
   default:
 return false;
-  case Builtin::BI__builtin_elementwise_popcount: {
+  case Builtin::BI__builtin_elementwise_popcount:
+  case Builtin::BI__builtin_elementwise_bitreverse: {
 APValue Source;
 if (!EvaluateAsRValue(Info, E->getArg(0), Source))
   return false;
@@ -11322,9 +11323,19 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 
 for (unsigned EltNum = 0; EltNum < SourceLen; ++EltNum) {
   APSInt Elt = Source.getVectorElt(EltNum).getInt();
-  ResultElements.push_back(
-  APValue(APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), 
Elt.popcount()),
- DestEltTy->isUnsignedIntegerOrEnumerationType(;
+  switch (E->getBuiltinCallee()) {
+  case Builtin::BI__builtin_elementwise_popcount:
+ResultElements.push_back(APValue(
+APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), Elt.popcount()),
+   DestEltTy->isUnsignedIntegerOrEnumerationType(;
+break;
+  case Builtin::BI__builtin_elementwise_bitreverse:
+ResultElements.push_back(
+APValue(APSInt(Elt.reverseBits(),
+   DestEltTy->isUnsignedIntegerOrEnumerationType())
+.extOrTrunc(Info.Ctx.getIntWidth(DestEltTy;
+break;
+  }
 }
 
 return Success(APValue(ResultElements.data(), ResultElements.size()), E);
@@ -12833,7 +12844,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
   case Builtin::BI__builtin_bitreverse8:
   case Builtin::BI__builtin_bitreverse16:
   case Builtin::BI__builtin_bitreverse32:
-  case Builtin::BI__builtin_bitreverse64: {
+  case Builtin::BI__builtin_bitreverse64:
+  case Builtin::BI__builtin_elementwise_bitreverse: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
diff --git a/clang/test/CodeGen/builtins-elementwise-math.c 
b/clang/test/CodeGen/builtins-elementwise-math.c
ind

[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Ilya Biryukov via cfe-commits


@@ -8612,7 +8612,10 @@ static void HandleLifetimeBoundAttr(TypeProcessingState 
&State,
 CurType = State.getAttributedType(
 createSimpleAttr(State.getSema().Context, Attr),
 CurType, CurType);
+return;
   }
+  State.getSema().Diag(Attr.getLoc(), diag::err_attribute_not_type_attr)

ilya-biryukov wrote:

The other error that says "only applies to parameters and implicit object 
parameters" seems to be provide more context.

Should we maybe use that instead? Are there any reasons to use the more generic 
one?

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


[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov commented:

Thanks for digging through that! This clearly looks like a good improvement and 
I wanted to mention that we had users genuinely confused about this before.

I only have a few suggestions, otherwise very supportive of the patch.

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


[clang] [clang] Fix non-deterministic infinite recursion... (PR #118288)

2024-12-02 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource updated 
https://github.com/llvm/llvm-project/pull/118288

From 998ea6184faa12f6137d5b20f0a5f9279b14623a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Mon, 2 Dec 2024 10:48:52 +0100
Subject: [PATCH 1/2] [clang] Fix non-deterministic infinite recursion...

...in `ASTContext::getAutoTypeInternal`

Given

```cpp
template < typename >
concept C1 = true;

template < typename , auto >
concept C2 = true;

template < C1 auto V, C2< V > auto>
struct S;
```

Both `C1 auto V` and `C2 auto` end on the set `AutoType`, the former
being a template parameter for the latter.

Since the hashing is not deterministic (i.e., pointers are hashed),
every now and then, both will end on the same bucket.
Given that `FoldingSet` recomputes the `FoldingSetID` for each node in
the target bucket on lookup, this triggers an infinite recursion:

1. Look for `X` in `AutoTypes`
2. Let's assume it would be in bucket N, so it iterates over nodes in
that bucket. Let's assume the first is `C2 auto`.
3. Computes the `FoldingSetID` for this one, which requires the profile
of its template parameters, so they are visited.
4. In some frames below, we end on the same `FoldingSet`, and, by
chance, `C1 auto V` would be in bucket N too.
5. But the first node in the bucket is `C2 auto` for which we need to
profile `C1 auto V`
6. ... stack overflow!

No step individually does anything wrong, but in general, `FoldingSet`
seems not to be re-entrant, and this fact is hidden behind many nested
calls.

With this change, we store the `AutoType`s inside a `DenseMap` instead.
The `FoldingSetID` is computed once only and then kept as the map's key,
avoiding the need to do recursive lookups.

We also now make sure the key for the inserted `AutoType` is the same as
the key used for lookup. Before, this was not the case, and it caused
also non-deterministic parsing errors.

Fixes https://github.com/llvm/llvm-project/issues/110231
---
 clang/include/clang/AST/ASTContext.h |  6 +++-
 clang/include/clang/AST/Type.h   |  2 +-
 clang/lib/AST/ASTContext.cpp | 43 +---
 clang/test/Parser/gh110231.cpp   | 12 
 4 files changed, 51 insertions(+), 12 deletions(-)
 create mode 100644 clang/test/Parser/gh110231.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 89fcb6789d880a..1e89a6805ce9c6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -245,7 +245,11 @@ class ASTContext : public RefCountedBase {
   mutable llvm::FoldingSet ObjCObjectPointerTypes;
   mutable llvm::FoldingSet
 DependentUnaryTransformTypes;
-  mutable llvm::ContextualFoldingSet AutoTypes;
+  // An AutoType can have a dependency on another AutoType via its template
+  // arguments. Since both dependent and dependency are on the same set,
+  // we can end up in an infinite recursion when looking for a node if we used
+  // a `FoldingSet`, since both could end up in the same bucket.
+  mutable llvm::DenseMap AutoTypes;
   mutable llvm::FoldingSet
 DeducedTemplateSpecializationTypes;
   mutable llvm::FoldingSet AtomicTypes;
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 90a52b1dcbf624..7a10aedbcb6437 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6551,7 +6551,7 @@ class DeducedType : public Type {
 
 /// Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained
 /// by a type-constraint.
-class AutoType : public DeducedType, public llvm::FoldingSetNode {
+class AutoType : public DeducedType {
   friend class ASTContext; // ASTContext creates these
 
   ConceptDecl *TypeConstraintConcept;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 80e8c5b9df58e7..f2cb9d3c57b5e9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -112,6 +112,27 @@ enum FloatingRank {
   Ibm128Rank
 };
 
+template <> struct llvm::DenseMapInfo {
+  static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; }
+
+  static FoldingSetNodeID getTombstoneKey() {
+FoldingSetNodeID id;
+for (size_t i = 0; i < sizeof(id) / sizeof(unsigned); ++i) {
+  id.AddInteger(std::numeric_limits::max());
+}
+return id;
+  }
+
+  static unsigned getHashValue(const FoldingSetNodeID &Val) {
+return Val.ComputeHash();
+  }
+
+  static bool isEqual(const FoldingSetNodeID &LHS,
+  const FoldingSetNodeID &RHS) {
+return LHS == RHS;
+  }
+};
+
 /// \returns The locations that are relevant when searching for Doc comments
 /// related to \p D.
 static SmallVector
@@ -899,7 +920,7 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager 
&SM,
   FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
   DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
   TemplateSpecializationTypes(this_()),
-

[clang] [clang][bytecode] Implement __builtin_reduce_and (PR #118289)

2024-12-02 Thread Timm Baeder via cfe-commits

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

>From a46b7045a7b043c7a984bc5cc33004162ed65380 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 2 Dec 2024 14:03:16 +0100
Subject: [PATCH] [clang][bytecode] Implement __builtin_reduce_and

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  |  6 +-
 clang/test/AST/ByteCode/builtin-functions.cpp | 16 
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index b35b90e55e5155..a4e1126bbfa8ae 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1700,7 +1700,7 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
   PrimType ElemT = *S.getContext().classify(ElemType);
   unsigned NumElems = Arg.getNumElems();
 
-  INT_TYPE_SWITCH(ElemT, {
+  INT_TYPE_SWITCH_NO_BOOL(ElemT, {
 T Result = Arg.atIndex(0).deref();
 unsigned BitWidth = Result.bitWidth();
 for (unsigned I = 1; I != NumElems; ++I) {
@@ -1723,6 +1723,9 @@ static bool interp__builtin_vector_reduce(InterpState &S, 
CodePtr OpPC,
 Elem.toAPSInt(OverflowBits)));
   return false;
 }
+
+  } else if (ID == Builtin::BI__builtin_reduce_and) {
+(void)T::bitAnd(Result, Elem, BitWidth, &Result);
   } else {
 llvm_unreachable("Unhandled vector reduce builtin");
   }
@@ -2206,6 +2209,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 
   case Builtin::BI__builtin_reduce_add:
   case Builtin::BI__builtin_reduce_mul:
+  case Builtin::BI__builtin_reduce_and:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e59b7616ac5ab9..8f56dcca852be0 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1064,6 +1064,22 @@ namespace ReduceMul {
   static_assert(__builtin_reduce_mul((vector4ulong){~0ULL, 1, 1, 2}) == ~0ULL 
- 1);
 }
 
+namespace ReduceAnd {
+  static_assert(__builtin_reduce_and((vector4char){}) == 0);
+  static_assert(__builtin_reduce_and((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == 0);
+  static_assert(__builtin_reduce_and((vector4short){(short)0x, 
(short)0x, (short)0x, (short)0x}) == 0);
+  static_assert(__builtin_reduce_and((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == 0);
+#if __INT_WIDTH__ == 32
+  static_assert(__builtin_reduce_and((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == 0L);
+  static_assert(__builtin_reduce_and((vector4char){(char)-1, (char)~0x22, 
(char)~0x44, (char)~0x88}) == 0x11);
+  static_assert(__builtin_reduce_and((vector4short){(short)~0x, (short)-1, 
(short)~0x, (short)~0x}) == 0x);
+  static_assert(__builtin_reduce_and((vector4int){(int)~0x, 
(int)~0x, (int)-1, (int)~0x}) == 0x);
+  static_assert(__builtin_reduce_and((vector4long){(long 
long)~0xL, (long long)~0xL, (long 
long)~0xL, (long long)-1}) == 0xL);
+  static_assert(__builtin_reduce_and((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0U);
+  static_assert(__builtin_reduce_and((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 0L);
+#endif
+}
+
 namespace BuiltinMemcpy {
   constexpr int simple() {
 int a = 12;

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


[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

2024-12-02 Thread via cfe-commits

https://github.com/SpencerAbson updated 
https://github.com/llvm/llvm-project/pull/117717

>From 850b7c0173f47a382093ff345d9bf35ee9e1643e Mon Sep 17 00:00:00 2001
From: Spencer Abson 
Date: Tue, 26 Nov 2024 13:49:12 +
Subject: [PATCH 1/8] Refactor parts of SveEmitter.cpp

---
 clang/include/clang/Basic/arm_sve.td  |   28 +-
 ...#12752a66d88e6d5bc8de5376bca6898e3e71f901# | 1874 +
 clang/utils/TableGen/SveEmitter.cpp   |  369 ++--
 3 files changed, 2048 insertions(+), 223 deletions(-)
 create mode 100644 
clang/utils/TableGen/#12752a66d88e6d5bc8de5376bca6898e3e71f901#

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index b36e592042da0b..e551d6e46b8f33 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -762,14 +762,14 @@ def SVCMPLS_WIDE_N : SInst<"svcmple_wide[_n_{d}]", 
"PPdj", "UcUsUi", MergeNone,
 

 // While comparisons
 
-def SVWHILELE_S32 : SInst<"svwhilele_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELE_S64 : SInst<"svwhilele_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELO_U32 : SInst<"svwhilelt_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELO_U64 : SInst<"svwhilelt_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELS_U32 : SInst<"svwhilele_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
+def SVWHILELE_S32 : SInst<"svwhilele_{d}[_{1}]", "Pkk", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELE_S64 : SInst<"svwhilele_{d}[_{1}]", "Pll", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilele", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELO_U32 : SInst<"svwhilelt_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELO_U64 : SInst<"svwhilelt_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilelo", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELS_U32 : SInst<"svwhilele_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilels", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
+def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl", MergeNone, 
"aarch64_sve_whilelt", [IsOverloadWhileOrMultiVecCvt, VerifyRuntimeMode]>;
 
 

 // Counting bit
@@ -1365,10 +1365,10 @@ def SVWHILEGE_S32 : SInst<"svwhilege_{d}[_{1}]", "Pkk", 
"PcPsPiPl", MergeNon
 def SVWHILEGE_S64 : SInst<"svwhilege_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilege", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
 def SVWHILEGT_S32 : SInst<"svwhilegt_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilegt", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
 def SVWHILEGT_S64 : SInst<"svwhilegt_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilegt", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILEHI_U32 : SInst<"svwhilegt_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilehi", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILEHI_U64 : SInst<"svwhilegt_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilehi", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILEHS_U32 : SInst<"svwhilege_{d}[_{1}]", "Pmm", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
-def SVWHILEHS_U64 : SInst<"svwhilege_{d}[_{1}]", "Pnn", "PUcPUsPUiPUl", 
MergeNone, "aarch64_sve_whilehs", [IsOverloadWhileOrMultiVecCvt, 
VerifyRuntimeMode]>;
+def SVWHILEHI_U32 : SInst<"svwhilegt_{d}[_{1}]", "Pmm", "PcPsPiPl", MergeNone, 
"aarch

[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

2024-12-02 Thread Sander de Smalen via cfe-commits


@@ -570,27 +579,35 @@ void SVEType::applyTypespec(StringRef TS) {
   for (char I : TS) {
 switch (I) {
 case 'Q':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Svcount;
   break;
 case 'P':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Predicate;
   break;
 case 'U':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = UInt;
   break;
 case 'c':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 8;
   break;
 case 's':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 16;
   break;
 case 'i':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 32;
   break;
 case 'l':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 64;
   break;
 case 'q':
+  Kind = SInt;

sdesmalen-arm wrote:

Can this not be `uint128_t` for `Uq` ?

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


[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

2024-12-02 Thread Sander de Smalen via cfe-commits


@@ -570,27 +579,35 @@ void SVEType::applyTypespec(StringRef TS) {
   for (char I : TS) {
 switch (I) {
 case 'Q':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Svcount;
   break;
 case 'P':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Predicate;
   break;
 case 'U':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = UInt;
   break;
 case 'c':
+  Kind = isInvalid() ? SInt : Kind;

sdesmalen-arm wrote:

nit: can you also add something like: `assert((Kind == Invalid || Kind == UInt) 
&& "Unexpected modifier used for typespec")`  ?

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


[clang] [clang][bytecode] Implement __builtin_reduce_and (PR #118289)

2024-12-02 Thread Timm Baeder via cfe-commits

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


[clang] [flang] [flang] Preserve fixed form in fc1 -x value (PR #117563)

2024-12-02 Thread via cfe-commits

https://github.com/macurtis-amd updated 
https://github.com/llvm/llvm-project/pull/117563

>From 2b61143e7bac96ee01cfbded4a26ac8206d6b247 Mon Sep 17 00:00:00 2001
From: Matthew Curtis 
Date: Mon, 2 Dec 2024 07:16:28 -0600
Subject: [PATCH] [flang] Treat pre-processed input as fixed

---
 clang/lib/Driver/ToolChains/Flang.cpp |  9 +
 flang/test/Driver/pp-fixed-form.f90   | 19 +++
 2 files changed, 28 insertions(+)
 create mode 100644 flang/test/Driver/pp-fixed-form.f90

diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 8c18c88fbde7f7..4c6ba5532af984 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -777,6 +777,15 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   addFortranDialectOptions(Args, CmdArgs);
 
+  // 'flang -E' always produces output that is suitable for use as fixed form
+  // Fortran. However it is only valid free form source if the original is also
+  // free form.
+  if (InputType == types::TY_PP_Fortran &&
+  !Args.hasArg(options::OPT_ffixed_form) &&
+  !Args.hasArg(options::OPT_ffree_form)) {
+CmdArgs.push_back("-ffixed-form");
+  }
+
   handleColorDiagnosticsArgs(D, Args, CmdArgs);
 
   // LTO mode is parsed by the Clang driver library.
diff --git a/flang/test/Driver/pp-fixed-form.f90 
b/flang/test/Driver/pp-fixed-form.f90
new file mode 100644
index 00..4695da78763ae5
--- /dev/null
+++ b/flang/test/Driver/pp-fixed-form.f90
@@ -0,0 +1,19 @@
+!RUN: %flang -save-temps -### %S/Inputs/free-form-test.f90  2>&1 | FileCheck 
%s --check-prefix=FREE
+FREE:   "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95-cpp-input" 
"{{.*}}/free-form-test.f90"
+FREE-NEXT:  "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "free-form-test.i"
+
+!RUN: %flang -save-temps -### %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s 
--check-prefix=FIXED
+FIXED:  "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95-cpp-input" 
"{{.*}}/fixed-form-test.f"
+FIXED-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "fixed-form-test.i"
+
+!RUN: %flang -save-temps -### -ffree-form %S/Inputs/free-form-test.f90  2>&1 | 
FileCheck %s --check-prefix=FREE-FLAG
+FREE-FLAG:   "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" 
"f95-cpp-input" "{{.*}}/free-form-test.f90"
+FREE-FLAG-NEXT:  "-fc1" {{.*}} "-emit-llvm-bc" "-ffree-form"
+FREE-FLAG-NOT:   "-ffixed-form"
+FREE-FLAG-SAME:  "-x" "f95" "free-form-test.i"
+
+!RUN: %flang -save-temps -### -ffixed-form %S/Inputs/fixed-form-test.f  2>&1 | 
FileCheck %s --check-prefix=FIXED-FLAG
+FIXED-FLAG:  "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" 
"f95-cpp-input" "{{.*}}/fixed-form-test.f"
+FIXED-FLAG-NEXT: "-fc1" {{.*}} "-emit-llvm-bc" "-ffixed-form"
+FIXED-FLAG-NOT:  "-ffixed-form"
+FIXED-FLAG-SAME: "-x" "f95" "fixed-form-test.i"

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


[clang] [analyzer][Z3] Restore the original timeout of 15s (PR #118291)

2024-12-02 Thread via cfe-commits

graphite-app[bot] wrote:

## Your org has enabled the Graphite merge queue for merging into main

Add the label “FP Bundles” to the PR and Graphite will automatically add it to 
the merge queue when it’s ready to merge.

You must have a Graphite account and log in to Graphite in order to use the 
merge queue. Sign up using [this 
link](https://app.graphite.dev/invite/github/llvm?ref=merge-queue-instructions-comment&prId=5671480345).

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


[clang] [flang] [Flang][LoongArch] Enable clang command-line options in flang. (PR #118244)

2024-12-02 Thread David Truby via cfe-commits

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

LGTM, thanks!

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


[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

2024-12-02 Thread via cfe-commits


@@ -570,27 +579,35 @@ void SVEType::applyTypespec(StringRef TS) {
   for (char I : TS) {
 switch (I) {
 case 'Q':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Svcount;
   break;
 case 'P':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = Predicate;
   break;
 case 'U':
+  assert(Kind == Invalid && "Invalid use of modifer!");
   Kind = UInt;
   break;
 case 'c':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 8;
   break;
 case 's':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 16;
   break;
 case 'i':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 32;
   break;
 case 'l':
+  Kind = isInvalid() ? SInt : Kind;
   ElementBitwidth = 64;
   break;
 case 'q':
+  Kind = SInt;

SpencerAbson wrote:

Ah, good spot!

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


[clang] [clang][bytecode] Implement __builtin_reduce_or (PR #118292)

2024-12-02 Thread Timm Baeder via cfe-commits

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

None

>From 778afb1f6e35f551b0eb56b055d21755f0c55136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 2 Dec 2024 14:24:11 +0100
Subject: [PATCH] [clang][bytecode] Implement __builtin_reduce_or

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  |  7 ++-
 clang/test/AST/ByteCode/builtin-functions.cpp | 14 ++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index a4e1126bbfa8ae..65fd1538595e5f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -104,6 +104,8 @@ template 
 static void pushInteger(InterpState &S, T Val, QualType QT) {
   if constexpr (std::is_same_v)
 pushInteger(S, APSInt(Val, !std::is_signed_v), QT);
+  else if constexpr (std::is_same_v)
+pushInteger(S, Val, QT);
   else
 pushInteger(S,
 APSInt(APInt(sizeof(T) * 8, static_cast(Val),
@@ -1726,11 +1728,13 @@ static bool interp__builtin_vector_reduce(InterpState 
&S, CodePtr OpPC,
 
   } else if (ID == Builtin::BI__builtin_reduce_and) {
 (void)T::bitAnd(Result, Elem, BitWidth, &Result);
+  } else if (ID == Builtin::BI__builtin_reduce_or) {
+(void)T::bitOr(Result, Elem, BitWidth, &Result);
   } else {
 llvm_unreachable("Unhandled vector reduce builtin");
   }
 }
-pushInteger(S, Result, Call->getType());
+pushInteger(S, Result.toAPSInt(), Call->getType());
   });
 
   return true;
@@ -2210,6 +2214,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
   case Builtin::BI__builtin_reduce_add:
   case Builtin::BI__builtin_reduce_mul:
   case Builtin::BI__builtin_reduce_and:
+  case Builtin::BI__builtin_reduce_or:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 8f56dcca852be0..9eb45f98169336 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1080,6 +1080,20 @@ namespace ReduceAnd {
 #endif
 }
 
+namespace ReduceOr {
+  static_assert(__builtin_reduce_or((vector4char){}) == 0);
+  static_assert(__builtin_reduce_or((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == (char)0xFF);
+  static_assert(__builtin_reduce_or((vector4short){(short)0x, 
(short)0x, (short)0x, (short)0x}) == (short)0x);
+  static_assert(__builtin_reduce_or((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == (int)0x);
+  static_assert(__builtin_reduce_or((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == (long 
long)0xL);
+  static_assert(__builtin_reduce_or((vector4char){(char)0, (char)0x22, 
(char)0x44, (char)0x88}) == ~0x11);
+  static_assert(__builtin_reduce_or((vector4short){(short)0x, (short)0, 
(short)0x, (short)0x}) == ~0x);
+  static_assert(__builtin_reduce_or((vector4int){(int)0x, 
(int)0x, (int)0, (int)0x}) == ~0x);
+  static_assert(__builtin_reduce_or((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0}) == ~0xL);
+  static_assert(__builtin_reduce_or((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0xU);
+  static_assert(__builtin_reduce_or((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 
0xL);
+}
+
 namespace BuiltinMemcpy {
   constexpr int simple() {
 int a = 12;

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


[clang] [flang] [flang] Treat pre-processed input as fixed (PR #117563)

2024-12-02 Thread via cfe-commits

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


[clang] [clang][bytecode] Implement __builtin_reduce_or (PR #118292)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+6-1) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+14) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index a4e1126bbfa8ae..65fd1538595e5f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -104,6 +104,8 @@ template 
 static void pushInteger(InterpState &S, T Val, QualType QT) {
   if constexpr (std::is_same_v)
 pushInteger(S, APSInt(Val, !std::is_signed_v), QT);
+  else if constexpr (std::is_same_v)
+pushInteger(S, Val, QT);
   else
 pushInteger(S,
 APSInt(APInt(sizeof(T) * 8, static_cast(Val),
@@ -1726,11 +1728,13 @@ static bool interp__builtin_vector_reduce(InterpState 
&S, CodePtr OpPC,
 
   } else if (ID == Builtin::BI__builtin_reduce_and) {
 (void)T::bitAnd(Result, Elem, BitWidth, &Result);
+  } else if (ID == Builtin::BI__builtin_reduce_or) {
+(void)T::bitOr(Result, Elem, BitWidth, &Result);
   } else {
 llvm_unreachable("Unhandled vector reduce builtin");
   }
 }
-pushInteger(S, Result, Call->getType());
+pushInteger(S, Result.toAPSInt(), Call->getType());
   });
 
   return true;
@@ -2210,6 +2214,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
   case Builtin::BI__builtin_reduce_add:
   case Builtin::BI__builtin_reduce_mul:
   case Builtin::BI__builtin_reduce_and:
+  case Builtin::BI__builtin_reduce_or:
 if (!interp__builtin_vector_reduce(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 8f56dcca852be0..9eb45f98169336 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1080,6 +1080,20 @@ namespace ReduceAnd {
 #endif
 }
 
+namespace ReduceOr {
+  static_assert(__builtin_reduce_or((vector4char){}) == 0);
+  static_assert(__builtin_reduce_or((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == (char)0xFF);
+  static_assert(__builtin_reduce_or((vector4short){(short)0x, 
(short)0x, (short)0x, (short)0x}) == (short)0x);
+  static_assert(__builtin_reduce_or((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == (int)0x);
+  static_assert(__builtin_reduce_or((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == (long 
long)0xL);
+  static_assert(__builtin_reduce_or((vector4char){(char)0, (char)0x22, 
(char)0x44, (char)0x88}) == ~0x11);
+  static_assert(__builtin_reduce_or((vector4short){(short)0x, (short)0, 
(short)0x, (short)0x}) == ~0x);
+  static_assert(__builtin_reduce_or((vector4int){(int)0x, 
(int)0x, (int)0, (int)0x}) == ~0x);
+  static_assert(__builtin_reduce_or((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0}) == ~0xL);
+  static_assert(__builtin_reduce_or((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0xU);
+  static_assert(__builtin_reduce_or((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 
0xL);
+}
+
 namespace BuiltinMemcpy {
   constexpr int simple() {
 int a = 12;

``




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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Erich Keane via cfe-commits


@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "

erichkeane wrote:

I would love some slight improvement to the first part of this diagnostic.  
Just some level of description as to why this is a bad idea.

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


[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/118315

None

>From 8a9fc5dfc40ecc46a21ce7c537e2ffe0dbbac8b0 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Mon, 2 Dec 2024 23:50:12 +0800
Subject: [PATCH] [clang-tidy] ignore `[[clang::lifetimebound]]` param in
 return-const-ref-from-parameter

---
 .../ReturnConstRefFromParameterCheck.cpp  | 12 -
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++-
 .../return-const-ref-from-parameter.rst   | 27 ---
 .../return-const-ref-from-parameter.cpp   |  6 +
 4 files changed, 37 insertions(+), 11 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
index 7da27c0474d519..06e1c5c407b175 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "ReturnConstRefFromParameterCheck.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/Expr.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
@@ -15,6 +16,14 @@ using namespace clang::ast_matchers;
 
 namespace clang::tidy::bugprone {
 
+namespace {
+
+AST_MATCHER(ParmVarDecl, hasLifetimeBoundAttr) {
+  return Node.getAttr() != nullptr;
+}
+
+} // namespace
+
 void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
   const auto DRef = ignoringParens(
   declRefExpr(
@@ -22,7 +31,8 @@ void 
ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
  qualType(lValueReferenceType(pointee(
   qualType(isConstQualified()
  .bind("type"))),
- hasDeclContext(functionDecl().bind("owner")))
+ hasDeclContext(functionDecl().bind("owner")),
+ unless(hasLifetimeBoundAttr()))
  .bind("param")))
   .bind("dref"));
   const auto Func =
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 453a91e3b504cd..c7d0c0f167e581 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -184,7 +184,8 @@ Changes in existing checks
   ` check to
   diagnose potential dangling references when returning a ``const &`` parameter
   by using the conditional operator ``cond ? var1 : var2`` and no longer giving
-  false positives for functions which contain lambda.
+  false positives for functions which contain lambda and ignore the parameters
+  with ``[[clang::lifetimebound]]`` attribute.
   
 - Improved :doc:`bugprone-sizeof-expression
   ` check to find suspicious
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
index 2349e51477b7de..aa2a43b6e8e6d1 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
@@ -12,15 +12,6 @@ after the call. When the function returns such a parameter 
also as constant refe
 then the returned reference can be used after the object it refers to has been
 destroyed.
 
-This issue can be resolved by declaring an overload of the problematic function
-where the ``const &`` parameter is instead declared as ``&&``. The developer 
has
-to ensure that the implementation of that function does not produce a
-use-after-free, the exact error that this check is warning against.
-Marking such an ``&&`` overload as ``deleted``, will silence the warning as 
-well. In the case of different ``const &`` parameters being returned depending
-on the control flow of the function, an overload where all problematic
-``const &`` parameters have been declared as ``&&`` will resolve the issue.
-
 Example
 ---
 
@@ -38,3 +29,21 @@ Example
 
   const S& s = fn(S{1});
   s.v; // use after free
+
+
+This issue can be resolved by declaring an overload of the problematic function
+where the ``const &`` parameter is instead declared as ``&&``. The developer 
has
+to ensure that the implementation of that function does not produce a
+use-after-free, the exact error that this check is warning against.
+Marking such an ``&&`` overload as ``deleted``, will silence the warning as 
+well. In the case of different ``const &`` parameters being returned depending
+on the control flow of the function, an overload where all problematic
+``const &`` parameters have been declared as ``&&`` will resolve the issue.
+
+This issue can also be resolved by adding ``[[clang::lifetimebound]]`` and
+enabling ``-Wd

[clang] [flang] [flang] Treat pre-processed input as fixed (PR #117563)

2024-12-02 Thread via cfe-commits


@@ -777,6 +777,15 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   addFortranDialectOptions(Args, CmdArgs);
 
+  // 'flang -E' always produces output that is suitable for use as fixed form
+  // Fortran. However it is only valid free form source if the original is also
+  // free form.
+  if (InputType == types::TY_PP_Fortran &&
+  !Args.hasArg(options::OPT_ffixed_form) &&
+  !Args.hasArg(options::OPT_ffree_form)) {

macurtis-amd wrote:

Updated to use getLastArg

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


[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Congcong Cai via cfe-commits

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


[libclc] [libcxx] [llvm] [openmp] [polly] [llvm] Move sub-project lead maintainers into their own Maintainers.md files (PR #118309)

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


@@ -434,29 +433,17 @@ Others only have a lead maintainer listed here.
 
 [Flang 
maintainers](https://github.com/llvm/llvm-project/blob/main/flang/Maintainers.txt)
 
-[LLD 
maintainers](https://github.com/llvm/llvm-project/blob/main/lld/CODE_OWNERS.TXT)
-
-[LLDB 
maintainers](https://github.com/llvm/llvm-project/blob/main/lldb/Maintainers.rst)
-
- libc++
-
-Louis Dionne \
-ldionn...@gmail.com (email), [ldionne](https://github.com/ldionne) (GitHub)
+[libc++ 
maintainers](https://github.com/llvm/llvm-project/blob/main/libcxx/Maintainers.rst)
 
- libclc
+[libclc 
maintainers](https://github.com/llvm/llvm-project/blob/main/libclc/Maintainers.rst)

DavidSpickett wrote:

Fixed them all.

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


[clang] [clang] constexpr built-in elementwise bitreverse function. (PR #118177)

2024-12-02 Thread Mariya Podchishchaeva via cfe-commits

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

Thanks!

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


[clang] [flang] [clang][driver] Special care for -l flags in config files (PR #117573)

2024-12-02 Thread David Truby via cfe-commits


@@ -0,0 +1 @@
+-ffast-math -Wl,--as-needed | -lm -Wl,-Bstatic -lhappy -Wl,-Bdynamic

DavidTruby wrote:

Can we check that this works for multiple line config files? E.g. I would 
expect:
```
-ffast-math | -lm
-Wl,--as-needed | -Wl,-Bstatic -lhappy
| -Wl,-Bdynamic
```
to end up being essentially the same as what is here on one line. I.e. 
`-ffast-math` and `-Wl,--as-needed` should appear before user-specified 
options, and `-lm` `-Wl,-Bstatic` `-lhappy` and `-Wl,-Bdynamic` to appear after.

I gave this a quick test and it seems like doing this on multiple lines like 
above changes the order; I think everything after the first pipe _in the file_ 
is considered to be added to the end, whereas I'd expect it to be on a 
line-by-line basis. I guess this might need a change in `readConfigFile()`.

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

Note paper [Remove Deprecated Array Comparisons from 
C++26](https://wg21.link/p2865) although the lastest version is not public yet. 

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


[clang] [Xtensa] Default to unsigned char (PR #115967)

2024-12-02 Thread Alexey Gerenkov via cfe-commits

gerekon wrote:

> Thanks, do you believe we need a backwards compatibility flag for the ABI to 
> be consistent with older clang or is this safe to land?

I think as far as we can control behavior with `-fsigned-char` we do not need 
another option for this. 
@MabezDev WDYT? Will it be critical for Rust builds?

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


[clang] [Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (PR #117717)

2024-12-02 Thread via cfe-commits

SpencerAbson wrote:

Thank you @sdesmalen-arm 

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


[clang] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-12-02 Thread Alex Voicu via cfe-commits


@@ -91,6 +97,88 @@ SPIRVTargetMachine::SPIRVTargetMachine(const Target &T, 
const Triple &TT,
   setRequiresStructuredCFG(false);
 }
 
+enum AddressSpace {
+  Function = storageClassToAddressSpace(SPIRV::StorageClass::Function),
+  CrossWorkgroup =
+  storageClassToAddressSpace(SPIRV::StorageClass::CrossWorkgroup),
+  UniformConstant =
+  storageClassToAddressSpace(SPIRV::StorageClass::UniformConstant),
+  Workgroup = storageClassToAddressSpace(SPIRV::StorageClass::Workgroup),
+  Generic = storageClassToAddressSpace(SPIRV::StorageClass::Generic)
+};
+
+unsigned SPIRVTargetMachine::getAssumedAddrSpace(const Value *V) const {
+  const auto *LD = dyn_cast(V);
+  if (!LD)
+return UINT32_MAX;
+
+  // It must be a load from a pointer to Generic.
+  assert(V->getType()->isPointerTy() &&
+ V->getType()->getPointerAddressSpace() == AddressSpace::Generic);
+
+  const auto *Ptr = LD->getPointerOperand();
+  if (Ptr->getType()->getPointerAddressSpace() != 
AddressSpace::UniformConstant)
+return UINT32_MAX;
+  // For a loaded from a pointer to UniformConstant, we can infer 
CrossWorkgroup
+  // storage, as this could only have been legally initialised with a
+  // CrossWorkgroup (aka device) constant pointer.
+  return AddressSpace::CrossWorkgroup;
+}
+
+std::pair
+SPIRVTargetMachine::getPredicatedAddrSpace(const Value *V) const {
+  using namespace PatternMatch;
+
+  if (auto *II = dyn_cast(V)) {
+switch (II->getIntrinsicID()) {
+case Intrinsic::amdgcn_is_shared:
+  return std::pair(II->getArgOperand(0), AddressSpace::Workgroup);
+case Intrinsic::amdgcn_is_private:
+  return std::pair(II->getArgOperand(0), AddressSpace::Function);
+default:
+  break;
+}
+return std::pair(nullptr, UINT32_MAX);
+  }
+  // Check the global pointer predication based on
+  // (!is_share(p) && !is_private(p)). Note that logic 'and' is commutative and
+  // the order of 'is_shared' and 'is_private' is not significant.
+  Value *Ptr;
+  if (getTargetTriple().getVendor() == Triple::VendorType::AMD &&
+  match(
+  const_cast(V),
+  
m_c_And(m_Not(m_Intrinsic(m_Value(Ptr))),
+m_Not(m_Intrinsic(
+m_Deferred(Ptr))

AlexVlx wrote:

I’m not quite sure how to parse this, apologies - what is an implementation in 
this case? It would be rather odd to have a valid implementation use e.g. 
setting the WorkGroup bit to denote CrossWorkGroup, would it not? Note I’m only 
considering SPIR-V, not what a target would decide to lower it to.

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


[clang] Revert [Clang] prevent errors for deduction guides using deduced type aliases (PR #118165)

2024-12-02 Thread Haojian Wu via cfe-commits

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


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


[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread Shilei Tian via cfe-commits


@@ -1780,6 +1786,15 @@ void CXXNameMangler::mangleDeviceStubName(const 
IdentifierInfo *II) {
   << II->getName();
 }
 
+void CXXNameMangler::mangleOCLDeviceStubName(const IdentifierInfo *II) {
+  //  ::=  __clang_ocl_kern_imp_
+  //   ::= [n]  
+  // ::= 
+  StringRef OCLDeviceStubNamePrefix = "__clang_ocl_kern_imp_";

shiltian wrote:

but you still can't prevent people from doing it right?

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


[clang] [clang] Document the return value of __builtin_COLUMN (PR #118360)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (GeorgeKA)


Changes

PR for issue #78657

Updated clang/docs/LanguageExtensions.rst to detail the return value of 
__builtin_COLUMN for this implementation.

--

Fyi, this is my first contribution, so please bear with me.

There already appears to be a unit test for __builtin_COLUMN in 
clang/test/SemaCXX/source_location.cpp.

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


1 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+5-1) 


``diff
diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 3c9078bcdf8118..00466fd2e7f020 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -4514,9 +4514,13 @@ default member initializer, the invocation point is the 
location of the
 constructor or aggregate initialization used to create the object. Otherwise
 the invocation point is the same as the location of the builtin.
 
-When the invocation point of ``__builtin_FUNCTION`` is not a function scope the
+When the invocation point of ``__builtin_FUNCTION`` is not a function scope, 
the
 empty string is returned.
 
+The builtin ``__builtin_COLUMN`` returns the offset from the start of the line,
+beginning from column 1. `This may differ from other implementations.
+`_
+
 The builtin ``__builtin_source_location`` returns a pointer to constant static
 data of type ``std::source_location::__impl``. This type must have already been
 defined, and must contain exactly four fields: ``const char *_M_file_name``,

``




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


[clang-tools-extra] [clang-tidy] ignore `[[clang::lifetimebound]]` param in return-const-ref-from-parameter (PR #118315)

2024-12-02 Thread Congcong Cai via cfe-commits

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


[clang] [Clang] Permit noescape on non-pointer types (PR #117344)

2024-12-02 Thread Erich Keane via cfe-commits


@@ -1,7 +1,12 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
+// expected-no-diagnostics
+
 template
 void test1(T __attribute__((noescape)) arr, int size);
 
-// expected-warning@+1 {{'noescape' attribute only applies to pointer 
arguments}}
-void test2(int __attribute__((noescape)) arr, int size);
\ No newline at end of file
+void test2(int __attribute__((noescape)) arr, int size);
+
+#if !__has_feature(attribute_noescape_nonpointer)

erichkeane wrote:

Got it, thanks for clarifying.

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


[clang] [clang] Fix non-deterministic infinite recursion... (PR #118288)

2024-12-02 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 0611fdd32046c41647a7719252166033f7bce2f2 
998ea6184faa12f6137d5b20f0a5f9279b14623a --extensions h,cpp -- 
clang/test/Parser/gh110231.cpp clang/include/clang/AST/ASTContext.h 
clang/include/clang/AST/Type.h clang/lib/AST/ASTContext.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index f2cb9d3c57..6ec927e13a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6318,8 +6318,9 @@ QualType ASTContext::getAutoTypeInternal(
   llvm::FoldingSetNodeID ID;
   bool IsDeducedDependent =
   !DeducedType.isNull() && DeducedType->isDependentType();
-  AutoType::Profile(ID, *this, DeducedType, Keyword, IsDependent || 
IsDeducedDependent,
-TypeConstraintConcept, TypeConstraintArgs);
+  AutoType::Profile(ID, *this, DeducedType, Keyword,
+IsDependent || IsDeducedDependent, TypeConstraintConcept,
+TypeConstraintArgs);
   if (auto const AT_iter = AutoTypes.find(ID); AT_iter != AutoTypes.end())
 return QualType(AT_iter->getSecond(), 0);
 

``




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


[clang] [flang] [flang] Preserve fixed form in fc1 -x value (PR #117563)

2024-12-02 Thread via cfe-commits

macurtis-amd wrote:

(Sorry for the delayed response ... was on Thanksgiving holiday)

@banach-space @DavidTruby Thanks for looking at this!

Latest version of the fix simply adds `-ffixed-form` for pre-processed input, 
unless the user manually specifies `-ffixed-form` or `-ffree-form`.

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


[clang] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently (PR #115993)

2024-12-02 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

> > However, notably, even on Darwin, if you pass _both_ flags, you still get 
> > the intended behavior of `-isysroot` affecting headers, and `--sysroot` 
> > affecting libraries. Your change would break that.
> 
> What's the use-case for this?
> 
> Because for most users, you almost certainly don't want to mix headers and 
> libraries of different versions, and keeping the existing behavior is 
> essentially a big footgun when trying to build a useful toolchain on Darwin.
> 
> At Homebrew, we used to configure the toolchain with `DEFAULT_SYSROOT` but 
> have recently switched that to setting the `--sysroot` flag in a Clang `.cfg` 
> file.[1](#user-content-fn-1-21a5728b47e790352033de78c44bc2e4) In either case, 
> if you set `SDKROOT` in your environment or try to run our `clang` using 
> Apple's `xcrun`, this becomes equivalent to setting `-isysroot` and you most 
> likely will end up with headers that mismatch the libraries you try to link 
> to.

The expected flow on Apple platforms is to only pass an `isysroot` argument 
whether it's inherited from `xcrun -sdk  clang` or passed 
explicitly. Could homebrew instead only pass `isysroot` for Darwin targets? Or 
check that `sysroot` and `isysroot` inputs are the same when creating an 
invocation.  It's unclear to me how homebrew gets into a situation where there 
are conflicting sdks passed for `sysroot` and `isysroot` when you effectively 
want to ignore whatever is passed to `sysroot`.


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


[clang] [llvm] [SPIR-V] Fixup storage class for global private (PR #116636)

2024-12-02 Thread Nathan Gauër via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

All comments are addressed, please take a second look. 

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


[clang] [llvm] [SelectionDAG][PowerPC] Add an intrinsic for memcmp. (PR #118178)

2024-12-02 Thread Stefan Pintilie via cfe-commits

stefanp-ibm wrote:

> You'll have to create an RFC on discourse if you want to add a new 
> target-independent memory intrinsic.
> 
> Though if changing the name is the extent of the "special handling" you need, 
> we probably shouldn't be adding an intrinsic for that.

We will want to add more handling than that in the future but it is not going 
to be soon. Very likely the additional handling will be for special cases where 
the `size_t num` parameter to `memcmp` is known at compile time. I wanted to 
add the intrinsic so that the backend knows that is isn't just looking at a 
regular function call where the function happened to be called `memcmp` but an 
actual call to THE `memcmp`. 

If this isn't the right way to do this what would you recommend? 


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


[clang] [clang] constexpr built-in elementwise bitreverse function. (PR #118177)

2024-12-02 Thread Simon Pilgrim via cfe-commits


@@ -11322,9 +11323,18 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 
 for (unsigned EltNum = 0; EltNum < SourceLen; ++EltNum) {
   APSInt Elt = Source.getVectorElt(EltNum).getInt();
-  ResultElements.push_back(
-  APValue(APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), 
Elt.popcount()),
- DestEltTy->isUnsignedIntegerOrEnumerationType(;
+  switch (E->getBuiltinCallee()) {
+  case Builtin::BI__builtin_elementwise_popcount:
+ResultElements.push_back(APValue(
+APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), Elt.popcount()),
+   DestEltTy->isUnsignedIntegerOrEnumerationType(;
+break;
+  case Builtin::BI__builtin_elementwise_bitreverse:
+ResultElements.push_back(
+APValue(APSInt(Elt.reverseBits(),
+   DestEltTy->isUnsignedIntegerOrEnumerationType(;
+break;

RKSimon wrote:

clang-format this

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Erich Keane via cfe-commits

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


[clang] [flang] [clang][driver] Special care for -l flags in config files (PR #117573)

2024-12-02 Thread Paul Osmialowski via cfe-commits

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


[clang] [flang] [flang] Treat pre-processed input as fixed (PR #117563)

2024-12-02 Thread David Truby via cfe-commits


@@ -777,6 +777,15 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   addFortranDialectOptions(Args, CmdArgs);
 
+  // 'flang -E' always produces output that is suitable for use as fixed form
+  // Fortran. However it is only valid free form source if the original is also
+  // free form.
+  if (InputType == types::TY_PP_Fortran &&
+  !Args.hasArg(options::OPT_ffixed_form) &&
+  !Args.hasArg(options::OPT_ffree_form)) {

DavidTruby wrote:

I'm not seeing `getLastArg` here on the github review.. Is this github being 
weird?

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Erich Keane via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Erich Keane via cfe-commits


@@ -702,6 +702,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;

erichkeane wrote:

Remove this please

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Think I'm happy here with 1 nit, but please let the others take a look.  

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


[clang] [CIR] Fix warning in CIRGenAction.cpp (PR #118389)

2024-12-02 Thread David Olsen via cfe-commits

https://github.com/dkolsen-pgi created 
https://github.com/llvm/llvm-project/pull/118389

Fix a compiler warning in `CIRGenConsumer::HandleTranslationUnit` in 
`clang/lib/CIR/FrontendAction/CIRGenAction.cpp`.  The warning was about a 
`default:` section in a switch statement that already covered all the values of 
an enum.  Delete the `default:` section.

>From 86ec263fb1d4d50fdf29501dceecedef64656d4a Mon Sep 17 00:00:00 2001
From: David Olsen 
Date: Mon, 2 Dec 2024 11:27:03 -0800
Subject: [PATCH] [CIR] Fix warning in CIRGenAction.cpp

Fix a compiler warning in `CIRGenConsumer::HandleTranslationUnit` in
`clang/lib/CIR/FrontendAction/CIRGenAction.cpp`.  The warning was about a
`default:` section in a switch statement that already covered all the
values of an enum.  Delete the `default:` section.
---
 clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp 
b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
index 5a31e207081936..21b6bc56ed0503 100644
--- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
+++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
@@ -66,9 +66,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
 MlirModule->print(*OutputStream, Flags);
   }
   break;
-default:
-  llvm_unreachable("NYI: CIRGenAction other than EmitCIR");
-  break;
 }
   }
 };

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


[clang] [CIR] Fix warning in CIRGenAction.cpp (PR #118389)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: David Olsen (dkolsen-pgi)


Changes

Fix a compiler warning in `CIRGenConsumer::HandleTranslationUnit` in 
`clang/lib/CIR/FrontendAction/CIRGenAction.cpp`.  The warning was about a 
`default:` section in a switch statement that already covered all the values of 
an enum.  Delete the `default:` section.

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


1 Files Affected:

- (modified) clang/lib/CIR/FrontendAction/CIRGenAction.cpp (-3) 


``diff
diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp 
b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
index 5a31e207081936..21b6bc56ed0503 100644
--- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
+++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
@@ -66,9 +66,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
 MlirModule->print(*OutputStream, Flags);
   }
   break;
-default:
-  llvm_unreachable("NYI: CIRGenAction other than EmitCIR");
-  break;
 }
   }
 };

``




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


[clang] [CIR] Fix warning in CIRGenAction.cpp (PR #118389)

2024-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: David Olsen (dkolsen-pgi)


Changes

Fix a compiler warning in `CIRGenConsumer::HandleTranslationUnit` in 
`clang/lib/CIR/FrontendAction/CIRGenAction.cpp`.  The warning was about a 
`default:` section in a switch statement that already covered all the values of 
an enum.  Delete the `default:` section.

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


1 Files Affected:

- (modified) clang/lib/CIR/FrontendAction/CIRGenAction.cpp (-3) 


``diff
diff --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp 
b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
index 5a31e207081936..21b6bc56ed0503 100644
--- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
+++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
@@ -66,9 +66,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
 MlirModule->print(*OutputStream, Flags);
   }
   break;
-default:
-  llvm_unreachable("NYI: CIRGenAction other than EmitCIR");
-  break;
 }
   }
 };

``




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


[clang] [CIR] Fix warning in CIRGenAction.cpp (PR #118389)

2024-12-02 Thread Erich Keane via cfe-commits

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

LGTM!

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


[clang] [clang] Warn [[clang::lifetimebound]] misusages on types (PR #118281)

2024-12-02 Thread Maksim Ivanov via cfe-commits


@@ -8612,7 +8612,10 @@ static void HandleLifetimeBoundAttr(TypeProcessingState 
&State,
 CurType = State.getAttributedType(
 createSimpleAttr(State.getSema().Context, Attr),
 CurType, CurType);
+return;
   }
+  State.getSema().Diag(Attr.getLoc(), diag::err_attribute_not_type_attr)

emaxx-google wrote:

Done, makes sense!

Probably I should also change the existing diagnostics on the decl-spec code? 
(This is the `int [[clang::lifetimebound]]` test above.) I'll do that in a 
separate PR because this would be a change of the warning that was already 
emitted previously.

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


[clang] [llvm] Revert "[SPIR-V] Fixup storage class for global private (#116636)" (PR #118312)

2024-12-02 Thread Nathan Gauër via cfe-commits

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

From e8c3d6da73e95fd03e5ccdf8e08bdc99ff52e6f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= 
Date: Mon, 2 Dec 2024 16:50:47 +0100
Subject: [PATCH 1/2] Revert "[SPIR-V] Fixup storage class for global private
 (#116636)"

This reverts commit aa7fe1c10e5d6d0d3aacdb345fed995de413e142.
---
 clang/include/clang/Basic/AddressSpaces.h |  1 -
 clang/lib/AST/TypePrinter.cpp |  2 -
 clang/lib/Basic/TargetInfo.cpp|  1 -
 clang/lib/Basic/Targets/AArch64.h |  1 -
 clang/lib/Basic/Targets/AMDGPU.cpp|  2 -
 clang/lib/Basic/Targets/DirectX.h | 19 -
 clang/lib/Basic/Targets/NVPTX.h   |  1 -
 clang/lib/Basic/Targets/SPIR.h| 42 +--
 clang/lib/Basic/Targets/SystemZ.h |  1 -
 clang/lib/Basic/Targets/TCE.h |  1 -
 clang/lib/Basic/Targets/WebAssembly.h | 41 +-
 clang/lib/Basic/Targets/X86.h |  1 -
 .../SemaTemplate/address_space-dependent.cpp  |  4 +-
 .../Target/SPIRV/SPIRVInstructionSelector.cpp | 30 +
 llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp  |  5 +--
 llvm/lib/Target/SPIRV/SPIRVUtils.cpp  |  4 --
 llvm/lib/Target/SPIRV/SPIRVUtils.h|  4 --
 .../SPIRV/pointers/global-addrspacecast.ll| 17 
 .../pointers/variables-storage-class-vk.ll| 15 ---
 .../SPIRV/pointers/variables-storage-class.ll | 23 +++---
 20 files changed, 68 insertions(+), 147 deletions(-)
 delete mode 100644 llvm/test/CodeGen/SPIRV/pointers/global-addrspacecast.ll
 delete mode 100644 
llvm/test/CodeGen/SPIRV/pointers/variables-storage-class-vk.ll

diff --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index 8563d373d87367..7b723d508fff17 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -58,7 +58,6 @@ enum class LangAS : unsigned {
 
   // HLSL specific address spaces.
   hlsl_groupshared,
-  hlsl_private,
 
   // Wasm specific address spaces.
   wasm_funcref,
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 1a273c76f71c41..7caebfb061a50b 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2553,8 +2553,6 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
 return "__funcref";
   case LangAS::hlsl_groupshared:
 return "groupshared";
-  case LangAS::hlsl_private:
-return "hlsl_private";
   default:
 return std::to_string(toTargetAddressSpace(AS));
   }
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 80aa212afc5c91..86befb1cbc74fc 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -47,7 +47,6 @@ static const LangASMap FakeAddrSpaceMap = {
 11, // ptr32_uptr
 12, // ptr64
 13, // hlsl_groupshared
-14, // hlsl_private
 20, // wasm_funcref
 };
 
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 6ef38fac6da280..68a8b1ebad8cde 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -44,7 +44,6 @@ static const unsigned ARM64AddrSpaceMap[] = {
 static_cast(AArch64AddrSpace::ptr32_uptr),
 static_cast(AArch64AddrSpace::ptr64),
 0, // hlsl_groupshared
-0, // hlsl_private
 // Wasm address space values for this target are dummy values,
 // as it is only enabled for Wasm targets.
 20, // wasm_funcref
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 83aac92e2ea3ca..99f8f2944e2796 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -59,7 +59,6 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_uptr
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
 llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
-llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_private
 };
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
@@ -84,7 +83,6 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr32_uptr
 llvm::AMDGPUAS::FLAT_ADDRESS, // ptr64
 llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_groupshared
-llvm::AMDGPUAS::FLAT_ADDRESS, // hlsl_private
 
 };
 } // namespace targets
diff --git a/clang/lib/Basic/Targets/DirectX.h 
b/clang/lib/Basic/Targets/DirectX.h
index 2cbb724386870e..ab22d1281a4df7 100644
--- a/clang/lib/Basic/Targets/DirectX.h
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -33,16 +33,15 @@ static const unsigned DirectXAddrSpaceMap[] = {
 0, // cuda_constant
 0, // cuda_shared
 // SYCL address space values for this map are dummy
-0,  // sycl_global
-0,  // sycl_global_device
-0,  // sycl_global_host
-0,  // sycl_local
-0,  // sycl_private
-   

[clang] [NFC][HLSL] Allow target intrinsic switching to optionally be set. (PR #117648)

2024-12-02 Thread Tex Riddell via cfe-commits

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

LGTM.

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


[clang] [llvm] AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins (PR #118297)

2024-12-02 Thread Matt Arsenault via cfe-commits

arsenm wrote:

### Merge activity

* **Dec 2, 2:39 PM EST**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/118297).


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


[clang] [llvm] AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins (PR #118297)

2024-12-02 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/118297

>From 46aca3bb3fef8903d9388d352be00ddd9aecf68b Mon Sep 17 00:00:00 2001
From: Sirish Pande 
Date: Thu, 18 Jul 2024 14:27:57 -0500
Subject: [PATCH] AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins

Co-authored-by: Sirish Pande 
---
 clang/include/clang/Basic/BuiltinsAMDGPU.def  |  2 +
 clang/lib/CodeGen/CGBuiltin.cpp   |  4 ++
 .../builtins-amdgcn-gfx950-read-tr.cl | 23 
 llvm/lib/Target/AMDGPU/DSInstructions.td  |  2 +
 .../UniformityAnalysis/AMDGPU/intrinsics.ll   | 22 
 .../AMDGPU/llvm.amdgcn.ds.read.tr.gfx950.ll   | 52 +++
 6 files changed, 105 insertions(+)

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 752a751a25a0c7..4758f6053ccb6d 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -467,6 +467,8 @@ TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr4_b64_v2i32, 
"V2iV2i*3", "nc", "gfx950
 TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr6_b96_v3i32, "V3iV3i*3", "nc", 
"gfx950-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr8_b64_v2i32, "V2iV2i*3", "nc", 
"gfx950-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr16_b64_v4i16, "V4sV4s*3", "nc", 
"gfx950-insts")
+TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr16_b64_v4f16, "V4hV4h*3", "nc", 
"gfx950-insts")
+TARGET_BUILTIN(__builtin_amdgcn_ds_read_tr16_b64_v4bf16, "V4yV4y*3", "nc", 
"gfx950-insts")
 
 TARGET_BUILTIN(__builtin_amdgcn_ashr_pk_i8_i32, "UsUiUiUi", "nc", 
"ashr-pk-insts")
 TARGET_BUILTIN(__builtin_amdgcn_ashr_pk_u8_i32, "UsUiUiUi", "nc", 
"ashr-pk-insts")
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index cb9c23b8e0a0d0..8d162d3b8add40 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19726,6 +19726,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr4_b64_v2i32:
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr8_b64_v2i32:
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr6_b96_v3i32:
+  case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4f16:
+  case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4bf16:
   case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4i16: {
 Intrinsic::ID IID;
 switch (BuiltinID) {
@@ -19751,6 +19753,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   IID = Intrinsic::amdgcn_ds_read_tr6_b96;
   break;
 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4i16:
+case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4f16:
+case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4bf16:
   IID = Intrinsic::amdgcn_ds_read_tr16_b64;
   break;
 }
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl
index 39fa46d5845f42..91e04430d4973a 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx950-read-tr.cl
@@ -4,6 +4,8 @@
 typedef intv2i   __attribute__((ext_vector_type(2)));
 typedef intv3i   __attribute__((ext_vector_type(3)));
 typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef __bf16 v4y   __attribute__((ext_vector_type(4)));
 
 // GFX950-LABEL: define dso_local <2 x i32> 
@test_amdgcn_ds_read_b64_tr_b4_v2i32(
 // GFX950-SAME: ptr addrspace(3) nocapture noundef readonly [[INPTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
@@ -48,3 +50,24 @@ v4s test_amdgcn_ds_read_b64_tr_b16_v2i16(local v4s* inptr)
 {
   return __builtin_amdgcn_ds_read_tr16_b64_v4i16(inptr);
 }
+
+// GFX950-LABEL: define dso_local <4 x half> 
@test_amdgcn_ds_read_b64_tr_b16_v2f16(
+// GFX950-SAME: ptr addrspace(3) nocapture noundef readonly [[INPTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// GFX950-NEXT:  entry:
+// GFX950-NEXT:[[TMP0:%.*]] = tail call <4 x half> 
@llvm.amdgcn.ds.read.tr16.b64.v4f16(ptr addrspace(3) [[INPTR]])
+// GFX950-NEXT:ret <4 x half> [[TMP0]]
+//
+v4h test_amdgcn_ds_read_b64_tr_b16_v2f16(local v4h* inptr)
+{
+  return __builtin_amdgcn_ds_read_tr16_b64_v4f16(inptr);
+}
+
+// GFX950-LABEL: define dso_local <4 x bfloat> 
@test_amdgcn_ds_read_b64_tr_b16_v2bf16(
+// GFX950-SAME: ptr addrspace(3) nocapture noundef readonly [[INPTR:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// GFX950-NEXT:  entry:
+// GFX950-NEXT:[[TMP0:%.*]] = tail call <4 x bfloat> 
@llvm.amdgcn.ds.read.tr16.b64.v4bf16(ptr addrspace(3) [[INPTR]])
+// GFX950-NEXT:ret <4 x bfloat> [[TMP0]]
+v4y test_amdgcn_ds_read_b64_tr_b16_v2bf16(local v4y* inptr)
+{
+  return __builtin_amdgcn_ds_read_tr16_b64_v4bf16(inptr);
+}
diff --git a/llvm/lib/Target/AMDGPU/DSInstructions.td 
b/llvm/lib/Target/AMDGPU/DSInstructions.td
index 7cbd6d2dc62097..ef618727258cf2 100644
--- a/llvm/lib/Target/AMDGPU/DSInstr

  1   2   3   4   5   6   >