[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

2024-10-02 Thread Dmitry Sidorov via cfe-commits

MrSidims wrote:

> There's nothing new to do here. This has always existed

@arsenm here is a small experiment, I've compiled the following OpenCL code:
```
struct S {
char i8_3[3];
};

kernel void test(global struct S *p, float3 v)
{
   int3 tmp;
   frexp(v, &tmp);
   tmp += 1;
   p->i8_3[0] = tmp.x;
   p->i8_3[1] = tmp.y;
   p->i8_3[2] = tmp.z;
}
```
with the PR pulled in (on top of LLVM's HEAD aadfba9b2a), the compilation 
command is:
`clang++ -cl-std=CL2.0 -emit-llvm -c -x cl -g0 --target=spir -Xclang 
-finclude-default-header -O2 test.cl`
The output LLVM IR after the optimizations is:
```
; Function Attrs: convergent norecurse nounwind
define dso_local spir_kernel void @test(ptr addrspace(1) nocapture noundef 
writeonly align 1 %p, <3 x float> noundef %v) local_unnamed_addr #0 
!kernel_arg_a>
entry:
  %tmp = alloca <3 x i32>, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %tmp) #3
  %tmp.ascast = addrspacecast ptr %tmp to ptr addrspace(4)
  %call = call spir_func <3 x float> @_Z5frexpDv3_fPU3AS4Dv3_i(<3 x float> 
noundef %v, ptr addrspace(4) noundef %tmp.ascast) #4
  %loadVec42 = load <4 x i32>, ptr %tmp, align 16
  %extractVec4 = add <4 x i32> %loadVec42, 
  %0 = bitcast <4 x i32> %extractVec4 to i128
  %1 = trunc i128 %0 to i96
  %2 = bitcast i96 %1 to <12 x i8>
  %conv = trunc i128 %0 to i8
  store i8 %conv, ptr addrspace(1) %p, align 1, !tbaa !9
  %conv5 = extractelement <12 x i8> %2, i64 4
  %arrayidx7 = getelementptr inbounds i8, ptr addrspace(1) %p, i32 1
  store i8 %conv5, ptr addrspace(1) %arrayidx7, align 1, !tbaa !9
  %conv8 = extractelement <12 x i8> %2, i64 8
  %arrayidx10 = getelementptr inbounds i8, ptr addrspace(1) %p, i32 2
  store i8 %conv8, ptr addrspace(1) %arrayidx10, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %tmp) #3
  ret void
}
```
note bitcast to i128 with the following truncation to i96 - those types aren't 
part of the datalayout, yet some optimization generated them. So something has 
to be done with it and changing the datalayout is not enough.

> This does not mean arbitrary integer bitwidths do not work. The n field is 
> weird, it's more of an optimization hint.

Let me clarify myself, _BitInt(N) will work with the change, I have no doubts. 
But I can imagine a SPIR-V extension to appear that would add support for 4-bit 
integers. And I can imagine that we would want to not only be able to emit 
4-bit integers in the frontend, but also allow optimization passes to emit 
them. For this it would be nice to have a mechanism that would change 
datalayout depending on --spirv-ext (or other option).

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread via cfe-commits

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

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/8] 110558

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

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/8] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/8] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread via cfe-commits

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

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/8] 110558

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

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/8] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/8] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [llvm] [AArch64] Split FeatureAES to FEAT_AES and FEAT_PMULL. (PR #110816)

2024-10-02 Thread Alexandros Lamprineas via cfe-commits


@@ -1117,39 +1117,41 @@ int caller(void) { return 
used_def_without_default_decl() + used_decl_without_de
 // CHECK: attributes #[[ATTR2]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+lse,+neon,+sha2" }
 // CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+ls64,+neon" }
 // CHECK: attributes #[[ATTR4]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fp16fml,+fullfp16,+neon" }
-// CHECK: attributes #[[ATTR5]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon" }
+// CHECK: attributes #[[ATTR5]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+aes,+fp-armv8,+neon" }
 // CHECK: attributes #[[ATTR6]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+crc,+ls64" }
 // CHECK: attributes #[[ATTR7]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bti" }
 // CHECK: attributes #[[ATTR8]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+sme,+sme2" }
 // CHECK: attributes #[[ATTR9]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" }
 // CHECK: attributes #[[ATTR10]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+ls64,+neon" }
 // CHECK: attributes #[[ATTR11]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+ccpp" }
-// CHECK: attributes #[[ATTR12]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+neon" }
-// CHECK: attributes #[[ATTR13:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
-// CHECK: attributes #[[ATTR14]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+mops" }
-// CHECK: attributes #[[ATTR15]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon" }
-// CHECK: attributes #[[ATTR16]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve" }
-// CHECK: attributes #[[ATTR17]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+lse" }
-// CHECK: attributes #[[ATTR18]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon,+rdm" }
-// CHECK: attributes #[[ATTR19:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+jsconv,+neon" }
-// CHECK: attributes #[[ATTR20]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon" }
-// CHECK: attributes #[[ATTR21:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+ls64" }
-// CHECK: attributes #[[ATTR22]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+sb" }
-// CHECK: attributes #[[ATTR23]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+aes,+f64mm,+fp-armv8,+fullfp16,+neon,+sha2,+sve" }
-// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+complxnum,+fp-armv8,+fullfp16,+neon,+rdm,+sme" }
-// CHECK: attributes #[[ATTR25]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+f32mm,+fp-armv8,+fullfp16,+i8mm,+neon,+sha2,+sha3,+sve" }
-// CHECK: attributes #[[ATTR26]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+dit,+fp-armv8,+fullfp16,+neon,+sve" }
-// CHECK: attributes #[[ATTR27]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+ccpp,+rcpc" }
-// CHECK: attributes #[[ATTR28]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+ccdp,+ccpp,+fp-armv8,+jsconv,+neon" }
-// CHECK: attributes #[[ATTR29]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fptoint,+rcpc" }
-// CHECK: attributes #[[ATTR30]] = { noinline nounwind optnone 
"n

[clang] [llvm] [AArch64] Split FeatureAES to FEAT_AES and FEAT_PMULL. (PR #110816)

2024-10-02 Thread Alexandros Lamprineas via cfe-commits

labrinea wrote:

Adding the GCC folks @andrewcarlotti and @Wilco1 for visibility.

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


[clang] [llvm] [AArch64] Split FeatureAES to FEAT_AES and FEAT_PMULL. (PR #110816)

2024-10-02 Thread Alexandros Lamprineas via cfe-commits


@@ -88,9 +88,9 @@ def : FMVExtension<"sve-bf16", "FEAT_SVE_BF16", 
"+sve,+bf16,+fullfp16,+fp-armv8,
 def : FMVExtension<"sve-ebf16", "FEAT_SVE_EBF16", 
"+sve,+bf16,+fullfp16,+fp-armv8,+neon", 330>;
 def : FMVExtension<"sve-i8mm", "FEAT_SVE_I8MM", 
"+sve,+i8mm,+fullfp16,+fp-armv8,+neon", 340>;
 def : FMVExtension<"sve2", "FEAT_SVE2", 
"+sve2,+sve,+fullfp16,+fp-armv8,+neon", 370>;
-def : FMVExtension<"sve2-aes", "FEAT_SVE_AES", 
"+sve2,+sve,+sve2-aes,+fullfp16,+fp-armv8,+neon", 380>;
+def : FMVExtension<"sve2-aes", "FEAT_SVE_AES", 
"+aes,+sve2,+sve,+sve2-aes,+fullfp16,+fp-armv8,+neon", 380>;
 def : FMVExtension<"sve2-bitperm", "FEAT_SVE_BITPERM", 
"+sve2,+sve,+sve2-bitperm,+fullfp16,+fp-armv8,+neon", 400>;
-def : FMVExtension<"sve2-pmull128", "FEAT_SVE_PMULL128", 
"+sve2,+sve,+sve2-aes,+fullfp16,+fp-armv8,+neon", 390>;
+def : FMVExtension<"sve2-pmull128", "FEAT_SVE_PMULL128", 
"+pmull,+aes,+sve2,+sve,+sve2-pmull128,+sve2-aes,+fullfp16,+fp-armv8,+neon", 
390>;

labrinea wrote:

Hand writing these dependencies is so error prone. Once we review the remaining 
FMV features I am planning to autogenerate those from tablegen. For example the 
two lines below are already wrong. `sve2-sha3` should enable +sha3 and 
`sve2-sm4` should enable +sm4.

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


[clang] [clang][RISC-V] fixed fp calling convention for fpcc eligible structs for risc-v (PR #110690)

2024-10-02 Thread Kamran Yousafzai via cfe-commits


@@ -251,6 +253,15 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType 
Ty, CharUnits CurOff,
 // bitwidth is XLen or less.
 if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
   QTy = getContext().getIntTypeForBitwidth(XLen, false);
+// Trim type to alignment/bitwidth if that is possible
+else if (getContext().getTypeSize(QTy) > Alignment &&
+ getContext().getTypeSize(QTy) > BitWidth) {
+  bool isSigned =
+  FD->getType().getTypePtr()->hasSignedIntegerRepresentation();
+  unsigned bits =

KamranYousafzai wrote:

Capitalized in the latest push.

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


[clang] [clang][RISC-V] fixed fp calling convention for fpcc eligible structs for risc-v (PR #110690)

2024-10-02 Thread Kamran Yousafzai via cfe-commits


@@ -251,6 +253,15 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType 
Ty, CharUnits CurOff,
 // bitwidth is XLen or less.
 if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
   QTy = getContext().getIntTypeForBitwidth(XLen, false);
+// Trim type to alignment/bitwidth if that is possible
+else if (getContext().getTypeSize(QTy) > Alignment &&
+ getContext().getTypeSize(QTy) > BitWidth) {
+  bool isSigned =

KamranYousafzai wrote:

Capitalized in the latest push

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


[clang] [llvm] Introduce the Armv9.6-A architecture version (PR #110825)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-arm

Author: Jonathan Thackray (jthackray)


Changes

This introduces the Armv9.6-A architecture version, including the relevant 
command-line option for -march.

More details about the Armv9.6-A architecture version can be found at:
  * 
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2024
  * https://developer.arm.com/documentation/ddi0602/2024-09/


---

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


20 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+11) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+2) 
- (modified) clang/lib/Basic/Targets/ARM.cpp (+4) 
- (modified) clang/test/CodeGen/arm-acle-coproc.c (+2) 
- (added) clang/test/Driver/aarch64-v96a.c (+19) 
- (modified) clang/test/Driver/arm-cortex-cpus-1.c (+17) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+2) 
- (modified) clang/test/Preprocessor/arm-target-features.c (+5) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+3-3) 
- (modified) llvm/include/llvm/TargetParser/ARMTargetParser.def (+5) 
- (modified) llvm/include/llvm/TargetParser/Triple.h (+1) 
- (modified) llvm/lib/Target/AArch64/AArch64Features.td (+8) 
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+2) 
- (modified) llvm/lib/Target/ARM/ARMArchitectures.td (+12-1) 
- (modified) llvm/lib/Target/ARM/ARMFeatures.td (+5) 
- (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (+1) 
- (modified) llvm/lib/TargetParser/ARMTargetParser.cpp (+2) 
- (modified) llvm/lib/TargetParser/ARMTargetParserCommon.cpp (+1) 
- (modified) llvm/lib/TargetParser/Triple.cpp (+2) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+8-2) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5f5dfcb722f9d4..61889861c9c803 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -373,6 +373,12 @@ void AArch64TargetInfo::getTargetDefinesARMV95A(const 
LangOptions &Opts,
   getTargetDefinesARMV94A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV96A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Armv9.6-A does not have a v8.* equivalent, but is a superset of v9.5-A.
+  getTargetDefinesARMV95A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   // Target identification.
@@ -657,6 +663,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 getTargetDefinesARMV94A(Opts, Builder);
   else if (*ArchInfo == llvm::AArch64::ARMV9_5A)
 getTargetDefinesARMV95A(Opts, Builder);
+  else if (*ArchInfo == llvm::AArch64::ARMV9_6A)
+getTargetDefinesARMV96A(Opts, Builder);
 
   // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8|16) builtins work.
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
@@ -1044,6 +1052,9 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
 if (Feature == "+v9.5a" &&
 ArchInfo->Version < llvm::AArch64::ARMV9_5A.Version)
   ArchInfo = &llvm::AArch64::ARMV9_5A;
+if (Feature == "+v9.6a" &&
+ArchInfo->Version < llvm::AArch64::ARMV9_6A.Version)
+  ArchInfo = &llvm::AArch64::ARMV9_6A;
 if (Feature == "+v8r")
   ArchInfo = &llvm::AArch64::ARMV8R;
 if (Feature == "+fullfp16") {
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 526f7f30a38618..1226ce4d4355c2 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -148,6 +148,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder &Builder) const;
   void getTargetDefinesARMV95A(const LangOptions &Opts,
MacroBuilder &Builder) const;
+  void getTargetDefinesARMV96A(const LangOptions &Opts,
+   MacroBuilder &Builder) const;
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 7423626d7c3cbf..c56b8d9a448508 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -228,6 +228,8 @@ StringRef ARMTargetInfo::getCPUAttr() const {
 return "9_4A";
   case llvm::ARM::ArchKind::ARMV9_5A:
 return "9_5A";
+  case llvm::ARM::ArchKind::ARMV9_6A:
+return "9_6A";
   case llvm::ARM::ArchKind::ARMV8MBaseline:
 return "8M_BASE";
   case llvm::ARM::ArchKind::ARMV8MMainline:
@@ -891,6 +893,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::ARM::ArchKind::ARMV9_3A:
   case llvm::ARM::

[clang] [llvm] Introduce the Armv9.6-A architecture version (PR #110825)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Jonathan Thackray (jthackray)


Changes

This introduces the Armv9.6-A architecture version, including the relevant 
command-line option for -march.

More details about the Armv9.6-A architecture version can be found at:
  * 
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2024
  * https://developer.arm.com/documentation/ddi0602/2024-09/


---

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


20 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+11) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+2) 
- (modified) clang/lib/Basic/Targets/ARM.cpp (+4) 
- (modified) clang/test/CodeGen/arm-acle-coproc.c (+2) 
- (added) clang/test/Driver/aarch64-v96a.c (+19) 
- (modified) clang/test/Driver/arm-cortex-cpus-1.c (+17) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+2) 
- (modified) clang/test/Preprocessor/arm-target-features.c (+5) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+3-3) 
- (modified) llvm/include/llvm/TargetParser/ARMTargetParser.def (+5) 
- (modified) llvm/include/llvm/TargetParser/Triple.h (+1) 
- (modified) llvm/lib/Target/AArch64/AArch64Features.td (+8) 
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+2) 
- (modified) llvm/lib/Target/ARM/ARMArchitectures.td (+12-1) 
- (modified) llvm/lib/Target/ARM/ARMFeatures.td (+5) 
- (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (+1) 
- (modified) llvm/lib/TargetParser/ARMTargetParser.cpp (+2) 
- (modified) llvm/lib/TargetParser/ARMTargetParserCommon.cpp (+1) 
- (modified) llvm/lib/TargetParser/Triple.cpp (+2) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+8-2) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5f5dfcb722f9d4..61889861c9c803 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -373,6 +373,12 @@ void AArch64TargetInfo::getTargetDefinesARMV95A(const 
LangOptions &Opts,
   getTargetDefinesARMV94A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV96A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Armv9.6-A does not have a v8.* equivalent, but is a superset of v9.5-A.
+  getTargetDefinesARMV95A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   // Target identification.
@@ -657,6 +663,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 getTargetDefinesARMV94A(Opts, Builder);
   else if (*ArchInfo == llvm::AArch64::ARMV9_5A)
 getTargetDefinesARMV95A(Opts, Builder);
+  else if (*ArchInfo == llvm::AArch64::ARMV9_6A)
+getTargetDefinesARMV96A(Opts, Builder);
 
   // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8|16) builtins work.
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
@@ -1044,6 +1052,9 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
 if (Feature == "+v9.5a" &&
 ArchInfo->Version < llvm::AArch64::ARMV9_5A.Version)
   ArchInfo = &llvm::AArch64::ARMV9_5A;
+if (Feature == "+v9.6a" &&
+ArchInfo->Version < llvm::AArch64::ARMV9_6A.Version)
+  ArchInfo = &llvm::AArch64::ARMV9_6A;
 if (Feature == "+v8r")
   ArchInfo = &llvm::AArch64::ARMV8R;
 if (Feature == "+fullfp16") {
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 526f7f30a38618..1226ce4d4355c2 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -148,6 +148,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder &Builder) const;
   void getTargetDefinesARMV95A(const LangOptions &Opts,
MacroBuilder &Builder) const;
+  void getTargetDefinesARMV96A(const LangOptions &Opts,
+   MacroBuilder &Builder) const;
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 7423626d7c3cbf..c56b8d9a448508 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -228,6 +228,8 @@ StringRef ARMTargetInfo::getCPUAttr() const {
 return "9_4A";
   case llvm::ARM::ArchKind::ARMV9_5A:
 return "9_5A";
+  case llvm::ARM::ArchKind::ARMV9_6A:
+return "9_6A";
   case llvm::ARM::ArchKind::ARMV8MBaseline:
 return "8M_BASE";
   case llvm::ARM::ArchKind::ARMV8MMainline:
@@ -891,6 +893,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::ARM::ArchKind::ARMV9_3A:
   case llvm::A

[clang] [llvm] Introduce the Armv9.6-A architecture version (PR #110825)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Jonathan Thackray (jthackray)


Changes

This introduces the Armv9.6-A architecture version, including the relevant 
command-line option for -march.

More details about the Armv9.6-A architecture version can be found at:
  * 
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2024
  * https://developer.arm.com/documentation/ddi0602/2024-09/


---

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


20 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+11) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+2) 
- (modified) clang/lib/Basic/Targets/ARM.cpp (+4) 
- (modified) clang/test/CodeGen/arm-acle-coproc.c (+2) 
- (added) clang/test/Driver/aarch64-v96a.c (+19) 
- (modified) clang/test/Driver/arm-cortex-cpus-1.c (+17) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+2) 
- (modified) clang/test/Preprocessor/arm-target-features.c (+5) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+3-3) 
- (modified) llvm/include/llvm/TargetParser/ARMTargetParser.def (+5) 
- (modified) llvm/include/llvm/TargetParser/Triple.h (+1) 
- (modified) llvm/lib/Target/AArch64/AArch64Features.td (+8) 
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+2) 
- (modified) llvm/lib/Target/ARM/ARMArchitectures.td (+12-1) 
- (modified) llvm/lib/Target/ARM/ARMFeatures.td (+5) 
- (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (+1) 
- (modified) llvm/lib/TargetParser/ARMTargetParser.cpp (+2) 
- (modified) llvm/lib/TargetParser/ARMTargetParserCommon.cpp (+1) 
- (modified) llvm/lib/TargetParser/Triple.cpp (+2) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+8-2) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5f5dfcb722f9d4..61889861c9c803 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -373,6 +373,12 @@ void AArch64TargetInfo::getTargetDefinesARMV95A(const 
LangOptions &Opts,
   getTargetDefinesARMV94A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV96A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Armv9.6-A does not have a v8.* equivalent, but is a superset of v9.5-A.
+  getTargetDefinesARMV95A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   // Target identification.
@@ -657,6 +663,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 getTargetDefinesARMV94A(Opts, Builder);
   else if (*ArchInfo == llvm::AArch64::ARMV9_5A)
 getTargetDefinesARMV95A(Opts, Builder);
+  else if (*ArchInfo == llvm::AArch64::ARMV9_6A)
+getTargetDefinesARMV96A(Opts, Builder);
 
   // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8|16) builtins work.
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
@@ -1044,6 +1052,9 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
 if (Feature == "+v9.5a" &&
 ArchInfo->Version < llvm::AArch64::ARMV9_5A.Version)
   ArchInfo = &llvm::AArch64::ARMV9_5A;
+if (Feature == "+v9.6a" &&
+ArchInfo->Version < llvm::AArch64::ARMV9_6A.Version)
+  ArchInfo = &llvm::AArch64::ARMV9_6A;
 if (Feature == "+v8r")
   ArchInfo = &llvm::AArch64::ARMV8R;
 if (Feature == "+fullfp16") {
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 526f7f30a38618..1226ce4d4355c2 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -148,6 +148,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder &Builder) const;
   void getTargetDefinesARMV95A(const LangOptions &Opts,
MacroBuilder &Builder) const;
+  void getTargetDefinesARMV96A(const LangOptions &Opts,
+   MacroBuilder &Builder) const;
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 7423626d7c3cbf..c56b8d9a448508 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -228,6 +228,8 @@ StringRef ARMTargetInfo::getCPUAttr() const {
 return "9_4A";
   case llvm::ARM::ArchKind::ARMV9_5A:
 return "9_5A";
+  case llvm::ARM::ArchKind::ARMV9_6A:
+return "9_6A";
   case llvm::ARM::ArchKind::ARMV8MBaseline:
 return "8M_BASE";
   case llvm::ARM::ArchKind::ARMV8MMainline:
@@ -891,6 +893,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::ARM::ArchKind::ARMV9_3A:
   case llvm::ARM:

[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-02 Thread Paul Walker via cfe-commits


@@ -4072,6 +4078,30 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, 
CallBase *CI, Function *F,
   return Rep;
 }
 
+static Value *upgradeAArch64IntrinsicCall(StringRef Name, CallBase *CI,
+  Function *F, IRBuilder<> &Builder) {
+  Intrinsic::ID NewID =
+  StringSwitch(Name)
+  .Case("sve.fcvt.bf16f32", Intrinsic::aarch64_sve_fcvt_bf16f32_v2)
+  .Case("sve.fcvtnt.bf16f32", Intrinsic::aarch64_sve_fcvtnt_bf16f32_v2)
+  .Default(Intrinsic::not_intrinsic);
+  if (NewID == Intrinsic::not_intrinsic)
+llvm_unreachable("Unhandled Intrinsic!");
+
+  SmallVector Args(CI->args());
+
+  // The original intrinsics incorrectly used a predicate based on the smallest
+  // element type rather than the largest.
+  Type *PredTy = ScalableVectorType::get(Builder.getInt1Ty(), 4);
+  Args[1] = Builder.CreateIntrinsic(Intrinsic::aarch64_sve_convert_to_svbool,

paulwalker-arm wrote:

Done.

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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-02 Thread Paul Walker via cfe-commits


@@ -5553,6 +5553,14 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue 
Op, SelectionDAG &DAG) {
   if (InVT == VT)
 return Op;
 
+  // Look through casts to  when their input has more lanes than

paulwalker-arm wrote:

Done, plus removed another redundant reference to ``.

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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-02 Thread Paul Walker via cfe-commits


@@ -1003,6 +998,13 @@ defm SVFCVT_F32_F64   : SInstCvtMXZ<"svcvt_f32[_f64]", 
"MMPd", "MPd", "d", "aarc
 defm SVFCVT_F64_F16   : SInstCvtMXZ<"svcvt_f64[_f16]", "ddPO", "dPO", "d", 
"aarch64_sve_fcvt_f64f16">;
 defm SVFCVT_F64_F32   : SInstCvtMXZ<"svcvt_f64[_f32]", "ddPM", "dPM", "d", 
"aarch64_sve_fcvt_f64f32">;
 
+let SVETargetGuard = "sve,bf16", SMETargetGuard = "sme,bf16" in {
+defm SVCVT_BF16_F32 : SInstCvtMXZ<"svcvt_bf16[_f32]", "$$Pd", "$Pd", "f", 
"aarch64_sve_fcvt_bf16f32_v2">;
+
+def SVCVTNT_BF16: SInst<"svcvtnt_bf16[_f32]", "$$Pd", "f", MergeOp1, 
"aarch64_sve_fcvtnt_bf16f32_v2", [IsOverloadNone, VerifyRuntimeMode]>;

paulwalker-arm wrote:

Done. I've also renamed the next block of SVCVT definitions to make them 
consistent.

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


[clang] [clang][RISC-V] fixed fp calling convention for fpcc eligible structs for risc-v (PR #110690)

2024-10-02 Thread Kamran Yousafzai via cfe-commits


@@ -251,6 +253,15 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType 
Ty, CharUnits CurOff,
 // bitwidth is XLen or less.
 if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
   QTy = getContext().getIntTypeForBitwidth(XLen, false);
+// Trim type to alignment/bitwidth if that is possible
+else if (getContext().getTypeSize(QTy) > Alignment &&

KamranYousafzai wrote:

You are right, the latest push reflects the change suggested. It now just 
checks against size of a byte to ensure the size at the very minimum is 8 bits.

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


[clang] [clang][RISC-V] fixed fp calling convention for fpcc eligible structs for risc-v (PR #110690)

2024-10-02 Thread Kamran Yousafzai via cfe-commits

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


[clang] [llvm] Introduce the Armv9.6-A architecture version (PR #110825)

2024-10-02 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray created 
https://github.com/llvm/llvm-project/pull/110825

This introduces the Armv9.6-A architecture version, including the relevant 
command-line option for -march.

More details about the Armv9.6-A architecture version can be found at:
  * 
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2024
  * https://developer.arm.com/documentation/ddi0602/2024-09/


>From 38c442a261eb5aa39f14d919581a1f08b64d3652 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Fri, 27 Sep 2024 23:37:44 +0100
Subject: [PATCH] Introduce the Armv9.6-A architecture version

This introduces the Armv9.6-A architecture version, including the
relevant command-line option for -march.

Mode details about the Armv9.6-A architecture version can be found at:
* 
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2024
* https://developer.arm.com/documentation/ddi0602/2024-09/
---
 clang/lib/Basic/Targets/AArch64.cpp   | 11 +++
 clang/lib/Basic/Targets/AArch64.h |  2 ++
 clang/lib/Basic/Targets/ARM.cpp   |  4 
 clang/test/CodeGen/arm-acle-coproc.c  |  2 ++
 clang/test/Driver/aarch64-v96a.c  | 19 +++
 clang/test/Driver/arm-cortex-cpus-1.c | 17 +
 .../Preprocessor/aarch64-target-features.c|  2 ++
 clang/test/Preprocessor/arm-target-features.c |  5 +
 .../llvm/TargetParser/AArch64TargetParser.h   |  6 +++---
 .../llvm/TargetParser/ARMTargetParser.def |  5 +
 llvm/include/llvm/TargetParser/Triple.h   |  1 +
 llvm/lib/Target/AArch64/AArch64Features.td|  8 
 .../AArch64/AsmParser/AArch64AsmParser.cpp|  2 ++
 llvm/lib/Target/ARM/ARMArchitectures.td   | 13 -
 llvm/lib/Target/ARM/ARMFeatures.td|  5 +
 .../ARM/MCTargetDesc/ARMELFStreamer.cpp   |  1 +
 llvm/lib/TargetParser/ARMTargetParser.cpp |  2 ++
 .../TargetParser/ARMTargetParserCommon.cpp|  1 +
 llvm/lib/TargetParser/Triple.cpp  |  2 ++
 .../TargetParser/TargetParserTest.cpp | 10 --
 20 files changed, 112 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/Driver/aarch64-v96a.c

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5f5dfcb722f9d4..61889861c9c803 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -373,6 +373,12 @@ void AArch64TargetInfo::getTargetDefinesARMV95A(const 
LangOptions &Opts,
   getTargetDefinesARMV94A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV96A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Armv9.6-A does not have a v8.* equivalent, but is a superset of v9.5-A.
+  getTargetDefinesARMV95A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   // Target identification.
@@ -657,6 +663,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 getTargetDefinesARMV94A(Opts, Builder);
   else if (*ArchInfo == llvm::AArch64::ARMV9_5A)
 getTargetDefinesARMV95A(Opts, Builder);
+  else if (*ArchInfo == llvm::AArch64::ARMV9_6A)
+getTargetDefinesARMV96A(Opts, Builder);
 
   // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8|16) builtins work.
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
@@ -1044,6 +1052,9 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
 if (Feature == "+v9.5a" &&
 ArchInfo->Version < llvm::AArch64::ARMV9_5A.Version)
   ArchInfo = &llvm::AArch64::ARMV9_5A;
+if (Feature == "+v9.6a" &&
+ArchInfo->Version < llvm::AArch64::ARMV9_6A.Version)
+  ArchInfo = &llvm::AArch64::ARMV9_6A;
 if (Feature == "+v8r")
   ArchInfo = &llvm::AArch64::ARMV8R;
 if (Feature == "+fullfp16") {
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 526f7f30a38618..1226ce4d4355c2 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -148,6 +148,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder &Builder) const;
   void getTargetDefinesARMV95A(const LangOptions &Opts,
MacroBuilder &Builder) const;
+  void getTargetDefinesARMV96A(const LangOptions &Opts,
+   MacroBuilder &Builder) const;
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 7423626d7c3cbf..c56b8d9a448508 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -228,

[clang] [llvm] [CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined functions (PR #75385)

2024-10-02 Thread Jeremy Morse via cfe-commits

jmorse wrote:

Hadn't realised lambda types will pop up everywhere, the cost might be too 
high. I'll test with building clang and our internal codebases to see if the 
fix works and what the cost is.

> Surely if we can compute a unique mangled name for this local class, we 
> should use it as the identifier and merge it.

Indeed, it's not the ODR-uniquing per-se that's causing the trouble here, it's 
the fact that we do not merge together the DISubprograms that are the 
containing scope for that type upon module linking. I'm not familiar with the 
design decisions behind that, but a courtesy glance suggests it's important to 
identify the compilation unit that a DISubprogram instance came from. We're 
then stuck with multiple DISubprograms and a single DIComposite type referring 
to one of them as being its scope, which presumably breaks a lot of assumptions.

Perhaps a worthwhile direction is separating DISubprograms into abstract and 
definition portions, much like DWARF does, which would allow us to put these 
types into the declaration and have a well defined scope hierarchy: types that 
get uniqued refer to the abstract-DISubprogram for their lexical scope. Perhaps 
that's can be achieved with the existing distinction between definition 
DISubprograms and "declaration" DISubprograms? A quick survey of callers to 
`DISubprogram::getDefinition` and `isDefinition` indicates there aren't many 
decisions made throughout LLVM based on the definition/declaration split, and 
there are comments in LLVMContextImpl.h suggesting declaration-DISubprograms 
are used in ODR'd types too.

If we took that route, the scope-chain would still become a tree of scopes 
instead of distinct chains, and we would still need to fix the problem of 
CodeGen LexicalScopes encountering the abstract/declaration DISubprogram. 
However, I think we'd have the reasonable solution of mapping 
declaration-DISubprograms in a function to their definition-DISubprogram 
(assuming the definition had been found already), which is much more reliable 
than seeking a DISubprogram by name or something.

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


[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

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

https://github.com/AlexVlx updated 
https://github.com/llvm/llvm-project/pull/110695

>From 758fb6e28844d89031b5497d651cb2a9b71b6a0e Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Tue, 1 Oct 2024 17:10:50 +0100
Subject: [PATCH 1/2] Explicitly encode native integer widths for SPIR-V.

---
 clang/lib/Basic/Targets/SPIR.h| 16 +++---
 clang/test/CodeGen/target-data.c  |  2 +-
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl   |  2 +-
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp  | 12 ++--
 .../SPIRV/optimizations/add-check-overflow.ll | 56 ---
 5 files changed, 16 insertions(+), 72 deletions(-)
 delete mode 100644 llvm/test/CodeGen/SPIRV/optimizations/add-check-overflow.ll

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index cc79562de2871e..09d4ad3c0ac620 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -314,8 +314,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public 
BaseSPIRVTargetInfo {
 
 // SPIR-V IDs are represented with a single 32-bit word.
 SizeType = TargetInfo::UnsignedInt;
-resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
+resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -338,8 +338,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public 
BaseSPIRVTargetInfo {
 // SPIR-V has core support for atomic ops, and Int32 is always available;
 // we take the maximum because it's possible the Host supports wider types.
 MaxAtomicInlineWidth = std::max(MaxAtomicInlineWidth, 32);
-resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
+resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-"
+"v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -362,8 +362,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public 
BaseSPIRVTargetInfo {
 // SPIR-V has core support for atomic ops, and Int64 is always available;
 // we take the maximum because it's possible the Host supports wider types.
 MaxAtomicInlineWidth = std::max(MaxAtomicInlineWidth, 64);
-resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
+resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -388,8 +388,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 AddrSpaceMap = &SPIRDefIsGenMap;
 
-resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1-P4-A0");
+resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0");
 
 BFloat16Width = BFloat16Align = 16;
 BFloat16Format = &llvm::APFloat::BFloat();
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 8548aa00cfe877..fa875fe68b0c5b 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -271,4 +271,4 @@
 
 // RUN: %clang_cc1 -triple spirv64-amd-amdhsa -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=AMDGPUSPIRV64
-// AMDGPUSPIRV64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1-P4-A0"
+// AMDGPUSPIRV64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0"
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index bf5f2971cf118c..9132cc8a717e0f 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -638,7 +638,7 @@ void test_get_workgroup_size(int d, global int *out)
 
 // CHECK-LABEL: @test_get_grid_size(
 // CHECK: {{.*}}call align 4 dereferenceable(64){{.*}} ptr addrspace(4) 
@llvm.amdgcn.dispatch.ptr()
-// CHECK: getelementptr inbounds i8, ptr addrspace(4) %{{.*}}, i64 %.sink
+// CHECK: getelementptr inbounds i8, ptr addrspace(4) %{{.*}}, i64 %{{.+}}
 // CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !invariant.load
 void test_get_grid_size(int d, global int *out)
 {
diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 
b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index e5384b2eb2c2c1..50c881a19cf58b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -54,14 +54,14 @@ sta

[clang] [clang][RISC-V] fixed fp calling convention for fpcc eligible structs for risc-v (PR #110690)

2024-10-02 Thread Kamran Yousafzai via cfe-commits

https://github.com/KamranYousafzai updated 
https://github.com/llvm/llvm-project/pull/110690

>From f1da56e337a4a2f0414fd600897addb0fa61b843 Mon Sep 17 00:00:00 2001
From: "muhammad.kamran4" 
Date: Tue, 1 Oct 2024 17:21:21 +0200
Subject: [PATCH] fixed fp calling convention for fpcc eligible structs for
 risc-v

---
 clang/lib/CodeGen/Targets/RISCV.cpp  |  7 +
 clang/test/CodeGen/RISCV/riscv-fpcc-struct.c | 28 
 clang/test/CodeGen/RISCV/riscv64-abi.c   |  4 +--
 3 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/RISCV/riscv-fpcc-struct.c

diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp 
b/clang/lib/CodeGen/Targets/RISCV.cpp
index fd72fe673b9b14..ba512f51e52b81 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -251,6 +251,13 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType 
Ty, CharUnits CurOff,
 // bitwidth is XLen or less.
 if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
   QTy = getContext().getIntTypeForBitwidth(XLen, false);
+// Trim type to alignment/bitwidth if that is possible
+else if (getContext().getTypeSize(QTy) > BitWidth) {
+  bool IsSigned =
+  FD->getType().getTypePtr()->hasSignedIntegerRepresentation();
+  unsigned Bits = std::max(8U, (unsigned)llvm::PowerOf2Ceil(BitWidth));
+  QTy = getContext().getIntTypeForBitwidth(Bits, IsSigned);
+}
 if (BitWidth == 0) {
   ZeroWidthBitFieldCount++;
   continue;
diff --git a/clang/test/CodeGen/RISCV/riscv-fpcc-struct.c 
b/clang/test/CodeGen/RISCV/riscv-fpcc-struct.c
new file mode 100644
index 00..a315b409da613a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/riscv-fpcc-struct.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -emit-llvm %s -o - \
+// RUN:   | FileCheck %s
+
+
+struct __attribute__((packed, aligned(1))) S {
+   const float  f0;
+   unsigned f1 : 1;
+};
+
+// CHECK-LABEL: define dso_local signext i32 @func(
+// CHECK-SAME: float [[TMP0:%.*]], i8 [[TMP1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[ARG:%.*]] = alloca [[STRUCT_S:%.*]], align 1
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds nuw { float, i8 }, ptr 
[[ARG]], i32 0, i32 0
+// CHECK-NEXT:store float [[TMP0]], ptr [[TMP2]], align 1
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds nuw { float, i8 }, ptr 
[[ARG]], i32 0, i32 1
+// CHECK-NEXT:store i8 [[TMP1]], ptr [[TMP3]], align 1
+// CHECK-NEXT:[[F1:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr 
[[ARG]], i32 0, i32 1
+// CHECK-NEXT:[[BF_LOAD:%.*]] = load i8, ptr [[F1]], align 1
+// CHECK-NEXT:[[BF_CLEAR:%.*]] = and i8 [[BF_LOAD]], 1
+// CHECK-NEXT:[[BF_CAST:%.*]] = zext i8 [[BF_CLEAR]] to i32
+// CHECK-NEXT:ret i32 [[BF_CAST]]
+//
+unsigned  func(struct S  arg)
+{
+return arg.f1;
+}
diff --git a/clang/test/CodeGen/RISCV/riscv64-abi.c 
b/clang/test/CodeGen/RISCV/riscv64-abi.c
index 021565238904e4..64c831361cb8e0 100644
--- a/clang/test/CodeGen/RISCV/riscv64-abi.c
+++ b/clang/test/CodeGen/RISCV/riscv64-abi.c
@@ -1710,7 +1710,7 @@ struct float16_int64_s f_ret_float16_int64_s(void) {
 // LP64:  entry:
 //
 // LP64F-LP64D-LABEL: define dso_local void @f_float16_int64bf_s_arg
-// LP64F-LP64D-SAME: (half [[TMP0:%.*]], i64 [[TMP1:%.*]]) #[[ATTR0]] {
+// LP64F-LP64D-SAME: (half [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR0]] {
 // LP64F-LP64D:  entry:
 //
 void f_float16_int64bf_s_arg(struct float16_int64bf_s a) {}
@@ -1719,7 +1719,7 @@ void f_float16_int64bf_s_arg(struct float16_int64bf_s a) 
{}
 // LP64-SAME: () #[[ATTR0]] {
 // LP64:  entry:
 //
-// LP64F-LP64D-LABEL: define dso_local <{ half, i64 }> @f_ret_float16_int64bf_s
+// LP64F-LP64D-LABEL: define dso_local <{ half, i32 }> @f_ret_float16_int64bf_s
 // LP64F-LP64D-SAME: () #[[ATTR0]] {
 // LP64F-LP64D:  entry:
 //

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


[clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-02 Thread Michael Buch via cfe-commits

Michael137 wrote:

> > Skipping empty fields does seem like a better heuristic here
> 
> FWIW, I (independently) came to the same conclusion when investigating the 
> fallout of #76756, though it's not fully clear to me whether the PR has been 
> updated to do that.

Not yet, but will have a look at this today

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


[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-10-02 Thread Viktoriia Bakalova via cfe-commits

https://github.com/VitaNuo updated 
https://github.com/llvm/llvm-project/pull/110503

>From 27c2b3d4d2d9b54ed635a6b00dbb545241b498e8 Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Mon, 30 Sep 2024 12:50:09 +
Subject: [PATCH] [clang][Itanium Mangle] Enable mangling of enclosing class
 for member-like friend function templates only if ` -fclang-abi-compat>=19`.

---
 clang/docs/ReleaseNotes.rst  |  2 +-
 clang/include/clang/Basic/LangOptions.h  |  4 +++-
 clang/lib/AST/ItaniumMangle.cpp  | 11 +--
 clang/test/CodeGenCXX/mangle-concept.cpp |  4 
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 35c31452cef411..2d457fba0686b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,6 +104,7 @@ ABI Changes in This Version
 
 - Fixed Microsoft name mangling of placeholder, auto and decltype(auto), 
return types for MSVC 1920+. This change resolves incompatibilities with code 
compiled by MSVC 1920+ but will introduce incompatibilities with code compiled 
by earlier versions of Clang unless such code is built with the compiler option 
-fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior.
 - Fixed the Itanium mangling of the construction vtable name. This change will 
introduce incompatibilities with code compiled by Clang 19 and earlier 
versions, unless the -fclang-abi-compat=19 option is used. (#GH108015)
+- Mangle member-like friend function templates as members of the enclosing 
class. (#GH110247, #GH110503)
 
 AST Dumping Potentially Breaking Changes
 
@@ -447,7 +448,6 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
-- Mangle friend function templates with a constraint that depends on a 
template parameter from an enclosing template as members of the enclosing 
class. (#GH110247)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 8c605f6852016e..e2d4206c72cc96 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -241,8 +241,10 @@ class LangOptionsBase {
 
 /// Attempt to be ABI-compatible with code generated by Clang 19.0.x.
 /// This causes clang to:
-///   - Incorrectly mangles the 'base type' substitutions of the CXX
+///   - Incorrectly mangle the 'base type' substitutions of the CXX
 ///   construction vtable because it hasn't added 'type' as a substitution.
+///   - Skip mangling enclosing class templates of member-like friend
+///   function templates.
 Ver19,
 
 /// Conform to the underlying platform's C and C++ ABIs as closely
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 117255178eebb4..8a4709a100739a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -693,14 +693,13 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const 
Decl *D) {
 if (VD->isExternC())
   return getASTContext().getTranslationUnitDecl();
 
-  if (const auto *FD = D->getAsFunction()) {
-if (FD->isExternC())
-  return getASTContext().getTranslationUnitDecl();
+  if (const auto *FD = getASTContext().getLangOpts().getClangABICompat() >
+   LangOptions::ClangABI::Ver19
+   ? D->getAsFunction()
+   : dyn_cast(D)) {
 // Member-like constrained friends are mangled as if they were members of
 // the enclosing class.
-if (FD->isMemberLikeConstrainedFriend() &&
-getASTContext().getLangOpts().getClangABICompat() >
-LangOptions::ClangABI::Ver17)
+if (FD->isMemberLikeConstrainedFriend())
   return D->getLexicalDeclContext()->getRedeclContext();
   }
 
diff --git a/clang/test/CodeGenCXX/mangle-concept.cpp 
b/clang/test/CodeGenCXX/mangle-concept.cpp
index 6053511c00a7b5..aa0940c35b237a 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -std=c++20 -emit-llvm -triple %itanium_abi_triple 
-o - %s -fclang-abi-compat=latest | FileCheck %s
+// RUN: %clang_cc1 -verify -std=c++20 -emit-llvm -triple %itanium_abi_triple 
-o - %s -fclang-abi-compat=19 | FileCheck %s --check-prefix=CLANG19
 // RUN: %clang_cc1 -verify -std=c++20 -emit-llvm -triple %itanium_abi_triple 
-o - %s -fclang-abi-compat=17 | FileCheck %s --check-prefix=CLANG17
 // expected-no-diagnostics
 
@@ -59,18 +60,21 @@ namespace test2 {
 // CLANG17: call {{.*}}@_ZN5test21fEz(
 f(ai);
 // CHECK: call {{.*}}

[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-10-02 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
735a5f67e351fc072a9f7c18b030036681f7935a...fb2d704c3dfe8d30c72eba4e848d0404d7349ec9
 clang/tools/scan-build-py/tests/unit/test_report.py 
libcxx/test/libcxx/clang_modules_include.gen.py 
libcxx/utils/libcxx/test/features.py mlir/python/mlir/dialects/tensor.py 
mlir/test/python/dialects/sparse_tensor/dialect.py
``





View the diff from darker here.


``diff
--- libcxx/test/libcxx/clang_modules_include.gen.py 2024-10-02 
09:35:41.00 +
+++ libcxx/test/libcxx/clang_modules_include.gen.py 2024-10-02 
09:41:52.824950 +
@@ -18,11 +18,12 @@
 import sys
 sys.path.append(sys.argv[1])
 from libcxx.header_information import lit_header_restrictions, public_headers
 
 for header in public_headers:
-  print(f"""\
+print(
+f"""\
 //--- {header}.compile.pass.cpp
 // RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules 
-fmodules-cache-path=%t -fsyntax-only
 
 // GCC doesn't support -fcxx-modules
 // UNSUPPORTED: gcc
@@ -41,11 +42,12 @@
 // UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
 
 {lit_header_restrictions.get(header, '')}
 
 #include <{header}>
-""")
+"""
+)
 
 print(
 f"""\
 //--- import_std.compile.pass.mm
 // RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules 
-fmodules-cache-path=%t -fsyntax-only

``




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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread Vlad Serebrennikov via cfe-commits


@@ -1009,18 +1012,20 @@ namespace cwg355 { struct ::cwg355_S s; }
 // cwg356: na
 
 namespace cwg357 { // cwg357: yes
-  template struct A {
+  template struct A { // #cwg357-A
 void f() const; // #cwg357-f
   };
   template void A::f() {}
   // expected-error@-1 {{out-of-line definition of 'f' does not match any 
declaration in 'A'}}
+  //   expected-note@#cwg357-A {{defined here}}
   //   expected-note@#cwg357-f {{member declaration does not match because it 
is const qualified}}
 
-  struct B {
+  struct B { // #cwg357-B
 template void f();
   };
   template void B::f() const {}
   // expected-error@-1 {{out-of-line definition of 'f' does not match any 
declaration in 'cwg357::B'}}
+  // expected-note@#cwg357-B {{defined here}}

Endilll wrote:

```suggestion
  //   expected-note@#cwg357-B {{defined here}}
```

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

LGTM otherwise

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


[clang] [Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (PR #110638)

2024-10-02 Thread via cfe-commits

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

>From 38430b6cdfc524972fbdabca6a037174eaf1549f Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 09:08:14 +
Subject: [PATCH 1/9] 110558

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

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ed189e02a51d22 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,6 +9085,11 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+CXXRecordDecl *RD = NewMD->getParent();
+SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
+<< RD->getName() << RD->getLocation();
+  }
 
   bool NewFDisConst = false;
   if (CXXMethodDecl *NewMD = dyn_cast(NewFD))

>From 8f37ce5dec7361b0dbc1ad6f912048fa6bbc38ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 10:19:00 +
Subject: [PATCH 2/9] fix

---
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ed189e02a51d22..7b62b4f6d6433d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,7 +9085,8 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD)) {
+  CXXMethodDecl *NewMD = dyn_cast(NewFD);
+  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();

>From c875c6cb3c0ec64d29a4b4c31ac4eb3605f43289 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Tue, 1 Oct 2024 11:52:22 +
Subject: [PATCH 3/9] fix test

---
 clang/lib/Sema/SemaDecl.cpp|  7 +++
 .../test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp |  1 +
 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp |  1 +
 clang/test/CXX/dcl/dcl.fct/p17.cpp |  1 +
 clang/test/CXX/drs/cwg22xx.cpp |  1 +
 clang/test/CXX/drs/cwg3xx.cpp  |  7 ++-
 clang/test/CXX/special/class.inhctor/p8.cpp|  1 +
 .../temp.constr.decl/func-template-decl.cpp|  1 +
 clang/test/CXX/temp/temp.res/temp.local/p8.cpp |  8 
 .../test/CXX/temp/temp.spec/temp.expl.spec/p12.cpp |  2 ++
 .../CXX/temp/temp.spec/temp.expl.spec/p14-23.cpp   |  1 +
 .../test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp |  1 +
 clang/test/FixIt/member-mismatch.cpp   |  2 ++
 clang/test/Parser/cxx-class.cpp|  1 +
 clang/test/SemaCXX/attr-target-mv.cpp  |  7 ---
 clang/test/SemaCXX/attr-target-version.cpp |  7 ---
 clang/test/SemaCXX/enable_if.cpp   |  2 +-
 clang/test/SemaCXX/function-redecl.cpp | 14 --
 clang/test/SemaCXX/lambda-unevaluated.cpp  |  2 ++
 clang/test/SemaCXX/nested-name-spec.cpp|  4 
 clang/test/SemaCXX/out-of-line-def-mismatch.cpp|  6 +-
 clang/test/SemaCXX/typo-correction.cpp |  1 +
 .../test/SemaTemplate/concepts-out-of-line-def.cpp |  4 +++-
 clang/test/SemaTemplate/recovery-crash.cpp |  5 +++--
 24 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7b62b4f6d6433d..e4c45cbc09e0f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9085,16 +9085,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
 
   SemaRef.Diag(NewFD->getLocation(), DiagMsg)
   << Name << NewDC << IsDefinition << NewFD->getLocation();
+
   CXXMethodDecl *NewMD = dyn_cast(NewFD);
-  if (DiagMsg == diag::err_member_decl_does_not_match && NewMD) {
+  if (NewMD && DiagMsg == diag::err_member_decl_does_not_match) {
 CXXRecordDecl *RD = NewMD->getParent();
 SemaRef.Diag(RD->getLocation(), diag::note_defined_here)
 << RD->getName() << RD->getLocation();
   }
 
-  bool NewFDisConst = false;
-  if (CXXMethodDecl *NewMD = dyn_cast(NewFD))
-NewFDisConst = NewMD->isConst();
+  bool NewFDisConst = NewMD && NewMD->isConst();
 
   for (SmallVectorImpl >::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 9e890204c78bd6..f0901733f8afeb 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -170,5 +170,6 @@ namespace ImplicitConstexprDef {
 
   constexpr void A::f() { } // expected-warning {{'constexpr' non-static 
member function will n

[clang] [llvm] [X86] Don't request 0x90 nop filling in p2align directives (PR #110134)

2024-10-02 Thread Jeremy Morse via cfe-commits

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


[clang] [llvm] [AArch64] Split FeatureAES to FEAT_AES and FEAT_PMULL. (PR #110816)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Alexandros Lamprineas (labrinea)


Changes

Currently in LLVM FeatureAES models both FEAT_AES and FEAT_PMULL lumped 
together. Similarly FeatureSVE2AES means FEAT_SVE_AES plus FEAT_SVE_PMULL128. 
However the architecture does not mandate that both need to be implemented at 
the same time. Splitting them will allow Function Multiversioning to enable 
backend support for 'aes' and 'sve2-aes'. I have added an override for the user 
visible names of the new features to preserve the old semantics for backwards 
compatibility with command line, target attribute and assembler directives.

---

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


89 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+2-2) 
- (modified) clang/test/CodeGen/aarch64-fmv-dependencies.c (+7-6) 
- (modified) clang/test/CodeGen/aarch64-targetattr.c (+6-6) 
- (modified) clang/test/CodeGen/arm64_crypto.c (+1-1) 
- (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+4-4) 
- (modified) clang/test/CodeGen/attr-target-version.c (+56-54) 
- (modified) clang/test/CodeGen/neon-crypto.c (+2-2) 
- (modified) clang/test/CodeGenCXX/attr-target-version.cpp (+1-1) 
- (added) clang/test/Driver/aarch64-aes.c (+9) 
- (added) clang/test/Driver/aarch64-sve2-aes.c (+9) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-a64fx.c (+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1a.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1b.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a10.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a11.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a12.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a13.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a14.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a15.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a16.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a17.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a7.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-m4.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-carmel.c (+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a34.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a35.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a53.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a55.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a57.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a65.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a65ae.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a72.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a73.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a75.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a76.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a76ae.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a77.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a78.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a78ae.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a78c.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-x1.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-x1c.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-exynos-m3.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-exynos-m4.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-exynos-m5.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-falkor.c (+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-kryo.c (+2-1) 
- (modified) 
clang/test/Driver/print-enabled-extensions/aarch64-neoverse-512tvb.c (+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-neoverse-e1.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-neoverse-n1.c 
(+2-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-neoverse-v1.c 
(+2-1) 
- (modified) clang/te

[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

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


@@ -693,14 +693,13 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const 
Decl *D) {
 if (VD->isExternC())
   return getASTContext().getTranslationUnitDecl();
 
-  if (const auto *FD = D->getAsFunction()) {
-if (FD->isExternC())

hokein wrote:

why removing the `isExternC()`? this will change the behavior.

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


[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

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


@@ -693,14 +693,13 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const 
Decl *D) {
 if (VD->isExternC())
   return getASTContext().getTranslationUnitDecl();
 
-  if (const auto *FD = D->getAsFunction()) {
-if (FD->isExternC())
-  return getASTContext().getTranslationUnitDecl();
+  if (const auto *FD = getASTContext().getLangOpts().getClangABICompat() >
+   LangOptions::ClangABI::Ver19
+   ? D->getAsFunction()
+   : dyn_cast(D)) {
 // Member-like constrained friends are mangled as if they were members of
 // the enclosing class.
-if (FD->isMemberLikeConstrainedFriend() &&
-getASTContext().getLangOpts().getClangABICompat() >
-LangOptions::ClangABI::Ver17)
+if (FD->isMemberLikeConstrainedFriend())

hokein wrote:

this looks like a behavior change, we should keep the `getClangABICompat() > 
LangOptions::ClangABI::Ver17` check.

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


[clang] 33fa40c - [clang][ExtractAPI] Generate subheading for typedef'd anonymous types (#110689)

2024-10-02 Thread via cfe-commits

Author: Daniel Grumberg
Date: 2024-10-02T11:14:27+01:00
New Revision: 33fa40cc9659b7b56a9b440edc0587ff58793cac

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

LOG: [clang][ExtractAPI] Generate subheading for typedef'd anonymous types 
(#110689)

When an anonymous type has a typedef we normally use the typedef's name
in places where we expect a named identifier in the symbol graph. This
extends this logic to apply to subheadings.

rdar://136690614

Added: 


Modified: 
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/test/ExtractAPI/typedef_anonymous_record.c

Removed: 




diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 9cb45c8fbf9cbc..66c03863293c2f 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -1621,6 +1621,9 @@ DeclarationFragmentsBuilder::getSubHeading(const 
NamedDecl *Decl) {
  cast(Decl)->isOverloadedOperator()) {
 Fragments.append(Decl->getNameAsString(),
  DeclarationFragments::FragmentKind::Identifier);
+  } else if (isa(Decl) &&
+ cast(Decl)->getTypedefNameForAnonDecl()) {
+return getSubHeading(cast(Decl)->getTypedefNameForAnonDecl());
   } else if (Decl->getIdentifier()) {
 Fragments.append(Decl->getName(),
  DeclarationFragments::FragmentKind::Identifier);

diff  --git a/clang/test/ExtractAPI/typedef_anonymous_record.c 
b/clang/test/ExtractAPI/typedef_anonymous_record.c
index 9c03e9e190ed6b..8e298f8d9ce829 100644
--- a/clang/test/ExtractAPI/typedef_anonymous_record.c
+++ b/clang/test/ExtractAPI/typedef_anonymous_record.c
@@ -35,7 +35,21 @@ typedef struct { } MyStruct;
 // MYSTRUCT:  "kind": {
 // MYSTRUCT-NEXT:   "displayName": "Structure",
 // MYSTRUCT-NEXT:   "identifier": "c.struct"
-// MYSTRUCT: "title": "MyStruct"
+// MYSTRUCT:   "names": {
+// MYSTRUCT-NEXT:"navigator": [
+// MYSTRUCT-NEXT:  {
+// MYSTRUCT-NEXT:"kind": "identifier",
+// MYSTRUCT-NEXT:"spelling": "MyStruct"
+// MYSTRUCT-NEXT:  }
+// MYSTRUCT-NEXT:],
+// MYSTRUCT-NEXT:"subHeading": [
+// MYSTRUCT-NEXT:  {
+// MYSTRUCT-NEXT:"kind": "identifier",
+// MYSTRUCT-NEXT:"spelling": "MyStruct"
+// MYSTRUCT-NEXT:  }
+// MYSTRUCT-NEXT:],
+// MYSTRUCT-NEXT:"title": "MyStruct"
+// MYSTRUCT-NEXT:  },
 // MYSTRUCT:  "pathComponents": [
 // MYSTRUCT-NEXT:"MyStruct"
 // MYSTRUCT-NEXT:  ]
@@ -111,7 +125,21 @@ typedef enum { Case } MyEnum;
 // MYENUM: "kind": {
 // MYENUM-NEXT:  "displayName": "Enumeration",
 // MYENUM-NEXT:  "identifier": "c.enum"
-// MYENUM: "title": "MyEnum"
+// MYENUM:   "names": {
+// MYENUM-NEXT:"navigator": [
+// MYENUM-NEXT:  {
+// MYENUM-NEXT:"kind": "identifier",
+// MYENUM-NEXT:"spelling": "MyEnum"
+// MYENUM-NEXT:  }
+// MYENUM-NEXT:],
+// MYENUM-NEXT:"subHeading": [
+// MYENUM-NEXT:  {
+// MYENUM-NEXT:"kind": "identifier",
+// MYENUM-NEXT:"spelling": "MyEnum"
+// MYENUM-NEXT:  }
+// MYENUM-NEXT:],
+// MYENUM-NEXT:"title": "MyEnum"
+// MYENUM-NEXT:  },
 
 // CASE-LABEL: "!testLabel": "c:@EA@MyEnum@Case"
 // CASE:  "pathComponents": [



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


[clang] [clang][ExtractAPI] Generate subheading for typedef'd anonymous types (PR #110689)

2024-10-02 Thread Daniel Grumberg via cfe-commits

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


[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

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

arsenm wrote:

> with the PR pulled in (on top of LLVM's HEAD 
> [aadfba9](https://github.com/llvm/llvm-project/commit/aadfba9b2aa107f9cada2fd9bcbe612cbf560650)),
>  the compilation command is: `clang++ -cl-std=CL2.0 -emit-llvm -c -x cl -g0 
> --target=spir -Xclang -finclude-default-header -O2 test.cl` The output LLVM 
> IR after the optimizations is:

You want spirv, not spir 

> note bitcast to i128 with the following truncation to i96 - those types 
> aren't part of the datalayout, yet some optimization generated them. So 
> something has to be done with it and changing the datalayout is not enough.

Any pass is allowed to introduce any IR type. This field is a pure optimization 
hint. It is not required to do anything, and places no restrictions on any pass

> 
> > This does not mean arbitrary integer bitwidths do not work. The n field is 
> > weird, it's more of an optimization hint.
> 
> And I can imagine that we would want to not only be able to emit 4-bit 
> integers in the frontend, but also allow optimization passes to emit them. 

Just because there's an extension doesn't mean it's desirable to use them. On 
real targets, they'll end up codegenning in wider types anyway

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


[clang] [compiler-rt] [llvm] [FMV][AArch64] Unify features ssbs and ssbs2. (PR #110297)

2024-10-02 Thread Alexandros Lamprineas via cfe-commits


@@ -1125,31 +1125,32 @@ int caller(void) { return 
used_def_without_default_decl() + used_decl_without_de
 // CHECK: attributes #[[ATTR10]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+ls64,+neon" }
 // CHECK: attributes #[[ATTR11]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+ccpp" }
 // CHECK: attributes #[[ATTR12]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+neon" }
-// CHECK: attributes #[[ATTR13:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" }
-// CHECK: attributes #[[ATTR14]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+mops" }
-// CHECK: attributes #[[ATTR15]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+dotprod,+fp-armv8,+neon" }
-// CHECK: attributes #[[ATTR16]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve" }
-// CHECK: attributes #[[ATTR17]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+lse" }
-// CHECK: attributes #[[ATTR18]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon,+rdm" }
-// CHECK: attributes #[[ATTR19:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+jsconv,+neon" }
-// CHECK: attributes #[[ATTR20]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+jsconv,+neon" }
-// CHECK: attributes #[[ATTR21:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+ls64" }
-// CHECK: attributes #[[ATTR22]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+sb" }
-// CHECK: attributes #[[ATTR23]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+aes,+f64mm,+fp-armv8,+fullfp16,+neon,+sha2,+sve" }
-// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+complxnum,+fp-armv8,+fullfp16,+neon,+rdm,+sme" }
-// CHECK: attributes #[[ATTR25]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+f32mm,+fp-armv8,+fullfp16,+i8mm,+neon,+sha2,+sha3,+sve" }
-// CHECK: attributes #[[ATTR26]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+dit,+fp-armv8,+fullfp16,+neon,+sve" }
-// CHECK: attributes #[[ATTR27]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+ccpp,+rcpc" }
-// CHECK: attributes #[[ATTR28]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+ccdp,+ccpp,+fp-armv8,+jsconv,+neon" }
-// CHECK: attributes #[[ATTR29]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fptoint,+rcpc" }
-// CHECK: attributes #[[ATTR30]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+bf16,+fp-armv8,+fullfp16,+neon,+sve" }
-// CHECK: attributes #[[ATTR31]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve,+sve2,+sve2-aes,+sve2-sha3" }
-// CHECK: attributes #[[ATTR32]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve,+sve2,+sve2-aes,+sve2-bitperm"
 }
-// CHECK: attributes #[[ATTR33]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+mte,+neon,+sve,+sve2,+sve2-sm4" }
-// CHECK: attributes #[[ATTR34]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+mops,+mte,+rcpc,+rcpc3" }
-// CHECK: attributes #[[ATTR35]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+neon,+sm4" }
-// CHECK: attributes #[[ATTR36]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+lse,+neon,+rdm" }
-// CHECK: attributes #[[ATTR37:[0-9]+]] = { "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+rdm" }
+// CHECK: attributes #[[ATTR13]] = { noinline nounwind optnone 
"n

[clang] [analyzer][NFC] Remove dangling method declaration from ErrnoChecker (PR #110820)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Donát Nagy (NagyDonat)


Changes

Remove the declaration of `ErrnoChecker::checkBranchCondition()` because this 
method is not defined or used anywhere. (It's probably a leftover from some old 
refactoring.)

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


1 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp (-1) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
index 72fd6781a75615..beb3c8574b5fd4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
@@ -42,7 +42,6 @@ class ErrnoChecker
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
-  void checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const;
 
   /// Indicates if a read (load) of \c errno is allowed in a non-condition part
   /// of \c if, \c switch, loop and conditional statements when the errno

``




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


[clang] [analyzer][NFC] Remove dangling method declaration from ErrnoChecker (PR #110820)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




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

Author: Donát Nagy (NagyDonat)


Changes

Remove the declaration of `ErrnoChecker::checkBranchCondition()` because this 
method is not defined or used anywhere. (It's probably a leftover from some old 
refactoring.)

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


1 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp (-1) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
index 72fd6781a75615..beb3c8574b5fd4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
@@ -42,7 +42,6 @@ class ErrnoChecker
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
-  void checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const;
 
   /// Indicates if a read (load) of \c errno is allowed in a non-condition part
   /// of \c if, \c switch, loop and conditional statements when the errno

``




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


[clang] [analyzer][NFC] Remove dangling method declaration from ErrnoChecker (PR #110820)

2024-10-02 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat created 
https://github.com/llvm/llvm-project/pull/110820

Remove the declaration of `ErrnoChecker::checkBranchCondition()` because this 
method is not defined or used anywhere. (It's probably a leftover from some old 
refactoring.)

From 72bc17b87a7955a58210dfe42d7d73b6c0c6803c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Wed, 2 Oct 2024 12:24:44 +0200
Subject: [PATCH] [analyzer][NFC] Remove dangling method declaration from
 ErrnoChecker

Remove the declaration of `ErrnoChecker::checkBranchCondition()` because
this method is not defined or used anywhere. (It's probably a leftover
from some old refactoring.)
---
 clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
index 72fd6781a75615..beb3c8574b5fd4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
@@ -42,7 +42,6 @@ class ErrnoChecker
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
-  void checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const;
 
   /// Indicates if a read (load) of \c errno is allowed in a non-condition part
   /// of \c if, \c switch, loop and conditional statements when the errno

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


[clang] Multilib error fixes (PR #110804)

2024-10-02 Thread Peter Smith via cfe-commits

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


[clang] Multilib error fixes (PR #110804)

2024-10-02 Thread Peter Smith via cfe-commits

https://github.com/smithp35 commented:

Change looks good to me. A few small comment nits.

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


[clang] Multilib error fixes (PR #110804)

2024-10-02 Thread Peter Smith via cfe-commits


@@ -124,12 +124,11 @@ bool MultilibSet::select(const Driver &D, const 
Multilib::flags_list &Flags,
 }
 
 // If this multilib is actually a placeholder containing a fatal
-// error message written by the multilib.yaml author, display that
-// error message, and return failure.
-if (M.isFatalError()) {
-  D.Diag(clang::diag::err_drv_multilib_custom_error) << M.getFatalError();
-  return false;
-}
+// error message written by the multilib.yaml author, then set a

smithp35 wrote:

On the line above, should that be "containing an error message written ... " 
rather than fatal error?

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


[clang] [clang][RISC-V] fixed fp calling convention for fpcc eligible structs for risc-v (PR #110690)

2024-10-02 Thread Kamran Yousafzai via cfe-commits

https://github.com/KamranYousafzai updated 
https://github.com/llvm/llvm-project/pull/110690

>From 8ca2d40d834c500fd463c6fa0d475cd9f91407c2 Mon Sep 17 00:00:00 2001
From: "muhammad.kamran4" 
Date: Tue, 1 Oct 2024 17:21:21 +0200
Subject: [PATCH] fixed fp calling convention for fpcc eligible structs for
 risc-v

---
 clang/lib/CodeGen/Targets/RISCV.cpp  |  7 +
 clang/test/CodeGen/RISCV/riscv-fpcc-struct.c | 28 
 2 files changed, 35 insertions(+)
 create mode 100644 clang/test/CodeGen/RISCV/riscv-fpcc-struct.c

diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp 
b/clang/lib/CodeGen/Targets/RISCV.cpp
index fd72fe673b9b14..ba512f51e52b81 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -251,6 +251,13 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType 
Ty, CharUnits CurOff,
 // bitwidth is XLen or less.
 if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
   QTy = getContext().getIntTypeForBitwidth(XLen, false);
+// Trim type to alignment/bitwidth if that is possible
+else if (getContext().getTypeSize(QTy) > BitWidth) {
+  bool IsSigned =
+  FD->getType().getTypePtr()->hasSignedIntegerRepresentation();
+  unsigned Bits = std::max(8U, (unsigned)llvm::PowerOf2Ceil(BitWidth));
+  QTy = getContext().getIntTypeForBitwidth(Bits, IsSigned);
+}
 if (BitWidth == 0) {
   ZeroWidthBitFieldCount++;
   continue;
diff --git a/clang/test/CodeGen/RISCV/riscv-fpcc-struct.c 
b/clang/test/CodeGen/RISCV/riscv-fpcc-struct.c
new file mode 100644
index 00..a315b409da613a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/riscv-fpcc-struct.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -emit-llvm %s -o - \
+// RUN:   | FileCheck %s
+
+
+struct __attribute__((packed, aligned(1))) S {
+   const float  f0;
+   unsigned f1 : 1;
+};
+
+// CHECK-LABEL: define dso_local signext i32 @func(
+// CHECK-SAME: float [[TMP0:%.*]], i8 [[TMP1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[ARG:%.*]] = alloca [[STRUCT_S:%.*]], align 1
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds nuw { float, i8 }, ptr 
[[ARG]], i32 0, i32 0
+// CHECK-NEXT:store float [[TMP0]], ptr [[TMP2]], align 1
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds nuw { float, i8 }, ptr 
[[ARG]], i32 0, i32 1
+// CHECK-NEXT:store i8 [[TMP1]], ptr [[TMP3]], align 1
+// CHECK-NEXT:[[F1:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr 
[[ARG]], i32 0, i32 1
+// CHECK-NEXT:[[BF_LOAD:%.*]] = load i8, ptr [[F1]], align 1
+// CHECK-NEXT:[[BF_CLEAR:%.*]] = and i8 [[BF_LOAD]], 1
+// CHECK-NEXT:[[BF_CAST:%.*]] = zext i8 [[BF_CLEAR]] to i32
+// CHECK-NEXT:ret i32 [[BF_CAST]]
+//
+unsigned  func(struct S  arg)
+{
+return arg.f1;
+}

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


[clang] [llvm] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics. (PR #110281)

2024-10-02 Thread Paul Walker via cfe-commits

https://github.com/paulwalker-arm updated 
https://github.com/llvm/llvm-project/pull/110281

>From 7fd66c7630ec03db05203c7ffdf8e36e23e30d93 Mon Sep 17 00:00:00 2001
From: Paul Walker 
Date: Thu, 26 Sep 2024 18:07:52 +0100
Subject: [PATCH 1/2] [AArch64][SVE] Fix definition of bfloat fcvt intrinsics.

Affected intrinsics:
  llvm.aarch64.sve.fcvt.bf16f32
  llvm.aarch64.sve.fcvtnt.bf16f32

The named intrinsics took a predicate based on the smallest element
type when it should be based on the largest. The intrinsics have
been replace by v2 equivalents and affected code ported to use them.

Patch includes changes to getSVEPredicateBitCast() that ensure the
generated code for the auto-upgraded old intrinsics is unchanged.
---
 clang/include/clang/Basic/arm_sve.td  | 13 
 .../acle_sve_cvt-bfloat.c | 24 +++---
 .../aarch64-sve-intrinsics/acle_sve_cvtnt.c   | 16 -
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  4 +--
 llvm/lib/IR/AutoUpgrade.cpp   | 33 +++
 .../Target/AArch64/AArch64ISelLowering.cpp|  8 +
 .../lib/Target/AArch64/AArch64SVEInstrInfo.td |  4 +--
 .../AArch64/AArch64TargetTransformInfo.cpp|  4 +--
 llvm/lib/Target/AArch64/SVEInstrFormats.td|  2 +-
 .../CodeGen/AArch64/sve-intrinsics-bfloat.ll  | 24 --
 ...sve-intrinsic-comb-all-active-lanes-cvt.ll | 32 +-
 .../sve-intrinsic-comb-no-active-lanes-cvt.ll |  4 +--
 12 files changed, 115 insertions(+), 53 deletions(-)

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index da496e30fbb523..b94a09c94c23e4 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -943,11 +943,6 @@ defm SVFCVTZS_S64_F16 : SInstCvtMXZ<"svcvt_s64[_f16]", 
"ddPO", "dPO", "l",  "aar
 defm SVFCVTZS_S32_F32 : SInstCvtMXZ<"svcvt_s32[_f32]", "ddPM", "dPM", "i",  
"aarch64_sve_fcvtzs", [IsOverloadCvt]>;
 defm SVFCVTZS_S64_F32 : SInstCvtMXZ<"svcvt_s64[_f32]", "ddPM", "dPM", "l",  
"aarch64_sve_fcvtzs_i64f32">;
 
-let SVETargetGuard = "sve,bf16", SMETargetGuard = "sme,bf16" in {
-  defm SVCVT_BF16_F32   : SInstCvtMXZ<"svcvt_bf16[_f32]",  "ddPM", "dPM", "b", 
 "aarch64_sve_fcvt_bf16f32">;
-  def SVCVTNT_BF16_F32 : SInst<"svcvtnt_bf16[_f32]", "ddPM", "b",  MergeOp1, 
"aarch64_sve_fcvtnt_bf16f32", [IsOverloadNone, VerifyRuntimeMode]>;
-}
-
 // svcvt_s##_f64
 defm SVFCVTZS_S32_F64 : SInstCvtMXZ<"svcvt_s32[_f64]", "ttPd", "tPd", "d",  
"aarch64_sve_fcvtzs_i32f64">;
 defm SVFCVTZS_S64_F64 : SInstCvtMXZ<"svcvt_s64[_f64]", "ddPN", "dPN", "l",  
"aarch64_sve_fcvtzs", [IsOverloadCvt]>;
@@ -1003,6 +998,13 @@ defm SVFCVT_F32_F64   : SInstCvtMXZ<"svcvt_f32[_f64]", 
"MMPd", "MPd", "d", "aarc
 defm SVFCVT_F64_F16   : SInstCvtMXZ<"svcvt_f64[_f16]", "ddPO", "dPO", "d", 
"aarch64_sve_fcvt_f64f16">;
 defm SVFCVT_F64_F32   : SInstCvtMXZ<"svcvt_f64[_f32]", "ddPM", "dPM", "d", 
"aarch64_sve_fcvt_f64f32">;
 
+let SVETargetGuard = "sve,bf16", SMETargetGuard = "sme,bf16" in {
+defm SVCVT_BF16_F32 : SInstCvtMXZ<"svcvt_bf16[_f32]", "$$Pd", "$Pd", "f", 
"aarch64_sve_fcvt_bf16f32_v2">;
+
+def SVCVTNT_BF16: SInst<"svcvtnt_bf16[_f32]", "$$Pd", "f", MergeOp1, 
"aarch64_sve_fcvtnt_bf16f32_v2", [IsOverloadNone, VerifyRuntimeMode]>;
+//  SVCVTNT_X_BF16  : Implemented as macro by SveEmitter.cpp
+}
+
 let SVETargetGuard = "sve2", SMETargetGuard = "sme" in {
 defm SVCVTLT_F32: SInstCvtMX<"svcvtlt_f32[_f16]",  "ddPh", "dPh", "f", 
"aarch64_sve_fcvtlt_f32f16">;
 defm SVCVTLT_F64: SInstCvtMX<"svcvtlt_f64[_f32]",  "ddPh", "dPh", "d", 
"aarch64_sve_fcvtlt_f64f32">;
@@ -1015,7 +1017,6 @@ def SVCVTNT_F64 : SInst<"svcvtnt_f32[_f64]",  "hhPd", 
"d", MergeOp1, "aarch6
 
 def SVCVTXNT_F32: SInst<"svcvtxnt_f32[_f64]", "MMPd", "d", MergeOp1, 
"aarch64_sve_fcvtxnt_f32f64", [IsOverloadNone, VerifyRuntimeMode]>;
 //  SVCVTXNT_X_F32  : Implemented as macro by SveEmitter.cpp
-
 }
 
 

diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
index 145d60db6eda3c..cbeac2f384f9a1 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
@@ -24,14 +24,14 @@
 
 // CHECK-LABEL: @test_svcvt_bf16_f32_x(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PG:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.fcvt.bf16f32( undef,  
[[TMP0]],  [[OP:%.*]])
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv4i1( [[PG:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.fcvt.bf16f32.v2( undef,  [[TMP0]],  [[OP:%.*]])
 // CHECK-NEXT:ret  [[TMP1]]
 //
 // CPP-CHECK-LABEL: @_Z21test_svcvt_bf16_f32_xu10__SVBool_tu13__SVFloat32_t(
 // CPP-CHECK

[clang] [Clang] omit parentheses in fold expressions with a single expansion (PR #110761)

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

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

>From 9c69d6584d6b71554aec55f0de52abb4baa9435f Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 2 Oct 2024 02:13:51 +0300
Subject: [PATCH] [Clang] omit parentheses in fold expressions with a single
 expansion

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/TreeTransform.h   |  3 +++
 clang/test/SemaCXX/warn-assignment-condition.cpp | 12 +++-
 .../test/SemaTemplate/instantiate-requires-expr.cpp  |  2 +-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index bf128e370b076e..254779dc734dea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -460,6 +460,7 @@ Bug Fixes to C++ Support
   containing outer unexpanded parameters were not correctly expanded. 
(#GH101754)
 - Fixed a bug in constraint expression comparison where the ``sizeof...`` 
expression was not handled properly
   in certain friend declarations. (#GH93099)
+- Fixed warnings for extra parentheses in fold expressions by eliminating them 
in single expansion cases. (#GH101863)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 6fdb18d51acef9..1a963858d0a3e4 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -15598,6 +15598,9 @@ 
TreeTransform::TransformCXXFoldExpr(CXXFoldExpr *E) {
 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
 E->getOperator());
 
+  if (*NumExpansions == 1)
+Result = Result.get()->IgnoreParens();
+
   return Result;
 }
 
diff --git a/clang/test/SemaCXX/warn-assignment-condition.cpp 
b/clang/test/SemaCXX/warn-assignment-condition.cpp
index 09084e36bb4916..1b644260aa61d5 100644
--- a/clang/test/SemaCXX/warn-assignment-condition.cpp
+++ b/clang/test/SemaCXX/warn-assignment-condition.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wparentheses -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wparentheses -std=c++2a -verify %s
 
 struct A {
   int foo();
@@ -144,3 +144,13 @@ void test() {
   f(S()); // expected-note {{in instantiation}}
 }
 }
+
+namespace GH101863 {
+void foo(auto... args) {
+  if (((args == 0) or ...)) {} // ok
+}
+
+void bar() {
+  foo(3);
+}
+}
diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp 
b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index 20a19d731ae169..ce2c060a176045 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -36,7 +36,7 @@ using r1i2 = r1; // expected-error {{constraints not 
satisfied for class t
 template requires
 false_v
 // expected-note@-1 {{because 'false_v'}}
-// expected-note@-2 {{because 'false_v' evaluated to false}}
+// expected-note@-2 {{because 'false_v' evaluated to false}}
 struct r2 {};
 
 using r2i1 = r2; // expected-error {{constraints not 
satisfied for class template 'r2' [with Ts = ]}}

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


[clang] [llvm] [clang][llvm][SPIR-V] Explicitly encode native integer widths for SPIR-V (PR #110695)

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

https://github.com/AlexVlx updated 
https://github.com/llvm/llvm-project/pull/110695

>From 758fb6e28844d89031b5497d651cb2a9b71b6a0e Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Tue, 1 Oct 2024 17:10:50 +0100
Subject: [PATCH] Explicitly encode native integer widths for SPIR-V.

---
 clang/lib/Basic/Targets/SPIR.h| 16 +++---
 clang/test/CodeGen/target-data.c  |  2 +-
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl   |  2 +-
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp  | 12 ++--
 .../SPIRV/optimizations/add-check-overflow.ll | 56 ---
 5 files changed, 16 insertions(+), 72 deletions(-)
 delete mode 100644 llvm/test/CodeGen/SPIRV/optimizations/add-check-overflow.ll

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index cc79562de2871e..09d4ad3c0ac620 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -314,8 +314,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRVTargetInfo : public 
BaseSPIRVTargetInfo {
 
 // SPIR-V IDs are represented with a single 32-bit word.
 SizeType = TargetInfo::UnsignedInt;
-resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
+resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -338,8 +338,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public 
BaseSPIRVTargetInfo {
 // SPIR-V has core support for atomic ops, and Int32 is always available;
 // we take the maximum because it's possible the Host supports wider types.
 MaxAtomicInlineWidth = std::max(MaxAtomicInlineWidth, 32);
-resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
+resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-"
+"v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -362,8 +362,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public 
BaseSPIRVTargetInfo {
 // SPIR-V has core support for atomic ops, and Int64 is always available;
 // we take the maximum because it's possible the Host supports wider types.
 MaxAtomicInlineWidth = std::max(MaxAtomicInlineWidth, 64);
-resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
+resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -388,8 +388,8 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 AddrSpaceMap = &SPIRDefIsGenMap;
 
-resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1-P4-A0");
+resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
+"v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0");
 
 BFloat16Width = BFloat16Align = 16;
 BFloat16Format = &llvm::APFloat::BFloat();
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 8548aa00cfe877..fa875fe68b0c5b 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -271,4 +271,4 @@
 
 // RUN: %clang_cc1 -triple spirv64-amd-amdhsa -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=AMDGPUSPIRV64
-// AMDGPUSPIRV64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1-P4-A0"
+// AMDGPUSPIRV64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0"
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index bf5f2971cf118c..9132cc8a717e0f 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -638,7 +638,7 @@ void test_get_workgroup_size(int d, global int *out)
 
 // CHECK-LABEL: @test_get_grid_size(
 // CHECK: {{.*}}call align 4 dereferenceable(64){{.*}} ptr addrspace(4) 
@llvm.amdgcn.dispatch.ptr()
-// CHECK: getelementptr inbounds i8, ptr addrspace(4) %{{.*}}, i64 %.sink
+// CHECK: getelementptr inbounds i8, ptr addrspace(4) %{{.*}}, i64 %{{.+}}
 // CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !invariant.load
 void test_get_grid_size(int d, global int *out)
 {
diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 
b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index e5384b2eb2c2c1..50c881a19cf58b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -54,14 +54,14 @@ static 

[clang] [llvm] [AArch64] Split FeatureAES to FEAT_AES and FEAT_PMULL. (PR #110816)

2024-10-02 Thread Andrew Carlotti via cfe-commits

andrewcarlotti wrote:

> However the architecture does not mandate that both need to be implemented at 
> the same time.

This premise is incorrect. For FEAT_SVE_AES and FEAT_SVE_PMULL128, the latest 
version of the Arm ARM (DDI 0487K.a) includes the following in the definition 
of  `ID_AA64ZFR0_EL1.AES`:

> FEAT_SVE_AES implements the functionality identified by the value 0b0001.
FEAT_SVE_PMULL128 implements the functionality identified by the value 0b0010.
The permitted values are 0b and 0b0010.

So it isn't permitted to implement just one of FEAT_SVE_AES and 
FEAT_SVE_PMULL128.

Similarly, for FEAT_AES and FEAT_PMULL, the previous version of the Arm ARM 
(DDI 0487J.a) includes the following in the definition of  
`ID_AA64ISAR0_EL1.AES`:

>FEAT_AES implements the functionality identified by the value 0b0001.
FEAT_PMULL implements the functionality identified by the value 0b0010.
>From Armv8, the permitted values are 0b and 0b0010.

This last line was deleted in the latest Arm ARM (DDI 0487K.a), but it appears 
to be a mistake that was not intended to relax the architecture constraints. 
I've reported this discrepancy internally.

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


[clang] [analyzer][NFC] Remove dangling method declaration from ErrnoChecker (PR #110820)

2024-10-02 Thread Balazs Benics via cfe-commits

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


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


[clang] a10d3d2 - [analyzer][NFC] Remove dangling method declaration from ErrnoChecker (#110820)

2024-10-02 Thread via cfe-commits

Author: Donát Nagy
Date: 2024-10-02T13:32:45+02:00
New Revision: a10d3d2a3a82a577625ee8877853b4c4c9e2bbdc

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

LOG: [analyzer][NFC] Remove dangling method declaration from ErrnoChecker 
(#110820)

Remove the declaration of `ErrnoChecker::checkBranchCondition()` because
this method is not defined or used anywhere. (It's probably a leftover
from some old refactoring.)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
index 72fd6781a75615..beb3c8574b5fd4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
@@ -42,7 +42,6 @@ class ErrnoChecker
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
-  void checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const;
 
   /// Indicates if a read (load) of \c errno is allowed in a non-condition part
   /// of \c if, \c switch, loop and conditional statements when the errno



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


[clang] [analyzer][NFC] Remove dangling method declaration from ErrnoChecker (PR #110820)

2024-10-02 Thread Donát Nagy via cfe-commits

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


[clang] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in host code without relying on target-dependent overload resolution (PR #109663)

2024-10-02 Thread Fabian Ritter via cfe-commits

ritter-x2a wrote:

@Artem-B  thank you for the suggestion!
Do I understand correctly that it boils down to the following?
  - If a (new) clang CLI option is set: enable PR #91478 - which, among other 
things, warns during host compilation whenever `__AMDGCN_WAVEFRONT_SIZE__` is 
used in template default arguments or template arguments outside of function 
bodies and global initializers,
  - provide `__AMDGCN_WAVEFRONT_SIZE_IS_64_ON_THE_HOST__` as an unchecked and 
more clearly named alternative, and
  - probably change the wording of the deprecation warning to also point to 
this new macro as an alternative to silence the warning.

We would then recommend to the users to use 
`__AMDGCN_WAVEFRONT_SIZE_IS_64_ON_THE_HOST__` instead of 
`__AMDGCN_WAVEFRONT_SIZE__` outside of function bodies and global initializers 
(and to make sure that that is the behavior they want).

My main concern with this is that I'm not sure if users are likely to manually 
turn on these extra checks, so that the less strict but always-on diagnostics 
produced by this PR might have a bigger impact in practice, at least until we 
change the default.
Also: With the host/device target selection outside of function bodies during 
the different compilation modes as it is, users would need quite deep knowledge 
about compiler internals to make sure that 
`__AMDGCN_WAVEFRONT_SIZE_IS_64_ON_THE_HOST__` is what they want (but, then, 
they also need that when using `__AMDGCN_WAVEFRONT_SIZE__` in these places 
right now, so it might be okay to require that).

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


[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-02 Thread Kevin Wolf via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 


kevmw wrote:

> This example from the failing test should warn I think
> [...]
> Since the definition of foo2 specifies attributes that aren't present in the 
> previous declaration.

Yes, this looks exactly like the thing we want to protect against to me 
(because chances are that the declaration is actually in a header file and 
other source files will check their calls only against this declaration, so 
real bugs can be expected to result from this).

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


[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-10-02 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/110458

From eb03076eca550ea53143bc753639f22bbb7caa35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Mon, 30 Sep 2024 09:19:52 +0200
Subject: [PATCH 1/2] [clang][analyzer] Less redundant warnings from
 FixedAddressChecker

If a fixed value is assigned to a pointer variable, the checker
did emit a warning. If the pointer variable is assigned to another
pointer variable, this resulted in another warning.
The checker now emits warning only if a value with non-pointer type is assigned
(to a pointer variable).
---
 clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp | 6 ++
 clang/test/Analysis/ptr-arith.c   | 4 
 2 files changed, 10 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
index e7fde3edc7f9ee..87ba8e070b328a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
@@ -43,6 +43,12 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator 
*B,
   if (!T->isPointerType())
 return;
 
+  // Omit warning if the RHS has already pointer type.
+  // The value may come from a variable and is candidate for a previous warning
+  // from the checker.
+  if (B->getRHS()->IgnoreParenCasts()->getType()->isPointerType())
+return;
+
   SVal RV = C.getSVal(B->getRHS());
 
   if (!RV.isConstant() || RV.isZeroConstant())
diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
index 020a5006292306..b5ccd2c207ead1 100644
--- a/clang/test/Analysis/ptr-arith.c
+++ b/clang/test/Analysis/ptr-arith.c
@@ -42,6 +42,10 @@ domain_port (const char *domain_b, const char *domain_e,
 void f4(void) {
   int *p;
   p = (int*) 0x1; // expected-warning{{Using a fixed address is not 
portable because that address will probably not be valid in all environments or 
platforms}}
+
+  int *p1;
+  p1 = p; // no warning
+
   long x = 0x10100;
   x += 10;
   p = (int*) x; // expected-warning{{Using a fixed address is not portable 
because that address will probably not be valid in all environments or 
platforms}}

From 5ea33cfb1651a65b82dd21925c2e47325e090fd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Wed, 2 Oct 2024 10:32:56 +0200
Subject: [PATCH 2/2] commit suggestion: change comment
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Donát Nagy 
---
 clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
index 87ba8e070b328a..f7fd92db7757e5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
@@ -43,9 +43,9 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator 
*B,
   if (!T->isPointerType())
 return;
 
-  // Omit warning if the RHS has already pointer type.
-  // The value may come from a variable and is candidate for a previous warning
-  // from the checker.
+  // Omit warning if the RHS has already pointer type. Without this passing
+  // around one fixed value in several pointer variables would produce several
+  // redundant warnings.
   if (B->getRHS()->IgnoreParenCasts()->getType()->isPointerType())
 return;
 

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


[clang] [clang][HLSL] Add radians intrinsic (PR #110802)

2024-10-02 Thread Adam Yang via cfe-commits

https://github.com/adam-yang created 
https://github.com/llvm/llvm-project/pull/110802

partially fixes #99151

### Changes
* Implemented `radians` clang builtin
* Linked `radians` clang builtin with `hlsl_intrinsics.h`
* Added sema checks for `radians` to `CheckHLSLBuiltinFunctionCall` in 
`SemaChecking.cpp`
* Add codegen for `radians` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
* Add codegen tests to `clang/test/CodeGenHLSL/builtins/radians.hlsl`
* Add sema tests to `clang/test/SemaHLSL/BuiltIns/radians-errors.hlsl`

### Related PRs
* [[DXIL] Add radians intrinsic 
#110616](https://github.com/llvm/llvm-project/pull/110616)
* [[SPIRV] Add radians intrinsic 
#110800](https://github.com/llvm/llvm-project/pull/110800)


>From be88a591ed220714b21b73e34406bfcdb866ac17 Mon Sep 17 00:00:00 2001
From: Adam Yang 
Date: Wed, 2 Oct 2024 01:21:19 -0700
Subject: [PATCH] Added radians to clang

---
 clang/include/clang/Basic/Builtins.td |  6 +++
 clang/lib/CodeGen/CGBuiltin.cpp   |  8 +++
 clang/lib/CodeGen/CGHLSLRuntime.h |  1 +
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 30 +++
 clang/lib/Sema/SemaHLSL.cpp   |  1 +
 clang/test/CodeGenHLSL/builtins/radians.hlsl  | 54 +++
 .../SemaHLSL/BuiltIns/radians-errors.hlsl | 27 ++
 7 files changed, 127 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/builtins/radians.hlsl
 create mode 100644 clang/test/SemaHLSL/BuiltIns/radians-errors.hlsl

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 8090119e512fbb..09b130e0def0d7 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4788,6 +4788,12 @@ def HLSLStep: LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLRadians : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_elementwise_radians"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(...)";
+}
+
 // Builtins for XRay.
 def XRayCustomEvent : Builtin {
   let Spellings = ["__xray_customevent"];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d739597de4c855..6c24c66a81e73c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18852,6 +18852,14 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
 retType, CGM.getHLSLRuntime().getSignIntrinsic(),
 ArrayRef{Op0}, nullptr, "hlsl.sign");
   }
+  case Builtin::BI__builtin_hlsl_elementwise_radians: {
+Value *Op0 = EmitScalarExpr(E->getArg(0));
+if (!E->getArg(0)->getType()->hasFloatingRepresentation())
+  llvm_unreachable("radians operand must have a float representation");
+return Builder.CreateIntrinsic(
+/*ReturnType=*/Op0->getType(), 
CGM.getHLSLRuntime().getRadiansIntrinsic(),
+ArrayRef{Op0}, nullptr, "hlsl.radians");
+  }
   }
   return nullptr;
 }
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index a8aabca7348ffb..c807a3216ec9ee 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -82,6 +82,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(Saturate, saturate)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Sign, sign)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Step, step)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Radians, radians)
   GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
   GENERATE_HLSL_INTRINSIC_FUNCTION(FDot, fdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 810a16d75f0228..81b297723da3f5 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -2086,5 +2086,35 @@ _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int3 sign(double3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int4 sign(double4);
+
+//===--===//
+// radians builtins
+//===--===//
+
+/// \fn T radians(T Val)
+/// \brief Converts the specified value from degrees to radians.
+
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+half radians(half);
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+half2 radians(half2);
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+half3 radians(half3);
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+half4 radians(half4);
+
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+float radians(float);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+float2 radians(float2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
+float3 radians(float3);
+_HLSL_BUILTIN_ALIAS(__builtin

[clang] [clang][HLSL] Add radians intrinsic (PR #110802)

2024-10-02 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [clang][ExtractAPI] Generate subheading for typedef'd anonymous types (PR #110689)

2024-10-02 Thread Daniel Grumberg via cfe-commits


@@ -1621,6 +1621,9 @@ DeclarationFragmentsBuilder::getSubHeading(const 
NamedDecl *Decl) {
  cast(Decl)->isOverloadedOperator()) {
 Fragments.append(Decl->getNameAsString(),
  DeclarationFragments::FragmentKind::Identifier);
+  } else if (dyn_cast(Decl) &&

daniel-grumberg wrote:

absolutely

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


[clang] [clang][ExtractAPI] Generate subheading for typedef'd anonymous types (PR #110689)

2024-10-02 Thread Daniel Grumberg via cfe-commits

https://github.com/daniel-grumberg updated 
https://github.com/llvm/llvm-project/pull/110689

>From 30e06bed5b8ba378b2b43f0706617f6978f4be6c Mon Sep 17 00:00:00 2001
From: Daniel Grumberg 
Date: Tue, 1 Oct 2024 16:29:30 +0100
Subject: [PATCH] [clang][ExtractAPI] Generate subheading for typedef'd
 anonymous types

When an anonymous type has a typedef we normally use the typedef's name
in places where we expect a named identifier in the symbol graph. This
extends this logic to apply to subheadings.

rdar://136690614
---
 clang/lib/ExtractAPI/DeclarationFragments.cpp |  3 ++
 .../ExtractAPI/typedef_anonymous_record.c | 32 +--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 9cb45c8fbf9cbc..66c03863293c2f 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -1621,6 +1621,9 @@ DeclarationFragmentsBuilder::getSubHeading(const 
NamedDecl *Decl) {
  cast(Decl)->isOverloadedOperator()) {
 Fragments.append(Decl->getNameAsString(),
  DeclarationFragments::FragmentKind::Identifier);
+  } else if (isa(Decl) &&
+ cast(Decl)->getTypedefNameForAnonDecl()) {
+return getSubHeading(cast(Decl)->getTypedefNameForAnonDecl());
   } else if (Decl->getIdentifier()) {
 Fragments.append(Decl->getName(),
  DeclarationFragments::FragmentKind::Identifier);
diff --git a/clang/test/ExtractAPI/typedef_anonymous_record.c 
b/clang/test/ExtractAPI/typedef_anonymous_record.c
index 9c03e9e190ed6b..8e298f8d9ce829 100644
--- a/clang/test/ExtractAPI/typedef_anonymous_record.c
+++ b/clang/test/ExtractAPI/typedef_anonymous_record.c
@@ -35,7 +35,21 @@ typedef struct { } MyStruct;
 // MYSTRUCT:  "kind": {
 // MYSTRUCT-NEXT:   "displayName": "Structure",
 // MYSTRUCT-NEXT:   "identifier": "c.struct"
-// MYSTRUCT: "title": "MyStruct"
+// MYSTRUCT:   "names": {
+// MYSTRUCT-NEXT:"navigator": [
+// MYSTRUCT-NEXT:  {
+// MYSTRUCT-NEXT:"kind": "identifier",
+// MYSTRUCT-NEXT:"spelling": "MyStruct"
+// MYSTRUCT-NEXT:  }
+// MYSTRUCT-NEXT:],
+// MYSTRUCT-NEXT:"subHeading": [
+// MYSTRUCT-NEXT:  {
+// MYSTRUCT-NEXT:"kind": "identifier",
+// MYSTRUCT-NEXT:"spelling": "MyStruct"
+// MYSTRUCT-NEXT:  }
+// MYSTRUCT-NEXT:],
+// MYSTRUCT-NEXT:"title": "MyStruct"
+// MYSTRUCT-NEXT:  },
 // MYSTRUCT:  "pathComponents": [
 // MYSTRUCT-NEXT:"MyStruct"
 // MYSTRUCT-NEXT:  ]
@@ -111,7 +125,21 @@ typedef enum { Case } MyEnum;
 // MYENUM: "kind": {
 // MYENUM-NEXT:  "displayName": "Enumeration",
 // MYENUM-NEXT:  "identifier": "c.enum"
-// MYENUM: "title": "MyEnum"
+// MYENUM:   "names": {
+// MYENUM-NEXT:"navigator": [
+// MYENUM-NEXT:  {
+// MYENUM-NEXT:"kind": "identifier",
+// MYENUM-NEXT:"spelling": "MyEnum"
+// MYENUM-NEXT:  }
+// MYENUM-NEXT:],
+// MYENUM-NEXT:"subHeading": [
+// MYENUM-NEXT:  {
+// MYENUM-NEXT:"kind": "identifier",
+// MYENUM-NEXT:"spelling": "MyEnum"
+// MYENUM-NEXT:  }
+// MYENUM-NEXT:],
+// MYENUM-NEXT:"title": "MyEnum"
+// MYENUM-NEXT:  },
 
 // CASE-LABEL: "!testLabel": "c:@EA@MyEnum@Case"
 // CASE:  "pathComponents": [

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


[clang-tools-extra] aadfba9 - [clang-tidy] Fix check alphabetical ordering in release notes (#110428)

2024-10-02 Thread via cfe-commits

Author: Mike Crowe
Date: 2024-10-02T09:10:45+02:00
New Revision: aadfba9b2aa107f9cada2fd9bcbe612cbf560650

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

LOG: [clang-tidy] Fix check alphabetical ordering in release notes (#110428)

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index e34e296b5a096d..702a8d2a3576b9 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -162,19 +162,15 @@ Changes in existing checks
   ` check by rewording the
   diagnostic note that suggests adding ``inline``.
 
+- Improved :doc:`misc-unconventional-assign-operator
+  ` check to avoid
+  false positive for C++23 deducing this.
+
 - Improved :doc:`modernize-avoid-c-arrays
   ` check to suggest using 
``std::span``
   as a replacement for parameters of incomplete C array type in C++20 and 
   ``std::array`` or ``std::vector`` before C++20.
 
-- Improved :doc:`modernize-use-std-format
-  ` check to support replacing
-  member function calls too.
-
-- Improved :doc:`misc-unconventional-assign-operator
-  ` check to avoid
-  false positive for C++23 deducing this.
-
 - Improved :doc:`modernize-min-max-use-initializer-list
   ` check by fixing
   a false positive when only an implicit conversion happened inside an
@@ -184,15 +180,14 @@ Changes in existing checks
   ` check to also recognize
   ``NULL``/``__null`` (but not ``0``) when used with a templated type.
 
+- Improved :doc:`modernize-use-std-format
+  ` check to support replacing
+  member function calls too.
+
 - Improved :doc:`modernize-use-std-print
   ` check to support replacing
   member function calls too.
 
-- Improved :doc:`readability-enum-initial-value
-  ` check by only issuing
-  diagnostics for the definition of an ``enum``, and by fixing a typo in the
-  diagnostic.
-
 - Improved :doc:`performance-avoid-endl
   ` check to use ``std::endl`` as
   placeholder when lexer cannot get source text.
@@ -201,6 +196,11 @@ Changes in existing checks
   ` check to let it work on
   any class that has a ``contains`` method.
 
+- Improved :doc:`readability-enum-initial-value
+  ` check by only issuing
+  diagnostics for the definition of an ``enum``, and by fixing a typo in the
+  diagnostic.
+
 - Improved :doc:`readability-implicit-bool-conversion
   ` check
   by adding the option `UseUpperCaseLiteralSuffix` to select the



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


[clang-tools-extra] [clang-tidy] Fix check alphabetical ordering in release notes (PR #110428)

2024-10-02 Thread Piotr Zegar via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix check alphabetical ordering in release notes (PR #110428)

2024-10-02 Thread Piotr Zegar via cfe-commits

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

LGTM

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


[clang] [Clang] Update Interpreter tests to use clang_target_link_libraries (PR #110154)

2024-10-02 Thread Vassil Vassilev via cfe-commits

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


[clang] f0858bf - [Clang] Update Interpreter tests to use clang_target_link_libraries (#110154)

2024-10-02 Thread via cfe-commits

Author: Thomas Fransham
Date: 2024-10-02T10:12:17+03:00
New Revision: f0858bfb62468e5887e7b7d158bd07543ed82467

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

LOG: [Clang] Update Interpreter tests to use clang_target_link_libraries 
(#110154)

This will fix duplicate and missing linker symbol errors when using
CLANG_LINK_CLANG_DYLIB on windows and explicit visibility macros are
used.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on
window.

Added: 


Modified: 
clang/unittests/Interpreter/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Interpreter/CMakeLists.txt 
b/clang/unittests/Interpreter/CMakeLists.txt
index ec6f81ea19b960..1ed1216c772e8f 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -16,13 +16,15 @@ add_clang_unittest(ClangReplInterpreterTests
 
   EXPORT_SYMBOLS
   )
-target_link_libraries(ClangReplInterpreterTests PUBLIC
+  
+target_link_libraries(ClangReplInterpreterTests PUBLIC LLVMTestingSupport)
+
+clang_target_link_libraries(ClangReplInterpreterTests PRIVATE
   clangAST
   clangBasic
   clangInterpreter
   clangFrontend
   clangSema
-  LLVMTestingSupport
   )
 
 # Exceptions on Windows are not yet supported.



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


[clang] [clang] Catch missing format attributes (PR #105479)

2024-10-02 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovichtec updated 
https://github.com/llvm/llvm-project/pull/105479

From 7dafc4011b5597dd7eaf931dab33980b0f51643b Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Fri, 5 Apr 2024 15:20:37 +0200
Subject: [PATCH] [clang] Catch missing format attributes

---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 -
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Sema/Attr.h   |   7 +
 clang/include/clang/Sema/Sema.h   |   2 +
 clang/lib/Sema/SemaDecl.cpp   |   2 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 228 +-
 clang/test/Sema/attr-format-missing.c | 217 +
 clang/test/Sema/attr-format-missing.cpp   | 180 ++
 9 files changed, 640 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/attr-format-missing.c
 create mode 100644 clang/test/Sema/attr-format-missing.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e7a5fb76b602b..917638aa3e54a0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -375,6 +375,9 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses when a ``requires`` expression has a local parameter of 
void type, aligning with the function parameter (#GH109831).
 
+- Clang now diagnoses missing format attributes for non-template functions and
+  class/struct/union members. Fixes #GH60718
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d81bdf827ea0c..b1943dd12cd9df 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -529,7 +529,6 @@ def MainReturnType : DiagGroup<"main-return-type">;
 def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
-def : DiagGroup<"missing-format-attribute">;
 def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 81cd0d4ed5cf1e..8d3e7b248ead1c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1046,6 +1046,9 @@ def err_opencl_invalid_param : Error<
   "declaring function parameter of type %0 is not allowed%select{; did you 
forget * ?|}1">;
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
+def warn_missing_format_attribute : Warning<
+  "diagnostic behavior may be improved by adding the %0 format attribute to 
the declaration of %1">,
+  InGroup>, DefaultIgnore;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 3f0b10212789a4..37c124ca7b454a 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool checkIfMethodHasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast(D))
+return MethodDecl->isInstance() &&
+   !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
+
 /// Diagnose mutually exclusive attributes when present on a given
 /// declaration. Returns true if diagnosed.
 template 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3d9f12d45d646e..260b58a9e88b0c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4642,6 +4642,8 @@ class Sema final : public SemaBase {
 
   enum class RetainOwnershipKind { NS, CF, OS };
 
+  void DiagnoseMissingFormatAttributes(Stmt *Body, const FunctionDecl *FDecl);
+
   UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
   StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
 
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0e536f71a2f70d..ef4692085da78b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16005,6 +16005,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
 }
   }
 
+  DiagnoseMissingFormatAttributes(Body, FD);
+
   // We might not have found a prototype because we didn't wish to warn on
   // the lack of a missing prototype. Try again without the checks for
   // whether we want to warn on the missing prototype.
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c9b9f3a0007daa

[clang] [Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (PR #110198)

2024-10-02 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Sema/aarch64-sve-vector-trig-ops.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -triple aarch64 -target-feature +sve-disable-O0-optnone -o 
- -fsyntax-only 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c
 -verify
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -triple aarch64 -target-feature +sve -disable-O0-optnone -o - 
-fsyntax-only 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c
 -verify
error: 'expected-error' diagnostics expected but not seen: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c
 Line 27 (directive at 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c:28):
 1st argument must be a vector, integer or floating point type
error: 'expected-error' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Sema/aarch64-sve-vector-trig-ops.c
 Line 27: 1st argument must be a floating point type (was 'svfloat32_t' (aka 
'__SVFloat32_t'))
2 errors generated.

--




```



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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-10-02 Thread Vassil Vassilev via cfe-commits

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

Looks good to me, too. We can wait a couple of more days for @AaronBallman to 
have the final say.

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-02 Thread Nikita Popov via cfe-commits

nikic wrote:

Based on llvm-opt-benchmark results, it looks like there are some significant 
compile-time regressions, could you please take a look?

I also see:
```
early-cse.NumCSECall 18050 -> 17883 -0.93%
simplifycfg.NumInvokesMerged 121710 -> 120984 -0.60%
```
EarlyCSE uses isIdenticalTo and invoke merging uses isSameOperationAs. We 
should add attribute intersection support for these transforms as well.

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-02 Thread Nikita Popov via cfe-commits

nikic wrote:

It may be a good idea to skip the inference for constant arguments. I see a 
decent amount of things like `range(i64 -2147483576, 34359738361) 272` in the 
diffs.

Though I still don't think that we should be inferring range at all.

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


[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-10-02 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/108276

>From 3c19f9edb391988c180b6a2dd35198b7b95e2144 Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Tue, 10 Sep 2024 02:22:18 +0100
Subject: [PATCH 1/6] [Clang] Add explicit visibility symbol macros and update
 CMake to control them

We need a different set of visibility macros to LLVM's since on windows you 
need a
different attribute to import and export a symbol unlike other platforms and 
many
translation units will be importing LLVM symbols and export some of Clangs.
Updated Clang CMake to define a macro to enable the symbol visibility macros.
---
 clang/cmake/modules/AddClang.cmake |  4 ++
 clang/include/clang/Support/Compiler.h | 69 ++
 clang/tools/libclang/CMakeLists.txt|  2 +-
 3 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 clang/include/clang/Support/Compiler.h

diff --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 5327b5d2f08928..dcdea378fb 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -108,6 +108,10 @@ macro(add_clang_library name)
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
+  if(NOT ARG_SHARED AND NOT ARG_STATIC)
+target_compile_definitions("obj.${name}" PRIVATE CLANG_EXPORTS)
+  endif()
+
   set(libs ${name})
   if(ARG_SHARED AND ARG_STATIC)
 list(APPEND libs ${name}_static)
diff --git a/clang/include/clang/Support/Compiler.h 
b/clang/include/clang/Support/Compiler.h
new file mode 100644
index 00..4a584e190dc16e
--- /dev/null
+++ b/clang/include/clang/Support/Compiler.h
@@ -0,0 +1,69 @@
+//===-- clang/Support/Compiler.h - Compiler abstraction support -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines explicit visibility macros used to export symbols from
+// clang-cpp
+//
+//===--===//
+
+#ifndef CLANG_SUPPORT_COMPILER_H
+#define CLANG_SUPPORT_COMPILER_H
+
+#include "llvm/Support/Compiler.h"
+
+/// CLANG_ABI is the main export/visibility macro to mark something as
+/// explicitly exported when clang is built as a shared library with everything
+/// else that is unannotated will have internal visibility.
+///
+/// CLANG_EXPORT_TEMPLATE is used on explicit template instantiations in source
+/// files that were declared extern in a header. This macro is only set as a
+/// compiler export attribute on windows, on other platforms it does nothing.
+///
+/// CLANG_TEMPLATE_ABI is for annotating extern template declarations in 
headers
+/// for both functions and classes. On windows its turned in to dllimport for
+/// library consumers, for other platforms its a default visibility attribute.
+#ifndef CLANG_ABI_GENERATING_ANNOTATIONS
+// Marker to add to classes or functions in public headers that should not have
+// export macros added to them by the clang tool
+#define CLANG_ABI_NOT_EXPORTED
+#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
+// Some libraries like those for tablegen are linked in to tools that used
+// in the build so can't depend on the llvm shared library. If export macros
+// were left enabled when building these we would get duplicate or
+// missing symbol linker errors on windows.
+#if defined(CLANG_BUILD_STATIC)
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#elif defined(_WIN32) && !defined(__MINGW32__)
+#if defined(CLANG_EXPORTS)
+#define CLANG_ABI __declspec(dllexport)
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE __declspec(dllexport)
+#else
+#define CLANG_ABI __declspec(dllimport)
+#define CLANG_TEMPLATE_ABI __declspec(dllimport)
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)
+#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_EXPORT_TEMPLATE
+#elif defined(__MACH__) || defined(__WASM__)
+#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#else
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#endif
+
+#endif
\ No newline at end of file
diff --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 968b46acb784cb..8c6a07f9e52a8c 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -166,7 +166,7 @@ if(ENABLE_SHARED)
 set_target_properties(libclang
   PROPERTIES
   VERSION ${LIBCLANG_LIBRARY_VERSION}
-  DEFINE_SYMBOL _CINDEX_LIB_)
+  DEFINE_

[libcxx] [libcxxabi] [libunwind] [llvm] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (PR #108357)

2024-10-02 Thread Martin Storsjö via cfe-commits


@@ -38,9 +38,13 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG)
 # required during compilation (which has the -nostdlib++ or -nodefaultlibs). 
libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler driver, before deciding to include them.
 
-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)

mstorsjo wrote:

Yes, exactly those; any of those basic compiler tests, `check_library_exists` 
(used a couple of times in libcxxabi and libcxx), `check_include_file` (not 
used in libcxxabi/libcxx, but used in openmp, and also struck by the same 
issue, in #90332), are executed as plain C compilation, and they will fail if 
we have stuck C++-only flags in `CMAKE_REQUIRED_FLAGS`.

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


[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-02 Thread Lei Wang via cfe-commits


@@ -1784,6 +1784,12 @@ defm debug_info_for_profiling : 
BoolFOption<"debug-info-for-profiling",
   PosFlag,
   NegFlag>;
+def fprofile_generate_cold_function_coverage : Flag<["-"], 
"fprofile-generate-cold-function-coverage">, 

wlei-llvm wrote:

> I meant, why not just use `clang ... -mllvm 
> -instrument-cold-function-coverage`? Is this a clang - only feature (i.e. 
> rust can't use it?) Is it just for symmetry with the current PGO flags?
> 
> (This is not a pushback, mainly curious. Also the patch would be quite 
> smaller if you didn't need to pass through the flags from clang to llvm)

I see, thanks for the suggestion!  We also need to link runtime 
lib(`compiler_rt.profile.a`)
but yeah, I agree it's possible to pass directly to llvm and linker without 
through clang. Then the full command line would be like 
```
clang ... -mllvm -instrument-cold-function-coverage -mllvm 
-instrument-sample-cold-function-path= -mllvm 
--pgo-function-entry-coverage 
ld.lld ... --u__llvm_runtime_variable  
.../lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a
```
So yes, adding the clang driver flag is kind of to mirror current[ IRPGO 
flags](https://fburl.com/na3cp3gn), for easy maintenance purpose(given that 
`-fprofile-generate` doesn't work with `-fprofile-sample-use`) and also to 
centralize the configuration for the convenience. IMO, the `compiler_rt` is 
probably the main blocker here, I didn't find an easy way to bundle it with a 
llvm flag. 

Appreciate any further suggestions!

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


[clang-tools-extra] [llvm] [clangd] Add CodeAction to swap operands to binary operators (PR #78999)

2024-10-02 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

> @5chmidti this should be ready for merge

Yep.

Though, please check out: 
https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it/74223
TLDR: LLVM wants commit emails that can be reached out to. I have created a new 
email address for this to separate that from my private one. You'd need to add 
the one you would like to commit as to your emails and disable keeping emails 
private: https://github.com/settings/emails. Sadly, that is an all or nothing 
toggle.
(Please mention which one I should choose in the UI. That can be deduced by 
GitHub by changing the local git config for the LLVM repo to use that email)

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


[clang] [flang] [llvm] [openmp] [flang][driver] rename flang-new to flang (PR #110023)

2024-10-02 Thread Leandro Lupori via cfe-commits


@@ -339,11 +335,11 @@ just added using your new frontend option.
 
 ## CMake Support
 As of [#7246](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7246)
-(and soon to be released CMake 3.24.0), `cmake` can detect `flang-new` as a
+(and soon to be released CMake 3.24.0), `cmake` can detect `flang` as a

luporl wrote:

```suggestion
(and CMake 3.24.0), `cmake` can detect `flang` as a
```
Can CMake already detect `flang` as well?

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


[clang] [llvm] [mlir] [NFC][TableGen] Change `Record::getSuperClasses` to use const Record* (PR #110845)

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

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


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


[clang] [llvm] [mlir] [NFC][TableGen] Change `Record::getSuperClasses` to use const Record* (PR #110845)

2024-10-02 Thread Rahul Joshi via cfe-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/110845

>From 71482b22871022ad783386680362f9e2430d9a38 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Wed, 2 Oct 2024 07:01:40 -0700
Subject: [PATCH] [NFC][TableGen] Change `Record::getSuperClasses` to use const
 Record*

Change `Record::getSuperClasses` to return a const pointer to the
superclass records.
---
 clang/utils/TableGen/ClangAttrEmitter.cpp   | 16 +++-
 llvm/docs/TableGen/BackGuide.rst|  2 +-
 llvm/include/llvm/TableGen/Record.h | 16 
 llvm/lib/TableGen/DetailedRecordsBackend.cpp|  3 ++-
 llvm/lib/TableGen/Record.cpp| 17 -
 llvm/lib/TableGen/TGParser.cpp  |  9 -
 llvm/utils/TableGen/CallingConvEmitter.cpp  |  2 +-
 llvm/utils/TableGen/Common/CodeGenRegisters.cpp |  5 ++---
 .../Tools/tblgen-lsp-server/TableGenServer.cpp  |  2 +-
 9 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 893a242099454e..28b7ec8f822cf8 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1529,9 +1529,8 @@ createArgument(const Record &Arg, StringRef Attr,
 
   if (!Ptr) {
 // Search in reverse order so that the most-derived type is handled first.
-ArrayRef> Bases = Search->getSuperClasses();
-for (const auto &Base : reverse(Bases)) {
-  if ((Ptr = createArgument(Arg, Attr, Base.first)))
+for (const auto &[Base, _] : reverse(Search->getSuperClasses())) {
+  if ((Ptr = createArgument(Arg, Attr, Base)))
 break;
 }
   }
@@ -2744,12 +2743,11 @@ static void emitAttributes(const RecordKeeper &Records, 
raw_ostream &OS,
 if (!R.getValueAsBit("ASTNode"))
   continue;
 
-ArrayRef> Supers = R.getSuperClasses();
+ArrayRef> Supers = R.getSuperClasses();
 assert(!Supers.empty() && "Forgot to specify a superclass for the attr");
 std::string SuperName;
 bool Inheritable = false;
-for (const auto &Super : reverse(Supers)) {
-  const Record *R = Super.first;
+for (const auto &[R, _] : reverse(Supers)) {
   if (R->getName() != "TargetSpecificAttr" &&
   R->getName() != "DeclOrTypeAttr" && SuperName.empty())
 SuperName = std::string(R->getName());
@@ -3434,7 +3432,7 @@ namespace {
 }
 
   private:
-AttrClass *findClassByRecord(Record *R) const {
+AttrClass *findClassByRecord(const Record *R) const {
   for (auto &Class : Classes) {
 if (Class->TheRecord == R)
   return Class.get();
@@ -4739,8 +4737,8 @@ void EmitClangAttrParsedAttrImpl(const RecordKeeper 
&Records, raw_ostream &OS) {
   if (Arg->getValueAsBitOrUnset("Fake", UnusedUnset))
 continue;
   ArgNames.push_back(Arg->getValueAsString("Name").str());
-  for (const auto &Class : Arg->getSuperClasses()) {
-if (Class.first->getName().starts_with("Variadic")) {
+  for (const auto &[Class, _] : Arg->getSuperClasses()) {
+if (Class->getName().starts_with("Variadic")) {
   ArgNames.back().append("...");
   break;
 }
diff --git a/llvm/docs/TableGen/BackGuide.rst b/llvm/docs/TableGen/BackGuide.rst
index 60677a6dcd627d..c26575272ad692 100644
--- a/llvm/docs/TableGen/BackGuide.rst
+++ b/llvm/docs/TableGen/BackGuide.rst
@@ -624,7 +624,7 @@ iterates over the pairs in the returned array.
 
 .. code-block:: text
 
-  ArrayRef>
+  ArrayRef>
   Superclasses = Prototype->getSuperClasses();
   for (const auto &SuperPair : Superclasses) {
 ...
diff --git a/llvm/include/llvm/TableGen/Record.h 
b/llvm/include/llvm/TableGen/Record.h
index 987a57965b2ea7..106fee39cb9f64 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1668,7 +1668,7 @@ class Record {
 
   // All superclasses in the inheritance forest in post-order (yes, it
   // must be a forest; diamond-shaped inheritance is not allowed).
-  SmallVector, 0> SuperClasses;
+  SmallVector, 0> SuperClasses;
 
   // Tracks Record instances. Not owned by Record.
   RecordKeeper &TrackedRecords;
@@ -1758,7 +1758,7 @@ class Record {
   ArrayRef getAssertions() const { return Assertions; }
   ArrayRef getDumps() const { return Dumps; }
 
-  ArrayRef> getSuperClasses() const {
+  ArrayRef> getSuperClasses() const {
 return SuperClasses;
   }
 
@@ -1832,25 +1832,25 @@ class Record {
   void checkUnusedTemplateArgs();
 
   bool isSubClassOf(const Record *R) const {
-for (const auto &SCPair : SuperClasses)
-  if (SCPair.first == R)
+for (const auto &[SC, _] : SuperClasses)
+  if (SC == R)
 return true;
 return false;
   }
 
   bool isSubClassOf(StringRef Name) const {
-for (const auto &SCPair : SuperClasses) {
-  if (const auto *SI = dyn_cast(SCPair.first->getNameInit())) {
+for (const auto &[SC, _] : SuperClasses) {
+ 

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

2024-10-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 09ba83be0ac178851e3c9c9c8fefddbdd4d8353f 
fcab1ddf1e7f53276c071b479f1b5b7749d33ba5 --extensions cpp,h -- 
llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 
llvm/lib/Target/SPIRV/SPIRVTargetMachine.h 
llvm/lib/Target/SPIRV/SPIRVTargetTransformInfo.h
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 
b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index 91bcd68813..ed0def104f 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -25,9 +25,9 @@
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
-#include "llvm/InitializePasses.h"
 #include "llvm/IR/IntrinsicsAMDGPU.h"
 #include "llvm/IR/PatternMatch.h"
+#include "llvm/InitializePasses.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Pass.h"
 #include "llvm/Passes/OptimizationLevel.h"
@@ -98,15 +98,15 @@ SPIRVTargetMachine::SPIRVTargetMachine(const Target &T, 
const Triple &TT,
 }
 
 namespace {
-  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)
-  };
+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 {
@@ -148,9 +148,10 @@ SPIRVTargetMachine::getPredicatedAddrSpace(const Value *V) 
const {
   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))
+  const_cast(V),
+  
m_c_And(m_Not(m_Intrinsic(m_Value(Ptr))),
+  m_Not(m_Intrinsic(
+  m_Deferred(Ptr))
 return std::pair(Ptr, AddressSpace::CrossWorkgroup);
 
   return std::pair(nullptr, UINT32_MAX);
@@ -165,19 +166,19 @@ bool SPIRVTargetMachine::isNoopAddrSpaceCast(unsigned 
SrcAS,
 }
 
 void SPIRVTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
-  PB.registerCGSCCOptimizerLateEPCallback([](CGSCCPassManager &PM,
- OptimizationLevel Level) {
-if (Level == OptimizationLevel::O0)
-  return;
+  PB.registerCGSCCOptimizerLateEPCallback(
+  [](CGSCCPassManager &PM, OptimizationLevel Level) {
+if (Level == OptimizationLevel::O0)
+  return;
 
-FunctionPassManager FPM;
+FunctionPassManager FPM;
 
-// Add infer address spaces pass to the opt pipeline after inlining
-// but before SROA to increase SROA opportunities.
-FPM.addPass(InferAddressSpacesPass(AddressSpace::Generic));
+// Add infer address spaces pass to the opt pipeline after inlining
+// but before SROA to increase SROA opportunities.
+FPM.addPass(InferAddressSpacesPass(AddressSpace::Generic));
 
-PM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
-  });
+PM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
+  });
 }
 
 namespace {

``




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] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

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

https://github.com/AlexVlx created 
https://github.com/llvm/llvm-project/pull/110897

Albeit not currently enabled, the InferAddressSpaces pass is desirable / 
profitable for SPIR-V, as it can leverage info that might subsequently be lost 
as transforms are applied to the IR/resulting SPIR-V. This patch enables the 
pass for all SPIR-V targets, and is modelled after the AMDGPU implementation.

>From 9f3cac44dde7d0adcf6cd090c0b91f57cb1c4dca Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Wed, 2 Oct 2024 11:18:36 +0100
Subject: [PATCH] Enable `InferAddressSpaces` for SPIR-V.

---
 .../amdgpu-kernel-arg-pointer-type.cu |  62 ++---
 llvm/lib/Target/SPIRV/CMakeLists.txt  |   2 +
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp  |  92 +++
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.h|   7 +
 .../Target/SPIRV/SPIRVTargetTransformInfo.h   |   4 +
 .../SPIRV/assumed-addrspace.ll|  31 +++
 .../InferAddressSpaces/SPIRV/basic.ll | 236 ++
 .../SPIRV/infer-address-space.ll  | 211 
 .../SPIRV/infer-addrspacecast.ll  |  65 +
 .../SPIRV/infer-getelementptr.ll  | 108 
 .../SPIRV/insert-pos-assert.ll| 158 
 .../InferAddressSpaces/SPIRV/is.constant.ll   |  57 +
 .../InferAddressSpaces/SPIRV/lit.local.cfg|   2 +
 .../SPIRV/mem-intrinsics.ll   | 145 +++
 .../SPIRV/multiple-uses-of-val.ll |  70 ++
 .../InferAddressSpaces/SPIRV/prefetch.ll  |  60 +
 .../preserving-debugloc-addrspacecast.ll  |  48 
 .../SPIRV/redundant-addrspacecast.ll  |  28 +++
 .../InferAddressSpaces/SPIRV/self-phi.ll  |  29 +++
 .../InferAddressSpaces/SPIRV/volatile.ll  | 187 ++
 20 files changed, 1567 insertions(+), 35 deletions(-)
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/assumed-addrspace.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/basic.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-address-space.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-addrspacecast.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-getelementptr.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/insert-pos-assert.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/is.constant.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/lit.local.cfg
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/mem-intrinsics.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/multiple-uses-of-val.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/prefetch.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/preserving-debugloc-addrspacecast.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/redundant-addrspacecast.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/self-phi.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/volatile.ll

diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index b295bbbdaaf955..15c8b46d278ea1 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -58,13 +58,11 @@
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel1Pi(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
-// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(4) [[TMP1]], align 4
+// OPT-SPIRV-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], 
align 4
+// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP0]], 1
+// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(1) [[X_COERCE]], align 4
 // OPT-SPIRV-NEXT:ret void
 //
 // HOST-LABEL: define dso_local void @_Z22__device_stub__kernel1Pi(
@@ -126,13 +124,11 @@ __global__ void kernel1(int *x) {
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel2Ri(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef align 4 dereferenceable(4) 
[[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef align 4 
dereferenceable(4) [[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] 
{
 // OPT-SPIRV-NEXT:

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

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alex Voicu (AlexVlx)


Changes

Albeit not currently enabled, the InferAddressSpaces pass is desirable / 
profitable for SPIR-V, as it can leverage info that might subsequently be lost 
as transforms are applied to the IR/resulting SPIR-V. This patch enables the 
pass for all SPIR-V targets, and is modelled after the AMDGPU implementation.

---

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


20 Files Affected:

- (modified) clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu (+27-35) 
- (modified) llvm/lib/Target/SPIRV/CMakeLists.txt (+2) 
- (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp (+92) 
- (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.h (+7) 
- (modified) llvm/lib/Target/SPIRV/SPIRVTargetTransformInfo.h (+4) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/assumed-addrspace.ll 
(+31) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/basic.ll (+236) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-address-space.ll 
(+211) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-addrspacecast.ll 
(+65) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-getelementptr.ll 
(+108) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/insert-pos-assert.ll 
(+158) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/is.constant.ll (+57) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/lit.local.cfg (+2) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/mem-intrinsics.ll 
(+145) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/multiple-uses-of-val.ll 
(+70) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/prefetch.ll (+60) 
- (added) 
llvm/test/Transforms/InferAddressSpaces/SPIRV/preserving-debugloc-addrspacecast.ll
 (+48) 
- (added) 
llvm/test/Transforms/InferAddressSpaces/SPIRV/redundant-addrspacecast.ll (+28) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/self-phi.ll (+29) 
- (added) llvm/test/Transforms/InferAddressSpaces/SPIRV/volatile.ll (+187) 


``diff
diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index b295bbbdaaf955..15c8b46d278ea1 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -58,13 +58,11 @@
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel1Pi(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
-// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(4) [[TMP1]], align 4
+// OPT-SPIRV-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], 
align 4
+// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP0]], 1
+// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(1) [[X_COERCE]], align 4
 // OPT-SPIRV-NEXT:ret void
 //
 // HOST-LABEL: define dso_local void @_Z22__device_stub__kernel1Pi(
@@ -126,13 +124,11 @@ __global__ void kernel1(int *x) {
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel2Ri(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef align 4 dereferenceable(4) 
[[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef align 4 
dereferenceable(4) [[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] 
{
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
-// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(4) [[TMP1]], align 4
+// OPT-SPIRV-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], 
align 4
+// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP0]], 1
+// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(1) [[X_COERCE]], align 4
 // OPT-SPIRV-NEXT:ret void
 //
 // HOST-LABEL: define dso_local void @_Z22__device_stub__kernel2Ri(
@@ -195,7 +191,7 @@ __global__ void kernel2(int &x) {
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel3PU3AS2iPU3AS1i(
-// OPT-SPIRV-SAME: ptr addrspace(2) nocapture noundef readonly [[X:%.*]], ptr 
addrspace(1) nocapture n

[clang] [clang][DebugInfo] Revert to printing canonical typenames for template aliases (PR #110767)

2024-10-02 Thread via cfe-commits

jimingham wrote:



> On Oct 2, 2024, at 9:22 AM, David Blaikie ***@***.***> wrote:
> 
> 
> Not quite sure how we get to caching and template specializations and pretty 
> printers.
> 
> If we're still producing the typedef-style DWARF for these alias template 
> specializations - perhaps lldb could not cache pretty printers for typedefs? 
> (I guess the pretty printers shouldn't be typedef-specific, right, since 
> typedefs are transparent anyway - but I guess maybe pretty printers can be 
> typedef-specific because typedefs can be intended to communicate what kind of 
> a thing is and possibly how to render it?) - it'll cache teh pretty printer 
> for the underlying type anyway, yeah?
> 
lldb has always allowed you to match formatters to typedef's, regardless of 
whether something past that typedef in the chain has it's own formatter.  That 
way, for instance, if you have some constraint you intend for the values of the 
typedef, you can alert yourself (e.g. color the summary red) when the values 
don't follow those constraints.  And when you do that you shouldn't have to 
worry about formatters lower down in the typedef chain.

OTOH, if you have a variable whose immediate type is a typedef that doesn't 
itself have a formatter match, but that typedef has a type lower in the typedef 
chain that DOES have a formatter, we will use that formatter for the typedef.  
Again, if this typedef is telling the author about some intent for that set of 
instances of the type, we shouldn't make using typedef's that way annoying by 
forcing people to recreate the useful formatter every time they introduce such 
a typedef.  

To be clear, neither of these design decisions is causing any problem here.  
The problem comes in here because we try to speed up the type recognizer 
matching by caching hits we found by inserting the matched type name to the 
found formatter in our "exact name" lookup table.  In this case, we can save 
ourselves from having to reconstruct this typedef chain every time we do the 
match on the original typedef in the future by caching the "original 
typedef"->"formatter from lower in the typedef chain" as an exact match. 

Normally, that's a fine thing to do, but in this case, we saw a typedef named 
"std::remove_cv_t" that was a typedef for `std::string`.  So we 
registered std::string as the formatter for the name 
"std::remove_cv_t".  Then the next time we saw something named this 
way, we found it in our cache and tried to use the `std::string` formatter.  
That failed because this time round  is in fact an "int"...  Prior 
to this, these templated types wouldn't have had this generic looking name but 
would have had the resolved type in the name, which wouldn't have been 
ambiguous.

The narrowest solution is that when you go to cache a type name -> formatter 
pair, you should  first check whether the type name is generic.  If it is, then 
you can't guarantee it will resolve to the same base type in the future, so you 
should not cache it.  IIUC, Michael started down this path but found there 
wasn't a way to tell straightforwardly whether a type was generic.  Since this 
is just an optimization, we should first prove to ourselves that failing to put 
one of these type names in the exact matches really makes enough difference to 
bother with a complex solution.  If the gains are some but not huge, some 
boneheaded solution like never caching anything where the from type has a '<' 
and a '>' is probably sufficient.

Hope that helps...

Jim




> —
> Reply to this email directly, view it on GitHub 
> , 
> or unsubscribe 
> .
> You are receiving this because your review was requested.
> 



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


[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-02 Thread Sean Perry via cfe-commits

perry-ca wrote:

> > sorry this is same as #107906 (with a bigger impact radius, as you're also 
> > changing getBufferForFile) and doesn't address any of the issues mention 
> > about explaining the semantics of `IsText` or justification for changing 
> > the core VFS interfaces, for an operation that's can solely be performed on 
> > physical fileystem.
> > @perry-ca raised some concerns in #109664 about this functionality 
> > requiring some context awareness, I don't think any of those is addressed 
> > by this patch either. Pretty much all of the callers apart from ASTReader 
> > is just using `IsText = true`.
> 
> To give some context, the problem we are trying to solve initially is that 
> file opened by `#embed` should not be utf-8 converted.

Correct.  The overall/original problem is that we have many places where text 
files were being read as binary files.  Adding the IsText parameter to the 
openFileForRead() function just like we have in the getFileOrStdin() group of 
functions solves that problem.  It tells the compiler to read files that should 
be text as text and binary as binary.

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


[clang-tools-extra] [clang-tidy] Create bugprone-bit-cast-pointers check (PR #108083)

2024-10-02 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

> What about `bugprone-bitwise-pointer-copy` @5chmidti ? 
> `bugprone-bitwise-pointer-cast` could work as well

Both sound good to me.

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


[clang] 694fd1f - Allow tag-based API notes on anonymous tag decls with typedef names

2024-10-02 Thread via cfe-commits

Author: Doug Gregor
Date: 2024-10-02T18:21:23+01:00
New Revision: 694fd1f297feaf59cd29a3d17e63ee2f6514dd16

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

LOG: Allow tag-based API notes on anonymous tag decls with typedef names

It is common practice in C to declare anonymous tags that are
immediately given a typedef name, e.g.,

typedef enum { ... } MyType;

At present, one can only express API notes on the typedef. However, that
excludes the possibility of tag-specific notes like EnumExtensibility.
For these anonymous declarations, process API notes using the typedef
name as the tag name, so that one can add API notes to `MyType` via the
`Tags` section.

Added: 


Modified: 
clang/lib/Sema/SemaAPINotes.cpp
clang/lib/Sema/SemaDecl.cpp

clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes

clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
clang/test/APINotes/types.m
clang/test/APINotes/yaml-roundtrip-2.test

Removed: 




diff  --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp
index d0236d08c98e68..ec43a0def9c1e6 100644
--- a/clang/lib/Sema/SemaAPINotes.cpp
+++ b/clang/lib/Sema/SemaAPINotes.cpp
@@ -913,7 +913,15 @@ void Sema::ProcessAPINotes(Decl *D) {
 
 // Tags
 if (auto Tag = dyn_cast(D)) {
-  std::string LookupName = Tag->getName().str();
+  // Determine the name of the entity to search for. If this is an
+  // anonymous tag that gets its linked name from a typedef, look for the
+  // typedef name. This allows tag-specific information to be added
+  // to the declaration.
+  std::string LookupName;
+  if (auto typedefName = Tag->getTypedefNameForAnonDecl())
+LookupName = typedefName->getName().str();
+  else
+LookupName = Tag->getName().str();
 
   // Use the source location to discern if this Tag is an OPTIONS macro.
   // For now we would like to limit this trick of looking up the APINote 
tag

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e4c45cbc09e0f7..add28b370bcfcc 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4974,6 +4974,9 @@ void Sema::setTagNameForLinkagePurposes(TagDecl 
*TagFromDeclSpec,
 
   // Otherwise, set this as the anon-decl typedef for the tag.
   TagFromDeclSpec->setTypedefNameForAnonDecl(NewTD);
+
+  // Now that we have a name for the tag, process API notes again.
+  ProcessAPINotes(TagFromDeclSpec);
 }
 
 static unsigned GetDiagnosticTypeSpecifierID(const DeclSpec &DS) {

diff  --git 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
index ef6e44c51c21c7..f51811354eb00b 100644
--- 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
+++ 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.apinotes
@@ -46,3 +46,5 @@ Tags:
 SwiftName:   SuccessfullyRenamedA
   - Name:RenamedAgainInAPINotesB
 SwiftName:   SuccessfullyRenamedB
+  - Name:AnonEnumWithTypedefName
+SwiftName:   SuccessfullyRenamedC

diff  --git 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
index bd73926e9d6af4..7342c3f83141bb 100644
--- 
a/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
+++ 
b/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h
@@ -27,3 +27,7 @@ void *getCFAuditedToNone_DUMP(void);
 - (id)getOwnedToUnowned __attribute__((__ns_returns_retained__));
 - (id)getUnownedToOwned __attribute__((__ns_returns_not_retained__));
 @end
+
+typedef enum {
+  kConstantInAnonEnum
+} AnonEnumWithTypedefName;

diff  --git a/clang/test/APINotes/types.m b/clang/test/APINotes/types.m
index 133d504713d76c..752f1026432844 100644
--- a/clang/test/APINotes/types.m
+++ b/clang/test/APINotes/types.m
@@ -7,6 +7,9 @@
 
 // CHECK: struct __attribute__((swift_name("SuccessfullyRenamedA"))) 
RenamedAgainInAPINotesA {
 // CHECK: struct __attribute__((swift_name("SuccessfullyRenamedB"))) 
RenamedAgainInAPINotesB {
+// CHECK: typedef enum __attribute__((swift_name("SuccessfullyRenamedC"))) {
+// CHECK-NEXT: kConstantInAnonEnum
+// CHECK-NEXT: } AnonEnumWithTypedefName
 
 void test(OverriddenTypes *overridden) {
   int *ip1 = global_int_ptr; // expected-warning{{incompatible pointer types 
initializing 'int *' with an expression of type 'double (*)(int, int)'}}

diff  --git a/clang/test/APINotes/yaml-roundtrip-2.test 
b/clang/test/APINotes/yaml-roundtrip-2.test
index b0b777b595

[clang-tools-extra] [clang-tidy][readability-container-contains] Fix matching of non-binaryOperator cases (PR #110386)

2024-10-02 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.

LGTM

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


[clang] Allow tag-based API notes on anonymous tag decls with typedef names (PR #110768)

2024-10-02 Thread Egor Zhdan via cfe-commits

https://github.com/egorzhdan closed 
https://github.com/llvm/llvm-project/pull/110768
___
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-10-02 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx updated 
https://github.com/llvm/llvm-project/pull/110897

>From 9f3cac44dde7d0adcf6cd090c0b91f57cb1c4dca Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Wed, 2 Oct 2024 11:18:36 +0100
Subject: [PATCH 1/2] Enable `InferAddressSpaces` for SPIR-V.

---
 .../amdgpu-kernel-arg-pointer-type.cu |  62 ++---
 llvm/lib/Target/SPIRV/CMakeLists.txt  |   2 +
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp  |  92 +++
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.h|   7 +
 .../Target/SPIRV/SPIRVTargetTransformInfo.h   |   4 +
 .../SPIRV/assumed-addrspace.ll|  31 +++
 .../InferAddressSpaces/SPIRV/basic.ll | 236 ++
 .../SPIRV/infer-address-space.ll  | 211 
 .../SPIRV/infer-addrspacecast.ll  |  65 +
 .../SPIRV/infer-getelementptr.ll  | 108 
 .../SPIRV/insert-pos-assert.ll| 158 
 .../InferAddressSpaces/SPIRV/is.constant.ll   |  57 +
 .../InferAddressSpaces/SPIRV/lit.local.cfg|   2 +
 .../SPIRV/mem-intrinsics.ll   | 145 +++
 .../SPIRV/multiple-uses-of-val.ll |  70 ++
 .../InferAddressSpaces/SPIRV/prefetch.ll  |  60 +
 .../preserving-debugloc-addrspacecast.ll  |  48 
 .../SPIRV/redundant-addrspacecast.ll  |  28 +++
 .../InferAddressSpaces/SPIRV/self-phi.ll  |  29 +++
 .../InferAddressSpaces/SPIRV/volatile.ll  | 187 ++
 20 files changed, 1567 insertions(+), 35 deletions(-)
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/assumed-addrspace.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/basic.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-address-space.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-addrspacecast.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-getelementptr.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/insert-pos-assert.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/is.constant.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/lit.local.cfg
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/mem-intrinsics.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/multiple-uses-of-val.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/prefetch.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/preserving-debugloc-addrspacecast.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/redundant-addrspacecast.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/self-phi.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/volatile.ll

diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index b295bbbdaaf955..15c8b46d278ea1 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -58,13 +58,11 @@
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel1Pi(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
-// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(4) [[TMP1]], align 4
+// OPT-SPIRV-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], 
align 4
+// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP0]], 1
+// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(1) [[X_COERCE]], align 4
 // OPT-SPIRV-NEXT:ret void
 //
 // HOST-LABEL: define dso_local void @_Z22__device_stub__kernel1Pi(
@@ -126,13 +124,11 @@ __global__ void kernel1(int *x) {
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel2Ri(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef align 4 dereferenceable(4) 
[[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef align 4 
dereferenceable(4) [[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] 
{
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add n

[clang] [clang-tools-extra] [RecursiveASTVisitor] Skip implicit instantiations. (PR #110899)

2024-10-02 Thread Harald van Dijk via cfe-commits

https://github.com/hvdijk created 
https://github.com/llvm/llvm-project/pull/110899

In DEF_TRAVERSE_TMPL_SPEC_DECL, we attempted to skip implicit instantiations by 
detecting that D->getTemplateArgsAsWritten() returns nullptr, but as this test 
shows, it is possible for that to return a non-null pointer even for implicit 
instantiations. Explicitly check for this case instead.

Fixes #110502

cc @sdkrystian, this fixes an issue introduced by 
12028373020739b388eb2b8141742509f1764e3c, does this look okay or do you feel 
there should be another way of doing it?

>From 5e0633679b88b2b22ab75cadd4ad447621656ae8 Mon Sep 17 00:00:00 2001
From: Harald van Dijk 
Date: Wed, 2 Oct 2024 18:14:38 +0100
Subject: [PATCH] [RecursiveASTVisitor] Skip implicit instantiations.

In DEF_TRAVERSE_TMPL_SPEC_DECL, we attempted to skip implicit
instantiations by detecting that D->getTemplateArgsAsWritten() returns
nullptr, but as this test shows, it is possible for that to return a
non-null pointer even for implicit instantiations. Explicitly check for
this case instead.

Fixes #110502
---
 .../checkers/modernize/type-traits.cpp| 21 +++
 clang/include/clang/AST/RecursiveASTVisitor.h | 16 +++---
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
index 72241846384bcf..854ffa7928635c 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
@@ -14,11 +14,22 @@ namespace std {
 static constexpr bool value = true;
   };
 
+  template 
+  static constexpr bool is_same_v = is_same::value;  // NOLINT
+
   template
   struct enable_if {
 using type = T;
   };
 
+  template 
+  using enable_if_t = typename enable_if::type;  // NOLINT
+
+  template 
+  struct remove_reference {
+using type = T;
+  };
+
 inline namespace __std_lib_version1 {
   template
   struct add_const {
@@ -117,3 +128,13 @@ namespace my_std = std;
 using Alias = my_std::add_const::type;
 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use c++14 style type templates
 // CHECK-FIXES: using Alias = my_std::add_const_t;
+
+template 
+struct ImplicitlyInstantiatedConstructor {
+  template >>
+  ImplicitlyInstantiatedConstructor(U) {}
+};
+
+const ImplicitlyInstantiatedConstructor 
ImplicitInstantiation(std::remove_reference::type(123));
+// CHECK-MESSAGES: :[[@LINE-1]]:68: warning: use c++14 style type templates
+// CHECK-FIXES: const ImplicitlyInstantiatedConstructor 
ImplicitInstantiation(std::remove_reference_t(123));
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index cd9947f7ab9805..b563b89875f08b 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2069,22 +2069,24 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
 
 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {
\
+auto TSK = D->getTemplateSpecializationKind(); 
\
 /* For implicit instantiations ("set x;"), we don't want to   
\
recurse at all, since the instatiated template isn't written in 
\
the source code anywhere.  (Note the instatiated *type* --  
\
set -- is written, and will still get a callback of
\
TemplateSpecializationType).  For explicit instantiations   
\
("template set;"), we do need a callback, since this   
\
-   is the only callback that's made for this instantiation.
\
-   We use getTemplateArgsAsWritten() to distinguish. */
\
-if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) { 
\
-  /* The args that remains unspecialized. */   
\
-  TRY_TO(TraverseTemplateArgumentLocsHelper(   
\
-  ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs));  
\
+   is the only callback that's made for this instantiation. */ 
\
+if (TSK != TSK_ImplicitInstantiation) {
\
+  if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) {   
\
+/* The args that remains unspecialized. */ 
\
+TRY_TO(TraverseTemplateArgumentLocsHelper( 
\
+ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs));
\
+  }
\
 }  
\
 

[clang] [clang-tools-extra] [RecursiveASTVisitor] Skip implicit instantiations. (PR #110899)

2024-10-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-tools-extra

Author: Harald van Dijk (hvdijk)


Changes

In DEF_TRAVERSE_TMPL_SPEC_DECL, we attempted to skip implicit instantiations by 
detecting that D->getTemplateArgsAsWritten() returns nullptr, but as this 
test shows, it is possible for that to return a non-null pointer even for 
implicit instantiations. Explicitly check for this case instead.

Fixes #110502

cc @sdkrystian, this fixes an issue introduced by 
12028373020739b388eb2b8141742509f1764e3c, does this look okay or do you feel 
there should be another way of doing it?

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


2 Files Affected:

- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp (+21) 
- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+9-7) 


``diff
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
index 72241846384bcf..854ffa7928635c 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
@@ -14,11 +14,22 @@ namespace std {
 static constexpr bool value = true;
   };
 
+  template 
+  static constexpr bool is_same_v = is_same::value;  // NOLINT
+
   template
   struct enable_if {
 using type = T;
   };
 
+  template 
+  using enable_if_t = typename enable_if::type;  // NOLINT
+
+  template 
+  struct remove_reference {
+using type = T;
+  };
+
 inline namespace __std_lib_version1 {
   template
   struct add_const {
@@ -117,3 +128,13 @@ namespace my_std = std;
 using Alias = my_std::add_const::type;
 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use c++14 style type templates
 // CHECK-FIXES: using Alias = my_std::add_const_t;
+
+template 
+struct ImplicitlyInstantiatedConstructor {
+  template >>
+  ImplicitlyInstantiatedConstructor(U) {}
+};
+
+const ImplicitlyInstantiatedConstructor 
ImplicitInstantiation(std::remove_reference::type(123));
+// CHECK-MESSAGES: :[[@LINE-1]]:68: warning: use c++14 style type templates
+// CHECK-FIXES: const ImplicitlyInstantiatedConstructor 
ImplicitInstantiation(std::remove_reference_t(123));
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index cd9947f7ab9805..b563b89875f08b 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2069,22 +2069,24 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
 
 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {
\
+auto TSK = D->getTemplateSpecializationKind(); 
\
 /* For implicit instantiations ("set x;"), we don't want to   
\
recurse at all, since the instatiated template isn't written in 
\
the source code anywhere.  (Note the instatiated *type* --  
\
set -- is written, and will still get a callback of
\
TemplateSpecializationType).  For explicit instantiations   
\
("template set;"), we do need a callback, since this   
\
-   is the only callback that's made for this instantiation.
\
-   We use getTemplateArgsAsWritten() to distinguish. */
\
-if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) { 
\
-  /* The args that remains unspecialized. */   
\
-  TRY_TO(TraverseTemplateArgumentLocsHelper(   
\
-  ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs));  
\
+   is the only callback that's made for this instantiation. */ 
\
+if (TSK != TSK_ImplicitInstantiation) {
\
+  if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) {   
\
+/* The args that remains unspecialized. */ 
\
+TRY_TO(TraverseTemplateArgumentLocsHelper( 
\
+ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs));
\
+  }
\
 }  
\

\
 if (getDerived().shouldVisitTemplateInstantiations() ||
\
-D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
\
+TSK == TSK_ExplicitSpecialization) {   
\
   /* Traverse base definition for explicit specializations */  
\
   TRY_TO(Traverse##DECLKIND##Helper(D)); 

[clang] [clang-tools-extra] [RecursiveASTVisitor] Skip implicit instantiations. (PR #110899)

2024-10-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Harald van Dijk (hvdijk)


Changes

In DEF_TRAVERSE_TMPL_SPEC_DECL, we attempted to skip implicit instantiations by 
detecting that D->getTemplateArgsAsWritten() returns nullptr, but as this 
test shows, it is possible for that to return a non-null pointer even for 
implicit instantiations. Explicitly check for this case instead.

Fixes #110502

cc @sdkrystian, this fixes an issue introduced by 
12028373020739b388eb2b8141742509f1764e3c, does this look okay or do you feel 
there should be another way of doing it?

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


2 Files Affected:

- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp (+21) 
- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+9-7) 


``diff
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
index 72241846384bcf..854ffa7928635c 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
@@ -14,11 +14,22 @@ namespace std {
 static constexpr bool value = true;
   };
 
+  template 
+  static constexpr bool is_same_v = is_same::value;  // NOLINT
+
   template
   struct enable_if {
 using type = T;
   };
 
+  template 
+  using enable_if_t = typename enable_if::type;  // NOLINT
+
+  template 
+  struct remove_reference {
+using type = T;
+  };
+
 inline namespace __std_lib_version1 {
   template
   struct add_const {
@@ -117,3 +128,13 @@ namespace my_std = std;
 using Alias = my_std::add_const::type;
 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use c++14 style type templates
 // CHECK-FIXES: using Alias = my_std::add_const_t;
+
+template 
+struct ImplicitlyInstantiatedConstructor {
+  template >>
+  ImplicitlyInstantiatedConstructor(U) {}
+};
+
+const ImplicitlyInstantiatedConstructor 
ImplicitInstantiation(std::remove_reference::type(123));
+// CHECK-MESSAGES: :[[@LINE-1]]:68: warning: use c++14 style type templates
+// CHECK-FIXES: const ImplicitlyInstantiatedConstructor 
ImplicitInstantiation(std::remove_reference_t(123));
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index cd9947f7ab9805..b563b89875f08b 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2069,22 +2069,24 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
 
 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {
\
+auto TSK = D->getTemplateSpecializationKind(); 
\
 /* For implicit instantiations ("set x;"), we don't want to   
\
recurse at all, since the instatiated template isn't written in 
\
the source code anywhere.  (Note the instatiated *type* --  
\
set -- is written, and will still get a callback of
\
TemplateSpecializationType).  For explicit instantiations   
\
("template set;"), we do need a callback, since this   
\
-   is the only callback that's made for this instantiation.
\
-   We use getTemplateArgsAsWritten() to distinguish. */
\
-if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) { 
\
-  /* The args that remains unspecialized. */   
\
-  TRY_TO(TraverseTemplateArgumentLocsHelper(   
\
-  ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs));  
\
+   is the only callback that's made for this instantiation. */ 
\
+if (TSK != TSK_ImplicitInstantiation) {
\
+  if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) {   
\
+/* The args that remains unspecialized. */ 
\
+TRY_TO(TraverseTemplateArgumentLocsHelper( 
\
+ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs));
\
+  }
\
 }  
\

\
 if (getDerived().shouldVisitTemplateInstantiations() ||
\
-D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
\
+TSK == TSK_ExplicitSpecialization) {   
\
   /* Traverse base definition for explicit specializations */  
\
   TRY_TO(Traverse##DECLKIND##Helper(D));   
\
 

[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)

2024-10-02 Thread Abhina Sree via cfe-commits

abhina-sree wrote:

> > sorry this is same as #107906 (with a bigger impact radius, as you're also 
> > changing getBufferForFile) and doesn't address any of the issues mention 
> > about explaining the semantics of `IsText` or justification for changing 
> > the core VFS interfaces, for an operation that's can solely be performed on 
> > physical fileystem.
> > @perry-ca raised some concerns in #109664 about this functionality 
> > requiring some context awareness, I don't think any of those is addressed 
> > by this patch either. Pretty much all of the callers apart from ASTReader 
> > is just using `IsText = true`.
> 
> To give some context, the problem we are trying to solve initially is that 
> file opened by `#embed` should not be utf-8 converted.

Thanks, I've tested the `#embed` lit tests with this fix and did not see any 
regressions

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


[clang-tools-extra] [llvm] [clangd] Add CodeAction to swap operands to binary operators (PR #78999)

2024-10-02 Thread Tor Shepherd via cfe-commits

torshepherd wrote:

I'll try to rectify this; for now you can add 

tor [dot] aksel [dot] shepherd [at] gmail [dot] com

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


[clang-tools-extra] [clang-tidy] exclude CXXParenListInitExpr from RedundantCastingCheck (PR #109741)

2024-10-02 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.


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


[clang] 5e92bfe - [OpenACC] Check Loop counts for 'collapse' clause. (#110851)

2024-10-02 Thread via cfe-commits

Author: Erich Keane
Date: 2024-10-02T10:33:49-07:00
New Revision: 5e92bfe97fe0f72f3052df53f813d8dcbb7038d3

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

LOG: [OpenACC] Check Loop counts for 'collapse' clause. (#110851)

OpenACC Spec requires that each loop associated with a 'collapse' have
exactly 1 loop/nest. This is implemented in 2 parts: 1- diagnosing when
we see a 2nd loop at any level with an applicable 'collapse'
2- Diagnosing if we didn't see enough 'depth' of loops.

Other loops (non-for) are diagnosed by a previous patch, and other
intervening code will be diagnosed in a followup.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/SemaOpenACC.h
clang/lib/Sema/SemaOpenACC.cpp
clang/test/SemaOpenACC/loop-construct-collapse-clause.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 880dda75ffb110..dae357eb2d370e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12622,6 +12622,12 @@ def err_acc_invalid_in_collapse_loop
 "in intervening code of a 'loop' with a 'collapse' clause">;
 def note_acc_collapse_clause_here
 : Note<"active 'collapse' clause defined here">;
+def err_acc_collapse_multiple_loops
+: Error<"more than one for-loop in a loop associated with OpenACC 'loop' "
+"construct with a 'collapse' clause">;
+def err_acc_collapse_insufficient_loops
+: Error<"'collapse' clause specifies a loop count greater than the number "
+"of available loops">;
 
 // AMDGCN builtins diagnostics
 def err_amdgcn_global_load_lds_size_invalid_value : Error<"invalid size 
value">;

diff  --git a/clang/include/clang/Sema/SemaOpenACC.h 
b/clang/include/clang/Sema/SemaOpenACC.h
index 43b1b1b8e870aa..26564835fa1af6 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -64,7 +64,20 @@ class SemaOpenACC : public SemaBase {
 /// 'collapse inner loop not a 'for' loop' diagnostic.
 LLVM_PREFERRED_TYPE(bool)
 unsigned TopLevelLoopSeen : 1;
-  } CollapseInfo{nullptr, std::nullopt, false};
+
+/// Records whether this 'tier' of the loop has already seen a 'for' loop,
+/// used to diagnose if there are multiple 'for' loops at any one level.
+LLVM_PREFERRED_TYPE(bool)
+unsigned CurLevelHasLoopAlready : 1;
+
+/// Records whether we've hit a CurCollapseCount of '0' on the way down,
+/// which allows us to diagnose if the value of 'N' is too large for the
+/// current number of 'for' loops.
+LLVM_PREFERRED_TYPE(bool)
+unsigned CollapseDepthSatisfied : 1;
+  } CollapseInfo{nullptr, std::nullopt, /*TopLevelLoopSeen=*/false,
+ /*CurLevelHasLoopAlready=*/false,
+ /*CollapseDepthSatisfied=*/true};
 
 public:
   // Redeclaration of the version in OpenACCClause.h.
@@ -515,11 +528,26 @@ class SemaOpenACC : public SemaBase {
   class LoopInConstructRAII {
 SemaOpenACC &SemaRef;
 CollapseCheckingInfo OldCollapseInfo;
+bool PreserveDepth;
 
   public:
-LoopInConstructRAII(SemaOpenACC &SemaRef)
-: SemaRef(SemaRef), OldCollapseInfo(SemaRef.CollapseInfo) {}
-~LoopInConstructRAII() { SemaRef.CollapseInfo = OldCollapseInfo; }
+LoopInConstructRAII(SemaOpenACC &SemaRef, bool PreserveDepth = true)
+: SemaRef(SemaRef), OldCollapseInfo(SemaRef.CollapseInfo),
+  PreserveDepth(PreserveDepth) {}
+~LoopInConstructRAII() {
+  // The associated-statement level of this should NOT preserve this, as it
+  // is a new construct, but other loop uses need to preserve the depth so
+  // it makes it to the 'top level' for diagnostics.
+  bool CollapseDepthSatisified =
+  PreserveDepth ? SemaRef.CollapseInfo.CollapseDepthSatisfied
+: OldCollapseInfo.CollapseDepthSatisfied;
+  bool CurLevelHasLoopAlready =
+  PreserveDepth ? SemaRef.CollapseInfo.CurLevelHasLoopAlready
+: OldCollapseInfo.CurLevelHasLoopAlready;
+  SemaRef.CollapseInfo = OldCollapseInfo;
+  SemaRef.CollapseInfo.CollapseDepthSatisfied = CollapseDepthSatisified;
+  SemaRef.CollapseInfo.CurLevelHasLoopAlready = CurLevelHasLoopAlready;
+}
   };
 
   /// Helper type for the registration/assignment of constructs that need to

diff  --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 58ed3f3cb0777f..47b4bd77d86d18 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -1078,7 +1078,7 @@ SemaOpenACC::AssociatedStmtRAII::AssociatedStmtRAII(
 ArrayRef UnInstClauses,
 ArrayRef Clauses)
  

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

2024-10-02 Thread Matt Arsenault 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))
+return std::pair(Ptr, AddressSpace::CrossWorkgroup);
+
+  return std::pair(nullptr, UINT32_MAX);
+}

arsenm wrote:

This is the fancy stuff that should go into a follow up patch to add assume 
support 

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] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

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


@@ -178,6 +266,9 @@ void SPIRVPassConfig::addIRPasses() {
 addPass(createSPIRVStructurizerPass());
   }
 
+  if (TM.getOptLevel() > CodeGenOptLevel::None)
+addPass(createInferAddressSpacesPass(AddressSpace::Generic));

arsenm wrote:

Not sure why this is a pass parameter to InferAddressSpaces, and a TTI hook 

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] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-10-02 Thread Matt Arsenault 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 {

arsenm wrote:

Move to separate change, not sure this is necessarily valid for spirv 

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] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-10-02 Thread Matt Arsenault 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))
+return std::pair(Ptr, AddressSpace::CrossWorkgroup);
+
+  return std::pair(nullptr, UINT32_MAX);
+}
+
+bool SPIRVTargetMachine::isNoopAddrSpaceCast(unsigned SrcAS,
+ unsigned DestAS) const {
+  if (SrcAS != AddressSpace::Generic && SrcAS != AddressSpace::CrossWorkgroup)
+return false;
+  return DestAS == AddressSpace::Generic ||
+ DestAS == AddressSpace::CrossWorkgroup;
+}

arsenm wrote:

This is separate, I don't think InferAddressSpaces relies on this 

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] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-10-02 Thread Matt Arsenault 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))

arsenm wrote:

Shouldn't be looking at the amdgcn intrinsics? Surely spirv has its own 
operations for this? 

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] [clang][dataflow] Add a test demonstrating an issue in unchecked-optional-access-check (PR #110870)

2024-10-02 Thread Yitzhak Mandelbaum via cfe-commits

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


https://github.com/llvm/llvm-project/pull/110870
___
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-10-02 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py

arsenm wrote:

You don't need to duplicate all of these tests. You just need some basic 
samples that the target is implemented, the full set is testing pass mechanics 
which can be done on any target 

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] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

2024-10-02 Thread Snehasish Kumar via cfe-commits


@@ -1784,6 +1784,12 @@ defm debug_info_for_profiling : 
BoolFOption<"debug-info-for-profiling",
   PosFlag,
   NegFlag>;
+def fprofile_generate_cold_function_coverage : Flag<["-"], 
"fprofile-generate-cold-function-coverage">, 

snehasish wrote:

>  also to centralize the configuration for the convenience

+1 I think a frontend flag is useful. It allows us to identify 
incompatibilities early and provide clear error messages instead of more 
obscure failures down the line.

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


[clang-tools-extra] [clang-tidy] Create bugprone-bitwise-pointer-cast check (PR #108083)

2024-10-02 Thread Carlos Galvez via cfe-commits

https://github.com/carlosgalvezp updated 
https://github.com/llvm/llvm-project/pull/108083

>From 1b1d54e0ce0d0bc4250ff045840b0a0a7bac59a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= 
Date: Tue, 10 Sep 2024 13:46:51 +
Subject: [PATCH] [clang-tidy] Create bugprone-bitwise-pointer-cast check

To detect unsafe usages of casting a pointer to another via copying
the bytes from one into the other, either via std::bit_cast or via
memcpy.use of bit_cast. This is currently not caught by any other
means.

Fixes #106987
---
 .../bugprone/BitwisePointerCastCheck.cpp  | 44 +
 .../bugprone/BitwisePointerCastCheck.h| 34 +++
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  1 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  8 ++-
 .../checks/bugprone/bitwise-pointer-cast.rst  | 52 
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../bugprone/bitwise-pointer-cast.cpp | 61 +++
 8 files changed, 203 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/bitwise-pointer-cast.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/bitwise-pointer-cast.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp
new file mode 100644
index 00..3a361a22ed9b73
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp
@@ -0,0 +1,44 @@
+//===--- BitwisePointerCastCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "BitwisePointerCastCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void BitwisePointerCastCheck::registerMatchers(MatchFinder *Finder) {
+  auto IsPointerType = refersToType(qualType(isAnyPointer()));
+  Finder->addMatcher(callExpr(hasDeclaration(functionDecl(allOf(
+  hasName("::std::bit_cast"),
+  hasTemplateArgument(0, IsPointerType),
+  hasTemplateArgument(1, IsPointerType)
+ .bind("bit_cast"),
+ this);
+
+  auto IsDoublePointerType =
+  hasType(qualType(pointsTo(qualType(isAnyPointer();
+  Finder->addMatcher(callExpr(hasArgument(0, IsDoublePointerType),
+  hasArgument(1, IsDoublePointerType),
+  
hasDeclaration(functionDecl(hasName("::memcpy"
+ .bind("memcpy"),
+ this);
+}
+
+void BitwisePointerCastCheck::check(const MatchFinder::MatchResult &Result) {
+  if (const auto *Call = Result.Nodes.getNodeAs("bit_cast"))
+diag(Call->getBeginLoc(),
+ "do not use 'std::bit_cast' to cast between pointers")
+<< Call->getSourceRange();
+  else if (const auto *Call = Result.Nodes.getNodeAs("memcpy"))
+diag(Call->getBeginLoc(), "do not use 'memcpy' to cast between pointers")
+<< Call->getSourceRange();
+}
+
+} // namespace clang::tidy::bugprone
diff --git a/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.h
new file mode 100644
index 00..1515519b3c9fda
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.h
@@ -0,0 +1,34 @@
+//===--- BitwisePointerCastCheck.h - clang-tidy -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BITWISEPOINTERCASTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BITWISEPOINTERCASTCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::bugprone {
+
+/// Warns about code that tries to cast between pointers by means of
+/// ``std::bit_cast`` or ``memcpy``.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/bugprone/bitwise-pointer-cast.html
+class BitwisePointerCastCheck : public ClangTidyCheck {
+public:
+  BitwisePointerCastCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name

[clang] [flang] [llvm] [openmp] [flang][driver] rename flang-new to flang (PR #110023)

2024-10-02 Thread Håkon Strandenes via cfe-commits


@@ -339,11 +335,11 @@ just added using your new frontend option.
 
 ## CMake Support
 As of [#7246](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7246)
-(and soon to be released CMake 3.24.0), `cmake` can detect `flang-new` as a
+(and soon to be released CMake 3.24.0), `cmake` can detect `flang` as a

hakostra wrote:

1. A search in the CMake repository revel that `flang-new` only appear in 
testcases and ci-related code - not in any code that eventually end up in 
CMake. This indicate that the name `flang-new` is not a magic token for CMake 
to recognize LLVM Flang.
2. I think that [this is the 
merge](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7246) that first 
introduced LLVM Flang to CMake. It seems like the check is through preprocessor 
macros defined by the different compilers. See 
[`Modules/CMakeFortranCompilerId.F.in`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/CMakeFortranCompilerId.F.in)
 in the CMake sources.

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


  1   2   3   4   5   >