[clang] d63cc4c - [analyzer] Unknown array lvalue element in Store (#133381)

2025-03-31 Thread via cfe-commits

Author: T-Gruber
Date: 2025-03-31T08:44:28+02:00
New Revision: d63cc4c87689a79d25521c9aa2ce4a335e5984e3

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

LOG: [analyzer] Unknown array lvalue element in Store (#133381)

Remove the early return for BaseRegions of type ElementRegion. Return
meaningful MemRegionVal for these cases as well.
Previous discussion:
https://discourse.llvm.org/t/lvalueelement-returns-unknownval-for-multi-dimensional-arrays/85476

Added: 
clang/test/Analysis/lvalue_elements.c

Modified: 
clang/lib/StaticAnalyzer/Core/Store.cpp
clang/test/Analysis/ArrayBound/assumption-reporting.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/Store.cpp 
b/clang/lib/StaticAnalyzer/Core/Store.cpp
index 5f30fae4b7047..da6885ecd0ec5 100644
--- a/clang/lib/StaticAnalyzer/Core/Store.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -511,13 +511,9 @@ SVal StoreManager::getLValueElement(QualType elementType, 
NonLoc Offset,
   // Only allow non-integer offsets if the base region has no offset itself.
   // FIXME: This is a somewhat arbitrary restriction. We should be using
   // SValBuilder here to add the two offsets without checking their types.
-  if (!isa(Offset)) {
-if (isa(BaseRegion->StripCasts()))
-  return UnknownVal();
-
+  if (!isa(Offset))
 return loc::MemRegionVal(MRMgr.getElementRegion(
 elementType, Offset, cast(ElemR->getSuperRegion()), Ctx));
-  }
 
   const llvm::APSInt& OffI = Offset.castAs().getValue();
   assert(BaseIdxI.isSigned());

diff  --git a/clang/test/Analysis/ArrayBound/assumption-reporting.c 
b/clang/test/Analysis/ArrayBound/assumption-reporting.c
index d687886ada1ae..535e623baa815 100644
--- a/clang/test/Analysis/ArrayBound/assumption-reporting.c
+++ b/clang/test/Analysis/ArrayBound/assumption-reporting.c
@@ -39,14 +39,9 @@ int assumingBothPointerToMiddle(int arg) {
   // will speak about the "byte offset" measured from the beginning of the 
TenElements.
   int *p = TenElements + 2;
   int a = p[arg];
-  // FIXME: The following note does not appear:
-  //  {{Assuming byte offset is non-negative and less than 40, the extent of 
'TenElements'}}
-  // It seems that the analyzer "gives up" modeling this pointer arithmetics
-  // and says that `p[arg]` is just an UnknownVal (instead of calculating that
-  // it's equivalent to `TenElements[2+arg]`).
+  // expected-note@-1 {{Assuming byte offset is non-negative and less than 40, 
the extent of 'TenElements'}}
 
   int b = TenElements[arg]; // This is normal access, and only the lower bound 
is new.
-  // expected-note@-1 {{Assuming index is non-negative}}
   int c = TenElements[arg + 10];
   // expected-warning@-1 {{Out of bound access to memory after the end of 
'TenElements'}}
   // expected-note@-2 {{Access of 'TenElements' at an overflowing index, while 
it holds only 10 'int' elements}}

diff  --git a/clang/test/Analysis/lvalue_elements.c 
b/clang/test/Analysis/lvalue_elements.c
new file mode 100644
index 0..73b9c037d80d2
--- /dev/null
+++ b/clang/test/Analysis/lvalue_elements.c
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 -std=c11 -analyzer-checker=debug.ExprInspection 
-verify %s
+
+void clang_analyzer_dump(int*);
+
+const int const_index = 1;
+extern int unknown_index;
+extern int array[3];
+extern int matrix[3][3];
+
+int main(){
+
+// expected-warning@+1 {{&Element{array,1 S64b,int}}}
+clang_analyzer_dump(&array[const_index]);
+
+// expected-warning@+1 {{&Element{array,reg_$1,int}}}
+clang_analyzer_dump(&array[unknown_index]);
+
+// expected-warning@+1 {{&Element{Element{matrix,1 S64b,int[3]},1 
S64b,int}}}
+clang_analyzer_dump(&matrix[const_index][const_index]);
+
+// expected-warning@+1 {{&Element{Element{matrix,reg_$1,int[3]},1 S64b,int}}}
+clang_analyzer_dump(&matrix[unknown_index][const_index]);
+
+// expected-warning@+1 {{&Element{Element{matrix,1 S64b,int[3]},reg_$1,int}}}
+clang_analyzer_dump(&matrix[const_index][unknown_index]);
+
+// expected-warning@+1 {{&Element{Element{matrix,reg_$1,int[3]},reg_$1,int}}}
+clang_analyzer_dump(&matrix[unknown_index][unknown_index]);
+
+return 0;
+}



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


[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-03-31 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez updated 
https://github.com/llvm/llvm-project/pull/133055

From bf3f06cc99a1ac2460ffea741c0fe495f0778e70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Thu, 20 Mar 2025 13:23:25 +0100
Subject: [PATCH 1/4] [AMDGPU] Add "lds-buffer-load-insts" attribute for all
 targets < gfx11

This are used to restrict the availability of buffer_load_lds
intrinsics to targets that actually have this instructions.
---
 clang/lib/Basic/Targets/AMDGPU.cpp   |  2 +-
 clang/test/CodeGen/link-builtin-bitcode.c|  6 +++---
 .../CodeGenCXX/dynamic-cast-address-space.cpp|  4 ++--
 flang/test/Lower/OpenMP/target_cpu_features.f90  |  4 ++--
 llvm/lib/Target/AMDGPU/AMDGPU.td | 16 +++-
 .../Target/AMDGPU/AMDGPUInstructionSelector.cpp  |  3 ++-
 llvm/lib/Target/AMDGPU/GCNSubtarget.h|  3 +++
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp|  3 ++-
 llvm/lib/TargetParser/TargetParser.cpp   |  5 +
 9 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index a42b4589fb5ac..ed578890fc71f 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -260,7 +260,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   CUMode = !(GPUFeatures & llvm::AMDGPU::FEATURE_WGP);
-  for (auto F : {"image-insts", "gws"})
+  for (auto F : {"image-insts", "gws", "lds-buffer-load-insts"})
 ReadOnlyFeatures.insert(F);
   HalfArgsAndReturns = true;
 }
diff --git a/clang/test/CodeGen/link-builtin-bitcode.c 
b/clang/test/CodeGen/link-builtin-bitcode.c
index 470180efa4247..efce9d0af5d49 100644
--- a/clang/test/CodeGen/link-builtin-bitcode.c
+++ b/clang/test/CodeGen/link-builtin-bitcode.c
@@ -44,6 +44,6 @@ int bar() { return no_attr() + attr_in_target() + 
attr_not_in_target() + attr_in
 // CHECK-SAME: () #[[ATTR_INCOMPATIBLE:[0-9]+]] {
 
 // CHECK: attributes #[[ATTR_BAR]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
-// CHECK: attributes #[[ATTR_COMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
-// CHECK: attributes #[[ATTR_EXTEND]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+extended-image-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
-// CHECK: attributes #[[ATTR_INCOMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-gfx9-insts"
 }
+// CHECK: attributes #[[ATTR_COMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+lds-buffer-load-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
+// CHECK: attributes #[[ATTR_EXTEND]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+extended-image-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+lds-buffer-load-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
+// CHECK: attributes #[[ATTR_INCOMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx90a-insts,+gws,+image-insts,+lds-buffer-load-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavef

[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-03-31 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -0,0 +1,45 @@
+; RUN: split-file %s %t
+;
+; RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx1100 %t/struct.ll 2>&1 | 
FileCheck --ignore-case %s
+; RUN: not --crash llc -global-isel -mtriple=amdgcn -mcpu=gfx1100 %t/struct.ll 
2>&1 | FileCheck --ignore-case %s
+; RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx1100 %t/struct.ptr.ll 2>&1 | 
FileCheck --ignore-case --check-prefix=LEGALIZER-FAIL %s
+; RUN: not --crash llc -global-isel -mtriple=amdgcn -mcpu=gfx1100 
%t/struct.ptr.ll 2>&1 | FileCheck --ignore-case %s
+; RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx1100 %t/raw.ll 2>&1 | 
FileCheck --ignore-case %s
+; RUN: not --crash llc -global-isel -mtriple=amdgcn -mcpu=gfx1100 %t/raw.ll 
2>&1 | FileCheck --ignore-case %s
+; RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx1100 %t/raw.ptr.ll 2>&1 | 
FileCheck --ignore-case --check-prefix=LEGALIZER-FAIL %s
+; RUN: not --crash llc -global-isel -mtriple=amdgcn -mcpu=gfx1100 
%t/raw.ptr.ll 2>&1 | FileCheck --ignore-case %s
+;
+; CHECK: LLVM ERROR: Cannot select
+; LEGALIZER-FAIL: Do not know how to expand this operator's operand!
+
+;--- struct.ll
+declare void @llvm.amdgcn.struct.buffer.load.lds(<4 x i32> %rsrc, ptr 
addrspace(3) nocapture, i32 %size, i32 %vindex, i32 %voffset, i32 %soffset, i32 
%offset, i32 %aux)

jmmartinez wrote:

Thanks ! I didn't know they could be implicit.

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


[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,407 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5

arsenm wrote:

You don't have a backend vectorization test. This PR contains no clang changes. 
You should delete the clang test and replace it with a backend IR test 

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


[libclc] [libclc][amdgpu] Implement native_exp via builtin (PR #133696)

2025-03-31 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

Just realised I missed the brief - `native_exp2` should use the builtin, 
`native_exp` should continue to call `native_exp2`.

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


[clang-tools-extra] [clang-tidy][NFC][doc] improve "options" sections of `misc-`, `cppcore-` and other checks (PR #133694)

2025-03-31 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor updated 
https://github.com/llvm/llvm-project/pull/133694

>From 3f2086a843ccbc2dca5185199bbb91c366bcae06 Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Mon, 31 Mar 2025 13:12:23 +0300
Subject: [PATCH 1/2] [clang-tidy] improve docs for various checks

---
 .../checks/android/comparison-in-temp-failure-retry.rst  | 1 +
 .../docs/clang-tidy/checks/cert/msc51-cpp.rst| 2 +-
 .../docs/clang-tidy/checks/concurrency/mt-unsafe.rst | 3 +++
 .../clang-tidy/checks/cppcoreguidelines/no-malloc.rst| 6 +++---
 .../checks/cppcoreguidelines/owning-memory.rst   | 4 ++--
 .../pro-bounds-constant-array-index.rst  | 1 +
 .../checks/cppcoreguidelines/pro-type-member-init.rst| 1 +
 .../clang-tidy/checks/misc/coroutine-hostile-raii.rst| 8 
 .../docs/clang-tidy/checks/misc/include-cleaner.rst  | 4 ++--
 .../misc/non-private-member-variables-in-classes.rst | 9 +
 10 files changed, 23 insertions(+), 16 deletions(-)

diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst
index 93112ee2bea64..31cc72b0579c4 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst
@@ -41,3 +41,4 @@ Options
 .. option:: RetryMacros
 
A comma-separated list of the names of retry macros to be checked.
+   Default is `TEMP_FAILURE_RETRY`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst 
b/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst
index 1e0e34efe0a58..99e550aef0e7a 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst
@@ -37,4 +37,4 @@ Options
 .. option:: DisallowedSeedTypes
 
A comma-separated list of the type names which are disallowed.
-   Default values are ``time_t``, ``std::time_t``.
+   Default value is `time_t,std::time_t`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst 
b/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst
index 4e46ba1edc34f..337be787d962b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst
@@ -32,6 +32,9 @@ Examples:
 
 sleep(1); // implementation may use SIGALRM
 
+Options
+---
+
 .. option:: FunctionSet
 
   Specifies which functions in libc should be considered thread-safe,
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst
index 237520aa6690a..e3a162078a3b8 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst
@@ -35,14 +35,14 @@ Options
 .. option:: Allocations
 
Semicolon-separated list of fully qualified names of memory allocation 
functions.
-   Defaults to ``::malloc;::calloc``.
+   Defaults to `::malloc;::calloc`.
 
 .. option:: Deallocations
 
Semicolon-separated list of fully qualified names of memory allocation 
functions.
-   Defaults to ``::free``.
+   Defaults to `::free`.
 
 .. option:: Reallocations
 
Semicolon-separated list of fully qualified names of memory allocation 
functions.
-   Defaults to ``::realloc``.
+   Defaults to `::realloc`.
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst
index 3c91d09dda1f2..4fc49f8bd6eee 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst
@@ -95,14 +95,14 @@ Options
 
Semicolon-separated list of fully qualified names of legacy functions that 
create
resources but cannot introduce ``gsl::owner<>``.
-   Defaults to 
``::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile``.
+   Defaults to 
`::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile`.
 
 
 .. option:: LegacyResourceConsumers
 
Semicolon-separated list of fully qualified names of legacy functions 
expecting
resource owners as pointer arguments but cannot introduce ``gsl::owner<>``.
-   Defaults to ``::free;::realloc;::freopen;::fclose``.
+   Defaults to `::free;::realloc;::freopen;::fclose`.
 
 
 Limitations
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-constant-array-index.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-constant-array-index.rst
index 4e877676cf1fe..9b82e0c45a314 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-cons

[clang] [clang][modules] Guard against bad -fmodule-file mappings (#132059) (PR #133462)

2025-03-31 Thread Naveen Seth Hanig via cfe-commits

naveen-seth wrote:

Hi @ChuanqiXu9, @mpark, @shafik,

For context, here is how this PR would change clang's behavior when replicating 
the original crash in #132059:

The original crash, where the module `hello` wasn’t mapped to any BMI file, 
would now display the following:

```bash
clang++ -fmodule-file=std=std.pcm -fmodule-file=std=hello.pcm -stdlib=libc++ 
-std=c++23 main.ccp
```

```bash
main.cpp:2:8: fatal error: module 'hello' not found
2 | import hello;
  | ~~~^
1 error generated.
```

When assigning the matching BMI file to `hello`, but the wrong one to `std`:

```bash
clang++ -stdlib=libc++ -std=c++23 -fmodule-file=std=std.pcm 
-fmodule-file=std=hello.pcm -fmodule-file=hello=hello.pcm main.ccp
```

```bash
main.ccp:2:1: fatal error: tried loading module 'std' from 'hello.pcm' but 
found module 'hello' instead
2 | import hello;
  | ^
main.ccp:2:1: note: imported by module 'hello' in 'hello.pcm'
1 error generated.
```


Would you be able to review the PR?

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


[libclc] [libclc][amdgpu] Implement native_exp2 via AMD builtin (PR #133696)

2025-03-31 Thread Fraser Cormack via cfe-commits

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


[libclc] [libclc][amdgpu] Implement native_exp2 via AMD builtin (PR #133696)

2025-03-31 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> Just realised I missed the brief - `native_exp2` should use the builtin, 
> `native_exp` should continue to call `native_exp2`.

Done

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


[clang] [Clang][Cmake] fix libtool duplicate member name warnings (PR #133619)

2025-03-31 Thread Nikita Popov via cfe-commits

nikic wrote:

@farzonl Instructions in the sense of the instructions retired during 
compilation, not the number of instructions in the object file :)

I wouldn't expect the changes you made here to have any significant impact on 
build time. (I guess it might serialize the build more, maybe?)

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


[clang] [analyzer] Unknown array lvalue element in Store (PR #133381)

2025-03-31 Thread Balazs Benics via cfe-commits


@@ -511,13 +511,9 @@ SVal StoreManager::getLValueElement(QualType elementType, 
NonLoc Offset,
   // Only allow non-integer offsets if the base region has no offset itself.
   // FIXME: This is a somewhat arbitrary restriction. We should be using
   // SValBuilder here to add the two offsets without checking their types.
-  if (!isa(Offset)) {
-if (isa(BaseRegion->StripCasts()))
-  return UnknownVal();
-
+  if (!isa(Offset))

steakhal wrote:

I think it's good as-is. Thanks.

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


[clang] [clang][Sema] Fix typo in 'offsetof' diagnostics (PR #133448)

2025-03-31 Thread Michael Buch via cfe-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/133448

>From 732a9b611bb4b6c49a0b4bf1d616870ffa051d8f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 28 Mar 2025 13:29:27 +
Subject: [PATCH 1/2] [clang][Sema] Fix typo in 'offsetof' diagnostics

Before:
```
offset of on non-POD type
```
After:
```
offsetof on non-POD type
```
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  4 ++--
 clang/test/SemaCXX/ms_struct.cpp |  4 ++--
 clang/test/SemaCXX/offsetof-0x.cpp   |  2 +-
 clang/test/SemaCXX/offsetof.cpp  | 14 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1e900437d41ce..01bcc1804cb87 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7031,10 +7031,10 @@ def err_offsetof_incomplete_type : Error<
 def err_offsetof_record_type : Error<
   "offsetof requires struct, union, or class type, %0 invalid">;
 def err_offsetof_array_type : Error<"offsetof requires array type, %0 
invalid">;
-def ext_offsetof_non_pod_type : ExtWarn<"offset of on non-POD type %0">,
+def ext_offsetof_non_pod_type : ExtWarn<"offsetof on non-POD type %0">,
   InGroup;
 def ext_offsetof_non_standardlayout_type : ExtWarn<
-  "offset of on non-standard-layout type %0">, InGroup;
+  "offsetof on non-standard-layout type %0">, InGroup;
 def err_offsetof_bitfield : Error<"cannot compute offset of bit-field %0">;
 def err_offsetof_field_of_virtual_base : Error<
   "invalid application of 'offsetof' to a field of a virtual base">;
diff --git a/clang/test/SemaCXX/ms_struct.cpp b/clang/test/SemaCXX/ms_struct.cpp
index 995e424d1f876..0b1d8a844faca 100644
--- a/clang/test/SemaCXX/ms_struct.cpp
+++ b/clang/test/SemaCXX/ms_struct.cpp
@@ -25,7 +25,7 @@ struct B : public A {
 
 static_assert(__builtin_offsetof(B, d) == 12,
   "We can't allocate the bitfield into the padding under ms_struct");
-// expected-warning@-2 {{offset of on non-standard-layout type 'B'}}
+// expected-warning@-2 {{offsetof on non-standard-layout type 'B'}}
 
 struct C {
 #ifdef TEST_FOR_ERROR
@@ -39,5 +39,5 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}
+// expected-warning@-2 {{offsetof on non-standard-layout type 'C'}}
 
diff --git a/clang/test/SemaCXX/offsetof-0x.cpp 
b/clang/test/SemaCXX/offsetof-0x.cpp
index a3fe2fbbad72d..f6e295caa2600 100644
--- a/clang/test/SemaCXX/offsetof-0x.cpp
+++ b/clang/test/SemaCXX/offsetof-0x.cpp
@@ -11,7 +11,7 @@ struct P {
 };
 
 void f() {
-  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offset of on non-standard-layout type 'P'}}
+  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offsetof on non-standard-layout type 'P'}}
 }
 
 struct StandardLayout {
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index 1722b91fafc86..a8f33e0c49a59 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -11,12 +11,12 @@ struct P {
 };
 
 void f() {
-  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offset of on non-POD type 'P'}}
+  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offsetof on non-POD type 'P'}}
 }
 
 struct Base { int x; };
 struct Derived : Base { int y; };
-int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
+int o = __builtin_offsetof(Derived, x); // expected-warning{{offsetof on 
non-POD type}}
 
 const int o2 = sizeof(__builtin_offsetof(Derived, x));
 
@@ -51,9 +51,9 @@ struct Derived2 : public Base1, public Base2 {
   int z;
 };
 
-int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
-int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
-int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{offsetof on non-POD type 'Derived2'}}
+int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1]; // 
expected-warning{{offsetof on non-POD type 'Derived2'}}
+int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1]; // 
expected-warning{{offsetof on non-POD type 'Derived2'}}
 
 // offsetof referring to anonymous struct in base.
 // PR7769
@@ -66,7 +66,7 @@ struct foo {
 struct bar : public foo  {
 };
 
-int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'bar'}}
+int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 

[libclc] [libclc][amdgpu] Implement native_exp via builtin (PR #133696)

2025-03-31 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/133696

This came up during a discussion on #129679, which has been split out as a 
preparatory commit.

An example of the AMDGPU codegen is:

define <2 x float> @_Z10native_expDv2_f(<2 x float> %x) {
  %0 = extractelement <2 x float> %x, i64 0
  %mul.i4 = fmul afn float %0, 0x3FF715476000
  %1 = tail call afn float @llvm.amdgcn.exp2.f32(float %mul.i4)
  %vecinit = insertelement <2 x float> poison, float %1, i64 0
  %2 = extractelement <2 x float> %x, i64 1
  %mul.i = fmul afn float %2, 0x3FF715476000
  %3 = tail call afn float @llvm.amdgcn.exp2.f32(float %mul.i)
  %vecinit2 = insertelement <2 x float> %vecinit, float %3, i64 1
  ret <2 x float> %vecinit2
}

>From 7fd1ba5a68aa2580202e31e53d8c50e32bca91e2 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 31 Mar 2025 11:37:43 +0100
Subject: [PATCH] [libclc][amdgpu] Implement native_exp via builtin

This came up during a discussion on #129679, which has been split out as
a preparatory commit.

An example of the AMDGPU codegen is:

define <2 x float> @_Z10native_expDv2_f(<2 x float> %x) {
  %0 = extractelement <2 x float> %x, i64 0
  %mul.i4 = fmul afn float %0, 0x3FF715476000
  %1 = tail call afn float @llvm.amdgcn.exp2.f32(float %mul.i4)
  %vecinit = insertelement <2 x float> poison, float %1, i64 0
  %2 = extractelement <2 x float> %x, i64 1
  %mul.i = fmul afn float %2, 0x3FF715476000
  %3 = tail call afn float @llvm.amdgcn.exp2.f32(float %mul.i)
  %vecinit2 = insertelement <2 x float> %vecinit, float %3, i64 1
  ret <2 x float> %vecinit2
}
---
 libclc/amdgpu/lib/math/native_exp.cl  |  9 ++---
 libclc/amdgpu/lib/math/native_exp.inc | 11 ---
 2 files changed, 6 insertions(+), 14 deletions(-)
 delete mode 100644 libclc/amdgpu/lib/math/native_exp.inc

diff --git a/libclc/amdgpu/lib/math/native_exp.cl 
b/libclc/amdgpu/lib/math/native_exp.cl
index e62b79d4ec9fa..f6ce043946488 100644
--- a/libclc/amdgpu/lib/math/native_exp.cl
+++ b/libclc/amdgpu/lib/math/native_exp.cl
@@ -7,7 +7,10 @@
 
//===--===//
 
 #include 
+#include 
 
-#define __CLC_BODY 
-#define __FLOAT_ONLY
-#include 
+_CLC_OVERLOAD _CLC_DEF float native_exp(float val) {
+  return __builtin_amdgcn_exp2f(val * M_LOG2E_F);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, native_exp, float)
diff --git a/libclc/amdgpu/lib/math/native_exp.inc 
b/libclc/amdgpu/lib/math/native_exp.inc
deleted file mode 100644
index d7dbd888d2988..0
--- a/libclc/amdgpu/lib/math/native_exp.inc
+++ /dev/null
@@ -1,11 +0,0 @@
-//===--===//
-//
-// 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
-//
-//===--===//
-
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_exp(__CLC_GENTYPE val) {
-  return native_exp2(val * M_LOG2E_F);
-}

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


[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-03-31 Thread via cfe-commits


@@ -1011,6 +1011,31 @@ static Value *foldPHINodeOrSelectInst(Instruction &I) {
   return foldSelectInst(cast(I));
 }
 
+/// Returns a fixed vector type equivalent to the memory set by II or nullptr 
if
+/// unable to do so.
+static FixedVectorType *getVectorTypeFor(const MemSetInst &II,
+ const DataLayout &DL) {
+  const ConstantInt *Length = dyn_cast(II.getLength());
+  if (!Length)
+return nullptr;
+
+  APInt Val = Length->getValue();
+  if (Val.ugt(std::numeric_limits::max()))
+return nullptr;

macurtis-amd wrote:

>Is this just because the maximum number of vector elts?

Yes.

> Although we probably shouldn't be trying to promote anything that's anything 
> close to that big.

Is there a better limit that I should use instead?

I see other similar checks 
[here](https://github.com/llvm/llvm-project/blob/f4d25c498a20d73b9d3e4828023486a7b2591f38/llvm/lib/Transforms/Scalar/SROA.cpp#L2219)
 and 
[here](https://github.com/llvm/llvm-project/blob/f4d25c498a20d73b9d3e4828023486a7b2591f38/llvm/lib/Transforms/Scalar/SROA.cpp#L3196).

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


[clang] [clang][CodeGen] Make pragma-loop test more rboust (NFC) (PR #133707)

2025-03-31 Thread Ryotaro Kasuga via cfe-commits

https://github.com/kasuga-fj created 
https://github.com/llvm/llvm-project/pull/133707

pragma-loop.cpp contains tests for loop metadata generated via pragma 
directives. These tests were not working as (perhaps) expected. This is because 
the regex `.*` consumes multiple elements in metadata. For example, there was a 
check directive as follows.

```
// CHECK: ![[LOOP_9]] = distinct !{![[LOOP_9]], ![[WIDTH_8:.*]], 
![[FIXED_VEC]], ...}
```

In the above case, `[[WIDTH_8]]` would have been expected to match a node like 
`[[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}`. However, since there is 
no check directive to verify the contents of `[[WIDTH_8]]`, the regex `.*` 
consumed more than one element. There were other similar cases.

This patch fixes this problem by not using regex matcher in the metadata 
contents (except for follow-up metadata). Instead, it uses string variables 
whose contents are validated elsewhere.

Related:
https://github.com/llvm/llvm-project/pull/131985#discussion_r2014369699

>From b3bd68366dd71f11d0629c16584b1b9d4057d3f7 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga 
Date: Mon, 31 Mar 2025 11:36:35 +
Subject: [PATCH] [clang][CodeGen] Make pragma-loop test more rboust (NFC)

pragma-loop.cpp contains tests for loop metadata generated via pragma
directives. These tests were not working as (perhaps) expected. This is
because the regex `.*` consumes multiple elements in metadata. For
example,

```
![[LOOP_9]] = distinct !{![[LOOP_9]], ![[WIDTH_8:.*]], ![[FIXED_VEC]], ...}
```

`[[WIDTH_8]]` would have been expected to match a node like
`[[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}`. However, since
there is no check directive to verify the contents of `[[WIDTH_8]]`,
`[[WIDTH_8:.*]]` consumed more than one element. There were other
similar cases.

This patch fixes this problem by not using regex matcher in the metadata
contents. Instead, it uses string variables whose contents are validated
elsewhere.

Related:
https://github.com/llvm/llvm-project/pull/131985#discussion_r2014369699
---
 clang/test/CodeGenCXX/pragma-loop.cpp | 92 +++
 1 file changed, 51 insertions(+), 41 deletions(-)

diff --git a/clang/test/CodeGenCXX/pragma-loop.cpp 
b/clang/test/CodeGenCXX/pragma-loop.cpp
index 76bdcc4a5a9c9..4857299f1c037 100644
--- a/clang/test/CodeGenCXX/pragma-loop.cpp
+++ b/clang/test/CodeGenCXX/pragma-loop.cpp
@@ -203,60 +203,70 @@ void for_test_scalable_1(int *List, int Length) {
   }
 }
 
-// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], [[MP:![0-9]+]], 
![[UNROLL_FULL:.*]]}
-// CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
+// CHECK-DAG: ![[MP:[0-9]+]] = !{!"llvm.loop.mustprogress"}
 
-// CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2]], [[MP]], 
![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_8:.*]], 
![[FIXED_VEC:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
-// CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
-// CHECK: ![[DISTRIBUTE_DISABLE]] = !{!"llvm.loop.distribute.enable", i1 false}
-// CHECK: ![[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}
-// CHECK: ![[FIXED_VEC]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false}
-// CHECK: ![[INTERLEAVE_4]] = !{!"llvm.loop.interleave.count", i32 4}
-// CHECK: ![[VECTORIZE_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true}
+// CHECK-DAG: ![[UNROLL_DISABLE:[0-9]+]] = !{!"llvm.loop.unroll.disable"}
+// CHECK-DAG: ![[UNROLL_8:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 8}
+// CHECK-DAG: ![[UNROLL_24:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 24}
+// CHECK-DAG: ![[UNROLL_32:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 32}
+// CHECK-DAG: ![[UNROLL_FULL:[0-9]+]] = !{!"llvm.loop.unroll.full"}
 
-// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], [[MP]], ![[INTERLEAVE_4:.*]], 
![[VECTORIZE_ENABLE]], ![[FOLLOWUP_VECTOR_3:.*]]}
-// CHECK: ![[FOLLOWUP_VECTOR_3]] = !{!"llvm.loop.vectorize.followup_all", 
[[MP]], ![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
-// CHECK: ![[ISVECTORIZED]] = !{!"llvm.loop.isvectorized"}
-// CHECK: ![[UNROLL_8]] = !{!"llvm.loop.unroll.count", i32 8}
+// CHECK-DAG: ![[DISTRIBUTE_DISABLE:[0-9]+]] = 
!{!"llvm.loop.distribute.enable", i1 false}
 
-// CHECK: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[WIDTH_2:.*]], 
![[FIXED_VEC]], ![[INTERLEAVE_2:.*]], ![[VECTORIZE_ENABLE]]}
-// CHECK: ![[WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2}
-// CHECK: ![[INTERLEAVE_2]] = !{!"llvm.loop.interleave.count", i32 2}
+// CHECK-DAG: ![[INTERLEAVE_2:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 
2}
+// CHECK-DAG: ![[INTERLEAVE_4:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 
4}
+// CHECK-DAG: ![[INTERLEAVE_8:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 
8}
+// CHECK-DAG: ![[INTERLEAVE_10:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 
10}
+// CHECK-DAG: ![[INTERLEAVE_16:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 
16}
 
-// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[UNROLL_DISABLE:.*]], 
![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_1:.*]]}
-// CHECK: ![[WIDTH_1]]

[clang] [clang][CodeGen] Make pragma-loop test more rboust (NFC) (PR #133707)

2025-03-31 Thread Ryotaro Kasuga via cfe-commits

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


[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2025-03-31 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/121044

>From 77537d523bc164a86b46e83651500a4b37c0c3bf Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 24 Dec 2024 13:06:44 +0800
Subject: [PATCH 1/6] Reapply "[Clang] Improve diagnostics for expansion length
 mismatch"

... and "[Clang] fix missing initialization of original number of expansions"

This reverts commit acecf68c8b7c3c625cfa00f00f8ddc8f15baae44.

Co-authored-by: Matheus Izvekov 
---
 clang/include/clang/Sema/Sema.h   |   8 +-
 clang/include/clang/Sema/SemaInternal.h   |   2 +-
 clang/lib/AST/ExprCXX.cpp |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   2 +-
 clang/lib/Sema/SemaTemplateDeduction.cpp  |   7 +-
 clang/lib/Sema/SemaTemplateVariadic.cpp   | 340 +-
 clang/lib/Sema/TreeTransform.h|   1 +
 .../CXX/temp/temp.decls/temp.variadic/p5.cpp  |  50 +++
 .../SemaTemplate/cxx1z-fold-expressions.cpp   |   2 +-
 clang/test/SemaTemplate/pack-deduction.cpp|  51 ++-
 10 files changed, 285 insertions(+), 180 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9ac26d8728446..34f99b8adf467 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -232,9 +232,11 @@ void threadSafetyCleanup(BeforeSet *Cache);
 
 // FIXME: No way to easily map from TemplateTypeParmTypes to
 // TemplateTypeParmDecls, so we have this horrible PointerUnion.
-typedef std::pair,
-  SourceLocation>
-UnexpandedParameterPack;
+using UnexpandedParameterPack = std::pair<
+llvm::PointerUnion<
+const TemplateTypeParmType *, const SubstTemplateTypeParmPackType *,
+const SubstNonTypeTemplateParmPackExpr *, const NamedDecl *>,
+SourceLocation>;
 
 /// Describes whether we've seen any nullability information for the given
 /// file.
diff --git a/clang/include/clang/Sema/SemaInternal.h 
b/clang/include/clang/Sema/SemaInternal.h
index 95874077050a9..acf6c8146d70d 100644
--- a/clang/include/clang/Sema/SemaInternal.h
+++ b/clang/include/clang/Sema/SemaInternal.h
@@ -75,7 +75,7 @@ getDepthAndIndex(UnexpandedParameterPack UPP) {
   if (const auto *TTP = dyn_cast(UPP.first))
 return std::make_pair(TTP->getDepth(), TTP->getIndex());
 
-  return getDepthAndIndex(cast(UPP.first));
+  return getDepthAndIndex(cast(UPP.first));
 }
 
 class TypoCorrectionConsumer : public VisibleDeclConsumer {
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index c8d61e2cf3f26..afa3db950284b 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1734,7 +1734,7 @@ PackIndexingExpr *PackIndexingExpr::Create(
 NamedDecl *PackIndexingExpr::getPackDecl() const {
   if (auto *D = dyn_cast(getPackIdExpression()); D) {
 NamedDecl *ND = dyn_cast(D->getDecl());
-assert(ND && "exected a named decl");
+assert(ND && "expected a named decl");
 return ND;
   }
   assert(false && "invalid declaration kind in pack indexing expression");
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 96aac7871db1e..756937f44e948 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17589,7 +17589,7 @@ DeclResult Sema::ActOnTemplatedFriendTag(
   unsigned FriendDeclDepth = TempParamLists.front()->getDepth();
   for (UnexpandedParameterPack &U : Unexpanded) {
 if (getDepthAndIndex(U).first >= FriendDeclDepth) {
-  auto *ND = dyn_cast(U.first);
+  auto *ND = dyn_cast(U.first);
   if (!ND)
 ND = cast(U.first)->getDecl();
   Diag(U.second, diag::friend_template_decl_malformed_pack_expansion)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index e6ec4a7178e81..6af842121ae79 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -874,8 +874,11 @@ class PackDeductionScope {
   SmallVector Unexpanded;
   S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
   for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
-unsigned Depth, Index;
-std::tie(Depth, Index) = getDepthAndIndex(Unexpanded[I]);
+UnexpandedParameterPack U = Unexpanded[I];
+if (isa(U.first))
+  continue;
+auto [Depth, Index] = getDepthAndIndex(U);
 if (Depth == Info.getDeducedDepth())
   AddPack(Index);
   }
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index d9256dbd07d7a..d6c71ecec13b6 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -38,7 +38,7 @@ class CollectUnexpandedParameterPacksVisitor
   unsigned DepthLimit = (unsigned)-1;
 
 #ifndef NDEBUG
-bool ContainsIntermediatePacks = false;
+  bool ContainsIntermediatePacks = false;
 #endif
 
 void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation(

[libclc] [libclc][amdgpu] Implement native_exp via AMD builtin (PR #133696)

2025-03-31 Thread Fraser Cormack via cfe-commits

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


[clang] [Clang] add emit -Wignored-base-class-qualifiers diagnostic for cv-qualified base classes (PR #132116)

2025-03-31 Thread Aaron Ballman via cfe-commits


@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify
+// RUN: %clang_cc1 %s -std=c++11 -Wignored-base-class-qualifiers -verify

AaronBallman wrote:

Might as well improve test coverage a bit.
```
// RUN: %clang_cc1 %s -std=c++11 -Wignored-base-class-qualifiers -verify
// RUN: %clang_cc1 %s -std=c++11 -Wno-ignored-qualifiers -verify=good
// good-no-diagnostics
```
The second line should disable the warnings hence giving it a new prefix and 
`no-diagnostics` markings.

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


[clang] [Clang] add emit -Wignored-base-class-qualifiers diagnostic for cv-qualified base classes (PR #132116)

2025-03-31 Thread Aaron Ballman via cfe-commits


@@ -497,6 +497,7 @@ def GNUImaginaryConstant : 
DiagGroup<"gnu-imaginary-constant">;
 def IgnoredGCH : DiagGroup<"ignored-gch">;
 def IgnoredReferenceQualifiers : DiagGroup<"ignored-reference-qualifiers">;
 def IgnoredQualifiers : DiagGroup<"ignored-qualifiers", 
[IgnoredReferenceQualifiers]>;
+def IgnoredBaseClassQualifiers : DiagGroup<"ignored-base-class-qualifiers", 
[IgnoredReferenceQualifiers]>;

AaronBallman wrote:

```suggestion
def IgnoredBaseClassQualifiers : DiagGroup<"ignored-base-class-qualifiers", 
[IgnoredQualifiers]>;
```
Right? This has nothing to do with reference qualifiers and the original group 
was `-Wignored-qualifiers`.

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


[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-03-31 Thread Juan Manuel Martinez Caamaño via cfe-commits


@@ -260,7 +260,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   CUMode = !(GPUFeatures & llvm::AMDGPU::FEATURE_WGP);
-  for (auto F : {"image-insts", "gws"})
+  for (auto F : {"image-insts", "gws", "mem-to-lds-load-insts"})

jmmartinez wrote:

I wasn't aware there were `buffer_store_lds` instructions. They seem to be 
removed after gfx940 and not available on gfx10.

I've renamed the attribute to match "vmem-to-lds-load-insts".

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


[libclc] [libclc][amdgpu] Implement native_exp2 via AMD builtin (PR #133696)

2025-03-31 Thread Matt Arsenault via cfe-commits

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


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


[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/133472

>From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 28 Mar 2025 13:01:58 -0400
Subject: [PATCH 1/6] [C11] Implement WG14 N1285 (temporary lifetimes)

This feature largely models the same behavior as in C++11. It is
technically a breaking change between C99 and C11, so the paper is not
being backported to older language modes.

One difference between C++ and C is that things which are rvalues in C
are often lvalues in C++ (such as the result of a ternary operator or a
comma operator).
---
 clang/docs/ReleaseNotes.rst  |   9 +
 clang/lib/CodeGen/CGExpr.cpp |   4 +-
 clang/lib/Sema/Sema.cpp  |   5 +-
 clang/lib/Sema/SemaInit.cpp  |   2 +-
 clang/test/C/C11/n1285.c |  83 ++--
 clang/test/C/C11/n1285_1.c   | 212 +++
 clang/test/CodeGenObjC/property-array-type.m |   5 +-
 clang/www/c_status.html  |   2 +-
 8 files changed, 301 insertions(+), 21 deletions(-)
 create mode 100644 clang/test/C/C11/n1285_1.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b96780cec75d9..c51b3c44f3b3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -160,6 +160,15 @@ C23 Feature Support
   treated as if the compound literal were within the body rather than at file
   scope.
 
+C11 Feature Support
+^^^
+- Implemented `WG14 N1285 
`_
+  which introduces the notion of objects with a temporary lifetime. When an
+  expression resulting in an rvalue with structure or union type and that type
+  contains a member of array type, the expression result is an automatic 
storage
+  duration object with temporary lifetime which begins when the expression is
+  evaluated and ends at the evaluation of the containing full expression.
+
 Non-comprehensive list of changes in this release
 -
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 5943ff9294e1a..2328ad0def736 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -387,8 +387,8 @@ pushTemporaryCleanup(CodeGenFunction &CGF, const 
MaterializeTemporaryExpr *M,
   if (const RecordType *RT =
   E->getType()->getBaseElementTypeUnsafe()->getAs()) {
 // Get the destructor for the reference temporary.
-auto *ClassDecl = cast(RT->getDecl());
-if (!ClassDecl->hasTrivialDestructor())
+if (auto *ClassDecl = dyn_cast(RT->getDecl());
+ClassDecl && !ClassDecl->hasTrivialDestructor())
   ReferenceTemporaryDtor = ClassDecl->getDestructor();
   }
 
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 93a2d797679d4..4b573abb8efba 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -741,10 +741,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
   if (Kind == CK_ArrayToPointerDecay) {
 // C++1z [conv.array]: The temporary materialization conversion is applied.
 // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
-if (getLangOpts().CPlusPlus && E->isPRValue()) {
+if ((getLangOpts().C11 || getLangOpts().CPlusPlus) && E->isPRValue()) {
   // The temporary is an lvalue in C++98 and an xvalue otherwise.
   ExprResult Materialized = CreateMaterializeTemporaryExpr(
-  E->getType(), E, !getLangOpts().CPlusPlus11);
+  E->getType(), E,
+  getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus11);
   if (Materialized.isInvalid())
 return ExprError();
   E = Materialized.get();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 9814c3f456f0d..c47ea71cbafb5 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7654,7 +7654,7 @@ ExprResult Sema::TemporaryMaterializationConversion(Expr 
*E) {
   // FIXME: This means that AST consumers need to deal with "prvalues" that
   // denote materialized temporaries. Maybe we should add another ValueKind
   // for "xvalue pretending to be a prvalue" for C++98 support.
-  if (!E->isPRValue() || !getLangOpts().CPlusPlus11)
+  if (!E->isPRValue() || (!getLangOpts().CPlusPlus11 && !getLangOpts().C11))
 return E;
 
   // C++1z [conv.rval]/1: T shall be a complete type.
diff --git a/clang/test/C/C11/n1285.c b/clang/test/C/C11/n1285.c
index e7a9463e68103..c4fb199e33ae5 100644
--- a/clang/test/C/C11/n1285.c
+++ b/clang/test/C/C11/n1285.c
@@ -1,24 +1,81 @@
-// RUN: %clang_cc1 -verify=wrong -std=c99 %s
-// RUN: %clang_cc1 -verify=wrong -std=c11 %s
-// RUN: %clang_cc1 -verify=cpp -std=c++11 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify=good -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expect

[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-03-31 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> However, we do have some prior art -- we're not inventing the whole idea of 
> decl-merging from scratch right now. So maybe we can follow that prior art? 
> For example, top-level attributes on a struct's definition can be inherited 
> from a declaration in the same scope. It seems plausible that the same would 
> be true for redefinition, and then maybe we'd also extend that same 
> declaration-attribute-merging to fields within the struct.

Well, yes and no. We have prior art of doing this when we are checking valid 
redeclaration, but this is also about type merging as much as declaration 
merging. And with redefinitions, you run into problems you wouldn't be able to 
run into with redeclarations. e.g.,
```
struct S {
  char c;
  int x;
};

void func(struct S s) { ... } // Expects an unpacked structure

struct S {
  [[gnu::packed]] char c;
  [[gnu::packed]] int x;
};

int main() {
  struct S s = {};
  func(s); // Passes a packed structure
}
```
You couldn't run into this situation with redeclarations because you previously 
could not redeclare the structure fields.

The logic would sort of work out for standard attributes, at least by 
happenstance. There could be observable differences with `[[reproducible]]` and 
`[[unsequenced]]` but those are much more contrived situations given the nature 
of the attributes.

> So...yeah...

Yeah, there's a fair amount of moving parts. This is why I want to go with the 
most conservative approach of rejecting unless the attributes are the same. At 
some point, we'll get around to being able to tablegen more of this logic 
(likely leaning on the existing tablegen for some things like inheritable 
declaration attributes, and introducing new concepts like inheritable type 
attributes) and we can then relax the restrictions. But if we release in an 
unrestricted form, users *will* begin to rely on invalid code being accepted 
and we'll be in a pickle.

Curiously, GCC doesn't merge the standard attributes either, it seems to do 
last-one-wins: https://godbolt.org/z/j3W7ej5Kq

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


[clang] [RISCV][NFC] Make generated intrinsic records more human-readable (PR #133710)

2025-03-31 Thread Kito Cheng via cfe-commits


@@ -1196,36 +1196,93 @@ SmallVector 
parsePrototypes(StringRef Prototypes) {
   return PrototypeDescriptors;
 }
 
+#define STRINGIFY(NAME)
\
+  case NAME:   
\
+OS << #NAME;   
\
+break;
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum PolicyScheme PS) {
+  switch (PS) {
+STRINGIFY(SchemeNone)
+STRINGIFY(HasPassthruOperand)
+STRINGIFY(HasPolicyOperand)
+  }
+  return OS;
+}
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, enum RVVRequire Require) {
+  switch (Require) {
+STRINGIFY(RVV_REQ_RV64)
+STRINGIFY(RVV_REQ_Zvfhmin)
+STRINGIFY(RVV_REQ_Xsfvcp)
+STRINGIFY(RVV_REQ_Xsfvfnrclipxfqf)
+STRINGIFY(RVV_REQ_Xsfvfwmaccqqq)
+STRINGIFY(RVV_REQ_Xsfvqmaccdod)
+STRINGIFY(RVV_REQ_Xsfvqmaccqoq)
+STRINGIFY(RVV_REQ_Zvbb)
+STRINGIFY(RVV_REQ_Zvbc)
+STRINGIFY(RVV_REQ_Zvkb)
+STRINGIFY(RVV_REQ_Zvkg)
+STRINGIFY(RVV_REQ_Zvkned)
+STRINGIFY(RVV_REQ_Zvknha)
+STRINGIFY(RVV_REQ_Zvknhb)
+STRINGIFY(RVV_REQ_Zvksed)
+STRINGIFY(RVV_REQ_Zvksh)
+STRINGIFY(RVV_REQ_Zvfbfwma)
+STRINGIFY(RVV_REQ_Zvfbfmin)
+STRINGIFY(RVV_REQ_Zvfh)
+STRINGIFY(RVV_REQ_Experimental)
+  default:
+break;
+  }
+  return OS;
+}
+
+#undef STRINGIFY
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
+  const RequiredExtensions &Exts) {
+  OS << "{";
+  const char *Sep = "";
+  for (unsigned I = 0; I < RVV_REQ_NUM; I++) {
+if (Exts[I]) {
+  OS << Sep << static_cast(I);
+  Sep = ", ";
+}
+  }

kito-cheng wrote:

There is a small utils class to do that:
```suggestion
  ListSeparator LS;
  for (unsigned I = 0; I < RVV_REQ_NUM; I++) {
if (Exts[I]) {
  OS << LS << static_cast(I);
}
  }
```

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


[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2025-03-31 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 HEAD~1 HEAD --extensions h,cpp -- 
clang/include/clang/Sema/Sema.h clang/include/clang/Sema/SemaInternal.h 
clang/lib/AST/ExprCXX.cpp clang/lib/Sema/SemaConcept.cpp 
clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaTemplateDeduction.cpp 
clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h 
clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp 
clang/test/SemaTemplate/cxx1z-fold-expressions.cpp 
clang/test/SemaTemplate/pack-deduction.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 14f65d76c..035523864 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -39,21 +39,21 @@ class CollectUnexpandedParameterPacksVisitor
 
   bool ContainsIntermediatePacks = false;
 
-void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) {
-  if (auto *VD = dyn_cast(ND)) {
-// For now, the only problematic case is a generic lambda's templated
-// call operator, so we don't need to look for all the other ways we
-// could have reached a dependent parameter pack.
-auto *FD = dyn_cast(VD->getDeclContext());
-auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
-if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
-  return;
-  } else if (ND->isTemplateParameterPack() &&
- getDepthAndIndex(ND).first >= DepthLimit) {
+  void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) {
+if (auto *VD = dyn_cast(ND)) {
+  // For now, the only problematic case is a generic lambda's templated
+  // call operator, so we don't need to look for all the other ways we
+  // could have reached a dependent parameter pack.
+  auto *FD = dyn_cast(VD->getDeclContext());
+  auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
+  if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
 return;
-  }
+} else if (ND->isTemplateParameterPack() &&
+   getDepthAndIndex(ND).first >= DepthLimit) {
+  return;
+}
 
-  Unexpanded.push_back({ND, Loc});
+Unexpanded.push_back({ND, Loc});
 }
 
 void addUnexpanded(const TemplateTypeParmType *T,

``




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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -3688,27 +3708,95 @@ static Function *getFreshReductionFunc(Module &M) {
   ".omp.reduction.func", &M);
 }
 
-OpenMPIRBuilder::InsertPointOrErrorTy
-OpenMPIRBuilder::createReductions(const LocationDescription &Loc,
-  InsertPointTy AllocaIP,
-  ArrayRef ReductionInfos,
-  ArrayRef IsByRef, bool IsNoWait) {
-  assert(ReductionInfos.size() == IsByRef.size());
-  for (const ReductionInfo &RI : ReductionInfos) {
-(void)RI;
-assert(RI.Variable && "expected non-null variable");
-assert(RI.PrivateVariable && "expected non-null private variable");
-assert(RI.ReductionGen && "expected non-null reduction generator 
callback");
-assert(RI.Variable->getType() == RI.PrivateVariable->getType() &&
-   "expected variables and their private equivalents to have the same "
-   "type");
-assert(RI.Variable->getType()->isPointerTy() &&
-   "expected variables to be pointers");
+static Error populateReductionFunction(
+Function *ReductionFunc,
+ArrayRef ReductionInfos,
+IRBuilder<> &Builder, ArrayRef IsByRef, bool IsGPU) {
+  Module *Module = ReductionFunc->getParent();
+  BasicBlock *ReductionFuncBlock =
+  BasicBlock::Create(Module->getContext(), "", ReductionFunc);
+  Builder.SetInsertPoint(ReductionFuncBlock);
+  Value *LHSArrayPtr = nullptr;
+  Value *RHSArrayPtr = nullptr;
+  if (IsGPU) {
+// Need to alloca memory here and deal with the pointers before getting
+// LHS/RHS pointers out
+//
+Argument *Arg0 = ReductionFunc->getArg(0);
+Argument *Arg1 = ReductionFunc->getArg(1);
+Type *Arg0Type = Arg0->getType();
+Type *Arg1Type = Arg1->getType();
+
+Value *LHSAlloca =
+Builder.CreateAlloca(Arg0Type, nullptr, Arg0->getName() + ".addr");
+Value *RHSAlloca =
+Builder.CreateAlloca(Arg1Type, nullptr, Arg1->getName() + ".addr");
+Value *LHSAddrCast =
+Builder.CreatePointerBitCastOrAddrSpaceCast(LHSAlloca, Arg0Type);
+Value *RHSAddrCast =
+Builder.CreatePointerBitCastOrAddrSpaceCast(RHSAlloca, Arg1Type);
+Builder.CreateStore(Arg0, LHSAddrCast);
+Builder.CreateStore(Arg1, RHSAddrCast);
+LHSArrayPtr = Builder.CreateLoad(Arg0Type, LHSAddrCast);
+RHSArrayPtr = Builder.CreateLoad(Arg1Type, RHSAddrCast);
+  } else {
+LHSArrayPtr = ReductionFunc->getArg(0);
+RHSArrayPtr = ReductionFunc->getArg(1);
   }
 
+  unsigned NumReductions = ReductionInfos.size();
+  Type *RedArrayTy = ArrayType::get(Builder.getPtrTy(), NumReductions);
+
+  for (auto En : enumerate(ReductionInfos)) {
+const OpenMPIRBuilder::ReductionInfo &RI = En.value();
+Value *LHSI8PtrPtr = Builder.CreateConstInBoundsGEP2_64(
+RedArrayTy, LHSArrayPtr, 0, En.index());
+Value *LHSI8Ptr = Builder.CreateLoad(Builder.getPtrTy(), LHSI8PtrPtr);
+Value *LHSPtr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+LHSI8Ptr, RI.Variable->getType());
+Value *LHS = Builder.CreateLoad(RI.ElementType, LHSPtr);
+Value *RHSI8PtrPtr = Builder.CreateConstInBoundsGEP2_64(
+RedArrayTy, RHSArrayPtr, 0, En.index());
+Value *RHSI8Ptr = Builder.CreateLoad(Builder.getPtrTy(), RHSI8PtrPtr);
+Value *RHSPtr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+RHSI8Ptr, RI.PrivateVariable->getType());
+Value *RHS = Builder.CreateLoad(RI.ElementType, RHSPtr);
+Value *Reduced;
+OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
+RI.ReductionGen(Builder.saveIP(), LHS, RHS, Reduced);
+if (!AfterIP)
+  return AfterIP.takeError();
+
+Builder.restoreIP(*AfterIP);
+// TODO: Consider flagging an error.
+if (!Builder.GetInsertBlock())
+  return Error::success();

skatrak wrote:

If the reduction callback returns an invalid IP, that seems like an 
implementation bug rather than some error condition based on the input the user 
should know about. Maybe we should just assert in this case, since there are 
plenty of other places where we assume the returned IP is valid if the callback 
didn't return an `llvm::Error`.

Having said that, I can see there are also a few other places where the IP is 
checked, so feel free to leave this if you think it's a better option. At some 
point, we should probably decide on one single approach and apply it 
everywhere, though.

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -4434,10 +4497,24 @@ getKmpcForStaticLoopForType(Type *Ty, OpenMPIRBuilder 
*OMPBuilder,
 static void createTargetLoopWorkshareCall(
 OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType,
 BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg,
-Type *ParallelTaskPtr, Value *TripCount, Function &LoopBodyFn) {
-  Type *TripCountTy = TripCount->getType();
+Type *ParallelTaskPtr, Value *TripCountOrig, Function &LoopBodyFn) {
   Module &M = OMPBuilder->M;
   IRBuilder<> &Builder = OMPBuilder->Builder;
+  Value *TripCount = TripCountOrig;
+  // The trip count is 1 larger than it should be for GPU, this is because
+  // of how the deviceRTL functions work with clang. TODO: make the trip
+  // count consistent between both so we don't have to subtract one here.
+  if (OMPBuilder->Config.isGPU()) {
+Builder.restoreIP({InsertBlock, std::prev(InsertBlock->end())});
+LLVMContext &Ctx = M.getContext();
+Type *IVTy = TripCountOrig->getType();
+Type *InternalIVTy = IVTy->getIntegerBitWidth() <= 32
+ ? Type::getInt32Ty(Ctx)
+ : Type::getInt64Ty(Ctx);
+Constant *One = ConstantInt::get(InternalIVTy, 1);
+TripCount = Builder.CreateSub(TripCountOrig, One, "modified_trip_count");
+  }
+  Type *TripCountTy = TripCount->getType();

skatrak wrote:

You're already aware of this, but just to make sure we don't forget, this and 
changes to _mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir_, 
_mlir/test/Target/LLVMIR/omptarget-wsloop-collapsed.mlir_ and 
_mlir/test/Target/LLVMIR/omptarget-wsloop.mlir_ would have to be reverted if  
#133435 is merged.

Also, I think _llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp_ would probably 
make more sense to set `IsGPU=true` at that point.

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -4434,10 +4497,24 @@ getKmpcForStaticLoopForType(Type *Ty, OpenMPIRBuilder 
*OMPBuilder,
 static void createTargetLoopWorkshareCall(
 OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType,
 BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg,
-Type *ParallelTaskPtr, Value *TripCount, Function &LoopBodyFn) {
-  Type *TripCountTy = TripCount->getType();
+Type *ParallelTaskPtr, Value *TripCountOrig, Function &LoopBodyFn) {
   Module &M = OMPBuilder->M;
   IRBuilder<> &Builder = OMPBuilder->Builder;
+  Value *TripCount = TripCountOrig;
+  // The trip count is 1 larger than it should be for GPU, this is because
+  // of how the deviceRTL functions work with clang. TODO: make the trip
+  // count consistent between both so we don't have to subtract one here.
+  if (OMPBuilder->Config.isGPU()) {
+Builder.restoreIP({InsertBlock, std::prev(InsertBlock->end())});
+LLVMContext &Ctx = M.getContext();
+Type *IVTy = TripCountOrig->getType();
+Type *InternalIVTy = IVTy->getIntegerBitWidth() <= 32
+ ? Type::getInt32Ty(Ctx)
+ : Type::getInt64Ty(Ctx);
+Constant *One = ConstantInt::get(InternalIVTy, 1);
+TripCount = Builder.CreateSub(TripCountOrig, One, "modified_trip_count");
+  }
+  Type *TripCountTy = TripCount->getType();

skatrak wrote:

Either way, I think the comment you added is slightly misleading because the 
only code path in clang that would result in it producing calls to the 
`__kmpc_*_loop` DeviceRTL functions (code path that seems to be currently 
broken in several spots, so I have not been able to get it to successfully do 
it) also executes this, so every call to these DeviceRTL functions will 
subtract one, regardless of it being triggered by clang or flang.

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -4645,12 +4789,23 @@ initTargetDefaultAttrs(omp::TargetOp targetOp, 
Operation *capturedOp,
   (maxThreadsVal >= 0 && maxThreadsVal < combinedMaxThreadsVal))
 combinedMaxThreadsVal = maxThreadsVal;
 
+  // Calculate reduction data size, limited to single reduction variable for
+  // now.
+  int32_t reductionDataSize = 0;
+  if (isGPU && capturedOp) {
+if (auto teamsOp = castOrGetParentOfType(capturedOp))
+  reductionDataSize = getReductionDataSize(teamsOp);
+  }
+
   // Update kernel bounds structure for the `OpenMPIRBuilder` to use.
   attrs.ExecFlags = targetOp.getKernelExecFlags(capturedOp);
   attrs.MinTeams = minTeamsVal;
   attrs.MaxTeams.front() = maxTeamsVal;
   attrs.MinThreads = 1;
   attrs.MaxThreads.front() = combinedMaxThreadsVal;
+  attrs.ReductionDataSize = reductionDataSize;
+  if (attrs.ReductionDataSize != 0)
+attrs.ReductionBufferLength = 1024;

skatrak wrote:

Nit: Could you add some comment to document the reasoning for this size, or add 
a TODO to actually calculate this based on the actual reductions?

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -4554,6 +4679,25 @@ static std::optional extractConstInteger(Value 
value) {
   return std::nullopt;
 }
 
+static uint64_t getTypeByteSize(mlir::Type type, const DataLayout &dl) {
+  uint64_t sizeInBits = dl.getTypeSizeInBits(type);
+  uint64_t sizeInBytes = sizeInBits / 8;
+  return sizeInBytes;
+}
+
+template 
+static uint64_t getReductionDataSize(OpTy &op) {
+  if (op.getNumReductionVars() > 0) {
+assert(op.getNumReductionVars() &&

skatrak wrote:

Is the condition for the assert correct? By looking at the message, it seems 
like this is what it should check instead:
```suggestion
assert(op.getNumReductionVars() == 1 &&
```

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -1018,19 +1017,31 @@ allocReductionVars(T loop, ArrayRef 
reductionArgs,
   // variable allocated in the inlined region)
   llvm::Value *var = builder.CreateAlloca(
   moduleTranslation.convertType(reductionDecls[i].getType()));
-  deferredStores.emplace_back(phis[0], var);
 
-  privateReductionVariables[i] = var;
-  moduleTranslation.mapValue(reductionArgs[i], phis[0]);
-  reductionVariableMap.try_emplace(loop.getReductionVars()[i], phis[0]);
+  llvm::Type *ptrTy = llvm::PointerType::getUnqual(builder.getContext());

skatrak wrote:

Nit: It's a bit simpler, I think. Same thing in the 'else'.
```suggestion
  llvm::Type *ptrTy = builder.getPtrTy();
```

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -4161,6 +4247,37 @@ convertOmpDistribute(Operation &opInst, 
llvm::IRBuilderBase &builder,
   if (failed(checkImplementationStatus(opInst)))
 return failure();
 
+  /// Process teams op reduction in distribute if the reduction is contained in
+  /// the distribute op.
+  omp::TeamsOp teamsOp = opInst.getParentOfType();
+  bool doDistributeReduction =
+  teamsOp ? teamsReductionContainedInDistribute(teamsOp) : false;
+
+  DenseMap reductionVariableMap;

skatrak wrote:

Nit: This looks like it could be moved into the `if`.

It actually looks like it would make sense to make it local to 
`allocAndInitializeReductionVars`, since I can't see anywhere it being used 
outside of it, but that can be looked into later on.

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


[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -1714,6 +1727,43 @@ convertOmpSingle(omp::SingleOp &singleOp, 
llvm::IRBuilderBase &builder,
   return success();
 }
 
+static bool teamsReductionContainedInDistribute(omp::TeamsOp teamsOp) {
+  auto iface =
+  llvm::cast(teamsOp.getOperation());
+  // Check that all uses of the reduction block arg has the same distribute op
+  // parent.
+  llvm::SmallVector debugUses;
+  Operation *distOp = nullptr;
+  for (auto ra : iface.getReductionBlockArgs())
+for (auto &use : ra.getUses()) {
+  auto *useOp = use.getOwner();
+  // Ignore debug uses.
+  if (mlir::isa(useOp) ||
+  mlir::isa(useOp)) {

skatrak wrote:

```suggestion
  if (isa(useOp)) {
```

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


[clang] [X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512 and m[no-]evex512 (PR #132542)

2025-03-31 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> LGTM - but we need to add a full explanation to the clang/llvm release notes 
> explaining the avx10 changes/deprecations (and future removal).

Good reminder! Done.

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


[clang] ab7cee8 - [clang-format] Handle C++ keywords in other languages better (#132941)

2025-03-31 Thread via cfe-commits

Author: sstwcw
Date: 2025-03-31T13:54:49Z
New Revision: ab7cee8a0ecf29fdb47c64c8d431a694d63390d2

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

LOG: [clang-format] Handle C++ keywords in other languages better (#132941)

There is some code to make sure that C++ keywords that are identifiers
in the other languages are not treated as keywords.  Right now, the kind
is set to identifier, and the identifier info is cleared.  The latter is
probably so that the code for identifying C++ structures does not
recognize those structures by mistake when formatting a language that
does not have those structures.  But we did not find an instance where
the language can have the sequence of tokens, the code tries to parse
the structure as if it is C++ using the identifier info instead of the
token kind, but without checking for the language setting.  However,
there are places where the code checks whether the identifier info field
is null or not.  They are places where an identifier and a keyword are
treated the same way.  For example, the name of a function in
JavaScript.  This patch removes the lines that clear the identifier
info.  This way, a C++ keyword gets treated in the same way as an
identifier in those places.

JavaScript

New

```JavaScript
async function
union(
myparamnameiswaytoolng) {
}
```

Old

```JavaScript
async function
union(
myparamnameiswaytoolng) {
}
```

Java

New

```Java
enum union { ABC, CDE }
```

Old

```Java
enum
union { ABC, CDE }
```

Added: 


Modified: 
clang/lib/Format/FormatTokenLexer.cpp
clang/unittests/Format/FormatTestJS.cpp
clang/unittests/Format/FormatTestJava.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index eed54a11684b5..014b10b206d90 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -1306,15 +1306,12 @@ FormatToken *FormatTokenLexer::getNextToken() {
 FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_delete,
tok::kw_operator)) {
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
 } else if (Style.isJavaScript() &&
FormatTok->isOneOf(tok::kw_struct, tok::kw_union,
   tok::kw_operator)) {
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
 } else if (Style.isTableGen() && !Keywords.isTableGenKeyword(*FormatTok)) {
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
 }
   } else if (FormatTok->is(tok::greatergreater)) {
 FormatTok->Tok.setKind(tok::greater);

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 78c9f887a159b..3dae67fbcdfcb 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -828,12 +828,18 @@ TEST_F(FormatTestJS, AsyncFunctions) {
"}  ");
   // clang-format must not insert breaks between async and function, otherwise
   // automatic semicolon insertion may trigger (in particular in a class body).
+  auto Style = getGoogleJSStyleWithColumns(10);
   verifyFormat("async function\n"
"hello(\n"
"myparamnameiswaytoolng) {\n"
"}",
"async function hello(myparamnameiswaytoolng) {}",
-   getGoogleJSStyleWithColumns(10));
+   Style);
+  verifyFormat("async function\n"
+   "union(\n"
+   "myparamnameiswaytoolng) {\n"
+   "}",
+   Style);
   verifyFormat("class C {\n"
"  async hello(\n"
"  myparamnameiswaytoolng) {\n"
@@ -841,7 +847,7 @@ TEST_F(FormatTestJS, AsyncFunctions) {
"}",
"class C {\n"
"  async hello(myparamnameiswaytoolng) {} }",
-   getGoogleJSStyleWithColumns(10));
+   Style);
   verifyFormat("async function* f() {\n"
"  yield fetch(x);\n"
"}");
@@ -1338,15 +1344,16 @@ TEST_F(FormatTestJS, 
WrapRespectsAutomaticSemicolonInsertion) {
   // The following statements must not wrap, as otherwise the program meaning
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
-  verifyFormat("return a;", getGoogleJSStyleWithColumns(10));
-  verifyFormat("yield a;", getGoogleJSStyleWithColumns(10));
-  verifyFormat("return /* hello! */ a;", getGoogleJSStyleWithColumns(10));
-  verifyFormat("continue a;", getGoogleJSStyleWithColumns(10));
-  verifyFormat("continu

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits

https://github.com/skatrak commented:

Thank you Jan, I have a few superficial comments, but the approach LGTM.

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


[clang] [clang-format] Recognize wait fork in Verilog (PR #132042)

2025-03-31 Thread via cfe-commits

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


[clang] c7572ae - [X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512 and m[no-]evex512 (#132542)

2025-03-31 Thread via cfe-commits

Author: Phoebe Wang
Date: 2025-03-31T22:05:50+08:00
New Revision: c7572ae213d215d54a10c8a03db75cc01f6291bd

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

LOG: [X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512 and 
m[no-]evex512 (#132542)

The 256-bit maximum vector register size control was removed from AVX10
whitepaper, ref: https://cdrdv2.intel.com/v1/dl/getContent/784343

- Re-target m[no-]avx10.1 to enable AVX10.1 with 512-bit maximum vector
register size;
- Emit warning for mavx10.x-256, noting AVX10/256 is not supported;
- Emit warning for mavx10.x-512, noting to use m[no-]avx10.x instead;
- Emit warning for m[no-]evex512, noting AVX10/256 is not supported;

This patch only changes Clang driver behavior. The features
avx10.x-256/512 keep unchanged and will be removed in the next release.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Driver/x86-target-features.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4b8e09d051616..daad01919ecd4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -413,10 +413,13 @@ Hexagon Support
 X86 Support
 ^^^
 
-- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
-  options.
-- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
-  256 and 512 bit instructions.
+- The 256-bit maximum vector register size control was removed from
+  `AVX10 whitepaper _`.
+  * Re-target ``m[no-]avx10.1`` to enable AVX10.1 with 512-bit maximum vector 
register size.
+  * Emit warning for ``mavx10.x-256``, noting AVX10/256 is not supported.
+  * Emit warning for ``mavx10.x-512``, noting to use ``m[no-]avx10.x`` instead.
+  * Emit warning for ``m[no-]evex512``, noting AVX10/256 is not supported.
+  * The features avx10.x-256/512 keep unchanged and will be removed in the 
next release.
 
 Arm and AArch64 Support
 ^^^

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3af072242d039..89cb03cc33b98 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6409,11 +6409,11 @@ def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, 
Group, 
Group;
 def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group;
 def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias;
-def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
-def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Group;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, 
Group;
 def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, 
Group;
 def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, 
Group;
-def mavx10_2 : Flag<["-"], "mavx10.2">, Alias;
+def mavx10_2 : Flag<["-"], "mavx10.2">, Group;
 def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, 
Group;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;

diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 47c2c3e23f9fd..429b041c9c513 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -243,10 +243,18 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 assert((Version == "1" || Version == "2") && "Invalid AVX10 feature 
name.");
 
 if (Width == "") {
-  assert(IsNegative && "Only negative options can omit width.");
-  Features.push_back(Args.MakeArgString("-" + Name + "-256"));
+  if (IsNegative)
+Features.push_back(Args.MakeArgString("-" + Name + "-256"));
+  else
+Features.push_back(Args.MakeArgString("+" + Name + "-512"));
 } else {
-  assert((Width == "256" || Width == "512") && "Invalid vector length.");
+  if (Width == "512")
+D.Diag(diag::warn_drv_deprecated_arg) << Name << 1 << 
Name.drop_back(4);
+  else if (Width == "256")
+D.Diag(diag::warn_drv_deprecated_custom)
+<< Name << "because AVX10/256 is not supported and will be 
removed";
+  else
+assert((Width == "256" || Width == "512") && "Invalid vector length.");
   Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
 }
   }
@@ -275,6 +283,11 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << Triple.getTriple();
 
+if (A->getOption().matches(options::OPT_mevex512) ||
+A->getOption().matches(options::OPT_mno_evex512))
+  D.Diag(dia

[clang] [X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512 and m[no-]evex512 (PR #132542)

2025-03-31 Thread Phoebe Wang via cfe-commits

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


[clang] [clang][Sema] Fix typo in 'offsetof' diagnostics (PR #133448)

2025-03-31 Thread Aaron Ballman via cfe-commits

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

LGTM!

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


[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/133472

>From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 28 Mar 2025 13:01:58 -0400
Subject: [PATCH 1/7] [C11] Implement WG14 N1285 (temporary lifetimes)

This feature largely models the same behavior as in C++11. It is
technically a breaking change between C99 and C11, so the paper is not
being backported to older language modes.

One difference between C++ and C is that things which are rvalues in C
are often lvalues in C++ (such as the result of a ternary operator or a
comma operator).
---
 clang/docs/ReleaseNotes.rst  |   9 +
 clang/lib/CodeGen/CGExpr.cpp |   4 +-
 clang/lib/Sema/Sema.cpp  |   5 +-
 clang/lib/Sema/SemaInit.cpp  |   2 +-
 clang/test/C/C11/n1285.c |  83 ++--
 clang/test/C/C11/n1285_1.c   | 212 +++
 clang/test/CodeGenObjC/property-array-type.m |   5 +-
 clang/www/c_status.html  |   2 +-
 8 files changed, 301 insertions(+), 21 deletions(-)
 create mode 100644 clang/test/C/C11/n1285_1.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b96780cec75d9..c51b3c44f3b3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -160,6 +160,15 @@ C23 Feature Support
   treated as if the compound literal were within the body rather than at file
   scope.
 
+C11 Feature Support
+^^^
+- Implemented `WG14 N1285 
`_
+  which introduces the notion of objects with a temporary lifetime. When an
+  expression resulting in an rvalue with structure or union type and that type
+  contains a member of array type, the expression result is an automatic 
storage
+  duration object with temporary lifetime which begins when the expression is
+  evaluated and ends at the evaluation of the containing full expression.
+
 Non-comprehensive list of changes in this release
 -
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 5943ff9294e1a..2328ad0def736 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -387,8 +387,8 @@ pushTemporaryCleanup(CodeGenFunction &CGF, const 
MaterializeTemporaryExpr *M,
   if (const RecordType *RT =
   E->getType()->getBaseElementTypeUnsafe()->getAs()) {
 // Get the destructor for the reference temporary.
-auto *ClassDecl = cast(RT->getDecl());
-if (!ClassDecl->hasTrivialDestructor())
+if (auto *ClassDecl = dyn_cast(RT->getDecl());
+ClassDecl && !ClassDecl->hasTrivialDestructor())
   ReferenceTemporaryDtor = ClassDecl->getDestructor();
   }
 
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 93a2d797679d4..4b573abb8efba 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -741,10 +741,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
   if (Kind == CK_ArrayToPointerDecay) {
 // C++1z [conv.array]: The temporary materialization conversion is applied.
 // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
-if (getLangOpts().CPlusPlus && E->isPRValue()) {
+if ((getLangOpts().C11 || getLangOpts().CPlusPlus) && E->isPRValue()) {
   // The temporary is an lvalue in C++98 and an xvalue otherwise.
   ExprResult Materialized = CreateMaterializeTemporaryExpr(
-  E->getType(), E, !getLangOpts().CPlusPlus11);
+  E->getType(), E,
+  getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus11);
   if (Materialized.isInvalid())
 return ExprError();
   E = Materialized.get();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 9814c3f456f0d..c47ea71cbafb5 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7654,7 +7654,7 @@ ExprResult Sema::TemporaryMaterializationConversion(Expr 
*E) {
   // FIXME: This means that AST consumers need to deal with "prvalues" that
   // denote materialized temporaries. Maybe we should add another ValueKind
   // for "xvalue pretending to be a prvalue" for C++98 support.
-  if (!E->isPRValue() || !getLangOpts().CPlusPlus11)
+  if (!E->isPRValue() || (!getLangOpts().CPlusPlus11 && !getLangOpts().C11))
 return E;
 
   // C++1z [conv.rval]/1: T shall be a complete type.
diff --git a/clang/test/C/C11/n1285.c b/clang/test/C/C11/n1285.c
index e7a9463e68103..c4fb199e33ae5 100644
--- a/clang/test/C/C11/n1285.c
+++ b/clang/test/C/C11/n1285.c
@@ -1,24 +1,81 @@
-// RUN: %clang_cc1 -verify=wrong -std=c99 %s
-// RUN: %clang_cc1 -verify=wrong -std=c11 %s
-// RUN: %clang_cc1 -verify=cpp -std=c++11 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify=good -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expect

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,212 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -std=c99 -Wno-dangling -emit-llvm -o - %s | FileCheck %s 
--check-prefix=C99
+// RUN: %clang_cc1 -std=c11 -Wno-dangling -emit-llvm -o - %s | FileCheck %s 
--check-prefix=C11

AaronBallman wrote:

I've added those tests now.

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


[clang] 0794d5c - [clang][Sema] Fix typo in 'offsetof' diagnostics (#133448)

2025-03-31 Thread via cfe-commits

Author: Michael Buch
Date: 2025-03-31T14:56:29+01:00
New Revision: 0794d5cfba4b78b1bf7980a5f9434382a697df23

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

LOG: [clang][Sema] Fix typo in 'offsetof' diagnostics (#133448)

Before:
```
offset of on non-POD type
```
After:
```
offsetof on non-POD type
```

-

Co-authored-by: Aaron Ballman 

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/ms_struct.cpp
clang/test/SemaCXX/offsetof-0x.cpp
clang/test/SemaCXX/offsetof.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1e900437d41ce..b03926db8170a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7031,10 +7031,10 @@ def err_offsetof_incomplete_type : Error<
 def err_offsetof_record_type : Error<
   "offsetof requires struct, union, or class type, %0 invalid">;
 def err_offsetof_array_type : Error<"offsetof requires array type, %0 
invalid">;
-def ext_offsetof_non_pod_type : ExtWarn<"offset of on non-POD type %0">,
+def ext_offsetof_non_pod_type : ExtWarn<"'offsetof' on non-POD type %0">,
   InGroup;
 def ext_offsetof_non_standardlayout_type : ExtWarn<
-  "offset of on non-standard-layout type %0">, InGroup;
+  "'offsetof' on non-standard-layout type %0">, InGroup;
 def err_offsetof_bitfield : Error<"cannot compute offset of bit-field %0">;
 def err_offsetof_field_of_virtual_base : Error<
   "invalid application of 'offsetof' to a field of a virtual base">;

diff  --git a/clang/test/SemaCXX/ms_struct.cpp 
b/clang/test/SemaCXX/ms_struct.cpp
index 995e424d1f876..409350f2606a9 100644
--- a/clang/test/SemaCXX/ms_struct.cpp
+++ b/clang/test/SemaCXX/ms_struct.cpp
@@ -25,7 +25,7 @@ struct B : public A {
 
 static_assert(__builtin_offsetof(B, d) == 12,
   "We can't allocate the bitfield into the padding under ms_struct");
-// expected-warning@-2 {{offset of on non-standard-layout type 'B'}}
+// expected-warning@-2 {{'offsetof' on non-standard-layout type 'B'}}
 
 struct C {
 #ifdef TEST_FOR_ERROR
@@ -39,5 +39,5 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}
+// expected-warning@-2 {{'offsetof' on non-standard-layout type 'C'}}
 

diff  --git a/clang/test/SemaCXX/offsetof-0x.cpp 
b/clang/test/SemaCXX/offsetof-0x.cpp
index a3fe2fbbad72d..d8d417b6885c4 100644
--- a/clang/test/SemaCXX/offsetof-0x.cpp
+++ b/clang/test/SemaCXX/offsetof-0x.cpp
@@ -11,7 +11,7 @@ struct P {
 };
 
 void f() {
-  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offset of on non-standard-layout type 'P'}}
+  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{'offsetof' on non-standard-layout type 'P'}}
 }
 
 struct StandardLayout {

diff  --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index 1722b91fafc86..367a907f03775 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -11,12 +11,12 @@ struct P {
 };
 
 void f() {
-  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offset of on non-POD type 'P'}}
+  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{'offsetof' on non-POD type 'P'}}
 }
 
 struct Base { int x; };
 struct Derived : Base { int y; };
-int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
+int o = __builtin_offsetof(Derived, x); // expected-warning{{'offsetof' on 
non-POD type}}
 
 const int o2 = sizeof(__builtin_offsetof(Derived, x));
 
@@ -51,9 +51,9 @@ struct Derived2 : public Base1, public Base2 {
   int z;
 };
 
-int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
-int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
-int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{'offsetof' on non-POD type 'Derived2'}}
+int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1]; // 
expected-warning{{'offsetof' on non-POD type 'Derived2'}}
+int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1]; // 
expected-warning{{'offsetof' on non-POD type 'Derived2'}}
 
 // offsetof referring to anonymous struct in base.
 // PR7769
@@ -66,7 +66,7 @@ struct foo {
 struct bar : public foo  {
 };
 
-int anonstruct[__builtin_offsetof(bar

[clang] [clang-format] Handle C++ keywords in other languages better (PR #132941)

2025-03-31 Thread via cfe-commits

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


[clang] [clang-format] Recognize TableGen paste operator on separate line (PR #133722)

2025-03-31 Thread via cfe-commits

https://github.com/sstwcw created 
https://github.com/llvm/llvm-project/pull/133722

Formatting this piece of code made the program crash.

```
class TypedVecListRegOperand
: RegisterOperand">;
```

The line starting with the `#` was treated as a separate preprocessor directive 
line.  Then the code dereferenced a null pointer when it tried to continue 
parsing the first line that did not end in a semicolon.

Now the 2 problems are fixed.

>From b018450ed1a2901dd5b8cd5e146c1ce5d8613c86 Mon Sep 17 00:00:00 2001
From: sstwcw 
Date: Mon, 31 Mar 2025 13:50:02 +
Subject: [PATCH] [clang-format] Recognize TableGen paste operator on separate
 line

Formatting this piece of code made the program crash.

```
class TypedVecListRegOperand
: RegisterOperand">;
```

The line starting with the `#` was treated as a separate preprocessor
directive line.  Then the code dereferenced a null pointer when it tried
to continue parsing the first line that did not end in a semicolon.

Now the 2 problems are fixed.
---
 clang/lib/Format/TokenAnnotator.cpp   |  2 ++
 clang/lib/Format/UnwrappedLineParser.cpp  | 11 +--
 clang/unittests/Format/FormatTestTableGen.cpp |  6 ++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 17 +
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d87b3a6088bd8..278355aa58586 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -949,6 +949,8 @@ class AnnotatingParser {
   HashTok->setType(TT_Unknown);
   if (!parseTableGenValue(ParseNameMode))
 return false;
+  if (!CurrentToken)
+return true;
 }
 // In name mode, '{' is regarded as the end of the value.
 // See TGParser::ParseValue in TGParser.cpp
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index f7712bea01c2c..aa0c372d5e15f 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -4853,9 +4853,16 @@ void UnwrappedLineParser::readToken(int LevelDifference) 
{
 PreviousWasComment = FormatTok->is(tok::comment);
 
 while (!Line->InPPDirective && FormatTok->is(tok::hash) &&
-   (!Style.isVerilog() ||
-Keywords.isVerilogPPDirective(*Tokens->peekNextToken())) &&
FirstNonCommentOnLine) {
+  // In Verilog, the backtick is used for macro invocations. In TableGen,
+  // the single hash is used for the paste operator.
+  const FormatToken *Next = Tokens->peekNextToken();
+  assert(Next); // There is an EOF token at the end.
+  if ((Style.isVerilog() && !Keywords.isVerilogPPDirective(*Next)) ||
+  (Style.isTableGen() &&
+   !Next->isOneOf(tok::pp_define, tok::pp_ifdef, tok::pp_ifndef))) {
+break;
+  }
   distributeComments(Comments, FormatTok);
   Comments.clear();
   // If there is an unfinished unwrapped line, we flush the preprocessor
diff --git a/clang/unittests/Format/FormatTestTableGen.cpp 
b/clang/unittests/Format/FormatTestTableGen.cpp
index 92377c31f2e91..b78f79f20704f 100644
--- a/clang/unittests/Format/FormatTestTableGen.cpp
+++ b/clang/unittests/Format/FormatTestTableGen.cpp
@@ -218,6 +218,12 @@ TEST_F(FormatTestTableGen, PasteOperator) {
"  string Z = [\"Traring\", \"Paste\", \"Traring\", 
\"Paste\",\n"
"  \"Traring\", \"Paste\"]#;\n"
"}");
+  verifyFormat("def x#x {}", "def x\n"
+ "#x {}");
+  verifyFormat("def x#x {}", "def x\n"
+ "#\n"
+ "x {}");
+  verifyFormat("def x#x");
 }
 
 TEST_F(FormatTestTableGen, ClassDefinition) {
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index ac5e979aea071..fb8f5d30a669f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2832,6 +2832,23 @@ TEST_F(TokenAnnotatorTest, UnderstandTableGenTokens) {
   Tokens = Annotate("!cond");
   EXPECT_TOKEN(Tokens[0], tok::identifier, TT_TableGenCondOperator);
 
+  // The paste operator should not be treated as a preprocessor directive even
+  // if it is on a separate line.
+  Tokens = Annotate("def x\n"
+"#embed {}");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[2], tok::hash, TT_Unknown);
+  EXPECT_EQ(Tokens[1]->Next, Tokens[2]);
+  Tokens = Annotate("def x\n"
+"#define x\n"
+"#embed {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[2], tok::hash, TT_Unknown);
+  EXPECT_TOKEN(Tokens[5], tok::hash, TT_Unknown);
+  EXPECT_EQ(Tokens[1]->Next, Tokens[5]);
+
   auto AnnotateValue

[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-03-31 Thread via cfe-commits


@@ -0,0 +1,124 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes='sroa' -S | FileCheck %s
+target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
+
+%ptr_pair = type { ptr, ptr }
+
+%struct.a = type { <32 x i8> }
+define void @vector_promote_memset_a(ptr %0) {
+; CHECK-LABEL: @vector_promote_memset_a(
+; CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
+; CHECK-NEXT:[[TMP3:%.*]] = load i8, ptr [[TMP2]], align 1
+; CHECK-NEXT:[[DOTSROA_0_0_VEC_INSERT:%.*]] = insertelement <32 x i8> 
zeroinitializer, i8 [[TMP3]], i32 0
+; CHECK-NEXT:ret void
+;
+  %2 = alloca %struct.a, align 32

macurtis-amd wrote:

Updated to named values.

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


[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-03-31 Thread via cfe-commits


@@ -1011,6 +1011,31 @@ static Value *foldPHINodeOrSelectInst(Instruction &I) {
   return foldSelectInst(cast(I));
 }
 
+/// Returns a fixed vector type equivalent to the memory set by II or nullptr 
if
+/// unable to do so.
+static FixedVectorType *getVectorTypeFor(const MemSetInst &II,
+ const DataLayout &DL) {
+  const ConstantInt *Length = dyn_cast(II.getLength());
+  if (!Length)
+return nullptr;
+
+  APInt Val = Length->getValue();

macurtis-amd wrote:

Changed to suggestion

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


[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-03-31 Thread via cfe-commits


@@ -0,0 +1,124 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes='sroa' -S | FileCheck %s
+target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
+
+%ptr_pair = type { ptr, ptr }
+
+%struct.a = type { <32 x i8> }
+define void @vector_promote_memset_a(ptr %0) {
+; CHECK-LABEL: @vector_promote_memset_a(
+; CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
+; CHECK-NEXT:[[TMP3:%.*]] = load i8, ptr [[TMP2]], align 1
+; CHECK-NEXT:[[DOTSROA_0_0_VEC_INSERT:%.*]] = insertelement <32 x i8> 
zeroinitializer, i8 [[TMP3]], i32 0
+; CHECK-NEXT:ret void
+;
+  %2 = alloca %struct.a, align 32
+  %3 = alloca %ptr_pair, align 8
+  call void @llvm.memset.p0.i64(ptr align 32 %2, i8 0, i64 32, i1 false)
+
+  store ptr %2, ptr %3, align 8
+
+  %4 = getelementptr inbounds %ptr_pair, ptr %3, i64 0, i32 1
+  %5 = load ptr, ptr %0, align 8
+  store ptr %5, ptr %4, align 8
+
+  %6 = getelementptr inbounds i8, ptr %3, i32 8
+  %7 = load ptr, ptr %6, align 8
+
+  %8 = load i8, ptr %7, align 1
+  store i8 %8, ptr %2, align 32
+
+  ret void
+}
+
+%struct.b = type { <16 x i16> }
+define void @vector_promote_memset_b(ptr %0) {
+; CHECK-LABEL: @vector_promote_memset_b(
+; CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
+; CHECK-NEXT:[[TMP3:%.*]] = load i16, ptr [[TMP2]], align 1
+; CHECK-NEXT:[[DOTSROA_0_0_VEC_INSERT:%.*]] = insertelement <16 x i16> 
zeroinitializer, i16 [[TMP3]], i32 0
+; CHECK-NEXT:ret void
+;
+  %2 = alloca %struct.b, align 16
+  %3 = alloca %ptr_pair, align 8
+  call void @llvm.memset.p0.i64(ptr align 32 %2, i8 0, i64 32, i1 false)
+
+  store ptr %2, ptr %3, align 8
+
+  %4 = getelementptr inbounds %ptr_pair, ptr %3, i64 0, i32 1
+  %5 = load ptr, ptr %0, align 8
+  store ptr %5, ptr %4, align 8
+
+  %6 = getelementptr inbounds i8, ptr %3, i32 8
+  %7 = load ptr, ptr %6, align 8
+
+  %8 = load i16, ptr %7, align 1
+  store i16 %8, ptr %2, align 16
+
+  ret void
+}
+
+%struct.c = type { <4 x i32> }
+define void @vector_promote_memset_c(ptr %0) {
+; CHECK-LABEL: @vector_promote_memset_c(
+; CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
+; CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[TMP2]], align 1
+; CHECK-NEXT:[[DOTSROA_0_8_VEC_INSERT:%.*]] = insertelement <4 x i32> 
zeroinitializer, i32 [[TMP3]], i32 2
+; CHECK-NEXT:ret void
+;
+  %2 = alloca %struct.c, align 4
+  %3 = alloca %ptr_pair, align 8
+  call void @llvm.memset.p0.i64(ptr align 32 %2, i8 0, i64 16, i1 false)
+
+  store ptr %2, ptr %3, align 8
+
+  %4 = getelementptr inbounds %ptr_pair, ptr %3, i64 0, i32 1
+  %5 = load ptr, ptr %0, align 8
+  store ptr %5, ptr %4, align 8
+
+  %6 = getelementptr inbounds i8, ptr %3, i32 8
+  %7 = load ptr, ptr %6, align 8
+
+  %8 = load i32, ptr %7, align 1
+
+  %9 = getelementptr inbounds i32, ptr %2, i32 2
+  store i32 %8, ptr %9, align 4
+
+  ret void
+}
+
+; We currently prevent promotion if the vector would require padding
+%struct.d = type { <6 x i32> }
+define void @vector_promote_memset_d(ptr %0) {
+; CHECK-LABEL: @vector_promote_memset_d(
+; CHECK-NEXT:[[DOTSROA_2:%.*]] = alloca [3 x i32], align 4
+; CHECK-NEXT:call void @llvm.memset.p0.i64(ptr align 4 [[DOTSROA_2]], i8 
0, i64 12, i1 false)
+; CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
+; CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[TMP2]], align 1
+; CHECK-NEXT:ret void
+;
+  %2 = alloca %struct.d, align 4
+  %3 = alloca %ptr_pair, align 8
+  call void @llvm.memset.p0.i64(ptr align 32 %2, i8 0, i64 24, i1 false)
+
+  store ptr %2, ptr %3, align 8
+
+  %4 = getelementptr inbounds %ptr_pair, ptr %3, i64 0, i32 1
+  %5 = load ptr, ptr %0, align 8
+  store ptr %5, ptr %4, align 8
+
+  %6 = getelementptr inbounds i8, ptr %3, i32 8
+  %7 = load ptr, ptr %6, align 8
+
+  %8 = load i32, ptr %7, align 1
+
+  %9 = getelementptr inbounds i32, ptr %2, i32 2
+  store i32 %8, ptr %9, align 4
+
+  ret void
+}
+

macurtis-amd wrote:

Added test for upper limit

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


[clang] [X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512 and m[no-]evex512 (PR #132542)

2025-03-31 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/132542

>From 9a8d9b7d5d3f07685579c3d1336e146755bb7efa Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Sat, 22 Mar 2025 19:15:01 +0800
Subject: [PATCH 1/3] [X86][AVX10] Re-target mavx10.1 and emit warning for
 mavx10.x-256/512

The 256-bit maximum vector register size control was removed from AVX10
whitepaper, ref: https://cdrdv2.intel.com/v1/dl/getContent/784343

- Re-target m[no-]avx10.1 to enable AVX10.1 with 512-bit maximum vector 
register size;
- Emit warning for m[no-]avx10.x-256, noting AVX10/256 is not supported;
- Emit warning for m[no-]avx10.x-512, noting to use m[no-]avx10.x instead;

This patch only changes Clang driver behavior. The features avx10.x-256/512 
keep unchanged and will be removed in the next release.
---
 clang/include/clang/Driver/Options.td|  6 +++---
 clang/lib/Driver/ToolChains/Arch/X86.cpp | 14 +++---
 clang/test/Driver/x86-target-features.c  | 20 +++-
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fbd5cf632c350..7e380929aeabc 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6406,11 +6406,11 @@ def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, 
Group, 
Group;
 def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, 
Group;
 def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias;
-def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
-def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
+def mavx10_1 : Flag<["-"], "mavx10.1">, Group;
+def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, 
Group;
 def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, 
Group;
 def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, 
Group;
-def mavx10_2 : Flag<["-"], "mavx10.2">, Alias;
+def mavx10_2 : Flag<["-"], "mavx10.2">, Group;
 def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, 
Group;
 def mavx2 : Flag<["-"], "mavx2">, Group;
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 47c2c3e23f9fd..d4e7c1e7a5391 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -243,10 +243,18 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 assert((Version == "1" || Version == "2") && "Invalid AVX10 feature 
name.");
 
 if (Width == "") {
-  assert(IsNegative && "Only negative options can omit width.");
-  Features.push_back(Args.MakeArgString("-" + Name + "-256"));
+  if (IsNegative)
+Features.push_back(Args.MakeArgString("-" + Name + "-256"));
+  else
+Features.push_back(Args.MakeArgString("+" + Name + "-512"));
 } else {
-  assert((Width == "256" || Width == "512") && "Invalid vector length.");
+  if (Width == "512")
+D.Diag(diag::warn_drv_deprecated_arg) << Name << 1 << 
Name.drop_back(4);
+  else if (Width == "256")
+D.Diag(diag::warn_drv_deprecated_custom)
+<< Name << "because AVX10/256 is not supported and will be 
removed";
+  else
+assert((Width == "256" || Width == "512") && "Invalid vector length.");
   Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
 }
   }
diff --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index 18361251dcebc..370e56559d1d5 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -395,10 +395,10 @@
 // EVEX512: "-target-feature" "+evex512"
 // NO-EVEX512: "-target-feature" "-evex512"
 
-// RUN: not %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=UNSUPPORT-AVX10 %s
-// RUN: not %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=UNSUPPORT-AVX10 %s
-// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_256 %s
-// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=AVX10_1_512 %s
+// RUN: %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 
-Werror | FileCheck -check-prefix=AVX10_1_512 %s
+// RUN: %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 
-Werror | FileCheck -check-prefix=NO-AVX10_1 %s
+// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefixes=AVX10_1_256,WARN-AVX10-256 %s
+// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefixes=AVX10_1_512,WARN-AVX10-512 %s
 // RUN: %clang --target=i386 -mavx10.1-256 -mavx10.1-512 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=AVX10_1_512 %s
 // RUN: %clang --target=i386 -mavx10.1-512 -mavx10.1-256 %s -### -o %t.o 2>&1 
| FileCheck -check-prefix=AVX10_1_256 %s
 // RUN: not %clang --target=i386 -march=i386 -mavx10.1-128 %s -#

[clang] [libcxx] [Clang] Add __builtin_common_reference (PR #121199)

2025-03-31 Thread Nikolas Klauser via cfe-commits

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


[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-03-31 Thread via cfe-commits


@@ -1011,6 +1011,31 @@ static Value *foldPHINodeOrSelectInst(Instruction &I) {
   return foldSelectInst(cast(I));
 }
 
+/// Returns a fixed vector type equivalent to the memory set by II or nullptr 
if
+/// unable to do so.
+static FixedVectorType *getVectorTypeFor(const MemSetInst &II,
+ const DataLayout &DL) {
+  const ConstantInt *Length = dyn_cast(II.getLength());
+  if (!Length)
+return nullptr;
+
+  APInt Val = Length->getValue();
+  if (Val.ugt(std::numeric_limits::max()))
+return nullptr;

macurtis-amd wrote:

I decided to move the limit from 
[checkVectorTypeForPromotion](https://github.com/llvm/llvm-project/blob/f4d25c498a20d73b9d3e4828023486a7b2591f38/llvm/lib/Transforms/Scalar/SROA.cpp#L2219)
 into a helper function and use it here.

Let me know if there is a more sensible limit to use instead.

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


[clang] [clang][CodeGen] Add range metadata for atomic load of boolean type. #131476 (PR #133546)

2025-03-31 Thread Jan Górski via cfe-commits

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


[clang] 4007de0 - Enable unnecessary-virtual-specifier by default (#133265)

2025-03-31 Thread via cfe-commits

Author: Devon Loehr
Date: 2025-03-31T16:28:53+02:00
New Revision: 4007de00a0574141695ace7a8d34aaf740a2c2e4

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

LOG: Enable unnecessary-virtual-specifier by default (#133265)

This turns on the unnecessary-virtual-specifier warning in general, but
disables it when building LLVM. It also tweaks the warning description
to be slightly more accurate.

Background: I've been working on cleaning up this warning in two
codebases: LLVM and chromium (plus its dependencies). The chromium
cleanup has been straightforward. Git archaeology shows that there are
two reasons for the warnings: classes to which `final` was added after
they were initially committed, and classes with virtual destructors that
nobody remarks on. Presumably the latter case is because people are just
very used to destructors being virtual.

The LLVM cleanup was more surprising: I discovered that we have an [old
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers)
about including out-of-line virtual functions in every class with a
vtable, even `final` ones. This means our codebase has many virtual
"anchor" functions which do nothing except control where the vtable is
emitted, and which trigger the warning. I looked into alternatives to
satisfy the policy, such as using destructors instead of introducing a
new function, but it wasn't clear if they had larger implications.

Overall, it seems like the warning is genuinely useful in most codebases
(evidenced by chromium and its dependencies), and LLVM is an unusual
case. Therefore we should enable the warning by default, and turn it off
only for LLVM builds.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
clang/test/CXX/class/p2-0x.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp
clang/test/SemaCXX/warn-final-dtor-non-final-class.cpp
llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index b9f08d96151c9..e6e9ebbc2c304 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -377,13 +377,12 @@ def CXX11WarnSuggestOverride : 
DiagGroup<"suggest-override">;
 def WarnUnnecessaryVirtualSpecifier : 
DiagGroup<"unnecessary-virtual-specifier"> {
   code Documentation = [{
 Warns when a ``final`` class contains a virtual method (including virtual
-destructors). Since ``final`` classes cannot be subclassed, their methods
-cannot be overridden, and hence the ``virtual`` specifier is useless.
+destructors) that does not override anything. Since ``final`` classes cannot be
+subclassed, their methods cannot be overridden, so there is no point to
+introducing new ``virtual`` methods.
 
 The warning also detects virtual methods in classes whose destructor is
 ``final``, for the same reason.
-
-The warning does not fire on virtual methods which are also marked 
``override``.
   }];
 }
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b03926db8170a..5e45482584946 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2733,7 +2733,7 @@ def note_final_dtor_non_final_class_silence : Note<
   "mark %0 as '%select{final|sealed}1' to silence this warning">;
 def warn_unnecessary_virtual_specifier : Warning<
   "virtual method %0 is inside a 'final' class and can never be overridden">,
-  InGroup, DefaultIgnore;
+  InGroup;
 
 // C++11 attributes
 def err_repeat_attribute : Error<"%0 attribute cannot be repeated">;

diff  --git 
a/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp 
b/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
index 4209db14eaa52..106091b240af6 100644
--- 
a/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
+++ 
b/clang/test/Analysis/Checkers/WebKit/ref-cntbl-crtp-base-no-virtual-dtor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor 
-verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.RefCntblBaseVirtualDtor 
-verify %s -Wno-unnecessary-virtual-specifier
 
 #include "mock-types.h"
 

diff  --git a/clang/test/CXX/class/p2-0x.cpp b/clang/test/CXX/class/p2-0x.cpp
index 5b39e0ada7e2c..2043486457baf 100644
--- a/clang/test/CXX/class/p2-0x.cpp
+++ b/clang/test/CXX/class/p2-0x.cpp
@@ -28,7 +28,7 @@ struct C : A { }; // expected-error {{base 'A' is marked 
'final'}}
 
 namespace Te

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-31 Thread Hans Wennborg via cfe-commits

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


[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread YunQiang Su via cfe-commits


@@ -0,0 +1,1059 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5

wzssyqa wrote:

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

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


[clang] [Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/133426

>From 464aaf0944cac75ccc689ebb82e08554c12c6340 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Thu, 27 Mar 2025 16:25:07 +0100
Subject: [PATCH 1/6] [Clang][WIP][RFC] Bypass TAD during overload resolution
 if a perfect match exists

This implements the same overload resolution behavior as GCC,
as described in https://wg21.link/p3606 (section 1-2, not 3)

If during overload resolution, there is a non-template candidate
that would be always be picked - because each of the argument
is a perfect match (ie the source and target types are the same),
we do not perform deduction for any template candidate
that might exists.

The goal is to be able to merge #122423 without being too disruptive.

This change means that the selection of the best viable candidate and
template argument deduction become interleaved.

To avoid rewriting half of Clang we store in `OverloadCandidateSet`
enough information to be able to deduce template candidates from
`OverloadCandidateSet::BestViableFunction`. Which means
the lifetime of any object used by template argument must outlive
a call to `Add*Template*Candidate`.

This two phase resolution is not performed for some initialization
as there are cases where template candidate are better match
in these cases per the standard. It's also bypassed for code completion.

The change has a nice impact on compile times
https://llvm-compile-time-tracker.com/compare.php?from=719b029c16eeb1035da522fd641dfcc4cee6be74&to=bf7041045c9408490c395230047c5461de72fc39&stat=instructions%3Au

Fixes #62096
Fixes #74581
---
 clang/include/clang/Sema/Overload.h | 130 +-
 clang/include/clang/Sema/Sema.h |  25 +++
 clang/lib/Sema/SemaCodeComplete.cpp |   6 +-
 clang/lib/Sema/SemaInit.cpp |  11 +-
 clang/lib/Sema/SemaOverload.cpp | 263 +---
 5 files changed, 395 insertions(+), 40 deletions(-)

diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 6e08762dcc6d7..2cc7e1809e26c 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 
@@ -743,6 +744,12 @@ class Sema;
   Standard.setAllToTypes(T);
 }
 
+bool isPerfect(const ASTContext &C) const {
+  return (isStandard() && Standard.isIdentityConversion() &&
+  C.hasSameType(Standard.getFromType(), Standard.getToType(2))) ||
+ getKind() == StaticObjectArgumentConversion;
+}
+
 // True iff this is a conversion sequence from an initializer list to an
 // array or std::initializer.
 bool hasInitializerListContainerType() const {
@@ -979,6 +986,18 @@ class Sema;
   return false;
 }
 
+bool isPerfectMatch(const ASTContext &Ctx) const {
+  if (!Viable)
+return false;
+  for (auto &C : Conversions) {
+if (!C.isInitialized())
+  return false;
+if (!C.isPerfect(Ctx))
+  return false;
+  }
+  return true;
+}
+
 bool TryToFixBadConversion(unsigned Idx, Sema &S) {
   bool CanFix = Fix.tryToFixConversion(
   Conversions[Idx].Bad.FromExpr,
@@ -1015,6 +1034,61 @@ class Sema;
   RewriteKind(CRK_None) {}
   };
 
+  struct NonDeducedConversionTemplateOverloadCandidate {
+FunctionTemplateDecl *FunctionTemplate;
+DeclAccessPair FoundDecl;
+CXXRecordDecl *ActingContext;
+Expr *From;
+QualType ToType;
+
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowObjCConversionOnExplicit : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowExplicit : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowResultConversion : 1;
+  };
+
+  struct NonDeducedMethodTemplateOverloadCandidate {
+FunctionTemplateDecl *FunctionTemplate;
+DeclAccessPair FoundDecl;
+ArrayRef Args;
+CXXRecordDecl *ActingContext;
+Expr::Classification ObjectClassification;
+QualType ObjectType;
+
+OverloadCandidateParamOrder PO;
+LLVM_PREFERRED_TYPE(bool)
+unsigned SuppressUserConversions : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned PartialOverloading : 1;
+  };
+
+  struct NonDeducedFunctionTemplateOverloadCandidate {
+FunctionTemplateDecl *FunctionTemplate;
+DeclAccessPair FoundDecl;
+ArrayRef Args;
+
+CallExpr::ADLCallKind IsADLCandidate;
+OverloadCandidateParamOrder PO;
+LLVM_PREFERRED_TYPE(bool)
+unsigned SuppressUserConversions : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned PartialOverloading : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowExplicit : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned AggregateCandidateDeduction : 1;
+  };
+
+  using NonDeducedTemplateOverloadCandidate =
+  std::variant;
+
+  static_assert(
+  std::is_trivially_destructible_v);
+
   /// OverloadCandidateSet - A set of overload candidates, used in C++
   /// overload resolution (C++ 

[clang] [Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits

cor3ntin wrote:

I could use help understanding how to fix 
`clang/test/Templight/templight-empty-entries-fix.cpp` - it always eludes me 
how to make FileCheck happy @AaronBallman  

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


[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-03-31 Thread via cfe-commits

macurtis-amd wrote:

@arsenm Any recommendations for appeasing the [undef 
deprecator](https://github.com/llvm/llvm-project/pull/133301#issuecomment-2759145421)?

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


[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)

2025-03-31 Thread Nathan Gauër via cfe-commits


@@ -57,22 +58,37 @@ void main(unsigned GI : SV_GroupIndex) {
 // CHECK:  define void @main()
 // CHECK-NEXT: entry:
 // Verify destructor is emitted
-// NOINLINE-NEXT:   call void @_GLOBAL__sub_I_GlobalDestructors.hlsl()
-// NOINLINE-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
-// NOINLINE-NEXT:   call void @_Z4mainj(i32 %0)
-// NOINLINE-NEXT:   call void @_GLOBAL__D_a()
-// NOINLINE-NEXT:   ret void
+// NOINLINE-DXIL-NEXT:   call void @_GLOBAL__sub_I_GlobalDestructors.hlsl()
+// NOINLINE-DXIL-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+// NOINLINE-DXIL-NEXT:   call void @_Z4mainj(i32 %0)
+// NOINLINE-DXIL-NEXT:   call void @_GLOBAL__D_a()
+// NOINLINE-DXIL-NEXT:   ret void
+
+// NOINLINE-SPIRV-NEXT:   %0 = call token 
@llvm.experimental.convergence.entry()
+// NOINLINE-SPIRV-NEXT:   call spir_func void 
@_GLOBAL__sub_I_GlobalDestructors.hlsl() [ "convergencectrl"(token %0) ]

Keenuts wrote:

Yes it does. If it didn't, LLVM would complain there there is a mix of 
controlled and un-controlled convergence (hence why I noticed I had to fix this 
:) )

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


[clang] 60199ee - [clang] Use DenseMap::insert_range (NFC) (#133655)

2025-03-31 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-03-30T22:57:25-07:00
New Revision: 60199ee5396c2242c7d3cfa882e28312e6895c2a

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

LOG: [clang] Use DenseMap::insert_range (NFC) (#133655)

Added: 


Modified: 
clang/lib/AST/VTableBuilder.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 18893b996b5d6..6c97b8718c65e 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -3736,8 +3736,7 @@ void 
MicrosoftVTableContext::computeVTableRelatedInformation(
 }
   }
 
-  MethodVFTableLocations.insert(NewMethodLocations.begin(),
-NewMethodLocations.end());
+  MethodVFTableLocations.insert_range(NewMethodLocations);
   if (Context.getLangOpts().DumpVTableLayouts)
 dumpMethodLocations(RD, NewMethodLocations, llvm::outs());
 }
@@ -3824,8 +3823,7 @@ const VirtualBaseInfo 
&MicrosoftVTableContext::computeVBTableRelatedInformation(
 // virtual bases come first so that the layout is the same.
 const VirtualBaseInfo &BaseInfo =
 computeVBTableRelatedInformation(VBPtrBase);
-VBI->VBTableIndices.insert(BaseInfo.VBTableIndices.begin(),
-   BaseInfo.VBTableIndices.end());
+VBI->VBTableIndices.insert_range(BaseInfo.VBTableIndices);
   }
 
   // New vbases are added to the end of the vbtable.

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 5dbd50be6ca1a..43345da268868 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -853,8 +853,7 @@ void CodeGenModule::Release() {
   if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
 EmitModuleInitializers(Primary);
   EmitDeferred();
-  DeferredDecls.insert(EmittedDeferredDecls.begin(),
-   EmittedDeferredDecls.end());
+  DeferredDecls.insert_range(EmittedDeferredDecls);
   EmittedDeferredDecls.clear();
   EmitVTablesOpportunistically();
   applyGlobalValReplacements();

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 52dec2013a24f..52d922abbcaec 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1099,7 +1099,7 @@ Expected getSymbolsFromBitcode(MemoryBufferRef 
Buffer, OffloadKind Kind,
 
   // If the file gets extracted we update the table with the new symbols.
   if (ShouldExtract)
-Syms.insert(std::begin(TmpSyms), std::end(TmpSyms));
+Syms.insert_range(TmpSyms);
 
   return ShouldExtract;
 }
@@ -1154,7 +1154,7 @@ Expected getSymbolsFromObject(const ObjectFile 
&Obj, OffloadKind Kind,
 
   // If the file gets extracted we update the table with the new symbols.
   if (ShouldExtract)
-Syms.insert(std::begin(TmpSyms), std::end(TmpSyms));
+Syms.insert_range(TmpSyms);
 
   return ShouldExtract;
 }



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


[clang] [analyzer] Unknown array lvalue element in Store (PR #133381)

2025-03-31 Thread Donát Nagy via cfe-commits


@@ -511,13 +511,9 @@ SVal StoreManager::getLValueElement(QualType elementType, 
NonLoc Offset,
   // Only allow non-integer offsets if the base region has no offset itself.
   // FIXME: This is a somewhat arbitrary restriction. We should be using
   // SValBuilder here to add the two offsets without checking their types.
-  if (!isa(Offset)) {
-if (isa(BaseRegion->StripCasts()))
-  return UnknownVal();
-
+  if (!isa(Offset))

NagyDonat wrote:

My current feeling is that the current (nested `ElementRegion`) model is the 
better one and the `FIXME` comment should be removed, but I'm postponing this 
question into a low priority „note to self”. Perhaps eventually I'll revisit 
this (and presumably just delete the FIXME) when I have nothing better to do 
(or when some other restructuring affects the modeling of regions). 

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


[clang] [sanitizer][CFI] Add support to build CFI with sanitize-coverage (PR #131296)

2025-03-31 Thread Maxim Zhukov via cfe-commits

Mephistophiles wrote:

@vitalybuka ping :) Can I merge this PR?

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


[clang] [clang-format] add option to control bin-packing keyworded parameters (PR #131605)

2025-03-31 Thread Eugene Shalygin via cfe-commits


@@ -3783,10 +3823,20 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
 static bool isFunctionDeclarationName(const LangOptions &LangOpts,
   const FormatToken &Current,
   const AnnotatedLine &Line,
+  const FormatStyle &Style,
   FormatToken *&ClosingParen) {
   if (Current.is(TT_FunctionDeclarationName))
 return true;
 
+  if (Current.is(TT_FunctionLikeOrFreestandingMacro) &&
+  std::find_if(
+  Style.KeywordedFunctionLikeMacros.begin(),
+  Style.KeywordedFunctionLikeMacros.end(),
+  [&Current](const FormatStyle::KeywordedFunctionLikeMacro &Decl) {
+return Current.TokenText == Decl.Name;
+  }) != Style.KeywordedFunctionLikeMacros.end()) {
+return true;
+  }

zeule wrote:

It is not necessary; undone. Thank you!

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


[clang] [clang-format] add option to control bin-packing keyworded parameters (PR #131605)

2025-03-31 Thread Eugene Shalygin via cfe-commits

https://github.com/zeule updated 
https://github.com/llvm/llvm-project/pull/131605

>From e2db7bd178a2c466b066787f235578b624a23644 Mon Sep 17 00:00:00 2001
From: Eugene Shalygin 
Date: Mon, 17 Mar 2025 11:23:35 +0100
Subject: [PATCH] [clang-format] option to control bin-packing keyworded
 parameters

The Q_PROPERTY declaration is almost like a function declaration, but
uses keywords as parameter separators. This allows users to provide list
of those keywords to be used to control bin-packing of the macro
parameters.
---
 clang/docs/ClangFormatStyleOptions.rst| 32 ++
 clang/docs/tools/dump_format_style.py |  1 +
 clang/docs/tools/plurals.txt  |  1 +
 clang/include/clang/Format/Format.h   | 40 +
 clang/lib/Format/ContinuationIndenter.cpp |  4 ++
 clang/lib/Format/Format.cpp   | 11 
 clang/lib/Format/FormatToken.cpp  |  2 +
 clang/lib/Format/FormatToken.h|  1 +
 clang/lib/Format/TokenAnnotator.cpp   | 50 ++--
 clang/unittests/Format/ConfigParseTest.cpp| 10 
 clang/unittests/Format/FormatTest.cpp | 59 +++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 33 +++
 12 files changed, 240 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 9ecac68ae72bf..d318fc3295c32 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4740,6 +4740,38 @@ the configuration (without a prefix: ``Auto``).
   replaced with a single newline and form feed followed by the remaining
   newlines.
 
+.. _KeywordedFunctionLikeMacros:
+
+**KeywordedFunctionLikeMacros** (``List of KeywordedFunctionLikeMacros``) 
:versionbadge:`clang-format 21` :ref:`¶ `
+  Allows to format function-like macros with keyworded parameters according
+  to the BinPackParameters setting, treating keywords as parameter
+  sepratators.
+
+  Q_PROPERTY is an example of such a macro:
+
+  .. code-block:: c++
+
+Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+
+  With ``BinPackParameters``  set to ``OnePerLine`` (or
+  ``AlwaysOnePerLine``) and
+
+  .. code-block:: yaml
+
+KeywordedFunctionLikeMacros:
+- Name: "Q_PROPERTY"
+  Keywords: ['READ', 'WRITE', 'MEMBER', 'RESET', 'NOTIFY']
+
+  the line above will be split on these keywords:
+
+  .. code-block:: c++
+
+Q_PROPERTY(
+int name
+READ name
+WRITE setName
+NOTIFY nameChanged)
+
 .. _LambdaBodyIndentation:
 
 **LambdaBodyIndentation** (``LambdaBodyIndentationKind``) 
:versionbadge:`clang-format 13` :ref:`¶ `
diff --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index f035143f6b3d1..85732af8e0a60 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -462,6 +462,7 @@ class State:
 "std::string",
 "std::vector",
 "std::vector",
+"std::vector",
 "std::vector",
 "std::optional",
 "deprecated",
diff --git a/clang/docs/tools/plurals.txt b/clang/docs/tools/plurals.txt
index e20b7f970ba43..bd08c65df1c52 100644
--- a/clang/docs/tools/plurals.txt
+++ b/clang/docs/tools/plurals.txt
@@ -1,3 +1,4 @@
 Strings
 IncludeCategories
+KeywordedFunctionLikeMacros
 RawStringFormats
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index fec47a248abb4..5ba27adb053a3 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3276,6 +3276,45 @@ struct FormatStyle {
   /// \version 20
   bool KeepFormFeed;
 
+  /// Function-like declaration with keyworded parameters.
+  /// Lists possible keywords for a named function-like macro.
+  struct KeywordedFunctionLikeMacro {
+std::string Name;
+std::vector Keywords;
+
+bool operator==(const KeywordedFunctionLikeMacro &Other) const {
+  return Name == Other.Name && Keywords == Other.Keywords;
+}
+  };
+
+  /// Allows to format function-like macros with keyworded parameters according
+  /// to the BinPackParameters setting, treating keywords as parameter
+  /// separators.
+  ///
+  /// Q_PROPERTY is an example of such a macro:
+  /// \code
+  ///   Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+  /// \endcode
+  ///
+  /// With ``BinPackParameters``  set to ``OnePerLine`` (or
+  /// ``AlwaysOnePerLine``) and
+  /// \code{.yaml}
+  ///   KeywordedFunctionLikeMacros:
+  ///   - Name: "Q_PROPERTY"
+  /// Keywords: ['READ', 'WRITE', 'MEMBER', 'RESET', 'NOTIFY']
+  /// \endcode
+  ///
+  /// the line above will be split on these keywords:
+  /// \code
+  ///   Q_PROPERTY(
+  ///   int name
+  ///   READ name
+  ///   WRITE setName
+  ///   NOTIFY nameChanged)
+  /// \endcode
+  /// \version 21
+  std::vector KeywordedFunctionLik

[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread Pengcheng Wang via cfe-commits


@@ -962,6 +962,8 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 static const unsigned ZvfhminZvfbfminPromoteOps[] = {
 ISD::FMINNUM,
 ISD::FMAXNUM,
+ISD::FMINIMUMNUM,

wangpc-pp wrote:

RISCV changes should be in another PR.

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


[clang] [clang-format] add option to control bin-packing keyworded parameters (PR #131605)

2025-03-31 Thread Eugene Shalygin via cfe-commits

https://github.com/zeule updated 
https://github.com/llvm/llvm-project/pull/131605

>From 7642499ca3bd2929c7392b7d619980b3cf9e648c Mon Sep 17 00:00:00 2001
From: Eugene Shalygin 
Date: Mon, 17 Mar 2025 11:23:35 +0100
Subject: [PATCH] [clang-format] option to control bin-packing keyworded
 parameters

The Q_PROPERTY declaration is almost like a function declaration, but
uses keywords as parameter separators. This allows users to provide list
of those keywords to be used to control bin-packing of the macro
parameters.
---
 clang/docs/ClangFormatStyleOptions.rst| 32 ++
 clang/docs/tools/dump_format_style.py |  1 +
 clang/docs/tools/plurals.txt  |  1 +
 clang/include/clang/Format/Format.h   | 40 +
 clang/lib/Format/ContinuationIndenter.cpp |  4 ++
 clang/lib/Format/Format.cpp   | 11 
 clang/lib/Format/FormatToken.cpp  |  2 +
 clang/lib/Format/FormatToken.h|  1 +
 clang/lib/Format/TokenAnnotator.cpp   | 47 ++-
 clang/unittests/Format/ConfigParseTest.cpp| 10 
 clang/unittests/Format/FormatTest.cpp | 59 +++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 33 +++
 12 files changed, 238 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 9ecac68ae72bf..d318fc3295c32 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4740,6 +4740,38 @@ the configuration (without a prefix: ``Auto``).
   replaced with a single newline and form feed followed by the remaining
   newlines.
 
+.. _KeywordedFunctionLikeMacros:
+
+**KeywordedFunctionLikeMacros** (``List of KeywordedFunctionLikeMacros``) 
:versionbadge:`clang-format 21` :ref:`¶ `
+  Allows to format function-like macros with keyworded parameters according
+  to the BinPackParameters setting, treating keywords as parameter
+  sepratators.
+
+  Q_PROPERTY is an example of such a macro:
+
+  .. code-block:: c++
+
+Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+
+  With ``BinPackParameters``  set to ``OnePerLine`` (or
+  ``AlwaysOnePerLine``) and
+
+  .. code-block:: yaml
+
+KeywordedFunctionLikeMacros:
+- Name: "Q_PROPERTY"
+  Keywords: ['READ', 'WRITE', 'MEMBER', 'RESET', 'NOTIFY']
+
+  the line above will be split on these keywords:
+
+  .. code-block:: c++
+
+Q_PROPERTY(
+int name
+READ name
+WRITE setName
+NOTIFY nameChanged)
+
 .. _LambdaBodyIndentation:
 
 **LambdaBodyIndentation** (``LambdaBodyIndentationKind``) 
:versionbadge:`clang-format 13` :ref:`¶ `
diff --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index f035143f6b3d1..85732af8e0a60 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -462,6 +462,7 @@ class State:
 "std::string",
 "std::vector",
 "std::vector",
+"std::vector",
 "std::vector",
 "std::optional",
 "deprecated",
diff --git a/clang/docs/tools/plurals.txt b/clang/docs/tools/plurals.txt
index e20b7f970ba43..bd08c65df1c52 100644
--- a/clang/docs/tools/plurals.txt
+++ b/clang/docs/tools/plurals.txt
@@ -1,3 +1,4 @@
 Strings
 IncludeCategories
+KeywordedFunctionLikeMacros
 RawStringFormats
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index fec47a248abb4..5ba27adb053a3 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3276,6 +3276,45 @@ struct FormatStyle {
   /// \version 20
   bool KeepFormFeed;
 
+  /// Function-like declaration with keyworded parameters.
+  /// Lists possible keywords for a named function-like macro.
+  struct KeywordedFunctionLikeMacro {
+std::string Name;
+std::vector Keywords;
+
+bool operator==(const KeywordedFunctionLikeMacro &Other) const {
+  return Name == Other.Name && Keywords == Other.Keywords;
+}
+  };
+
+  /// Allows to format function-like macros with keyworded parameters according
+  /// to the BinPackParameters setting, treating keywords as parameter
+  /// separators.
+  ///
+  /// Q_PROPERTY is an example of such a macro:
+  /// \code
+  ///   Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+  /// \endcode
+  ///
+  /// With ``BinPackParameters``  set to ``OnePerLine`` (or
+  /// ``AlwaysOnePerLine``) and
+  /// \code{.yaml}
+  ///   KeywordedFunctionLikeMacros:
+  ///   - Name: "Q_PROPERTY"
+  /// Keywords: ['READ', 'WRITE', 'MEMBER', 'RESET', 'NOTIFY']
+  /// \endcode
+  ///
+  /// the line above will be split on these keywords:
+  /// \code
+  ///   Q_PROPERTY(
+  ///   int name
+  ///   READ name
+  ///   WRITE setName
+  ///   NOTIFY nameChanged)
+  /// \endcode
+  /// \version 21
+  std::vector KeywordedFunctionLike

[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread YunQiang Su via cfe-commits


@@ -0,0 +1,1059 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5

wzssyqa wrote:

Do you mean that we should add this test case first and then this patch with 
update of the test case?

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


[clang] Reland [MS][clang] Add support for vector deleting destructors (PR #133451)

2025-03-31 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-bootstrap-msan` running on `sanitizer-buildbot10` 
while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 84372 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: lit :: allow-retries.py (81367 of 84372)
 TEST 'lit :: allow-retries.py' FAILED 
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 6
rm -f 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
# executed command: rm -f 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
# note: command had no output on stdout or stderr
# RUN: at line 7
env -u FILECHECK_OPTS "/usr/bin/python3" 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit.py
 -j1 --order=lexical Inputs/allow-retries/succeeds-within-limit.py 
-Dcounter=/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
 -Dpython="/usr/bin/python3" | FileCheck --check-prefix=CHECK-TEST1 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/allow-retries.py
# executed command: env -u FILECHECK_OPTS /usr/bin/python3 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit.py
 -j1 --order=lexical Inputs/allow-retries/succeeds-within-limit.py 
-Dcounter=/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
 -Dpython=/usr/bin/python3
# note: command had no output on stdout or stderr
# executed command: FileCheck --check-prefix=CHECK-TEST1 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/allow-retries.py
# note: command had no output on stdout or stderr
# RUN: at line 12
rm -f 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
# executed command: rm -f 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
# note: command had no output on stdout or stderr
# RUN: at line 13
env -u FILECHECK_OPTS "/usr/bin/python3" 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit.py
 -j1 --order=lexical Inputs/allow-retries/succeeds-within-limit.py 
-Dtest_retry_attempts=2 
-Dcounter=/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/Output/allow-retries.py.tmp.counter
 -Dpython="/usr/bin/python3" | FileCheck --check-prefix=CHECK-TEST2 
/home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build2_msan/utils/lit/tests/allow-retries.py
# exe

[clang] [clang][Sema] Fix typo in 'offsetof' diagnostics (PR #133448)

2025-03-31 Thread Michael Buch via cfe-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/133448

>From 732a9b611bb4b6c49a0b4bf1d616870ffa051d8f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 28 Mar 2025 13:29:27 +
Subject: [PATCH 1/3] [clang][Sema] Fix typo in 'offsetof' diagnostics

Before:
```
offset of on non-POD type
```
After:
```
offsetof on non-POD type
```
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  4 ++--
 clang/test/SemaCXX/ms_struct.cpp |  4 ++--
 clang/test/SemaCXX/offsetof-0x.cpp   |  2 +-
 clang/test/SemaCXX/offsetof.cpp  | 14 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1e900437d41ce..01bcc1804cb87 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7031,10 +7031,10 @@ def err_offsetof_incomplete_type : Error<
 def err_offsetof_record_type : Error<
   "offsetof requires struct, union, or class type, %0 invalid">;
 def err_offsetof_array_type : Error<"offsetof requires array type, %0 
invalid">;
-def ext_offsetof_non_pod_type : ExtWarn<"offset of on non-POD type %0">,
+def ext_offsetof_non_pod_type : ExtWarn<"offsetof on non-POD type %0">,
   InGroup;
 def ext_offsetof_non_standardlayout_type : ExtWarn<
-  "offset of on non-standard-layout type %0">, InGroup;
+  "offsetof on non-standard-layout type %0">, InGroup;
 def err_offsetof_bitfield : Error<"cannot compute offset of bit-field %0">;
 def err_offsetof_field_of_virtual_base : Error<
   "invalid application of 'offsetof' to a field of a virtual base">;
diff --git a/clang/test/SemaCXX/ms_struct.cpp b/clang/test/SemaCXX/ms_struct.cpp
index 995e424d1f876..0b1d8a844faca 100644
--- a/clang/test/SemaCXX/ms_struct.cpp
+++ b/clang/test/SemaCXX/ms_struct.cpp
@@ -25,7 +25,7 @@ struct B : public A {
 
 static_assert(__builtin_offsetof(B, d) == 12,
   "We can't allocate the bitfield into the padding under ms_struct");
-// expected-warning@-2 {{offset of on non-standard-layout type 'B'}}
+// expected-warning@-2 {{offsetof on non-standard-layout type 'B'}}
 
 struct C {
 #ifdef TEST_FOR_ERROR
@@ -39,5 +39,5 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}
+// expected-warning@-2 {{offsetof on non-standard-layout type 'C'}}
 
diff --git a/clang/test/SemaCXX/offsetof-0x.cpp 
b/clang/test/SemaCXX/offsetof-0x.cpp
index a3fe2fbbad72d..f6e295caa2600 100644
--- a/clang/test/SemaCXX/offsetof-0x.cpp
+++ b/clang/test/SemaCXX/offsetof-0x.cpp
@@ -11,7 +11,7 @@ struct P {
 };
 
 void f() {
-  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offset of on non-standard-layout type 'P'}}
+  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offsetof on non-standard-layout type 'P'}}
 }
 
 struct StandardLayout {
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
index 1722b91fafc86..a8f33e0c49a59 100644
--- a/clang/test/SemaCXX/offsetof.cpp
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -11,12 +11,12 @@ struct P {
 };
 
 void f() {
-  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offset of on non-POD type 'P'}}
+  int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // 
expected-warning{{offsetof on non-POD type 'P'}}
 }
 
 struct Base { int x; };
 struct Derived : Base { int y; };
-int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
+int o = __builtin_offsetof(Derived, x); // expected-warning{{offsetof on 
non-POD type}}
 
 const int o2 = sizeof(__builtin_offsetof(Derived, x));
 
@@ -51,9 +51,9 @@ struct Derived2 : public Base1, public Base2 {
   int z;
 };
 
-int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
-int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
-int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{offsetof on non-POD type 'Derived2'}}
+int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1]; // 
expected-warning{{offsetof on non-POD type 'Derived2'}}
+int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1]; // 
expected-warning{{offsetof on non-POD type 'Derived2'}}
 
 // offsetof referring to anonymous struct in base.
 // PR7769
@@ -66,7 +66,7 @@ struct foo {
 struct bar : public foo  {
 };
 
-int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'bar'}}
+int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 

[clang] [clang-format] Correctly annotate pointer/reference in _Generic (PR #133673)

2025-03-31 Thread Björn Schäpers via cfe-commits

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


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


[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,1059 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt --passes=loop-vectorize --mtriple=riscv64 -mattr="+zvfh,+v" -S < %s 
| FileCheck %s --check-prefix=RV64
+; RUN: opt --passes=loop-vectorize --mtriple=aarch64 -mattr="+neon" -S < %s | 
FileCheck %s --check-prefix=ARM64
+; FIXME: ARM64+SVE cannot output vscale style code
+; RUN: opt --passes=loop-vectorize --mtriple=x86_64 -S < %s | FileCheck %s 
--check-prefix=X64
+
+@af32 = dso_local local_unnamed_addr global [4096 x float] zeroinitializer, 
align 4
+@bf32 = dso_local local_unnamed_addr global [4096 x float] zeroinitializer, 
align 4
+@cf32 = dso_local local_unnamed_addr global [4096 x float] zeroinitializer, 
align 4
+@af64 = dso_local local_unnamed_addr global [4096 x double] zeroinitializer, 
align 8
+@bf64 = dso_local local_unnamed_addr global [4096 x double] zeroinitializer, 
align 8
+@cf64 = dso_local local_unnamed_addr global [4096 x double] zeroinitializer, 
align 8
+@af16 = dso_local local_unnamed_addr global [4096 x half] zeroinitializer, 
align 2
+@bf16 = dso_local local_unnamed_addr global [4096 x half] zeroinitializer, 
align 2
+@cf16 = dso_local local_unnamed_addr global [4096 x half] zeroinitializer, 
align 2
+
+; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: 
none, inaccessiblemem: none) uwtable
+define dso_local void @f32min() local_unnamed_addr  {
+; RV64-LABEL: define dso_local void @f32min(
+; RV64-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; RV64-NEXT:  [[ENTRY:.*]]:
+; RV64-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
+; RV64-NEXT:[[TMP1:%.*]] = mul i64 [[TMP0]], 4
+; RV64-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 4096, [[TMP1]]
+; RV64-NEXT:br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label 
%[[VECTOR_PH:.*]]
+; RV64:   [[VECTOR_PH]]:
+; RV64-NEXT:[[TMP2:%.*]] = call i64 @llvm.vscale.i64()
+; RV64-NEXT:[[TMP3:%.*]] = mul i64 [[TMP2]], 4
+; RV64-NEXT:[[N_MOD_VF:%.*]] = urem i64 4096, [[TMP3]]
+; RV64-NEXT:[[N_VEC:%.*]] = sub i64 4096, [[N_MOD_VF]]
+; RV64-NEXT:[[TMP4:%.*]] = call i64 @llvm.vscale.i64()
+; RV64-NEXT:[[TMP5:%.*]] = mul i64 [[TMP4]], 4
+; RV64-NEXT:br label %[[VECTOR_BODY:.*]]
+; RV64:   [[VECTOR_BODY]]:
+; RV64-NEXT:[[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
+; RV64-NEXT:[[TMP6:%.*]] = getelementptr inbounds nuw [4096 x float], ptr 
@af32, i64 0, i64 [[INDEX]]
+; RV64-NEXT:[[TMP7:%.*]] = getelementptr inbounds nuw float, ptr [[TMP6]], 
i32 0
+; RV64-NEXT:[[WIDE_LOAD:%.*]] = load , ptr [[TMP7]], 
align 4
+; RV64-NEXT:[[TMP8:%.*]] = getelementptr inbounds nuw [4096 x float], ptr 
@bf32, i64 0, i64 [[INDEX]]
+; RV64-NEXT:[[TMP9:%.*]] = getelementptr inbounds nuw float, ptr [[TMP8]], 
i32 0
+; RV64-NEXT:[[WIDE_LOAD1:%.*]] = load , ptr [[TMP9]], 
align 4
+; RV64-NEXT:[[TMP10:%.*]] = call  
@llvm.minimumnum.nxv4f32( [[WIDE_LOAD]],  [[WIDE_LOAD1]])
+; RV64-NEXT:[[TMP11:%.*]] = getelementptr inbounds nuw [4096 x float], ptr 
@cf32, i64 0, i64 [[INDEX]]
+; RV64-NEXT:[[TMP12:%.*]] = getelementptr inbounds nuw float, ptr 
[[TMP11]], i32 0
+; RV64-NEXT:store  [[TMP10]], ptr [[TMP12]], align 4
+; RV64-NEXT:[[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
+; RV64-NEXT:[[TMP13:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
+; RV64-NEXT:br i1 [[TMP13]], label %[[MIDDLE_BLOCK:.*]], label 
%[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
+; RV64:   [[MIDDLE_BLOCK]]:
+; RV64-NEXT:[[CMP_N:%.*]] = icmp eq i64 4096, [[N_VEC]]
+; RV64-NEXT:br i1 [[CMP_N]], label %[[FOR_COND_CLEANUP:.*]], label 
%[[SCALAR_PH]]
+; RV64:   [[SCALAR_PH]]:
+; RV64-NEXT:[[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] 
], [ 0, %[[ENTRY]] ]
+; RV64-NEXT:br label %[[FOR_BODY:.*]]
+; RV64:   [[FOR_COND_CLEANUP]]:
+; RV64-NEXT:ret void
+; RV64:   [[FOR_BODY]]:
+; RV64-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], 
%[[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], %[[FOR_BODY]] ]
+; RV64-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds nuw [4096 x float], 
ptr @af32, i64 0, i64 [[INDVARS_IV]]
+; RV64-NEXT:[[TMP14:%.*]] = load float, ptr [[ARRAYIDX]], align 4
+; RV64-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds nuw [4096 x float], 
ptr @bf32, i64 0, i64 [[INDVARS_IV]]
+; RV64-NEXT:[[TMP15:%.*]] = load float, ptr [[ARRAYIDX2]], align 4
+; RV64-NEXT:[[TMP16:%.*]] = tail call float @llvm.minimumnum.f32(float 
[[TMP14]], float [[TMP15]])
+; RV64-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds nuw [4096 x float], 
ptr @cf32, i64 0, i64 [[INDVARS_IV]]
+; RV64-NEXT:store float [[TMP16]], ptr [[ARRAYIDX4]], align 4
+; RV64-NEXT:[[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; RV64-NEXT:[[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 4096
+; RV64-NEXT:br i1 [[EXITCOND_NOT]], la

[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,1059 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt --passes=loop-vectorize --mtriple=riscv64 -mattr="+zvfh,+v" -S < %s 
| FileCheck %s --check-prefix=RV64
+; RUN: opt --passes=loop-vectorize --mtriple=aarch64 -mattr="+neon" -S < %s | 
FileCheck %s --check-prefix=ARM64
+; FIXME: ARM64+SVE cannot output vscale style code
+; RUN: opt --passes=loop-vectorize --mtriple=x86_64 -S < %s | FileCheck %s 
--check-prefix=X64
+
+@af32 = dso_local local_unnamed_addr global [4096 x float] zeroinitializer, 
align 4
+@bf32 = dso_local local_unnamed_addr global [4096 x float] zeroinitializer, 
align 4
+@cf32 = dso_local local_unnamed_addr global [4096 x float] zeroinitializer, 
align 4
+@af64 = dso_local local_unnamed_addr global [4096 x double] zeroinitializer, 
align 8
+@bf64 = dso_local local_unnamed_addr global [4096 x double] zeroinitializer, 
align 8
+@cf64 = dso_local local_unnamed_addr global [4096 x double] zeroinitializer, 
align 8
+@af16 = dso_local local_unnamed_addr global [4096 x half] zeroinitializer, 
align 2
+@bf16 = dso_local local_unnamed_addr global [4096 x half] zeroinitializer, 
align 2
+@cf16 = dso_local local_unnamed_addr global [4096 x half] zeroinitializer, 
align 2
+
+; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: 
none, inaccessiblemem: none) uwtable
+define dso_local void @f32min() local_unnamed_addr  {
+; RV64-LABEL: define dso_local void @f32min(
+; RV64-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; RV64-NEXT:  [[ENTRY:.*]]:
+; RV64-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
+; RV64-NEXT:[[TMP1:%.*]] = mul i64 [[TMP0]], 4
+; RV64-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 4096, [[TMP1]]
+; RV64-NEXT:br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label 
%[[VECTOR_PH:.*]]
+; RV64:   [[VECTOR_PH]]:
+; RV64-NEXT:[[TMP2:%.*]] = call i64 @llvm.vscale.i64()
+; RV64-NEXT:[[TMP3:%.*]] = mul i64 [[TMP2]], 4
+; RV64-NEXT:[[N_MOD_VF:%.*]] = urem i64 4096, [[TMP3]]
+; RV64-NEXT:[[N_VEC:%.*]] = sub i64 4096, [[N_MOD_VF]]
+; RV64-NEXT:[[TMP4:%.*]] = call i64 @llvm.vscale.i64()
+; RV64-NEXT:[[TMP5:%.*]] = mul i64 [[TMP4]], 4
+; RV64-NEXT:br label %[[VECTOR_BODY:.*]]
+; RV64:   [[VECTOR_BODY]]:
+; RV64-NEXT:[[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
+; RV64-NEXT:[[TMP6:%.*]] = getelementptr inbounds nuw [4096 x float], ptr 
@af32, i64 0, i64 [[INDEX]]
+; RV64-NEXT:[[TMP7:%.*]] = getelementptr inbounds nuw float, ptr [[TMP6]], 
i32 0
+; RV64-NEXT:[[WIDE_LOAD:%.*]] = load , ptr [[TMP7]], 
align 4
+; RV64-NEXT:[[TMP8:%.*]] = getelementptr inbounds nuw [4096 x float], ptr 
@bf32, i64 0, i64 [[INDEX]]
+; RV64-NEXT:[[TMP9:%.*]] = getelementptr inbounds nuw float, ptr [[TMP8]], 
i32 0
+; RV64-NEXT:[[WIDE_LOAD1:%.*]] = load , ptr [[TMP9]], 
align 4
+; RV64-NEXT:[[TMP10:%.*]] = call  
@llvm.minimumnum.nxv4f32( [[WIDE_LOAD]],  [[WIDE_LOAD1]])
+; RV64-NEXT:[[TMP11:%.*]] = getelementptr inbounds nuw [4096 x float], ptr 
@cf32, i64 0, i64 [[INDEX]]
+; RV64-NEXT:[[TMP12:%.*]] = getelementptr inbounds nuw float, ptr 
[[TMP11]], i32 0
+; RV64-NEXT:store  [[TMP10]], ptr [[TMP12]], align 4
+; RV64-NEXT:[[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
+; RV64-NEXT:[[TMP13:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
+; RV64-NEXT:br i1 [[TMP13]], label %[[MIDDLE_BLOCK:.*]], label 
%[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
+; RV64:   [[MIDDLE_BLOCK]]:
+; RV64-NEXT:[[CMP_N:%.*]] = icmp eq i64 4096, [[N_VEC]]
+; RV64-NEXT:br i1 [[CMP_N]], label %[[FOR_COND_CLEANUP:.*]], label 
%[[SCALAR_PH]]
+; RV64:   [[SCALAR_PH]]:
+; RV64-NEXT:[[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] 
], [ 0, %[[ENTRY]] ]
+; RV64-NEXT:br label %[[FOR_BODY:.*]]
+; RV64:   [[FOR_COND_CLEANUP]]:
+; RV64-NEXT:ret void
+; RV64:   [[FOR_BODY]]:
+; RV64-NEXT:[[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], 
%[[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], %[[FOR_BODY]] ]
+; RV64-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds nuw [4096 x float], 
ptr @af32, i64 0, i64 [[INDVARS_IV]]
+; RV64-NEXT:[[TMP14:%.*]] = load float, ptr [[ARRAYIDX]], align 4
+; RV64-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds nuw [4096 x float], 
ptr @bf32, i64 0, i64 [[INDVARS_IV]]
+; RV64-NEXT:[[TMP15:%.*]] = load float, ptr [[ARRAYIDX2]], align 4
+; RV64-NEXT:[[TMP16:%.*]] = tail call float @llvm.minimumnum.f32(float 
[[TMP14]], float [[TMP15]])
+; RV64-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds nuw [4096 x float], 
ptr @cf32, i64 0, i64 [[INDVARS_IV]]
+; RV64-NEXT:store float [[TMP16]], ptr [[ARRAYIDX4]], align 4
+; RV64-NEXT:[[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; RV64-NEXT:[[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 4096
+; RV64-NEXT:br i1 [[EXITCOND_NOT]], la

[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

You can probably write a smaller test using SLPVectorizer, e.g. 
/llvm/test/Transforms/SLPVectorizer/AMDGPU/round.ll 

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


[clang] [llvm] Vectorize: Support fminimumnum and fmaximumnum (PR #131781)

2025-03-31 Thread Matt Arsenault via cfe-commits

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


[clang] [llvm] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)

2025-03-31 Thread via cfe-commits

https://github.com/CarolineConcatto commented:

Hi Marian,
There is some tests failing with the codegen. Can you rebase this patch and fix 
the failings tests

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


[libclc] [libclc] Move rootn to the CLC library; optimize (PR #133735)

2025-03-31 Thread Matt Arsenault via cfe-commits

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


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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits

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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits

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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits

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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)


Changes


This implements the same overload resolution behavior as GCC, 
as described in https://wg21.link/p3606 (sections 1-2, not 3)

If, during overload resolution, a non-template candidate is always picked 
because each argument is a perfect match (i.e., the source and target types are 
the same), we do not perform deduction for any template candidate that might 
exist.

The goal is to be able to merge #122423 without being too disruptive.

This change means that the selection of the best viable candidate and template 
argument deduction become interleaved.

To avoid rewriting half of Clang, we store in `OverloadCandidateSet` enough 
information to deduce template candidates from 
`OverloadCandidateSet::BestViableFunction`. This means the lifetime of any 
object used by the template argument must outlive a call to 
`Add*Template*Candidate`.

This two-phase resolution is not performed for some initialization as there are 
cases where template candidates are a better match per the standard. It's also 
bypassed for code completion.

The change has a nice impact on compile times
https://llvm-compile-time-tracker.com/compare.php?from=719b029c16eeb1035da522fd641dfcc4cee6be74&to=bf7041045c9408490c395230047c5461de72fc39&stat=instructions%3Au
 .

Fixes #62096
Fixes #74581

---

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


9 Files Affected:

- (modified) clang/include/clang/Sema/Overload.h (+150-7) 
- (modified) clang/include/clang/Sema/Sema.h (+2) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+4-2) 
- (modified) clang/lib/Sema/SemaInit.cpp (+11-4) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+344-101) 
- (modified) 
clang/test/CXX/temp/temp.constr/temp.constr.atomic/constrant-satisfaction-conversions.cpp
 (+4-4) 
- (modified) clang/test/SemaCXX/implicit-member-functions.cpp (+7-14) 
- (modified) clang/test/SemaTemplate/instantiate-function-params.cpp (+3-4) 
- (modified) clang/test/Templight/templight-empty-entries-fix.cpp (+51-75) 


``diff
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 6e08762dcc6d7..547845c01db11 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 
@@ -407,6 +408,11 @@ class Sema;
  Third == ICK_Identity;
 }
 
+bool isPerfect(const ASTContext &C) const {
+  return isIdentityConversion() &&
+ (!ReferenceBinding || C.hasSameType(getFromType(), getToType(2)));
+}
+
 ImplicitConversionRank getRank() const;
 NarrowingKind
 getNarrowingKind(ASTContext &Context, const Expr *Converted,
@@ -743,6 +749,10 @@ class Sema;
   Standard.setAllToTypes(T);
 }
 
+bool isPerfect(const ASTContext &C) const {
+  return isStandard() && Standard.isPerfect(C);
+}
+
 // True iff this is a conversion sequence from an initializer list to an
 // array or std::initializer.
 bool hasInitializerListContainerType() const {
@@ -979,6 +989,20 @@ class Sema;
   return false;
 }
 
+bool isPerfectMatch(const ASTContext &Ctx) const {
+  if (!Viable)
+return false;
+  for (const auto &C : Conversions) {
+if (!C.isInitialized())
+  return false;
+if (!C.isPerfect(Ctx))
+  return false;
+  }
+  if (isa_and_nonnull(Function))
+return FinalConversion.isPerfect(Ctx);
+  return true;
+}
+
 bool TryToFixBadConversion(unsigned Idx, Sema &S) {
   bool CanFix = Fix.tryToFixConversion(
   Conversions[Idx].Bad.FromExpr,
@@ -1015,6 +1039,61 @@ class Sema;
   RewriteKind(CRK_None) {}
   };
 
+  struct DeferredConversionTemplateOverloadCandidate {
+FunctionTemplateDecl *FunctionTemplate;
+DeclAccessPair FoundDecl;
+CXXRecordDecl *ActingContext;
+Expr *From;
+QualType ToType;
+
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowObjCConversionOnExplicit : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowExplicit : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned AllowResultConversion : 1;
+  };
+
+  struct DeferredMethodTemplateOverloadCandidate {
+FunctionTemplateDecl *FunctionTemplate;
+DeclAccessPair FoundDecl;
+ArrayRef Args;
+CXXRecordDecl *ActingContext;
+Expr::Classification ObjectClassification;
+QualType ObjectType;
+
+OverloadCandidateParamOrder PO;
+LLVM_PREFERRED_TYPE(bool)
+unsigned SuppressUserConversions : 1;
+LLVM_PREFERRED_TYPE(bool)
+unsigned PartialOverloading : 1;
+  };
+
+  struct DeferredFunctionTemplateOverloadCandidate {
+FunctionTemplateDecl *FunctionTemplate;
+DeclAccessPair FoundDecl;
+ArrayRef Args;
+
+CallExpr::ADLCallKind IsADLCandidate;
+OverloadCandidateParamOrder PO;
+LLVM_PREFERRED_TYPE(bool)

[clang] [llvm] [Clang][AMDGPU] Add __builtin_amdgcn_cvt_off_f32_i4 (PR #133741)

2025-03-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Juan Manuel Martinez Caamaño (jmmartinez)


Changes

This built-in that maps to `V_CVT_OFF_F32_I4` which treats its input as a 4-bit 
signed integer and returns `0.0625f * src`.

SWDEV-518861

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


10 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsAMDGPU.def (+1) 
- (added) clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl (+15) 
- (added) clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl (+8) 
- (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+6) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp (+9) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/VOP1Instructions.td (+5) 
- (added) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.off.f32.i4.ll (+23) 
- (added) llvm/test/CodeGen/AMDGPU/simplify-amdgcn.cvt.off.f32.i4.ll (+158) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 44ef404aee72f..f38148cc795dc 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -140,6 +140,7 @@ BUILTIN(__builtin_amdgcn_cvt_pknorm_u16, "E2Usff", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_i16, "E2sii", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_u16, "E2UsUiUi", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_u8_f32, "UifUiUi", "nc")
+BUILTIN(__builtin_amdgcn_cvt_off_f32_i4, "fUi", "nc")
 BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc")
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
new file mode 100644
index 0..6dc235f9cc6c7
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL1.2 \
+// RUN: -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: @test_builtin_amdgcn_cvt_off_f32_i4(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:store i32 [[N:%.*]], ptr addrspace(5) [[N_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.amdgcn.cvt.off.f32.i4(i32 
[[TMP0]])
+// CHECK-NEXT:ret float [[TMP1]]
+//
+float test_builtin_amdgcn_cvt_off_f32_i4(unsigned n) {
+return __builtin_amdgcn_cvt_off_f32_i4(n);
+}
diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl 
b/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
new file mode 100644
index 0..f5b02b80c37da
--- /dev/null
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple amdgcn-- -verify -S -o - %s
+
+void test_builtin_amdgcn_cvt_off_f32_i4(unsigned n) {
+struct A{ unsigned x; } a;
+__builtin_amdgcn_cvt_off_f32_i4(n, n); // expected-error {{too many 
arguments to function call, expected 1, have 2}}
+__builtin_amdgcn_cvt_off_f32_i4(); // expected-error {{too few arguments 
to function call, expected 1, have 0}}
+__builtin_amdgcn_cvt_off_f32_i4(a); // expected-error {{passing '__private 
struct A' to parameter of incompatible type 'unsigned int'}}
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index f53016f62abbe..ebac0f9029791 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -3375,6 +3375,12 @@ def int_amdgcn_cvt_sr_fp8_f32 : 
ClangBuiltin<"__builtin_amdgcn_cvt_sr_fp8_f32">,
 [llvm_float_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
 [IntrNoMem, ImmArg>]>;
 
+// llvm.amdgcn.cvt.off.fp32.i4 int srcA
+def int_amdgcn_cvt_off_f32_i4: ClangBuiltin<"__builtin_amdgcn_cvt_off_f32_i4">,
+  DefaultAttrsIntrinsic<[llvm_float_ty],
+[llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
 
//===--===//
 // gfx950 intrinsics
 
//===--===//
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
index 3246e575ea6a9..533ad349f7500 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -6042,6 +6042,7 @@ bool 
AMDGPUTargetLowering::isKnownNeverNaNForTargetNode(SDValue Op,
 // TODO: Handle more intrinsics
 switch (IntrinsicID) {
 case Intrinsic::amdgcn_cubeid:
+case Intrinsic::amdgcn_cvt_off_f32_i4:
   return true;
 
 case In

[clang] [llvm] [Clang][AMDGPU] Add __builtin_amdgcn_cvt_off_f32_i4 (PR #133741)

2025-03-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-ir

Author: Juan Manuel Martinez Caamaño (jmmartinez)


Changes

This built-in that maps to `V_CVT_OFF_F32_I4` which treats its input as a 4-bit 
signed integer and returns `0.0625f * src`.

SWDEV-518861

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


10 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsAMDGPU.def (+1) 
- (added) clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl (+15) 
- (added) clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl (+8) 
- (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+6) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp (+9) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/VOP1Instructions.td (+5) 
- (added) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.off.f32.i4.ll (+23) 
- (added) llvm/test/CodeGen/AMDGPU/simplify-amdgcn.cvt.off.f32.i4.ll (+158) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 44ef404aee72f..f38148cc795dc 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -140,6 +140,7 @@ BUILTIN(__builtin_amdgcn_cvt_pknorm_u16, "E2Usff", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_i16, "E2sii", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_u16, "E2UsUiUi", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_u8_f32, "UifUiUi", "nc")
+BUILTIN(__builtin_amdgcn_cvt_off_f32_i4, "fUi", "nc")
 BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc")
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
new file mode 100644
index 0..6dc235f9cc6c7
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL1.2 \
+// RUN: -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: @test_builtin_amdgcn_cvt_off_f32_i4(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:store i32 [[N:%.*]], ptr addrspace(5) [[N_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.amdgcn.cvt.off.f32.i4(i32 
[[TMP0]])
+// CHECK-NEXT:ret float [[TMP1]]
+//
+float test_builtin_amdgcn_cvt_off_f32_i4(unsigned n) {
+return __builtin_amdgcn_cvt_off_f32_i4(n);
+}
diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl 
b/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
new file mode 100644
index 0..f5b02b80c37da
--- /dev/null
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple amdgcn-- -verify -S -o - %s
+
+void test_builtin_amdgcn_cvt_off_f32_i4(unsigned n) {
+struct A{ unsigned x; } a;
+__builtin_amdgcn_cvt_off_f32_i4(n, n); // expected-error {{too many 
arguments to function call, expected 1, have 2}}
+__builtin_amdgcn_cvt_off_f32_i4(); // expected-error {{too few arguments 
to function call, expected 1, have 0}}
+__builtin_amdgcn_cvt_off_f32_i4(a); // expected-error {{passing '__private 
struct A' to parameter of incompatible type 'unsigned int'}}
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index f53016f62abbe..ebac0f9029791 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -3375,6 +3375,12 @@ def int_amdgcn_cvt_sr_fp8_f32 : 
ClangBuiltin<"__builtin_amdgcn_cvt_sr_fp8_f32">,
 [llvm_float_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
 [IntrNoMem, ImmArg>]>;
 
+// llvm.amdgcn.cvt.off.fp32.i4 int srcA
+def int_amdgcn_cvt_off_f32_i4: ClangBuiltin<"__builtin_amdgcn_cvt_off_f32_i4">,
+  DefaultAttrsIntrinsic<[llvm_float_ty],
+[llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
 
//===--===//
 // gfx950 intrinsics
 
//===--===//
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
index 3246e575ea6a9..533ad349f7500 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -6042,6 +6042,7 @@ bool 
AMDGPUTargetLowering::isKnownNeverNaNForTargetNode(SDValue Op,
 // TODO: Handle more intrinsics
 switch (IntrinsicID) {
 case Intrinsic::amdgcn_cubeid:
+case Intrinsic::amdgcn_cvt_off_f32_i4:
   return true;
 
 case 

[clang] Fix complex long double division with -mno-x87. (PR #133152)

2025-03-31 Thread Zahira Ammarguellat via cfe-commits

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

>From 56a000612da3f58928362229a46800c6f077cc71 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Wed, 26 Mar 2025 13:18:36 -0700
Subject: [PATCH 1/2] Fix complex long division with -mno-x87.

---
 clang/lib/CodeGen/CGExprComplex.cpp   |  4 ++
 clang/lib/Sema/SemaExpr.cpp   |  6 ++-
 clang/test/CodeGen/promoted-complex-div.c | 49 +++
 3 files changed, 57 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/promoted-complex-div.c

diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index a7c8b96da6853..184a355734046 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -303,6 +303,10 @@ class ComplexExprEmitter
 // doubles the exponent of SmallerType.LargestFiniteVal)
 if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 <=
 llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  if (!Ctx.getTargetInfo().hasLongDoubleType() &&
+  HigherElementType.getCanonicalType().getUnqualifiedType() ==
+  Ctx.LongDoubleTy)
+return QualType();
   FPHasBeenPromoted = true;
   return Ctx.getComplexType(HigherElementType);
 } else {
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..69a13aff14a00 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15304,8 +15304,10 @@ static void DetectPrecisionLossInComplexDivision(Sema 
&S, SourceLocation OpLoc,
   Ctx.getFloatTypeSemantics(ElementType);
   const llvm::fltSemantics &HigherElementTypeSemantics =
   Ctx.getFloatTypeSemantics(HigherElementType);
-  if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
-  llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
+   llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
+  (HigherElementType == Ctx.LongDoubleTy &&
+   !Ctx.getTargetInfo().hasLongDoubleType())) {
 // Retain the location of the first use of higher precision type.
 if (!S.LocationOfExcessPrecisionNotSatisfied.isValid())
   S.LocationOfExcessPrecisionNotSatisfied = OpLoc;
diff --git a/clang/test/CodeGen/promoted-complex-div.c 
b/clang/test/CodeGen/promoted-complex-div.c
new file mode 100644
index 0..02300126965ed
--- /dev/null
+++ b/clang/test/CodeGen/promoted-complex-div.c
@@ -0,0 +1,49 @@
+// RUN %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
+// RUN -verify -complex-range=promoted -o - | FileCheck %s
+
+// RUN %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
+// RUN -verify=nopromotion -complex-range=promoted -target-feature -x87 -o - | 
FileCheck %s --check-prefix=X87
+
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-windows \
+// RUN: -verify=nopromotion -complex-range=promoted -o - | FileCheck %s 
--check-prefix=X87
+
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-windows \
+// RUN: -verify=nopromotion -complex-range=promoted -target-feature -x87 -o - 
| FileCheck %s --check-prefix=X87
+
+
+
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local <2 x float> @divd
+_Complex float divd(_Complex float a, _Complex float b) {
+  // CHECK: fpext float {{.*}} to double
+  // CHECK: fpext float {{.*}} to double
+  // CHECK: fdiv double
+  // CHECK: fdiv double
+  // CHECK: fptrunc double {{.*}} to float
+  // CHECK: fptrunc double {{.*}} to float
+
+  // X87: fpext float {{.*}} to double
+  // X87: fpext float {{.*}} to double
+  // X87: fdiv double
+  // X87: fdiv double
+  // X87: fptrunc double {{.*}} to float
+  // X87: fptrunc double {{.*}} to float
+
+  return a / b;
+}
+
+// CHECK-LABEL: define dso_local { double, double } @divf
+_Complex double divf(_Complex double a, _Complex double b) {
+  // CHECK: fpext double {{.*}} to x86_fp80
+  // CHECK: fpext double {{.*}} to x86_fp80
+  // CHECK: fdiv x86_fp80
+  // CHECK: fdiv x86_fp80
+  // CHECK: fptrunc x86_fp80
+  // CHECK: fptrunc x86_fp80
+
+  // X87: fdiv double
+  // X87: fdiv double
+
+  return a / b; // nopromotion-warning{{excess precision is requested but the 
target does not support excess precision which may result in observable 
differences in complex division behavior}}
+}

>From 15396dc494ee1ea3c18b1221a3aaaf1532d7010d Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Mon, 31 Mar 2025 08:06:43 -0700
Subject: [PATCH 2/2] Addressed Josh's review comments.

---
 clang/test/CodeGen/promoted-complex-div.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/test/CodeGen/promoted-complex-div.c 
b/clang/test/CodeGen/promoted-complex-div.c
index 02300126965ed..ce520f93db4f1 100644
--- a/clang/test/CodeGen/

[clang] [llvm] [clang][DebugInfo] Add symbol for debugger with VTable information. (PR #130255)

2025-03-31 Thread Tom Tromey via cfe-commits

tromey wrote:

> Removing the vtable global variable and moving the "location info" into the 
> static within the class, will work for the SCE debugger.

I was thinking about this last night and wondering if the vtable will appear as 
a class member even if the class is local to a function?

If so then it seems like this would be hard for gdb to find (can't speak for 
other debuggers).  The issue being that gdb tends not to read DIEs that it 
thinks are uninteresting, and this means function bodies in general are skipped.

If the vtable were a global-but-artificial object, then it would readily be 
found by the initial scan.

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


[libclc] 3fd0eaa - [libclc][amdgpu] Implement native_exp2 via AMD builtin (#133696)

2025-03-31 Thread via cfe-commits

Author: Fraser Cormack
Date: 2025-03-31T16:54:04+01:00
New Revision: 3fd0eaae52503ee2bbdffc75753acc4bcc72fe60

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

LOG: [libclc][amdgpu] Implement native_exp2 via AMD builtin (#133696)

This came up during a discussion on #129679, which has been split out as
a preparatory commit.

An example of the AMDGPU codegen is:

define <2 x float> @_Z10native_expDv2_f(<2 x float> %val) {
  %mul = fmul afn <2 x float> %val, splat (float 0x3FF715476000)
  %0 = extractelement <2 x float> %mul, i64 0
  %1 = tail call float @llvm.amdgcn.exp2.f32(float %0)
  %vecinit.i = insertelement <2 x float> poison, float %1, i64 0
  %2 = extractelement <2 x float> %mul, i64 1
  %3 = tail call float @llvm.amdgcn.exp2.f32(float %2)
%vecinit2.i = insertelement <2 x float> %vecinit.i, float %3, i64 1
  ret <2 x float> %vecinit2.i
}

define <2 x float> @_Z11native_exp2Dv2_f(<2 x float> %x) {
  %0 = extractelement <2 x float> %x, i64 0
  %1 = tail call float @llvm.amdgcn.exp2.f32(float %0)
  %vecinit = insertelement <2 x float> poison, float %1, i64 0
  %2 = extractelement <2 x float> %x, i64 1
  %3 = tail call float @llvm.amdgcn.exp2.f32(float %2)
  %vecinit2 = insertelement <2 x float> %vecinit, float %3, i64 1
  ret <2 x float> %vecinit2
}

Added: 
libclc/amdgpu/lib/math/native_exp2.cl

Modified: 
libclc/amdgpu/lib/SOURCES

Removed: 




diff  --git a/libclc/amdgpu/lib/SOURCES b/libclc/amdgpu/lib/SOURCES
index d7782a2ae14dc..ed5e45a37c18d 100644
--- a/libclc/amdgpu/lib/SOURCES
+++ b/libclc/amdgpu/lib/SOURCES
@@ -1,4 +1,5 @@
 math/native_exp.cl
+math/native_exp2.cl
 math/native_log.cl
 math/native_log10.cl
 math/half_exp.cl

diff  --git a/libclc/amdgpu/lib/math/native_exp2.cl 
b/libclc/amdgpu/lib/math/native_exp2.cl
new file mode 100644
index 0..39ae914b19634
--- /dev/null
+++ b/libclc/amdgpu/lib/math/native_exp2.cl
@@ -0,0 +1,16 @@
+//===--===//
+//
+// 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 
+#include 
+
+_CLC_OVERLOAD _CLC_DEF float native_exp2(float val) {
+  return __builtin_amdgcn_exp2f(val);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, native_exp2, float)



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


[libclc] 87602f6 - [libclc] Fix unresolved reference to missing table (#133691)

2025-03-31 Thread via cfe-commits

Author: Fraser Cormack
Date: 2025-03-31T16:55:23+01:00
New Revision: 87602f6d03ada10d0de7f1440320ffec4eb86790

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

LOG: [libclc] Fix unresolved reference to missing table (#133691)

Splitting the 'ln_tbl' into two in db98e292 wasn't done thoroughly
enough as some references to the old table still remained. This commit
fixes the unresolved references by updating to the new split table.

Added: 


Modified: 
libclc/clc/include/clc/math/tables.h
libclc/clc/lib/generic/math/clc_log_base.h

Removed: 




diff  --git a/libclc/clc/include/clc/math/tables.h 
b/libclc/clc/include/clc/math/tables.h
index f2118082b1bdb..3120a18cc996e 100644
--- a/libclc/clc/include/clc/math/tables.h
+++ b/libclc/clc/include/clc/math/tables.h
@@ -78,7 +78,6 @@ CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_tail);
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
-TABLE_FUNCTION_DECL(double2, ln_tbl);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
 CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);

diff  --git a/libclc/clc/lib/generic/math/clc_log_base.h 
b/libclc/clc/lib/generic/math/clc_log_base.h
index 7d084c037f67e..9418535db827d 100644
--- a/libclc/clc/lib/generic/math/clc_log_base.h
+++ b/libclc/clc/lib/generic/math/clc_log_base.h
@@ -261,9 +261,8 @@ __clc_log(double x)
   int index = __clc_as_int2(ux).hi >> 13;
   index = ((0x80 | (index & 0x7e)) >> 1) + (index & 0x1);
 
-  double2 tv = USE_TABLE(ln_tbl, index - 64);
-  double z1 = tv.s0;
-  double q = tv.s1;
+  double z1 = USE_TABLE(ln_tbl_lo, index - 64);
+  double q = USE_TABLE(ln_tbl_hi, index - 64);
 
   double f1 = index * 0x1.0p-7;
   double f2 = f - f1;



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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread via cfe-commits


@@ -10918,7 +11083,44 @@ bool 
OverloadCandidate::NotValidBecauseConstraintExprHasError() const {
 OverloadingResult
 OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc,
  iterator &Best) {
+
+  bool TwoPhaseResolution =
+  !NonDeducedCandidates.empty() && Kind != CSK_CodeCompletion &&
+  Kind != CSK_InitByUserDefinedConversion && Kind != CSK_InitByConstructor;
+
+  if (TwoPhaseResolution) {
+Best = end();
+for (auto It = begin(); It != end(); ++It) {
+  if (It->isPerfectMatch(S.getASTContext())) {
+if (Best == end()) {
+  Best = It;
+} else {
+  Best = end();
+  break;
+}
+  }
+}
+if (Best != end()) {
+  Best->Best = true;
+  if (Best->Function && Best->Function->isDeleted())
+return OR_Deleted;
+  if (auto *M = dyn_cast_or_null(Best->Function);
+  Kind == CSK_AddressOfOverloadSet && M &&
+  M->isImplicitObjectMemberFunction()) {
+return OR_No_Viable_Function;

cor3ntin wrote:

It was pre-existing but also... not great. I moved it to  
`BuildOverloadedCallExpr` and commented

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


[clang] [llvm] [Clang][AMDGPU] Add __builtin_amdgcn_cvt_off_f32_i4 (PR #133741)

2025-03-31 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez created 
https://github.com/llvm/llvm-project/pull/133741

This built-in that maps to `V_CVT_OFF_F32_I4` which treats its input as a 4-bit 
signed integer and returns `0.0625f * src`.

SWDEV-518861

From 41af38793161b0f1535c98c4695c36e081ef2f67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Thu, 27 Mar 2025 17:46:34 +0100
Subject: [PATCH] [Clang][AMDGPU] Add __builtin_amdgcn_cvt_off_f32_i4

This builtin maps to V_CVT_OFF_F32_I4 which treats its input as a 4-bit
signed integer and returns 0.0625f * src .

SWDEV-518861
---
 clang/include/clang/Basic/BuiltinsAMDGPU.def  |   1 +
 .../builtins-amdgcn-cvt-off-f32-i4.cl |  15 ++
 .../builtins-amdgcn-cvt-off-f32-i4-err.cl |   8 +
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td  |   6 +
 llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp |   1 +
 .../AMDGPU/AMDGPUInstCombineIntrinsic.cpp |   9 +
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  |   1 +
 llvm/lib/Target/AMDGPU/VOP1Instructions.td|   5 +
 .../AMDGPU/llvm.amdgcn.cvt.off.f32.i4.ll  |  23 +++
 .../AMDGPU/simplify-amdgcn.cvt.off.f32.i4.ll  | 158 ++
 10 files changed, 227 insertions(+)
 create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
 create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
 create mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.off.f32.i4.ll
 create mode 100644 llvm/test/CodeGen/AMDGPU/simplify-amdgcn.cvt.off.f32.i4.ll

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 44ef404aee72f..f38148cc795dc 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -140,6 +140,7 @@ BUILTIN(__builtin_amdgcn_cvt_pknorm_u16, "E2Usff", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_i16, "E2sii", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_u16, "E2UsUiUi", "nc")
 BUILTIN(__builtin_amdgcn_cvt_pk_u8_f32, "UifUiUi", "nc")
+BUILTIN(__builtin_amdgcn_cvt_off_f32_i4, "fUi", "nc")
 BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc")
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
new file mode 100644
index 0..6dc235f9cc6c7
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-cvt-off-f32-i4.cl
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL1.2 \
+// RUN: -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: @test_builtin_amdgcn_cvt_off_f32_i4(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[N_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:store i32 [[N:%.*]], ptr addrspace(5) [[N_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(5) [[N_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.amdgcn.cvt.off.f32.i4(i32 
[[TMP0]])
+// CHECK-NEXT:ret float [[TMP1]]
+//
+float test_builtin_amdgcn_cvt_off_f32_i4(unsigned n) {
+return __builtin_amdgcn_cvt_off_f32_i4(n);
+}
diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl 
b/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
new file mode 100644
index 0..f5b02b80c37da
--- /dev/null
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-cvt-off-f32-i4-err.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple amdgcn-- -verify -S -o - %s
+
+void test_builtin_amdgcn_cvt_off_f32_i4(unsigned n) {
+struct A{ unsigned x; } a;
+__builtin_amdgcn_cvt_off_f32_i4(n, n); // expected-error {{too many 
arguments to function call, expected 1, have 2}}
+__builtin_amdgcn_cvt_off_f32_i4(); // expected-error {{too few arguments 
to function call, expected 1, have 0}}
+__builtin_amdgcn_cvt_off_f32_i4(a); // expected-error {{passing '__private 
struct A' to parameter of incompatible type 'unsigned int'}}
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index f53016f62abbe..ebac0f9029791 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -3375,6 +3375,12 @@ def int_amdgcn_cvt_sr_fp8_f32 : 
ClangBuiltin<"__builtin_amdgcn_cvt_sr_fp8_f32">,
 [llvm_float_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
 [IntrNoMem, ImmArg>]>;
 
+// llvm.amdgcn.cvt.off.fp32.i4 int srcA
+def int_amdgcn_cvt_off_f32_i4: ClangBuiltin<"__builtin_amdgcn_cvt_off_f32_i4">,
+  DefaultAttrsIntrinsic<[llvm_float_ty],
+[llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
 
//===--===//
 // gfx950 intrinsics
 
//===--===//
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowerin

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits


@@ -3832,38 +3920,13 @@ OpenMPIRBuilder::createReductions(const 
LocationDescription &Loc,
   // Populate the outlined reduction function using the elementwise reduction
   // function. Partial values are extracted from the type-erased array of
   // pointers to private variables.
-  BasicBlock *ReductionFuncBlock =
-  BasicBlock::Create(Module->getContext(), "", ReductionFunc);
-  Builder.SetInsertPoint(ReductionFuncBlock);
-  Value *LHSArrayPtr = ReductionFunc->getArg(0);
-  Value *RHSArrayPtr = ReductionFunc->getArg(1);
+  Error Err = populateReductionFunction(ReductionFunc, ReductionInfos, Builder,
+IsByRef, false);

skatrak wrote:

```suggestion
IsByRef, /*IsGPU=*/false);
```

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


[clang] [Driver] Add linker options to support statical linking to shared flang-rt on AIX. (PR #131822)

2025-03-31 Thread Daniel Chen via cfe-commits

https://github.com/DanielCChen updated 
https://github.com/llvm/llvm-project/pull/131822

>From 21f3ec3b644ea201e3aa15d18f74c795ccf120f3 Mon Sep 17 00:00:00 2001
From: Daniel Chen 
Date: Tue, 18 Mar 2025 11:09:41 -0400
Subject: [PATCH 1/3] [Driver] Add linker options to support statical linking
 to shared flang-rt on AIX.

---
 clang/lib/Driver/ToolChains/AIX.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 001f3a5178943..7ed26c42c80ce 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -127,8 +127,15 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   // Force static linking when "-static" is present.
-  if (Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_static)) {
 CmdArgs.push_back("-bnso");
+// The folllowing linker options are needed to statically link to the
+// shared libflang_rt.runtime.a on AIX
+CmdArgs.push_back("-bI:/usr/lib/syscalls.exp");
+CmdArgs.push_back("-bI:/usr/lib/aio.exp");
+CmdArgs.push_back("-bI:/usr/lib/threads.exp");
+CmdArgs.push_back("-lcrypt");
+  }
 
   // Add options for shared libraries.
   if (Args.hasArg(options::OPT_shared)) {

>From 54eb891e4a9cb14830b680cd956edc85d40daff6 Mon Sep 17 00:00:00 2001
From: Daniel Chen 
Date: Sat, 29 Mar 2025 13:22:31 -0400
Subject: [PATCH 2/3] Make the addtional import list for static linking for
 flang invocation only.

---
 clang/lib/Driver/ToolChains/AIX.cpp | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 7ed26c42c80ce..2692ef75a2198 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -129,12 +129,15 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // Force static linking when "-static" is present.
   if (Args.hasArg(options::OPT_static)) {
 CmdArgs.push_back("-bnso");
-// The folllowing linker options are needed to statically link to the
-// shared libflang_rt.runtime.a on AIX
-CmdArgs.push_back("-bI:/usr/lib/syscalls.exp");
-CmdArgs.push_back("-bI:/usr/lib/aio.exp");
-CmdArgs.push_back("-bI:/usr/lib/threads.exp");
-CmdArgs.push_back("-lcrypt");
+
+if (D.IsFlangMode()) {
+  // The folllowing linker options are needed to statically link to the
+  // shared libflang_rt.runtime.a on AIX
+  CmdArgs.push_back("-bI:/usr/lib/syscalls.exp");
+  CmdArgs.push_back("-bI:/usr/lib/aio.exp");
+  CmdArgs.push_back("-bI:/usr/lib/threads.exp");
+  CmdArgs.push_back("-lcrypt");
+}
   }
 
   // Add options for shared libraries.

>From 28907a624a8d9561badc20d77254791918ba6210 Mon Sep 17 00:00:00 2001
From: Daniel Chen 
Date: Mon, 31 Mar 2025 12:17:13 -0400
Subject: [PATCH 3/3] Remove aio.exp as it is not needed.

---
 clang/lib/Driver/ToolChains/AIX.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 2692ef75a2198..1c26b58db400f 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -134,7 +134,6 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // The folllowing linker options are needed to statically link to the
   // shared libflang_rt.runtime.a on AIX
   CmdArgs.push_back("-bI:/usr/lib/syscalls.exp");
-  CmdArgs.push_back("-bI:/usr/lib/aio.exp");
   CmdArgs.push_back("-bI:/usr/lib/threads.exp");
   CmdArgs.push_back("-lcrypt");
 }

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


[clang] Remove duplicate API (PR #132776)

2025-03-31 Thread Vlad Serebrennikov via cfe-commits

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

libclang's API is called stable for a reason.
It's too late to remove anything. The best we can do is to implement one 
function in terms of another to avoid duplication on implementation side, and 
put `[[deprecated("use the other one")]]` on the one we think shouldn't be used.

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


[clang] [alpha.webkit.NoUnretainedMemberChecker] Ignore system-header-defined ivar / property of a forward declared type (PR #133755)

2025-03-31 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created 
https://github.com/llvm/llvm-project/pull/133755

Prior to this PR, we were emitting warnings for Objective-C ivars and 
properties if the forward declaration of the type appeared first in a 
non-system header. This PR fixes the checker so tha we'd ignore ivars and 
properties defined for a forward declared type.

>From 0fb864bc5ae7d2b58879a6ad59babffe722bbf72 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Mon, 31 Mar 2025 10:11:10 -0700
Subject: [PATCH] [alpha.webkit.NoUnretainedMemberChecker] Ignore
 system-header-defined ivar / property of a forward declared type

Prior to this PR, we were emitting warnings for Objective-C ivars and 
properties if the forward declaration of
the type appeared first in a non-system header. This PR fixes the checker so 
tha we'd ignore ivars and properties
defined for a forward declared type.
---
 .../Checkers/WebKit/RawPtrRefMemberChecker.cpp   | 5 +
 clang/test/Analysis/Checkers/WebKit/unretained-members.mm| 2 ++
 2 files changed, 7 insertions(+)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
index 89df1a725ab92..233bd8471bf89 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
@@ -133,6 +133,8 @@ class RawPtrRefMemberChecker
 
   void visitIvarDecl(const ObjCContainerDecl *CD,
  const ObjCIvarDecl *Ivar) const {
+if (BR->getSourceManager().isInSystemHeader(Ivar->getLocation()))
+  return;
 auto QT = Ivar->getType();
 const Type *IvarType = QT.getTypePtrOrNull();
 if (!IvarType)
@@ -154,6 +156,8 @@ class RawPtrRefMemberChecker
 
   void visitObjCPropertyDecl(const ObjCContainerDecl *CD,
  const ObjCPropertyDecl *PD) const {
+if (BR->getSourceManager().isInSystemHeader(PD->getLocation()))
+  return;
 auto QT = PD->getType();
 const Type *PropType = QT.getTypePtrOrNull();
 if (!PropType)
@@ -241,6 +245,7 @@ class RawPtrRefMemberChecker
  BR->getSourceManager());
 auto Report = std::make_unique(Bug, Os.str(), BSLoc);
 Report->addRange(Member->getSourceRange());
+Report->setDeclWithIssue(ClassCXXRD);
 BR->emitReport(std::move(Report));
   }
 
diff --git a/clang/test/Analysis/Checkers/WebKit/unretained-members.mm 
b/clang/test/Analysis/Checkers/WebKit/unretained-members.mm
index 92d70a94427c0..fff1f8ede091b 100644
--- a/clang/test/Analysis/Checkers/WebKit/unretained-members.mm
+++ b/clang/test/Analysis/Checkers/WebKit/unretained-members.mm
@@ -1,5 +1,7 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.webkit.NoUnretainedMemberChecker -verify %s
 
+@class SystemObject;
+
 #include "objc-mock-types.h"
 #include "mock-system-header.h"
 

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


[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-03-31 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-darwin` 
running on `doug-worker-3` while building `clang,llvm` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang-Unit :: 
DirectoryWatcher/./DirectoryWatcherTests/5/8' FAILED 
Script(shard):
--
GTEST_OUTPUT=json:/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/unittests/DirectoryWatcher/./DirectoryWatcherTests-Clang-Unit-11964-5-8.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=8 GTEST_SHARD_INDEX=5 
/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/unittests/DirectoryWatcher/./DirectoryWatcherTests
--

Script:
--
/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/unittests/DirectoryWatcher/./DirectoryWatcherTests
 --gtest_filter=DirectoryWatcherTest.DeleteWatchedDir
--
/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:259:
 Failure
Value of: WaitForExpectedStateResult.wait_for(EventualResultTimeout) == 
std::future_status::ready
  Actual: false
Expected: true
The expected result state wasn't reached before the time-out.

/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:262:
 Failure
Value of: TestConsumer.result().has_value()
  Actual: false
Expected: true


/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:259
Value of: WaitForExpectedStateResult.wait_for(EventualResultTimeout) == 
std::future_status::ready
  Actual: false
Expected: true
The expected result state wasn't reached before the time-out.

/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:262
Value of: TestConsumer.result().has_value()
  Actual: false
Expected: true






```



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


[clang] [clang] Automatically add the `returns_twice` attribute to certain functions even if `-fno-builtin` is set (PR #133511)

2025-03-31 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-aarch64-linux` 
running on `sanitizer-buildbot7` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/aarch64-unknown-linux-gnu".
 This path was found by running 
['/home/b/sanitizer-aarch64-linux/build/build_default/bin/clang', 
'--target=aarch64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-beta', '-nobuiltininc', 
'-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/include', 
'-idirafter', 
'/home/b/sanitizer-aarch64-linux/build/build_default/lib/clang/21/include', 
'-resource-dir=/home/b/sanitizer-aarch64-linux/build/compiler_rt_build', 
'-Wl,-rpath,/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/linux', 
'-print-runtime-dir'].
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/aarch64-unknown-linux-gnu".
 This path was found by running 
['/home/b/sanitizer-aarch64-linux/build/build_default/bin/clang', 
'--target=aarch64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-beta', '-nobuiltininc', 
'-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/include', 
'-idirafter', 
'/home/b/sanitizer-aarch64-linux/build/build_default/lib/clang/21/include', 
'-resource-dir=/home/b/sanitizer-aarch64-linux/build/compiler_rt_build', 
'-Wl,-rpath,/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/linux', 
'-print-runtime-dir'].
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/aarch64-unknown-linux-gnu".
 This path was found by running 
['/home/b/sanitizer-aarch64-linux/build/build_default/bin/clang', 
'--target=aarch64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-beta', '-nobuiltininc', 
'-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/include', 
'-idirafter', 
'/home/b/sanitizer-aarch64-linux/build/build_default/lib/clang/21/include', 
'-resource-dir=/home/b/sanitizer-aarch64-linux/build/compiler_rt_build', 
'-Wl,-rpath,/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/linux', 
'-print-runtime-dir'].
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/aarch64-unknown-linux-gnu".
 This path was found by running 
['/home/b/sanitizer-aarch64-linux/build/build_default/bin/clang', 
'--target=aarch64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-beta', '-nobuiltininc', 
'-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/include', 
'-idirafter', 
'/home/b/sanitizer-aarch64-linux/build/build_default/lib/clang/21/include', 
'-resource-dir=/home/b/sanitizer-aarch64-linux/build/compiler_rt_build', 
'-Wl,-rpath,/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/linux', 
'-print-runtime-dir'].
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/aarch64-unknown-linux-gnu".
 This path was found by running 
['/home/b/sanitizer-aarch64-linux/build/build_default/bin/clang', 
'--target=aarch64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-beta', '-nobuiltininc', 
'-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/include', 
'-idirafter', 
'/home/b/sanitizer-aarch64-linux/build/build_default/lib/clang/21/include', 
'-resource-dir=/home/b/sanitizer-aarch64-linux/build/compiler_rt_build', 
'-Wl,-rpath,/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/linux', 
'-print-runtime-dir'].
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/home/b/sanitizer-aarch64-linux/build/compiler_rt_build/lib/aarch64-unknown-linux-gnu".
 This path was found by running 
['/home/b/sanitizer-aarch64-linux/build/build_default/bin/clang', 
'--target=aarch64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-be

[clang] [clang] Clear `NeedsCleaning` flag after `ExpandBuiltinMacro` (PR #133574)

2025-03-31 Thread Aaron Ballman via cfe-commits


@@ -1646,7 +1646,6 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
 
   // Set up the return result.
   Tok.setIdentifierInfo(nullptr);
-  Tok.clearFlag(Token::NeedsCleaning);

AaronBallman wrote:

There are early returns between where we used to clear the needs cleaning flag 
and where we set it now; doesn't this mean we'll leave the flag in "needs 
cleaning" state in circumstances where it won't need cleaning (e.g., when 
dealing with `__DATE__`)?

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


[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

2025-03-31 Thread Jonas Paulsson via cfe-commits

JonPsson1 wrote:

Patch rebased.

The reported formatting issue here is in the test which however was mostly 
copied from a pre-existing test, so maybe clang-format should be done on all 
these tests or not. Skipping it for now.

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


[clang-tools-extra] [clang-tidy] Use --match-full-lines instead of --strict-whitespace in check_clang_tidy (PR #133756)

2025-03-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Nicolas van Kempen (nicovank)


Changes


See Discourse post here:
https://discourse.llvm.org/t/rfc-using-match-full-lines-in-clang-tidy-tests/85553

I've added `--match-partial-fixes` to all tests that were failing, unless I 
noticed the fix was quick and trivial. I'll do a second pass after this lands 
to update more tests.


---

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


97 Files Affected:

- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+6) 
- (modified) clang-tools-extra/test/clang-tidy/check_clang_tidy.py (+15-9) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-addition.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-comparison.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-conversion-cast.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-float.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-scale.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-subtraction.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/time-comparison.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/time-subtraction.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/abseil/upgrade-duration-conversions.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/altera/struct-pack-align.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/android/cloexec-memfd-create.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/android/cloexec-open.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/android/cloexec-socket.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/move-forwarding-reference.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-in-initialization-strlen.c
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-memcpy-safe-cxx.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/posix-return.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp 
(+22-22) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/stringview-nullptr.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-string-compare.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-use-assignment.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/google/build-explicit-make-pair.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-nsobject-new.m 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/google/upgrade-googletest-case.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-register-over-unsigned.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-register-over-unsigned2.cpp
 (+2-2) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-register-over-unsigned3.cpp
 (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/llvm/twine-local.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers

[clang] [llvm] [HLSL][RootSignature] Implement parsing of a DescriptorTable with empty clauses (PR #133302)

2025-03-31 Thread Finn Plummer via cfe-commits

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


[clang-tools-extra] [clang-tidy] Use --match-full-lines instead of --strict-whitespace in check_clang_tidy (PR #133756)

2025-03-31 Thread Nicolas van Kempen via cfe-commits




nicovank wrote:

The main changes are here.

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


  1   2   3   4   >