[clang] [HLSL][NFC] Refactor HLSLExternalSemaSource (PR #131032)

2025-03-20 Thread Ashley Coleman via cfe-commits

https://github.com/V-FEXrt approved this pull request.


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


[clang-tools-extra] [clang-doc][fix] crashes when generating HTML without `--repository` (PR #131698)

2025-03-20 Thread Paul Kirth via cfe-commits

ilovepi wrote:

hey, sorry, I ended up landing 
https://github.com/llvm/llvm-project/pull/131939. There are two reasons: 1) I 
really wanted to fix that crash ASAP. 2) I made the mistake of stacking other 
patches on top of it with graphite, and it turns out it isn't easy to reorder 
them. As a result I couldn't fix the basic functionality of HTML links without 
reuploading the entire rest of the stack. Normally, I'd much prefer to just 
mentor you through the process, but I really needed to fix those links.

If you're still interested in working on this though, I think the test could be 
improved , and I wouldn't mid seeing that code cleaned up. In particular, I'm 
wondering how great of an idea it is to use those optionals, when we end up w/ 
a `.value_or("")`.  The amount of unique_ptr we're using is also not the 
greatest. And I wouldn't be surprised if using ASan/TSan on something like LLVM 
wouldn't find several bugs. Lastly, the testing story in clang-doc is quite 
weak. We've improved it a lot over last year's GSOC, but I still don't think 
its all that well exercised.


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


[clang] [HLSL] Buffer handle globals should not be constants (PR #130231)

2025-03-20 Thread Justin Bogner via cfe-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/130231

>From bf5e5b4b1060f51d37b05c905b4327a40316f158 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Thu, 6 Mar 2025 17:50:12 -0800
Subject: [PATCH] [HLSL] Buffer handle globals should not be constants

If these are constants their initializers will be removed by
InstCombine. Change them to not be constants and initialize them with
poison.
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp | 13 ++---
 clang/test/CodeGenHLSL/cbuffer.hlsl | 10 +-
 clang/test/CodeGenHLSL/cbuffer_and_namespaces.hlsl  |  6 +++---
 clang/test/CodeGenHLSL/cbuffer_with_packoffset.hlsl |  2 +-
 .../cbuffer_with_static_global_and_function.hlsl|  2 +-
 clang/test/CodeGenHLSL/default_cbuffer.hlsl |  2 +-
 6 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index a273f1e50c8b5..e3e3102fe8d5c 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -31,7 +31,6 @@
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
 #include "llvm/Support/Alignment.h"
-
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 
@@ -245,12 +244,12 @@ void CGHLSLRuntime::addBuffer(const HLSLBufferDecl 
*BufDecl) {
   llvm::TargetExtType *TargetTy =
   cast(convertHLSLSpecificType(
   ResHandleTy, BufDecl->hasValidPackoffset() ? &Layout : nullptr));
-  llvm::GlobalVariable *BufGV =
-  new GlobalVariable(TargetTy, /*isConstant*/ true,
- GlobalValue::LinkageTypes::ExternalLinkage, nullptr,
- llvm::formatv("{0}{1}", BufDecl->getName(),
-   BufDecl->isCBuffer() ? ".cb" : ".tb"),
- GlobalValue::NotThreadLocal);
+  llvm::GlobalVariable *BufGV = new GlobalVariable(
+  TargetTy, /*isConstant*/ false,
+  GlobalValue::LinkageTypes::ExternalLinkage, PoisonValue::get(TargetTy),
+  llvm::formatv("{0}{1}", BufDecl->getName(),
+BufDecl->isCBuffer() ? ".cb" : ".tb"),
+  GlobalValue::NotThreadLocal);
   CGM.getModule().insertGlobalVariable(BufGV);
 
   // Add globals for constant buffer elements and create metadata nodes
diff --git a/clang/test/CodeGenHLSL/cbuffer.hlsl 
b/clang/test/CodeGenHLSL/cbuffer.hlsl
index b5e435619438f..2220154bc7bbd 100644
--- a/clang/test/CodeGenHLSL/cbuffer.hlsl
+++ b/clang/test/CodeGenHLSL/cbuffer.hlsl
@@ -39,7 +39,7 @@ cbuffer CBScalars : register(b1, space5) {
   int64_t a8;
 }
 
-// CHECK: @CBScalars.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CBScalars, 
+// CHECK: @CBScalars.cb = global target("dx.CBuffer", target("dx.Layout", 
%__cblayout_CBScalars,
 // CHECK-SAME: 56, 0, 8, 16, 24, 32, 36, 40, 48))
 // CHECK: @a1 = external addrspace(2) global float, align 4
 // CHECK: @a2 = external addrspace(2) global double, align 8
@@ -61,7 +61,7 @@ cbuffer CBVectors {
   // FIXME: add a bool vectors after llvm-project/llvm#91639 is added
 }
 
-// CHECK: @CBVectors.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CBVectors, 
+// CHECK: @CBVectors.cb = global target("dx.CBuffer", target("dx.Layout", 
%__cblayout_CBVectors,
 // CHECK-SAME: 136, 0, 16, 40, 48, 80, 96, 112))
 // CHECK: @b1 = external addrspace(2) global <3 x float>, align 16
 // CHECK: @b2 = external addrspace(2) global <3 x double>, align 32
@@ -82,7 +82,7 @@ cbuffer CBArrays : register(b2) {
   bool c8[4];
 }
 
-// CHECK: @CBArrays.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CBArrays, 
+// CHECK: @CBArrays.cb = global target("dx.CBuffer", target("dx.Layout", 
%__cblayout_CBArrays,
 // CHECK-SAME: 708, 0, 48, 112, 176, 224, 608, 624, 656))
 // CHECK: @c1 = external addrspace(2) global [3 x float], align 4
 // CHECK: @c2 = external addrspace(2) global [2 x <3 x double>], align 32
@@ -113,7 +113,7 @@ struct D {
   Empty es;
 };
 
-// CHECK: @CBStructs.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CBStructs, 
+// CHECK: @CBStructs.cb = global target("dx.CBuffer", target("dx.Layout", 
%__cblayout_CBStructs,
 // CHECK-SAME: 246, 0, 16, 32, 64, 144, 238, 240))
 // CHECK: @a = external addrspace(2) global target("dx.Layout", %A, 8, 0), 
align 8
 // CHECK: @b = external addrspace(2) global target("dx.Layout", %B, 14, 0, 8), 
align 8
@@ -137,7 +137,7 @@ struct Test {
 float a, b;
 };
 
-// CHECK: @CBMix.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CBMix,
+// CHECK: @CBMix.cb = global target("dx.CBuffer", target("dx.Layout", 
%__cblayout_CBMix,
 // CHECK-SAME: 170, 0, 24, 32, 120, 128, 136, 144, 152, 160, 168))
 // CHECK: @test = external addrspace(2) global [2 x target("dx.Layout", %Test, 
8, 0, 4)], align 4
 // CHECK: @f1 = external addrspace(2) global float, align 4
diff --git a/clang/test/CodeGen

[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Sergei Barannikov via cfe-commits


@@ -0,0 +1,102 @@
+//===-- CGBuiltin.h - LLVM CodeGen wrappers for llvm::Value* --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+
+#include "CodeGenFunction.h"
+
+using namespace clang;

s-barannikov wrote:

Are `using` directives permitted in header files?


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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Sergei Barannikov via cfe-commits


@@ -0,0 +1,102 @@
+//===-- CGBuiltin.h - LLVM CodeGen wrappers for llvm::Value* --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+
+#include "CodeGenFunction.h"
+
+using namespace clang;
+using namespace CodeGen;
+using namespace llvm;
+
+// Many of MSVC builtins are on x64, ARM and AArch64; to avoid repeating code,
+// we handle them here.
+enum class CodeGenFunction::MSVCIntrin {
+  _BitScanForward,
+  _BitScanReverse,
+  _InterlockedAnd,
+  _InterlockedCompareExchange,
+  _InterlockedDecrement,
+  _InterlockedExchange,
+  _InterlockedExchangeAdd,
+  _InterlockedExchangeSub,
+  _InterlockedIncrement,
+  _InterlockedOr,
+  _InterlockedXor,
+  _InterlockedExchangeAdd_acq,
+  _InterlockedExchangeAdd_rel,
+  _InterlockedExchangeAdd_nf,
+  _InterlockedExchange_acq,
+  _InterlockedExchange_rel,
+  _InterlockedExchange_nf,
+  _InterlockedCompareExchange_acq,
+  _InterlockedCompareExchange_rel,
+  _InterlockedCompareExchange_nf,
+  _InterlockedCompareExchange128,
+  _InterlockedCompareExchange128_acq,
+  _InterlockedCompareExchange128_rel,
+  _InterlockedCompareExchange128_nf,
+  _InterlockedOr_acq,
+  _InterlockedOr_rel,
+  _InterlockedOr_nf,
+  _InterlockedXor_acq,
+  _InterlockedXor_rel,
+  _InterlockedXor_nf,
+  _InterlockedAnd_acq,
+  _InterlockedAnd_rel,
+  _InterlockedAnd_nf,
+  _InterlockedIncrement_acq,
+  _InterlockedIncrement_rel,
+  _InterlockedIncrement_nf,
+  _InterlockedDecrement_acq,
+  _InterlockedDecrement_rel,
+  _InterlockedDecrement_nf,
+  __fastfail,
+};
+
+// Emit a simple intrinsic that has N scalar arguments and a return type
+// matching the argument type. It is assumed that only the first argument is
+// overloaded.
+template 
+static Value *emitBuiltinWithOneOverloadedType(CodeGenFunction &CGF,

s-barannikov wrote:

It seems to be used only in AMDGPU.cpp. If the plan is to reuse it in other 
files, should it omit static?

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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Sergei Barannikov via cfe-commits


@@ -0,0 +1,102 @@
+//===-- CGBuiltin.h - LLVM CodeGen wrappers for llvm::Value* --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+
+#include "CodeGenFunction.h"
+
+using namespace clang;
+using namespace CodeGen;
+using namespace llvm;
+
+// Many of MSVC builtins are on x64, ARM and AArch64; to avoid repeating code,
+// we handle them here.
+enum class CodeGenFunction::MSVCIntrin {

s-barannikov wrote:

The contents of this file should be in `clang::` namespace (or rather in 
`clang::CodeGen::`).
This would allow eliminating two `using` directives above.

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-03-20 Thread Ashley Coleman via cfe-commits


@@ -19681,6 +19681,21 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 getDotProductIntrinsic(CGM.getHLSLRuntime(), VecTy0->getElementType()),
 ArrayRef{Op0, Op1}, nullptr, "hlsl.dot");
   }
+  case Builtin::BI__builtin_hlsl_dot2add: {
+llvm::Triple::ArchType Arch = CGM.getTarget().getTriple().getArch();
+if (Arch != llvm::Triple::dxil) {
+  llvm_unreachable("Intrinsic dot2add can be executed as a builtin only on 
dxil");
+}
+Value *A = EmitScalarExpr(E->getArg(0));
+Value *B = EmitScalarExpr(E->getArg(1));
+Value *C = EmitScalarExpr(E->getArg(2));
+
+//llvm::Intrinsic::dx_##IntrinsicPostfix

V-FEXrt wrote:

Delete outdated commented code

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-03-20 Thread Ashley Coleman via cfe-commits


@@ -19681,6 +19681,21 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 getDotProductIntrinsic(CGM.getHLSLRuntime(), VecTy0->getElementType()),
 ArrayRef{Op0, Op1}, nullptr, "hlsl.dot");
   }
+  case Builtin::BI__builtin_hlsl_dot2add: {
+llvm::Triple::ArchType Arch = CGM.getTarget().getTriple().getArch();
+if (Arch != llvm::Triple::dxil) {
+  llvm_unreachable("Intrinsic dot2add can be executed as a builtin only on 
dxil");
+}

V-FEXrt wrote:

IMO you  should use assert here. Its not that this is "unreachable" its that 
arriving here is a developer bug

```suggestion
assert(Arch == llvm::Triple::dxil && "Intrinsic dot2add can be executed as 
a builtin only on dxil");
```

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


[clang-tools-extra] [clang-tidy] 'modernize-use-starts-ends-with': fixed false positives on `find` and `rfind` (PR #129564)

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

vbvictor wrote:

Since commit access request takes time than I expected, could you please merge 
this PR, @nicovank?
Thank you in advance

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


[clang] [llvm] Hlsl asint16 intrinsic (PR #131900)

2025-03-20 Thread via cfe-commits

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


[clang] [llvm] Hlsl asuint16 function (PR #132315)

2025-03-20 Thread via cfe-commits

https://github.com/metkarpoonam updated 
https://github.com/llvm/llvm-project/pull/132315

>From 6ce249d7e4bea669480c06a935f88a21894aba67 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar 
Date: Wed, 19 Mar 2025 09:16:30 -0700
Subject: [PATCH 1/8] Add asuint16 intrinsic and codegen test

---
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 17 +++
 clang/test/CodeGenHLSL/builtins/asuint16.hlsl | 48 +++
 2 files changed, 65 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/builtins/asuint16.hlsl

diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index a48a8e998a015..4d06aa7f5e207 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -80,6 +80,23 @@ void asuint(double3, out uint3, out uint3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
 void asuint(double4, out uint4, out uint4);
 
+//===--===//
+// asuint16 builtins
+//===--===//
+
+/// \fn uint16_t asuint16(T Val)
+/// \brief Interprets the bit pattern of x as an 16-bit unsigned integer.
+/// \param Val The input value.
+#ifdef __HLSL_ENABLE_16BIT
+template  constexpr vector asuint16(vector V) {
+  return __detail::bit_cast(V);
+}
+
+template  constexpr uint16_t asuint16(T F) {
+  return __detail::bit_cast(F);
+}
+#endif
+
 
//===--===//
 // distance builtins
 
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/asuint16.hlsl 
b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
new file mode 100644
index 0..7387520947efe
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/asuint16.hlsl
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple 
dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | 
FileCheck %s
+// CHECK: define {{.*}}test_ints{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+// CHECK-NOT: bitcast
+// CHECK: ret i16 [[VAL]]
+uint16_t test_int(int16_t p0)
+{
+return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_uint{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret i16 [[VAL]]
+uint16_t test_uint(uint16_t p0)
+{
+return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_half{{.*}}(half {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast half [[VAL]] to i16
+//CHECK : ret i16 [[RES]]
+uint16_t test_half(half p0)
+{
+return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_int{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+uint16_t4 test_vector_int(int16_t4 p0)
+{
+return asuint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_uint{{.*}}(<4 x i16> {{.*}} 
[[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+uint16_t4 test_vector_uint(uint16_t4 p0)
+{
+return asuint16(p0);
+}
+
+//CHECK: define {{.*}}fn{{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast <4 x half> [[VAL]] to <4 x i16>
+//CHECK: ret <4 x i16> [[RES]]
+uint16_t4 fn(half4 p1)
+{
+return asuint16(p1);
+}

>From a912b35743a13079679b111702dbe313ec0683ee Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar 
Date: Thu, 20 Mar 2025 11:06:29 -0700
Subject: [PATCH 2/8] Update the uint16 function call and add space in
 uint16.hlsl

---
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 23 ++-
 clang/test/CodeGenHLSL/builtins/asuint16.hlsl |  2 ++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 4d06aa7f5e207..70cbed851f0f0 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -84,15 +84,26 @@ void asuint(double4, out uint4, out uint4);
 // asuint16 builtins
 
//===--===//
 
-/// \fn uint16_t asuint16(T Val)
-/// \brief Interprets the bit pattern of x as an 16-bit unsigned integer.
-/// \param Val The input value.
-#ifdef __HLSL_ENABLE_16BIT
-template  constexpr vector asuint16(vector V) {
+/// \fn uint16_t asuint16(T X)
+/// \brief Interprets the bit pattern of \a X as an 16-bit unsigned integer.
+/// \param X The input value.
+#ifdef __HLSL_ENABLE_16_BIT
+
+template 
+constexpr __detail::enable_if_t<__detail::is_same::value ||
+__detail::is_same::value ||
+__detail::is_same::value,
+vector>
+asuint16(vector V) {
   return __detail::bit_cast(V);
 }
 
-template  constexpr uint16_t asuint16(T F) {
+template 
+constexpr __detail::enable_if_t<__detail::is_same::value ||
+__detail::is_same::value ||
+

[clang] [alpha.webkit.RetainPtrCtorAdoptChecker] Support adopt(cast(copy(~)) (PR #132316)

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

https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/132316

>From 642057c409b1c3b98ee4ecb16e95b5fb5be47a01 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 20 Mar 2025 17:54:22 -0700
Subject: [PATCH 1/2] [alpha.webkit.RetainPtrCtorAdoptChecker] Support
 adopt(cast(copy(~))

This PR adds the support for recognizing calling adoptCF/adoptNS on the result 
of a cast
operation on the return value of a function which creates NS or CF types. It 
also fixes
a bug that we weren't reporting memory leaks when CF types are created without 
ever
calling RetainPtr's constructor, adoptCF, or adoptNS.

To do this, this PR adds a new mechanism to report a memory leak whenever 
create or copy
CF functions are invoked unless this CallExpr has already been visited while 
validating
a call to adoptCF. Also added an early exit when isOwned returns 
IsOwnedResult::Skip due
to an unresolved template argument.
---
 .../WebKit/RetainPtrCtorAdoptChecker.cpp  | 70 ++
 .../Checkers/WebKit/objc-mock-types.h | 72 ++-
 .../WebKit/retain-ptr-ctor-adopt-use-arc.mm   |  9 ++-
 .../WebKit/retain-ptr-ctor-adopt-use.mm   |  9 ++-
 4 files changed, 140 insertions(+), 20 deletions(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
index 4ce3262e90e13..2d9620cc8ee5e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
@@ -34,6 +34,7 @@ class RetainPtrCtorAdoptChecker
   mutable BugReporter *BR;
   mutable std::unique_ptr Summaries;
   mutable llvm::DenseSet CreateOrCopyOutArguments;
+  mutable llvm::DenseSet CreateOrCopyFnCall;
   mutable RetainTypeChecker RTC;
 
 public:
@@ -119,7 +120,7 @@ class RetainPtrCtorAdoptChecker
   return;
 
 if (!isAdoptFn(F) || !CE->getNumArgs()) {
-  rememberOutArguments(CE, F);
+  checkCreateOrCopyFunction(CE, F, DeclWithIssue);
   return;
 }
 
@@ -128,24 +129,30 @@ class RetainPtrCtorAdoptChecker
 auto Name = safeGetName(F);
 if (Result == IsOwnedResult::Unknown)
   Result = IsOwnedResult::NotOwned;
-if (Result == IsOwnedResult::NotOwned && !isAllocInit(Arg) &&
-!isCreateOrCopy(Arg)) {
-  if (auto *DRE = dyn_cast(Arg)) {
-if (CreateOrCopyOutArguments.contains(DRE->getDecl()))
-  return;
-  }
-  if (RTC.isARCEnabled() && isAdoptNS(F))
-reportUseAfterFree(Name, CE, DeclWithIssue, "when ARC is disabled");
-  else
-reportUseAfterFree(Name, CE, DeclWithIssue);
+if (isAllocInit(Arg) || isCreateOrCopy(Arg)) {
+  CreateOrCopyFnCall.insert(Arg); // Avoid double reporting.
+  return;
+}
+if (Result == IsOwnedResult::Owned || Result == IsOwnedResult::Skip)
+  return;
+
+if (auto *DRE = dyn_cast(Arg)) {
+  if (CreateOrCopyOutArguments.contains(DRE->getDecl()))
+return;
 }
+if (RTC.isARCEnabled() && isAdoptNS(F))
+  reportUseAfterFree(Name, CE, DeclWithIssue, "when ARC is disabled");
+else
+  reportUseAfterFree(Name, CE, DeclWithIssue);
   }
 
-  void rememberOutArguments(const CallExpr *CE,
-const FunctionDecl *Callee) const {
+  void checkCreateOrCopyFunction(const CallExpr *CE,
+ const FunctionDecl *Callee,
+ const Decl *DeclWithIssue) const {
 if (!isCreateOrCopyFunction(Callee))
   return;
 
+bool hasOutArgument = false;
 unsigned ArgCount = CE->getNumArgs();
 for (unsigned ArgIndex = 0; ArgIndex < ArgCount; ++ArgIndex) {
   auto *Arg = CE->getArg(ArgIndex)->IgnoreParenCasts();
@@ -164,7 +171,10 @@ class RetainPtrCtorAdoptChecker
   if (!Decl)
 continue;
   CreateOrCopyOutArguments.insert(Decl);
+  hasOutArgument = true;
 }
+if (!hasOutArgument && !CreateOrCopyFnCall.contains(CE))
+  reportLeak(CE, DeclWithIssue);
   }
 
   void visitConstructExpr(const CXXConstructExpr *CE,
@@ -190,6 +200,13 @@ class RetainPtrCtorAdoptChecker
 std::string Name = "RetainPtr constructor";
 auto *Arg = CE->getArg(0)->IgnoreParenCasts();
 auto Result = isOwned(Arg);
+
+if (isCreateOrCopy(Arg))
+  CreateOrCopyFnCall.insert(Arg); // Avoid double reporting.
+
+if (Result == IsOwnedResult::Skip)
+  return;
+
 if (Result == IsOwnedResult::Unknown)
   Result = IsOwnedResult::NotOwned;
 if (Result == IsOwnedResult::Owned)
@@ -303,11 +320,22 @@ class RetainPtrCtorAdoptChecker
 if (auto *Callee = CE->getDirectCallee()) {
   if (isAdoptFn(Callee))
 return IsOwnedResult::NotOwned;
-  if (safeGetName(Callee) == "__builtin___CFStringMakeConstantString")
+  auto Name = safeGetName(Callee);
+  if (Name == "__builtin___CFStringMakeConstantString")
 return IsO

[clang] [alpha.webkit.RetainPtrCtorAdoptChecker] Support adopt(cast(copy(~)) (PR #132316)

2025-03-20 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 fe6bced9e40f7d4c35550c51ef9cdc7be2a055e7 
642057c409b1c3b98ee4ecb16e95b5fb5be47a01 --extensions h,cpp -- 
clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp 
clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
``





View the diff from clang-format here.


``diff
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
index 2d9620cc8e..5f9d7b81f1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
@@ -146,8 +146,7 @@ public:
   reportUseAfterFree(Name, CE, DeclWithIssue);
   }
 
-  void checkCreateOrCopyFunction(const CallExpr *CE,
- const FunctionDecl *Callee,
+  void checkCreateOrCopyFunction(const CallExpr *CE, const FunctionDecl 
*Callee,
  const Decl *DeclWithIssue) const {
 if (!isCreateOrCopyFunction(Callee))
   return;
@@ -203,7 +202,7 @@ public:
 
 if (isCreateOrCopy(Arg))
   CreateOrCopyFnCall.insert(Arg); // Avoid double reporting.
-
+
 if (Result == IsOwnedResult::Skip)
   return;
 

``




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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Jonathan Thackray via cfe-commits


@@ -61,6 +61,16 @@ add_clang_library(clangCodeGen
   CGAtomic.cpp
   CGBlocks.cpp
   CGBuiltin.cpp
+  TargetBuiltins/AArch64.cpp

jthackray wrote:

Done.

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


[clang] [llvm] [RISCV][MC] Implement MC for Base P extension (PR #123271)

2025-03-20 Thread Craig Topper via cfe-commits


@@ -0,0 +1,1079 @@
+//===-- RISCVInstrInfoP.td - RISC-V 'P' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Base P'
+// Packed SIMD instruction set extension.
+//
+//  This version is still experimental as the 'P' extension hasn't been
+//  ratified yet.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def RVPGPRPairRV32 : RegisterOperand {
+  let ParserMatchClass = GPRPairRV32Operand;
+  let EncoderMethod = "getRVPGPRPair";
+  let DecoderMethod = "decodeRVPGPRPair";
+}
+
+def simm10 : RISCVSImmLeafOp<10> {
+  let MCOperandPredicate = [{
+int64_t Imm;
+if (!MCOp.evaluateAsConstantImm(Imm))
+  return false;
+return isInt<10>(Imm);
+  }];
+}
+
+//===--===//
+// Instruction class templates
+//===--===//
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnary funct5, bits<7> wuimm,
+   bits<3> funct3, RISCVOpcode opcode,
+   string opcodestr>
+: RVInstIBase {
+  let Inst{31-27} = funct5;
+  let Inst{26-20} = wuimm;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm9 funct7, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins simm10:$simm10),
+  opcodestr, "$rd, $simm10"> {
+  bits<10> simm10;
+
+  let Inst{31-25} = funct7;
+  let Inst{24-15} = simm10;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm9Rdp funct7, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
+  (ins simm10:$simm10),
+  opcodestr, "$rdp, $simm10"> {
+  bits<10> simm10;
+  bits<4> rdp;
+
+  let Inst{31-25} = funct7;
+  let Inst{24-15} = simm10;
+  let Inst{11-8}  = rdp;
+  let Inst{7} = 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm8 funct8, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins uimm8:$uimm8),
+  opcodestr, "$rd, $uimm8"> {
+  bits<8> uimm8;
+
+  let Inst{31-24} = funct8;
+  let Inst{23-16} = uimm8;
+  let Inst{15}= 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm8Rdp funct8, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
+  (ins uimm8:$uimm8), opcodestr, "$rdp, $uimm8"> {
+  bits<8> uimm8;
+  bits<4> rdp;
+
+  let Inst{31-24} = funct8;
+  let Inst{23-16} = uimm8;
+  let Inst{15}= 0b0;
+  let Inst{11-8}  = rdp;
+  let Inst{7} = 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryWUF w, bits<5> uf, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins GPR:$rs1),
+  opcodestr, "$rd, $rs1">  {
+  let Inst{31-27} = 0b11100;
+  let Inst{26-25} = w;
+  let Inst{24-20} = uf;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryWUFRs1pRdp w, bits<5> uf, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
+  (ins RVPGPRPairRV32:$rs1p), opcodestr, "$rdp, $rs1p">  {
+  bits<4> rs1p;
+  bits<4> rdp;
+
+  let Inst{31-27} = 0b01100;
+  let Inst{26-25} = w;
+  let Inst{24-20} = uf;
+  let Inst{19-16} = rs1p;
+  let Inst{15}= 0b0;
+  let Inst{11-8}  = rdp;
+  let Inst{7} = 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryF f, bit aft, bits<7> wuimm, string opcodestr,
+bits<3> funct3, dag outs, dag ins, string argstr>
+: RVInstIBase  {
+  let Inst{31}= bfr;
+  let Inst{30-28} = f;
+  let Inst{27}= aft;
+  let Inst{26-20} = wuimm;
+}
+
+class RVPUnary1F0 f, bits<7> wuimm, string opcodestr>
+: RVPUnaryF<1, f, 0, wuimm, opcodestr, 0b100, (outs GPR:$rd),
+(ins GPR:$rs1), "$rd, $rs1">;
+
+class RVPUnary0F0Rdp f, bits<7> wuimm, string opcodestr>
+: RVPUnaryF<0, f, 0, wuimm, opcodestr, 0b010, (outs RVPGPRPairRV32:$rdp),
+   (ins GPR:$rs1), "$rdp, $rs1"> {
+  bits<4> rdp;
+
+  let Inst{11-8} = rdp;
+  let Inst{7}= 0b0;
+}
+
+class RVPUnary0F0Rs1p f, bits<7> wuimm, string opcodestr>
+: RVPUnaryF<0, f, 0, wuimm, opcodestr, 0b100, (outs GPR:$rd),
+(ins RVPGPRPairRV32:$rs1p), "$rd, $rs1p"> {
+  bits<4> rs1p;
+
+  let Inst{19-16} = rs

[clang] [llvm] Hlsl asuint16 function (PR #132315)

2025-03-20 Thread via cfe-commits


@@ -0,0 +1,38 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | 
FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - 
-filetype=obj | spirv-val %}
+
+; CHECK-DAG: %[[#half:]] = OpTypeFloat 16

metkarpoonam wrote:

I've removed the asuint16.ll as suggested.

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


[clang] [llvm] Hlsl asuint16 function (PR #132315)

2025-03-20 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 fe6bced9e40f7d4c35550c51ef9cdc7be2a055e7 
4c0e7637f9aa34bd13c6d0e5b72519eb0e543a99 --extensions h -- 
clang/lib/Headers/hlsl/hlsl_intrinsics.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 228d2e0646..103709f3ba 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -94,8 +94,7 @@ _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 constexpr __detail::enable_if_t<__detail::is_same::value ||
 __detail::is_same::value ||
 __detail::is_same::value,
-vector>
-asuint16(vector V) {
+vector> asuint16(vector V) {
   return __detail::bit_cast(V);
 }
 
@@ -104,8 +103,7 @@ _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
 constexpr __detail::enable_if_t<__detail::is_same::value ||
 __detail::is_same::value ||
 __detail::is_same::value,
-uint16_t>
-asuint16(T F) {
+uint16_t> asuint16(T F) {
   return __detail::bit_cast(F);
 }
 #endif

``




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


[clang] [llvm] [RISCV] Add Svrsw60t59b extension (PR #132321)

2025-03-20 Thread Craig Topper via cfe-commits


@@ -55,6 +55,7 @@
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
 // CHECK-NOT: __riscv_svvptc {{.*$}}
+// CHECK-NOT: __riscv_svrsw60t59b {{.*$}}

topperc wrote:

This should be above __riscv_svvptc alphabetically

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


[clang] [llvm] [RISCV] Add Svrsw60t59b extension (PR #132321)

2025-03-20 Thread Craig Topper via cfe-commits


@@ -984,6 +984,10 @@ def FeatureStdExtSvvptc
 : RISCVExtension<1, 0,
  "Obviating Memory-Management Instructions after Marking 
PTEs Valid">;
 
+def FeatureStdExtSvrsw60t59b

topperc wrote:

Put this above FeatureStdExtSvvptc

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


[clang] [Dependency Scanning] Teach `DependencyScanningTool::getModuleDependencies` to Process a List of Module Names (PR #129915)

2025-03-20 Thread Qiongsi Wu via cfe-commits

https://github.com/qiongsiwu updated 
https://github.com/llvm/llvm-project/pull/129915

>From 7f29cb0c9e422f00ce5b6b26af8ebfb228b59830 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu 
Date: Wed, 5 Mar 2025 11:16:38 -0800
Subject: [PATCH 1/3] Changing DependencyScanningTool::getModuleDependencies to
 take a list of module names instead of one module name.

---
 .../include/clang/Frontend/FrontendActions.h  |  6 ++--
 .../DependencyScanningTool.h  | 14 
 .../DependencyScanningWorker.h|  6 ++--
 clang/lib/Frontend/FrontendActions.cpp| 20 +++
 .../DependencyScanningTool.cpp|  9 +++--
 .../DependencyScanningWorker.cpp  | 35 +++
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  4 +--
 7 files changed, 56 insertions(+), 38 deletions(-)

diff --git a/clang/include/clang/Frontend/FrontendActions.h 
b/clang/include/clang/Frontend/FrontendActions.h
index a620ddfc40447..c80422e97462d 100644
--- a/clang/include/clang/Frontend/FrontendActions.h
+++ b/clang/include/clang/Frontend/FrontendActions.h
@@ -320,12 +320,12 @@ class PrintPreprocessedAction : public 
PreprocessorFrontendAction {
 };
 
 class GetDependenciesByModuleNameAction : public PreprocessOnlyAction {
-  StringRef ModuleName;
+  ArrayRef ModuleNames;
   void ExecuteAction() override;
 
 public:
-  GetDependenciesByModuleNameAction(StringRef ModuleName)
-  : ModuleName(ModuleName) {}
+  GetDependenciesByModuleNameAction(ArrayRef ModuleNames)
+  : ModuleNames(ModuleNames) {}
 };
 
 }  // end namespace clang
diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index d13c3ee76d74f..25473b5c2500f 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -144,12 +144,14 @@ class DependencyScanningTool {
   std::optional TUBuffer = std::nullopt);
 
   /// Given a compilation context specified via the Clang driver command-line,
-  /// gather modular dependencies of module with the given name, and return the
-  /// information needed for explicit build.
-  llvm::Expected getModuleDependencies(
-  StringRef ModuleName, const std::vector &CommandLine,
-  StringRef CWD, const llvm::DenseSet &AlreadySeen,
-  LookupModuleOutputCallback LookupModuleOutput);
+  /// gather modular dependencies of modules specified by the the given list of
+  /// names, and return the information needed for explicit build.
+  llvm::Expected
+  getModuleDependencies(ArrayRef ModuleNames,
+const std::vector &CommandLine,
+StringRef CWD,
+const llvm::DenseSet &AlreadySeen,
+LookupModuleOutputCallback LookupModuleOutput);
 
   llvm::vfs::FileSystem &getWorkerVFS() const { return Worker.getVFS(); }
 
diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
index 5f0b983ebb58f..901f42715e6e6 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -111,7 +111,7 @@ class DependencyScanningWorker {
DependencyConsumer &DepConsumer,
DependencyActionController &Controller,
DiagnosticConsumer &DiagConsumer,
-   StringRef ModuleName);
+   ArrayRef ModuleNames);
 
   /// Run the dependency scanning tool for a given clang driver command-line
   /// for a specific translation unit via file system or memory buffer.
@@ -132,7 +132,7 @@ class DependencyScanningWorker {
   const std::vector &CommandLine,
   DependencyConsumer &Consumer,
   DependencyActionController &Controller,
-  StringRef ModuleName);
+  ArrayRef ModuleNames);
 
   llvm::vfs::FileSystem &getVFS() const { return *BaseFS; }
 
@@ -156,7 +156,7 @@ class DependencyScanningWorker {
 DependencyActionController &Controller,
 DiagnosticConsumer &DC,
 llvm::IntrusiveRefCntPtr FS,
-std::optional ModuleName);
+std::optional> ModuleNames);
 };
 
 } // end namespace dependencies
diff --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 1ea4a2e9e88cf..5c6419bd4e677 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -1213,11 +1213,17 @@ void GetDependenciesByModuleNameAction::ExecuteAction() 
{
   Preprocessor &PP = CI.getPre

[clang] [llvm] [RISCV] Add Svrsw60t59b extension (PR #132321)

2025-03-20 Thread Craig Topper via cfe-commits

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

Tests are failing.

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


[clang] Revert "[Clang][CMake][MSVC] Install PDBs alongside executables" (PR #126934)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-s390x-linux-multistage` running on `systemz-1` while building `clang` at 
step 5 "ninja check 1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'libFuzzer-s390x-default-Linux :: 
fuzzer-timeout.test' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang 
   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer
  
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
+ 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer
 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
RUN: at line 2: 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang 
   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer
  
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
+ 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer
 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
RUN: at line 3: not  
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 2>&1 | FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=TimeoutTest
+ not 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1
+ FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=TimeoutTest
RUN: at line 12: not  
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/hi.txt
 2>&1 | FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=SingleInputTimeoutTest
+ not 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/hi.txt
+ FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=SingleInputTimeoutTest
RUN: at line 16: 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 -timeout_exitcode=0
+ 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes

[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

2025-03-20 Thread via cfe-commits

https://github.com/hchandel updated 
https://github.com/llvm/llvm-project/pull/132184

>From 8c4875b817b303d611998f8a8ef9f444c282d2b1 Mon Sep 17 00:00:00 2001
From: Harsh Chandel 
Date: Thu, 20 Mar 2025 13:49:03 +0530
Subject: [PATCH 1/3] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension
 This extension adds nine instructions, eight for non-memory-mapped devices
 synchronization and delay instruction.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/tag/Xqci-0.7.0

This patch adds assembler only support.

Change-Id: I0472a9b3cd999f0b7d16aa351215cce12a788569
---
 .../Driver/print-supported-extensions-riscv.c |   1 +
 llvm/docs/RISCVUsage.rst  |   3 +
 llvm/docs/ReleaseNotes.md |   2 +
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp |  16 +++
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  26 ++--
 .../Target/RISCV/MCTargetDesc/RISCVBaseInfo.h |   1 +
 .../RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp |  34 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|   8 ++
 llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td   |  56 
 llvm/lib/TargetParser/RISCVISAInfo.cpp|   8 +-
 llvm/test/CodeGen/RISCV/attributes.ll |   2 +
 llvm/test/MC/RISCV/xqcisync-invalid.s | 121 ++
 llvm/test/MC/RISCV/xqcisync-valid.s   |  47 +++
 .../TargetParser/RISCVISAInfoTest.cpp |   3 +-
 14 files changed, 315 insertions(+), 13 deletions(-)
 create mode 100644 llvm/test/MC/RISCV/xqcisync-invalid.s
 create mode 100644 llvm/test/MC/RISCV/xqcisync-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 40b8eb6217240..74ceb24548b9c 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -212,6 +212,7 @@
 // CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
 // CHECK-NEXT: xqcisim  0.2   'Xqcisim' (Qualcomm uC 
Simulation Hint Extension)
 // CHECK-NEXT: xqcisls  0.2   'Xqcisls' (Qualcomm uC 
Scaled Load Store Extension)
+// CHECK-NEXT: xqcisync 0.2   'Xqcisync' (Qualcomm uC Sync 
Delay Extension)
 // CHECK-NEXT: xrivosvisni  0.1   'XRivosVisni' (Rivos Vector 
Integer Small New)
 // CHECK-NEXT: xrivosvizip  0.1   'XRivosVizip' (Rivos Vector 
Register Zips)
 // CHECK-EMPTY:
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 28d09cffa95c0..701296226e07f 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -482,6 +482,9 @@ The current vendor extensions supported are:
 ``experimental-Xqcisls``
   LLVM implements `version 0.2 of the Qualcomm uC Scaled Load Store extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
+``experimental-Xqcisync``
+  LLVM implements `version 0.2 of the Qualcomm uC Sync Delay extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
+
 ``Xmipscmove``
   LLVM implements conditional move for the `p8700 processor 
` by MIPS.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 205c2ad25f23e..8d3c93d389b49 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -130,6 +130,8 @@ Changes to the RISC-V Backend
 * Added non-quadratic ``log-vrgather`` cost model for ``vrgather.vv`` 
instruction
 * Adds experimental assembler support for the Qualcomm uC 'Xqcisim` 
(Simulation Hint)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqcisync` (Sync 
Delay)
+  extension.
 * Adds assembler support for the 'Zilsd` (Load/Store Pair Instructions)
   extension.
 * Adds assembler support for the 'Zclsd` (Compressed Load/Store Pair 
Instructions)
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index d3500e3e44c50..91e211f335e3f 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -772,6 +772,18 @@ struct RISCVOperand final : public MCParsedAsmOperand {
VK == RISCVMCExpr::VK_None;
   }
 
+  bool isUImm5Slist() const {
+if (!isImm())
+  return false;
+RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
+int64_t Imm;
+bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
+return IsConstantImm &&
+   ((Imm == 0) || (Imm == 1) || (Imm == 2) || (Imm == 4) ||
+(Imm == 8) || (Imm == 16) || (Imm == 15) || (Imm == 31)) &&
+   

[clang] [clang-tools-extra] [clang] NFC: Clear some uses of MemberPointerType::getClass (PR #131965)

2025-03-20 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

thanks!

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


[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)

2025-03-20 Thread Paul Kirth via cfe-commits

ilovepi wrote:

> @ilovepi About `writeFileDefiniation`, what's your opinion about making it 
> similar to the markdown generator like this?
> 
> ```c++
> static void writeFileDefinition(const ClangDocContext &CDCtx, const Location 
> &L);
> ```
> 
> I think it's more better

That would probably be fine, except we do need some way to customize those 
strings. How do you envision the API would work if you remove those parameters?

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


[clang-tools-extra] [clang-tidy] add new check: modernize-use-scoped-lock (PR #126434)

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


@@ -0,0 +1,342 @@
+//===--- UseScopedLockCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseScopedLockCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Twine.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+
+bool isLockGuard(const QualType &Type) {
+  if (const auto *Record = Type->getAs())
+if (const RecordDecl *Decl = Record->getDecl())
+  return Decl->getName() == "lock_guard" && Decl->isInStdNamespace();

vbvictor wrote:

added new function `isLockGuardDecl` with needed logic

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


[clang-tools-extra] [clang-tidy] add new check: modernize-use-scoped-lock (PR #126434)

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

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

>From bc1b4ada7615d407c2df009f414d62da3857ee86 Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Mon, 3 Mar 2025 09:25:03 +0300
Subject: [PATCH 01/11] [clang-tidy] add scoped-lock-check

---
 .../clang-tidy/modernize/CMakeLists.txt   |   1 +
 .../modernize/ModernizeTidyModule.cpp |   3 +
 .../modernize/UseScopedLockCheck.cpp  | 319 +++
 .../clang-tidy/modernize/UseScopedLockCheck.h |  54 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checks/modernize/use-scoped-lock.rst  | 102 +
 .../clang-tidy/checkers/Inputs/Headers/mutex  |  33 ++
 ...e-lock-warn-on-using-and-typedef-false.cpp |  31 ++
 ...scoped-lock-warn-on-single-locks-false.cpp |  96 +
 .../checkers/modernize/use-scoped-lock.cpp| 372 ++
 11 files changed, 1018 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
 create mode 100644 clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/mutex
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-scope-lock-warn-on-using-and-typedef-false.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-scoped-lock-warn-on-single-locks-false.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-scoped-lock.cpp

diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
index bab1167fb15ff..619a27b2f9bb6 100644
--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
@@ -42,6 +42,7 @@ add_clang_library(clangTidyModernizeModule STATIC
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseRangesCheck.cpp
+  UseScopedLockCheck.cpp
   UseStartsEndsWithCheck.cpp
   UseStdFormatCheck.cpp
   UseStdNumbersCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp 
b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
index fc46c72982fdc..b2d4ddd667502 100644
--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -43,6 +43,7 @@
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseRangesCheck.h"
+#include "UseScopedLockCheck.h"
 #include "UseStartsEndsWithCheck.h"
 #include "UseStdFormatCheck.h"
 #include "UseStdNumbersCheck.h"
@@ -80,6 +81,8 @@ class ModernizeModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "modernize-use-integer-sign-comparison");
 CheckFactories.registerCheck("modernize-use-ranges");
+CheckFactories.registerCheck(
+"modernize-use-scoped-lock");
 CheckFactories.registerCheck(
 "modernize-use-starts-ends-with");
 
CheckFactories.registerCheck("modernize-use-std-format");
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
new file mode 100644
index 0..5dbb3a2f671e6
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
@@ -0,0 +1,319 @@
+//===--- UseScopedLockCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseScopedLockCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Twine.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+
+bool isLockGuard(const QualType &Type) {
+  if (const auto *Record = Type->getAs()) {
+if (const RecordDecl *Decl = Record->getDecl()) {
+  return Decl->getName() == "lock_guard" && Decl->isInStdNamespace();
+}
+  }
+
+  if (const auto *TemplateSpecType =
+  Type->getAs()) {
+if (const TemplateDecl *Decl =
+TemplateSpecType->getTemplateName().getAsTemplateDecl()) {
+  return Decl->getName() == "lock_guard" && Decl->isInStdNamespace();
+}
+  }
+
+  return false;
+}
+
+llvm::SmallVector getLockGuardsFromDecl(const DeclStmt *DS) {
+  llvm::SmallVector LockGuards;
+
+  for (const Decl *Decl : DS->decls()) {
+if

[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Sergei Barannikov via cfe-commits


@@ -0,0 +1,102 @@
+//===-- CGBuiltin.h - LLVM CodeGen wrappers for llvm::Value* --*- C++ 
-*-===//

s-barannikov wrote:

Copy&paste bug?
Note that per updated coding standard this line may be the same as line 7.


https://github.com/llvm/llvm-project/pull/132252
___
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-20 Thread Trevor Gross via cfe-commits


@@ -548,11 +543,28 @@ SystemZTargetLowering::SystemZTargetLowering(const 
TargetMachine &TM,
   }
 
   // Handle floating-point types.
+  if (!useSoftFloat()) {
+// Promote all f16 operations to float, with some exceptions below.
+for (unsigned Opc = 0; Opc < ISD::BUILTIN_OP_END; ++Opc)
+  setOperationAction(Opc, MVT::f16, Promote);

tgross35 wrote:

@nikic are you referring to https://github.com/llvm/llvm-project/issues/97975 
and https://github.com/llvm/llvm-project/issues/97981? It would probably be 
good to add a test against those issues here if there isn't already. 

Cc issue author @beetrees

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] [Clang] Do not create dependent CallExpr having UnresolvedLookupExpr inside non-dependent context (PR #124609)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-amdgpu-runtime` running on `omp-vega20-0` while building 
`clang` at step 7 "Add check check-offload".

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


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

```
Step 7 (Add check check-offload) failure: test (failure)
 TEST 'libomptarget :: amdgcn-amd-amdhsa :: 
offloading/gpupgo/pgo1.c' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fcreate-profile  -Xarch_device -fprofile-generate
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
-fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fcreate-profile -Xarch_device -fprofile-generate
# note: command had no output on stdout or stderr
# RUN: at line 3
env LLVM_PROFILE_FILE=pgo1.c.llvm.profraw  
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
 2>&1
# executed command: env LLVM_PROFILE_FILE=pgo1.c.llvm.profraw 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
# note: command had no output on stdout or stderr
# RUN: at line 5
llvm-profdata show --all-functions --counts  
amdgcn-amd-amdhsa.pgo1.c.llvm.profraw |  
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 --check-prefix="LLVM-PGO"
# executed command: llvm-profdata show --all-functions --counts 
amdgcn-amd-amdhsa.pgo1.c.llvm.profraw
# note: command had no output on stdout or stderr
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 --check-prefix=LLVM-PGO
# note: command had no output on stdout or stderr
# RUN: at line 9
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-ru

[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

2025-03-20 Thread CHANDRA GHALE via cfe-commits

chandraghale wrote:

Thank you for the review.

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


[clang] [llvm] dot2add working for dxil without sema check (PR #131237)

2025-03-20 Thread Sumit Agarwal via cfe-commits

https://github.com/sumitsays updated 
https://github.com/llvm/llvm-project/pull/131237

>From 6d5c4053c90975d64e378e52779dab9c3ffb64cd Mon Sep 17 00:00:00 2001
From: Sumit Agarwal 
Date: Thu, 13 Mar 2025 16:02:32 -0700
Subject: [PATCH 1/5] dot2add working for dxil without sema check

---
 clang/include/clang/Basic/Builtins.td  |   6 +
 clang/lib/CodeGen/CGBuiltin.cpp|  10 +
 clang/lib/CodeGen/CGHLSLRuntime.h  |   1 +
 clang/lib/Headers/hlsl/hlsl_intrinsics.h   | 366 +
 llvm/include/llvm/IR/IntrinsicsDirectX.td  |   4 +
 llvm/include/llvm/IR/IntrinsicsSPIRV.td|   5 +
 llvm/lib/Target/DirectX/DXIL.td|  11 +
 llvm/lib/Target/DirectX/DXILOpLowering.cpp |  33 ++
 8 files changed, 436 insertions(+)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 72a5e495c4059..8a0237171f7df 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4891,6 +4891,12 @@ def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLDot2Add : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_dot2add"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(...)";
+}
+
 def HLSLDot4AddI8Packed : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_dot4add_i8packed"];
   let Attributes = [NoThrow, Const];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c126f88b9e3a5..8c0f42e0c85f7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19681,6 +19681,16 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 getDotProductIntrinsic(CGM.getHLSLRuntime(), VecTy0->getElementType()),
 ArrayRef{Op0, Op1}, nullptr, "hlsl.dot");
   }
+  case Builtin::BI__builtin_hlsl_dot2add: {
+Value *A = EmitScalarExpr(E->getArg(0));
+Value *B = EmitScalarExpr(E->getArg(1));
+Value *C = EmitScalarExpr(E->getArg(2));
+
+Intrinsic::ID ID = CGM.getHLSLRuntime().getDot2AddIntrinsic();
+return Builder.CreateIntrinsic(
+/*ReturnType=*/C->getType(), ID, ArrayRef{A, B, C}, nullptr,
+"hlsl.dot2add");
+  }
   case Builtin::BI__builtin_hlsl_dot4add_i8packed: {
 Value *A = EmitScalarExpr(E->getArg(0));
 Value *B = EmitScalarExpr(E->getArg(1));
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 23f187b24284f..5ba69819e5431 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -99,6 +99,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(FDot, fdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Dot2Add, dot2add)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Dot4AddI8Packed, dot4add_i8packed)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Dot4AddU8Packed, dot4add_u8packed)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAllTrue, wave_all)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 5459cbeb34fd0..3849e018d 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -118,6 +118,372 @@ const inline float 
distance(__detail::HLSL_FIXED_VECTOR X,
 }
 
 
//===--===//
+<<< Updated upstream
+===
+// dot product builtins
+//===--===//
+
+/// \fn K dot(T X, T Y)
+/// \brief Return the dot product (a scalar value) of \a X and \a Y.
+/// \param X The X input value.
+/// \param Y The Y input value.
+
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half, half);
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half2, half2);
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half3, half3);
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+half dot(half4, half4);
+
+#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t, int16_t);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t2, int16_t2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t3, int16_t3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+int16_t dot(int16_t4, int16_t4);
+
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t, uint16_t);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t2, uint16_t2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
+uint16_t dot(uint16_t3, uint16_t3);

[clang] [clang][bytecode] Implement __builtin_wmemchr (PR #132254)

2025-03-20 Thread Timm Baeder via cfe-commits

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


[clang] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (PR #131976)

2025-03-20 Thread Eli Friedman via cfe-commits


@@ -114,3 +114,13 @@ struct s15 fooa(char a, char b) {
   x.arr[1] = b;
   return x;
 }
+
+struct s8_t {
+  char a;
+};
+
+// AVR:  define {{.*}} i8 @foob(i8 {{.*}})
+// TINY  define {{.*}} i8 @foob(i8 {{.*}})

efriedma-quic wrote:

```suggestion
// AVR:  define {{.*}} i8 @foob(i8 %{{.*}})
// TINY: define {{.*}} i8 @foob(i8 %{{.*}})
```

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


[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-20 Thread Richard Smith via cfe-commits

zygoloid wrote:

> > But still I feel generate a warning for this case went too far.
> 
> Yeah, that's probably right. Maybe for `-` on a signed operand, we should 
> just return the original range with the `NonNegative` flag cleared out, and 
> shouldn't add the extra bit for the `-128 -> 128` edge case. That's not 
> technically correct, but probably is more useful in practice.

Hm. That change will reintroduce a false positive warning for:
```c++
bool b(signed char c) {
  return -c >= 128;
}
```
... that this patch fixed. But we don't produce a false positive for `0 - c >= 
128`, so I still think what we ought to do here is to make `-c` behave the same 
way that `0 - c` does.

https://github.com/llvm/llvm-project/pull/126846
___
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-20 Thread Craig Topper via cfe-commits


@@ -548,11 +543,28 @@ SystemZTargetLowering::SystemZTargetLowering(const 
TargetMachine &TM,
   }
 
   // Handle floating-point types.
+  if (!useSoftFloat()) {
+// Promote all f16 operations to float, with some exceptions below.
+for (unsigned Opc = 0; Opc < ISD::BUILTIN_OP_END; ++Opc)
+  setOperationAction(Opc, MVT::f16, Promote);

topperc wrote:

SoftPromoteHalf is a type legalizer action not an OperationAction. Promote as 
an OperationAction should work for f16.

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] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Jonathan Thackray via cfe-commits

jthackray wrote:

> This makes a lot of sense to me, just wondering why you chose 
> `clang/lib/CodeGen/BuiltinTargets/` rather than 
> `clang/lib/CodeGen/TargetBuiltins/`? The former shounds like it contains the 
> list of all builtin targets, rather than the codegen for target-specific 
> builtins.

@arichardson @MacDue Thanks. Now updated.

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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Jonathan Thackray via cfe-commits

jthackray wrote:

> Seems something with AArch64 has made the CI unhappy as well.

Thanks. It appears `clang-format` breaks some of the fragile `#define`s around 
`NEONMAP0` and similar. If I revert the `clang-format`, it passes.

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


[clang] [Clang][NFC] Code cleanup in CGBuiltin.cpp (PR #132060)

2025-03-20 Thread Jonathan Thackray via cfe-commits

jthackray wrote:

> The timing of this is sort of unfortunate with #132252; the merge conflict 
> there is going to be very painful. @jthackray , thoughts?

@efriedma-quic I think I can update my diff after this is merged; yes, might 
take a while to resolve the diffs.

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


[clang] [clang-tools-extra] [clang] NFC: Clear some uses of MemberPointerType::getClass (PR #131965)

2025-03-20 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

seems like there are conflicts reverting this at head, could you take a look 
@mizvekov?

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


[clang] [clang-tools-extra] [lldb] Revert "Reland: [clang] preserve class type sugar when taking pointer to member" (PR #132280)

2025-03-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

Reverts llvm/llvm-project#132234

Needs to be reverted due to dependency.

This blocks reverting another PR, see here: 
https://github.com/llvm/llvm-project/pull/131965#issuecomment-2741619498

---

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


71 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp (+2-1) 
- (modified) clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp (+1-3) 
- (modified) clang-tools-extra/clangd/unittests/FindTargetTests.cpp (+1-1) 
- (modified) clang/docs/ReleaseNotes.rst (-1) 
- (modified) clang/include/clang/AST/ASTContext.h (+4-3) 
- (modified) clang/include/clang/AST/ASTNodeTraverser.h (+2-5) 
- (modified) clang/include/clang/AST/CanonicalType.h (+1-1) 
- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+4-5) 
- (modified) clang/include/clang/AST/Type.h (+13-15) 
- (modified) clang/include/clang/AST/TypeLoc.h (+14-19) 
- (modified) clang/include/clang/AST/TypeProperties.td (+3-6) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+4-2) 
- (modified) clang/include/clang/Sema/Sema.h (+2-9) 
- (modified) clang/lib/AST/ASTContext.cpp (+21-47) 
- (modified) clang/lib/AST/ASTImporter.cpp (+5-9) 
- (modified) clang/lib/AST/ASTStructuralEquivalence.cpp (+2-6) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-10) 
- (modified) clang/lib/AST/NestedNameSpecifier.cpp (-1) 
- (modified) clang/lib/AST/ODRHash.cpp (+1-1) 
- (modified) clang/lib/AST/QualTypeNames.cpp (+3-4) 
- (modified) clang/lib/AST/Type.cpp (+4-30) 
- (modified) clang/lib/AST/TypePrinter.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGCXXABI.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGPointerAuth.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+3-2) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+5-5) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+3-4) 
- (modified) clang/lib/Sema/SemaAccess.cpp (+8-18) 
- (modified) clang/lib/Sema/SemaCast.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+6-4) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+1-3) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+3-2) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+27-60) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+2-6) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+5-16) 
- (modified) clang/lib/Sema/SemaType.cpp (+100-22) 
- (modified) clang/lib/Sema/TreeTransform.h (+30-29) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1) 
- (modified) clang/lib/Serialization/TemplateArgumentHasher.cpp (+1-3) 
- (modified) clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp 
(+1-3) 
- (modified) clang/test/AST/ast-dump-templates.cpp (-238) 
- (modified) clang/test/AST/ast-dump-types-json.cpp (+44-338) 
- (modified) clang/test/AST/attr-print-emit.cpp (+1-1) 
- (modified) clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp (+5-5) 
- (modified) clang/test/CXX/class.access/p6.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg0xx.cpp (+6-6) 
- (modified) clang/test/CXX/drs/cwg13xx.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg26xx.cpp (+3-3) 
- (modified) clang/test/CXX/drs/cwg2xx.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg4xx.cpp (+1-1) 
- (modified) clang/test/CXX/drs/cwg7xx.cpp (+2-1) 
- (modified) clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp (+1-1) 
- (modified) clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp (+3-3) 
- (modified) clang/test/Index/print-type.cpp (+1-1) 
- (modified) clang/test/SemaCXX/addr-of-overloaded-function.cpp (+13-13) 
- (modified) clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp (+2-2) 
- (modified) clang/test/SemaCXX/calling-conv-compat.cpp (+21-21) 
- (modified) clang/test/SemaCXX/err_init_conversion_failed.cpp (+1-1) 
- (modified) clang/test/SemaCXX/member-pointer.cpp (+4-13) 
- (modified) clang/test/SemaOpenACC/combined-construct-if-ast.cpp (+2-2) 
- (modified) clang/test/SemaOpenACC/combined-construct-num_workers-ast.cpp 
(+2-2) 
- (modified) clang/test/SemaOpenACC/compute-construct-clause-ast.cpp (+2-2) 
- (modified) clang/test/SemaOpenACC/compute-construct-intexpr-clause-ast.cpp 
(+2-2) 
- (modified) clang/test/SemaOpenACC/data-construct-if-ast.cpp (+2-2) 
- (modified) clang/test/SemaTemplate/instantiate-member-pointers.cpp (+1-2) 
- (modified) clang/tools/libclang/CXType.cpp (+1-3) 
- (modified) clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (+4-4) 
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp (+1-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+3-4) 


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index a6b00be75abf8..108717e151b57 100644
--- a/clang

[clang] [clang-tools-extra] [lldb] Revert "Reland: [clang] preserve class type sugar when taking pointer to member" (PR #132280)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-amdgpu-runtime` running on `omp-vega20-0` while building 
`clang-tools-extra,clang,lldb` at step 7 "Add check check-offload".

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


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

```
Step 7 (Add check check-offload) failure: test (failure)
 TEST 'libomptarget :: amdgcn-amd-amdhsa :: 
offloading/gpupgo/pgo2.c' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo2.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo2.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-generate
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
-fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo2.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo2.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-generate
# note: command had no output on stdout or stderr
# RUN: at line 2
env LLVM_PROFILE_FILE=pgo2.c.llvm.profraw  
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo2.c.tmp
 2>&1
# executed command: env LLVM_PROFILE_FILE=pgo2.c.llvm.profraw 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo2.c.tmp
# note: command had no output on stdout or stderr
# RUN: at line 4
llvm-profdata show --all-functions --counts  pgo2.c.llvm.profraw | 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo2.c
  --check-prefix="LLVM-HOST"
# executed command: llvm-profdata show --all-functions --counts 
pgo2.c.llvm.profraw
# note: command had no output on stdout or stderr
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo2.c
 --check-prefix=LLVM-HOST
# note: command had no output on stdout or stderr
# RUN: at line 7
llvm-profdata show --all-functions --counts  
amdgcn-amd-amdhsa.pgo2.c.llvm.profraw  | 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo2.c
 --check-prefix="LLVM-DEVICE"
# executed command: llvm-profdata show --all-functions --counts 
amdgcn-amd-amdhsa.pgo2.c.llvm.profraw
# note: command had no output on stdout or stderr
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworke

[clang-tools-extra] [clang-doc] Avoid deref of invalid std::optional (PR #131939)

2025-03-20 Thread Paul Kirth via cfe-commits

ilovepi wrote:

### Merge activity

* **Mar 20, 5:02 PM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/131939).


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


[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #132287)

2025-03-20 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [clang] Fix crash on invalid `std::initializer_list` template-id (PR #132284)

2025-03-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (offsetof)


Changes

In `Sema::BuildStdInitializerList`, check that the synthesized template-id 
`std::initializer_list` is valid (which might not be the case if the 
template has associated constraints or subsequent parameters with default 
arguments) before forming the type.

Fixes #132256

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+6-2) 
- (added) clang/test/SemaCXX/invalid-std-initializer-list.cpp (+14) 


``diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 7b2e0df8cb55d..54f7bc9a3b021 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -12182,10 +12182,14 @@ QualType Sema::BuildStdInitializerList(QualType 
Element, SourceLocation Loc) {
   Args.addArgument(TemplateArgumentLoc(TemplateArgument(Element),

Context.getTrivialTypeSourceInfo(Element,
 Loc)));
+
+  QualType T = CheckTemplateIdType(TemplateName(StdInitializerList), Loc, 
Args);
+  if (T.isNull())
+return QualType();
+
   return Context.getElaboratedType(
   ElaboratedTypeKeyword::None,
-  NestedNameSpecifier::Create(Context, nullptr, getStdNamespace()),
-  CheckTemplateIdType(TemplateName(StdInitializerList), Loc, Args));
+  NestedNameSpecifier::Create(Context, nullptr, getStdNamespace()), T);
 }
 
 bool Sema::isInitListConstructor(const FunctionDecl *Ctor) {
diff --git a/clang/test/SemaCXX/invalid-std-initializer-list.cpp 
b/clang/test/SemaCXX/invalid-std-initializer-list.cpp
new file mode 100644
index 0..080a712759c45
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-std-initializer-list.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -std=c++20
+
+namespace std {
+
+template // expected-error 2 {{type 'int' cannot be 
used prior to '::' because it has no members}}
+class initializer_list;
+
+}
+
+auto x = {1}; // expected-note {{in instantiation of default argument for 
'initializer_list' required here}}
+
+void f() {
+   for(int x : {1, 2}); // expected-note {{in instantiation of default 
argument for 'initializer_list' required here}}
+}

``




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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

2025-03-20 Thread Craig Topper via cfe-commits


@@ -1655,6 +1667,10 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc 
IDLoc, unsigned &Opcode,
 return generateImmOutOfRangeError(Operands, ErrorInfo, 1, (1 << 5));
   case Match_InvalidUImm5GE6Plus1:
 return generateImmOutOfRangeError(Operands, ErrorInfo, 6, (1 << 5));
+  case Match_InvalidUImm5Slist:
+return generateImmOutOfRangeError(
+Operands, ErrorInfo, 0, (1 << 5) - 1,
+"immediate must be one of: 0, 1, 2, 4, 8, 15, 16, 31 in the range ");

topperc wrote:

Is the "in the range" useful here after listing all the values? Maybe we should 
just do 

```
return Error(ErrorLoc, "immediate must be one of: 0, 1, 2, 4, 8, 15, 16, 31");
```

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


[compiler-rt] [libcxx] [libcxxabi] [libunwind] [lldb] [llvm] [compiler-rt] Disable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON on AIX. (PR #131200)

2025-03-20 Thread Louis Dionne via cfe-commits


@@ -223,6 +223,13 @@ endif()
 # This can be used to detect whether we're in the runtimes build.
 set(LLVM_RUNTIMES_BUILD ON)
 
+if (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND UNIX AND ${CMAKE_SYSTEM_NAME} 
MATCHES "AIX")
+  # Set LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF as AIX doesn't support it
+  message(WARNING
+  "LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON is not supported on AIX. 
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is set to OFF.")
+  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR OFF CACHE BOOL "" FORCE)
+endif()

ldionne wrote:

What we do for Apple is also bad, and we should fix that. In fact we want to 
make it work on Apple platforms but we haven't gotten to it yet.

The reason for my push back is that we don't want to have configuration logic, 
especially when it's imperative, in the CMake files. We're working really hard 
to get away from that and that's why I care so strongly about it.

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


[clang-tools-extra] a87a64b - [clang-doc] Avoid deref of invalid std::optional (#131939)

2025-03-20 Thread via cfe-commits

Author: Paul Kirth
Date: 2025-03-20T14:04:58-07:00
New Revision: a87a64b2e487995f9de90a614c7caa7a888147df

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

LOG: [clang-doc] Avoid deref of invalid std::optional (#131939)

Since our existing guard is insufficient to prevent accessing the
std::optional when in an invalid state, guard the access with
`.value_or()`. This maintains the desired behavior, without running into
UB.

The new test should prevent regressions.

Fixes #131697

Added: 
clang-tools-extra/test/clang-doc/DR-131697.cpp

Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 18a0de826630c..a8404479569f9 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -498,7 +498,7 @@ writeFileDefinition(const Location &L,
 return std::make_unique(
 HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) +
 " of file " + L.Filename);
-  SmallString<128> FileURL(*RepositoryUrl);
+  SmallString<128> FileURL(RepositoryUrl.value_or(""));
   llvm::sys::path::append(
   FileURL, llvm::sys::path::Style::posix,
   // If we're on Windows, the file name will be in the wrong format, and

diff  --git a/clang-tools-extra/test/clang-doc/DR-131697.cpp 
b/clang-tools-extra/test/clang-doc/DR-131697.cpp
new file mode 100644
index 0..67bd55b897973
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/DR-131697.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: split-file %s %t
+// RUN: clang-doc -format=html %t/compile_commands.json %t/main.cpp
+
+//--- main.cpp
+
+class Foo {
+  void getFoo();
+};
+
+int main() {
+  return 0;
+}
+
+//--- compile_commands.json
+[
+{
+  "directory": "foo",
+  "file":"main.cpp",
+  "command":"clang main.cpp -c"
+}
+]



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


[clang-tools-extra] [clang-doc][NFC] Remove unnecessary directory cleanup (PR #132101)

2025-03-20 Thread Paul Kirth via cfe-commits

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


[clang-tools-extra] [clang-doc] Correct improper file paths in HTML output (PR #132103)

2025-03-20 Thread Paul Kirth via cfe-commits

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


[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #132287)

2025-03-20 Thread Ayush Pareek via cfe-commits

https://github.com/ayushpareek2003 created 
https://github.com/llvm/llvm-project/pull/132287

Optimized addModuleFiles functions for both CompilerInvocation and 
CowCompilerInvocation to reduce redundant function calls and improve efficiency

Introduced memory preallocation using reserve() when eager load is enabled to 
reduce reallocation overhead

Used try_emplace() instead of insert() for PrebuiltModuleFiles to avoid 
unnecessary overwrites

>From 1c09daa2979f8b6f2840979736e64d9d49541197 Mon Sep 17 00:00:00 2001
From: Ayush Pareek 
Date: Fri, 21 Mar 2025 02:33:00 +0530
Subject: [PATCH] Optimize Module Dependency Handling for Efficient Memory
 Usage

-Optimized addModuleFiles functions for both CompilerInvocation and 
CowCompilerInvocation to reduce redundant function calls and improve efficiency

-Introduced memory preallocation using reserve() when eager load is enabled to 
reduce reallocation overhead

-Used try_emplace() instead of insert() for PrebuiltModuleFiles to avoid 
unnecessary overwrites.
---
 .../DependencyScanning/ModuleDepCollector.cpp | 64 +--
 1 file changed, 43 insertions(+), 21 deletions(-)

diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index d715ef874e002..576b27c6a1132 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -394,40 +394,62 @@ void ModuleDepCollector::addModuleMapFiles(
   if (Service.shouldEagerLoadModules())
 return; // Only pcm is needed for eager load.
 
+  // Preallocate memory to avoid multiple allocations
+  CI.getFrontendOpts().ModuleMapFiles.reserve(
+  CI.getFrontendOpts().ModuleMapFiles.size() + ClangModuleDeps.size());
+  
   for (const ModuleID &MID : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(MID);
-assert(MD && "Inconsistent dependency info");
-CI.getFrontendOpts().ModuleMapFiles.push_back(MD->ClangModuleMapFile);
+ 
+if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) { // Single lookup
+  assert(MD && "Inconsistent dependency info");
+  CI.getFrontendOpts().ModuleMapFiles.emplace_back(MD->ClangModuleMapFile);
+}
   }
 }
 
 void ModuleDepCollector::addModuleFiles(
 CompilerInvocation &CI, ArrayRef ClangModuleDeps) const {
+  
+  // Preallocate memory if eager load is enabled
+  if (Service.shouldEagerLoadModules()) {
+CI.getFrontendOpts().ModuleFiles.reserve(
+CI.getFrontendOpts().ModuleFiles.size() + ClangModuleDeps.size());
+  }
   for (const ModuleID &MID : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(MID);
-std::string PCMPath =
-Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
-
-if (Service.shouldEagerLoadModules())
-  CI.getFrontendOpts().ModuleFiles.push_back(std::move(PCMPath));
-else
-  CI.getHeaderSearchOpts().PrebuiltModuleFiles.insert(
-  {MID.ModuleName, std::move(PCMPath)});
+if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) {  
+  std::string PCMPath =
+  Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
+
+  if (Service.shouldEagerLoadModules()) {
+CI.getFrontendOpts().ModuleFiles.emplace_back(std::move(PCMPath));
+  } else {
+CI.getHeaderSearchOpts().PrebuiltModuleFiles.try_emplace(
+MID.ModuleName, std::move(PCMPath));
+  }
+}
   }
 }
 
 void ModuleDepCollector::addModuleFiles(
 CowCompilerInvocation &CI, ArrayRef ClangModuleDeps) const {
-  for (const ModuleID &MID : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(MID);
-std::string PCMPath =
-Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
 
-if (Service.shouldEagerLoadModules())
-  CI.getMutFrontendOpts().ModuleFiles.push_back(std::move(PCMPath));
-else
-  CI.getMutHeaderSearchOpts().PrebuiltModuleFiles.insert(
-  {MID.ModuleName, std::move(PCMPath)});
+// Preallocation
+  if (Service.shouldEagerLoadModules()) {
+CI.getMutFrontendOpts().ModuleFiles.reserve(
+CI.getMutFrontendOpts().ModuleFiles.size() + ClangModuleDeps.size());
+  }
+  for (const ModuleID &MID : ClangModuleDeps) {
+if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) {  
+  std::string PCMPath =
+  Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
+
+  if (EagerLoad) {
+CI.getMutFrontendOpts().ModuleFiles.emplace_back(std::move(PCMPath));
+  } else {
+CI.getMutHeaderSearchOpts().PrebuiltModuleFiles.try_emplace(
+MID.ModuleName, std::move(PCMPath));
+  }
+}
   }
 }
 

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


[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-20 Thread Kaitlin Peng via cfe-commits

https://github.com/kmpeng created 
https://github.com/llvm/llvm-project/pull/132288

Closes #99156.


Tasks completed:
- Implement `smoothstep` using HLSL source in `hlsl_intrinsics.h`
- Implement the `smoothstep` SPIR-V target built-in in 
`clang/include/clang/Basic/BuiltinsSPIRV.td`
- Add sema checks for `smoothstep` to `CheckSPIRVBuiltinFunctionCall` in 
`clang/lib/Sema/SemaSPIRV.cpp`
- Add codegen for spv `smoothstep` to `EmitSPIRVBuiltinExpr` in `CGBuiltin.cpp`
- Add codegen tests to `clang/test/CodeGenHLSL/builtins/smoothstep.hlsl`
- Add spv codegen test to `clang/test/CodeGenSPIRV/Builtins/smoothstep.c`
- Add sema tests to `clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl`
- Add spv sema tests to `clang/test/SemaSPIRV/BuiltIns/smoothstep-errors.c`
- Create the `int_spv_smoothstep` intrinsic in `IntrinsicsSPIRV.td`
- In SPIRVInstructionSelector.cpp create the `smoothstep` lowering and map it 
to `int_spv_smoothstep` in `SPIRVInstructionSelector::selectIntrinsic`
- Create SPIR-V backend test case in 
`llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll`
- Create SPIR-V backend test case in 
`llvm/test/CodeGen/SPIRV/opencl/smoothstep.ll`

>From 0a5da660c5aae053d87d556e59f98c121d916b79 Mon Sep 17 00:00:00 2001
From: kmpeng 
Date: Tue, 18 Mar 2025 13:25:10 -0700
Subject: [PATCH 1/5] create int_spv_smoothstep intrinsic, create smoothstep
 lowering & map to int_spv_smoothstep, create SPIR-V backend test cases

---
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  1 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp |  2 +
 .../SPIRV/hlsl-intrinsics/smoothstep.ll   | 60 ++
 llvm/test/CodeGen/SPIRV/opencl/smoothstep.ll  | 61 +++
 4 files changed, 124 insertions(+)
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll
 create mode 100644 llvm/test/CodeGen/SPIRV/opencl/smoothstep.ll

diff --git a/llvm/include/llvm/IR/IntrinsicsSPIRV.td 
b/llvm/include/llvm/IR/IntrinsicsSPIRV.td
index 4a0e10db2f1e4..7760961de7b6c 100644
--- a/llvm/include/llvm/IR/IntrinsicsSPIRV.td
+++ b/llvm/include/llvm/IR/IntrinsicsSPIRV.td
@@ -75,6 +75,7 @@ let TargetPrefix = "spv" in {
   def int_spv_reflect : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty, LLVMMatchType<0>], [IntrNoMem]>;
   def int_spv_rsqrt : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty], [IntrNoMem]>;
   def int_spv_saturate : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 
[LLVMMatchType<0>], [IntrNoMem]>;
+  def int_spv_smoothstep : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
   def int_spv_step : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[LLVMMatchType<0>, llvm_anyfloat_ty], [IntrNoMem]>;
   def int_spv_fdot :
 DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp 
b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index 2aba950037ec3..73b06027823f3 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -3121,6 +3121,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register 
ResVReg,
 return selectExtInst(ResVReg, ResType, I, CL::rsqrt, GL::InverseSqrt);
   case Intrinsic::spv_sign:
 return selectSign(ResVReg, ResType, I);
+  case Intrinsic::spv_smoothstep:
+return selectExtInst(ResVReg, ResType, I, CL::smoothstep, GL::SmoothStep);
   case Intrinsic::spv_firstbituhigh: // There is no CL equivalent of FindUMsb
 return selectFirstBitHigh(ResVReg, ResType, I, /*IsSigned=*/false);
   case Intrinsic::spv_firstbitshigh: // There is no CL equivalent of FindSMsb
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll 
b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll
new file mode 100644
index 0..09f93ab7955d3
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll
@@ -0,0 +1,60 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | 
FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - 
-filetype=obj | spirv-val %}
+
+; Make sure SPIRV operation function calls for smoothstep are lowered 
correctly.
+
+; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450"
+; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16
+; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4
+; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32
+; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4
+
+define noundef half @smoothstep_half(half noundef %a, half noundef %b, half 
noundef %c) {
+entry:
+  ; CHECK: %[[#]] = OpFunction %[[#float_16]] None %[[#]]
+  ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_16]]
+  ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#float_16]]
+  ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#float_16]]
+  ; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext_glsl]] SmoothStep 
%[[#arg0]] %[[#arg1]] %[[#arg2]]
+  %spv.smoothstep = call half @

[clang] [Clang] [NFC] Introduce helpers for defining compatibilty warnings (PR #132129)

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


@@ -155,6 +155,38 @@ class DefaultWarnNoWerror {
 }
 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
 
+// C++ compatibility warnings.
+multiclass CXXCompat<
+string message,
+int std_ver,
+bit ext_warn = true,
+string std_ver_override = ""#std_ver> {
+// 'X is a C++YZ extension'.
+def compat_pre_cxx#std_ver#_#NAME :
+Diagnostic,
+InGroup("CXX"#std_ver)>;
+
+// 'X is incompatible with C++98' (if std_ver == 11).
+// 'X is incompatible with C++ standards before C++YZ' (otherwise).
+def compat_cxx#std_ver#_#NAME :
+Warning,
+InGroup(!if(!eq(std_ver, 11),
+ "CXX98Compat",
+ "CXXPre"#std_ver#"Compat"))>,
+DefaultIgnore;
+}
+
+multiclass CXX11Compat : 
CXXCompat;

AaronBallman wrote:

The helper function would address my concerns such that we probably don't need 
to rename the diagnostics at all.

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Bruno Cardoso Lopes via cfe-commits


@@ -52,6 +52,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return cir::BoolAttr::get(getContext(), getBoolTy(), state);
   }
 
+  /// Create a for operation.
+  cir::ForOp createFor(
+  mlir::Location loc,
+  llvm::function_ref condBuilder,

bcardosolopes wrote:

The initialization happens within the scope preceding the actual cir.for, etc. 
We have no intend of reproducing the AST 100% here, because of nested regions 
the alloca needs to be visible and dominate all the loop.

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


[clang] [clang] Remove deprecated `FileManager` APIs (PR #132063)

2025-03-20 Thread Jan Svoboda via cfe-commits

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


[clang] 99b1a2a - [clang] Remove deprecated `FileManager` APIs (#132063)

2025-03-20 Thread via cfe-commits

Author: Jan Svoboda
Date: 2025-03-20T09:38:19-07:00
New Revision: 99b1a2ac078fe52300d270b3e77ddbababa8f951

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

LOG: [clang] Remove deprecated `FileManager` APIs (#132063)

This PR removes the `FileManager` APIs that have been deprecated for a
while.

LLVM 20.1.0 that was released earlier this month contains the formal
deprecation of these APIs, so these should be fine to remove in the next
major release.

Added: 


Modified: 
clang/include/clang/Basic/FileManager.h
clang/lib/Basic/FileManager.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileManager.h 
b/clang/include/clang/Basic/FileManager.h
index 6cc6c2bfd2b6b..e83a61d6ff00c 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -177,43 +177,6 @@ class FileManager : public RefCountedBase {
 return llvm::expectedToOptional(getDirectoryRef(DirName, CacheFailure));
   }
 
-  /// Lookup, cache, and verify the specified directory (real or
-  /// virtual).
-  ///
-  /// This function is deprecated and will be removed at some point in the
-  /// future, new clients should use
-  ///  \c getDirectoryRef.
-  ///
-  /// This returns a \c std::error_code if there was an error reading the
-  /// directory. If there is no error, the DirectoryEntry is guaranteed to be
-  /// non-NULL.
-  ///
-  /// \param CacheFailure If true and the file does not exist, we'll cache
-  /// the failure to find this file.
-  LLVM_DEPRECATED("Functions returning DirectoryEntry are deprecated.",
-  "getOptionalDirectoryRef()")
-  llvm::ErrorOr
-  getDirectory(StringRef DirName, bool CacheFailure = true);
-
-  /// Lookup, cache, and verify the specified file (real or
-  /// virtual).
-  ///
-  /// This function is deprecated and will be removed at some point in the
-  /// future, new clients should use
-  ///  \c getFileRef.
-  ///
-  /// This returns a \c std::error_code if there was an error loading the file.
-  /// If there is no error, the FileEntry is guaranteed to be non-NULL.
-  ///
-  /// \param OpenFile if true and the file exists, it will be opened.
-  ///
-  /// \param CacheFailure If true and the file does not exist, we'll cache
-  /// the failure to find this file.
-  LLVM_DEPRECATED("Functions returning FileEntry are deprecated.",
-  "getOptionalFileRef()")
-  llvm::ErrorOr
-  getFile(StringRef Filename, bool OpenFile = false, bool CacheFailure = true);
-
   /// Lookup, cache, and verify the specified file (real or virtual). Return 
the
   /// reference to the file entry together with the exact path that was used to
   /// access a file by a particular call to getFileRef. If the underlying VFS 
is

diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f0b6f7be6c84f..ec84aad72e6be 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -196,22 +196,6 @@ FileManager::getDirectoryRef(StringRef DirName, bool 
CacheFailure) {
   return DirectoryEntryRef(NamedDirEnt);
 }
 
-llvm::ErrorOr
-FileManager::getDirectory(StringRef DirName, bool CacheFailure) {
-  auto Result = getDirectoryRef(DirName, CacheFailure);
-  if (Result)
-return &Result->getDirEntry();
-  return llvm::errorToErrorCode(Result.takeError());
-}
-
-llvm::ErrorOr
-FileManager::getFile(StringRef Filename, bool openFile, bool CacheFailure) {
-  auto Result = getFileRef(Filename, openFile, CacheFailure);
-  if (Result)
-return &Result->getFileEntry();
-  return llvm::errorToErrorCode(Result.takeError());
-}
-
 llvm::Expected FileManager::getFileRef(StringRef Filename,
  bool openFile,
  bool CacheFailure,



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


[clang] [compiler-rt] [llvm] [openmp] [PGO][Offload] Profile profraw generation for GPU instrumentation #76587 (PR #93365)

2025-03-20 Thread David Tellenbach via cfe-commits

dtellenbach wrote:

@EthanLuisMcDonough I think your patch effectively introduces a dependency on 
libc because `__llvm_write_custom_profile` has `__attribute__((used))`` but 
calls e.g. `atoi` through `setupIOBuffer`.

In compiler-rt it's not safe to make that assumption because it potentially 
breaks embedded platforms. IMO it's also bad practice to force used symbols 
into a static archive. Would you please take another look and at least make the 
functionality dependent on offloading or something similar?

Thanks a lot!

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


[libclc] [libclc] add --only-needed to llvm-link when INTERNALIZE flag is set (PR #130871)

2025-03-20 Thread Wenju He via cfe-commits

wenju-he wrote:

@frasercrmck could you please try this PR on https://github.com/intel/llvm repo?

My experiment:
clang --version
clang version 21.0.0git (https://github.com/llvm/llvm-project 
f5ee10538b68835112323c241ca7db67ca78bf62)

before PR: 
find . -name "builtins.link*.bc" -printf "%s\n" | paste -sd+ | bc
101593692

after PR:
find . -name "builtins.link*.bc" -printf "%s\n" | paste -sd+ | bc
101316928

This PR reduces bitcode file sizes by 0.27%

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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 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 9b1f905b483a2b42e4681bbef42b2641f8ccf5ad 
c389db7ffd143fbf462aafc0e1897f96c7478fad --extensions h,cpp -- 
clang/lib/CodeGen/BuiltinTargets/AArch64.cpp 
clang/lib/CodeGen/BuiltinTargets/AMDGPU.cpp 
clang/lib/CodeGen/BuiltinTargets/Hexagon.cpp 
clang/lib/CodeGen/BuiltinTargets/NVPTX.cpp 
clang/lib/CodeGen/BuiltinTargets/PPC.cpp 
clang/lib/CodeGen/BuiltinTargets/RISCV.cpp 
clang/lib/CodeGen/BuiltinTargets/SPIR.cpp 
clang/lib/CodeGen/BuiltinTargets/SystemZ.cpp 
clang/lib/CodeGen/BuiltinTargets/WebAssembly.cpp 
clang/lib/CodeGen/BuiltinTargets/X86.cpp clang/lib/CodeGen/CGBuiltin.h 
clang/lib/CodeGen/CGBuiltin.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/BuiltinTargets/AArch64.cpp 
b/clang/lib/CodeGen/BuiltinTargets/AArch64.cpp
index 1b4907b947..ce4ee6920e 100644
--- a/clang/lib/CodeGen/BuiltinTargets/AArch64.cpp
+++ b/clang/lib/CodeGen/BuiltinTargets/AArch64.cpp
@@ -578,19 +578,15 @@ struct ARMVectorIntrinsicInfo {
 } // end anonymous namespace
 
 #define NEONMAP0(NameBase) 
\
-  { #NameBase, NEON::BI__builtin_neon_##NameBase, 0, 0, 0 }
+  {#NameBase, NEON::BI__builtin_neon_##NameBase, 0, 0, 0}
 
 #define NEONMAP1(NameBase, LLVMIntrinsic, TypeModifier)
\
-  {
\
-#NameBase, NEON::BI__builtin_neon_##NameBase, Intrinsic::LLVMIntrinsic, 0, 
\
-TypeModifier   
\
-  }
+  {#NameBase, NEON::BI__builtin_neon_##NameBase, Intrinsic::LLVMIntrinsic, 0,  
\
+   TypeModifier}
 
 #define NEONMAP2(NameBase, LLVMIntrinsic, AltLLVMIntrinsic, TypeModifier)  
\
-  {
\
-#NameBase, NEON::BI__builtin_neon_##NameBase, Intrinsic::LLVMIntrinsic,
\
-Intrinsic::AltLLVMIntrinsic, TypeModifier  
\
-  }
+  {#NameBase, NEON::BI__builtin_neon_##NameBase, Intrinsic::LLVMIntrinsic, 
\
+   Intrinsic::AltLLVMIntrinsic, TypeModifier}
 
 static const ARMVectorIntrinsicInfo ARMSIMDIntrinsicMap[] = {
 NEONMAP1(__a32_vcvt_bf16_f32, arm_neon_vcvtfp2bf, 0),
@@ -1937,13 +1933,11 @@ static const std::pair 
NEONEquivalentIntrinsicMap[] = {
 #undef NEONMAP2
 
 #define SVEMAP1(NameBase, LLVMIntrinsic, TypeModifier) 
\
-  {
\
-#NameBase, SVE::BI__builtin_sve_##NameBase, Intrinsic::LLVMIntrinsic, 0,   
\
-TypeModifier   
\
-  }
+  {#NameBase, SVE::BI__builtin_sve_##NameBase, Intrinsic::LLVMIntrinsic, 0,
\
+   TypeModifier}
 
 #define SVEMAP2(NameBase, TypeModifier)
\
-  { #NameBase, SVE::BI__builtin_sve_##NameBase, 0, 0, TypeModifier }
+  {#NameBase, SVE::BI__builtin_sve_##NameBase, 0, 0, TypeModifier}
 static const ARMVectorIntrinsicInfo AArch64SVEIntrinsicMap[] = {
 #define GET_SVE_LLVM_INTRINSIC_MAP
 #include "clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def"
@@ -1955,13 +1949,11 @@ static const ARMVectorIntrinsicInfo 
AArch64SVEIntrinsicMap[] = {
 #undef SVEMAP2
 
 #define SMEMAP1(NameBase, LLVMIntrinsic, TypeModifier) 
\
-  {
\
-#NameBase, SME::BI__builtin_sme_##NameBase, Intrinsic::LLVMIntrinsic, 0,   
\
-TypeModifier   
\
-  }
+  {#NameBase, SME::BI__builtin_sme_##NameBase, Intrinsic::LLVMIntrinsic, 0,
\
+   TypeModifier}
 
 #define SMEMAP2(NameBase, TypeModifier)
\
-  { #NameBase, SME::BI__builtin_sme_##NameBase, 0, 0, TypeModifier }
+  {#NameBase, SME::BI__builtin_sme_##NameBase, 0, 0, TypeModifier}
 static const ARMVectorIntrinsicInfo AArch64SMEIntrinsicMap[] = {
 #define GET_SME_LLVM_INTRINSIC_MAP
 #include "clang/Basic/arm_sme_builtin_cg.inc"
diff --git a/clang/lib/CodeGen/BuiltinTargets/NVPTX.cpp 
b/clang/lib/CodeGen/BuiltinTargets/NVPTX.cpp
index d73ec27385..73b7177474 100644
--- a/clang/lib/CodeGen/BuiltinTargets/NVPTX.cpp
+++ b/clang/lib/CodeGen/BuiltinTargets/NVPTX.cpp
@@ -36,7 +36,7 @@ struct NVPTXMmaLdstInfo {
 #define MMA_INTR(geom_op_type, layout) 
\
   Intrinsic::nvvm_wmma_##geom_op_type##_##layout##_stride
 #define MMA_LDST(n, geom_op_type)  
\
-  { n, MMA_INTR(geom_op_type, col), MMA_INTR(geom_op_type, row) }
+  {n, MMA_INTR(geom_op_type, col), MMA_INTR(geom_op_type, row)}
 
 static NVPTXMmaLdstInfo getNVPTXMmaLdstInfo(unsigned

[clang] [clang][bytecode] Implement __builtin_wmemchr (PR #132254)

2025-03-20 Thread Timm Baeder via cfe-commits

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

None

>From d64d8d99a96d85b6048eff9130b29e5126ca9607 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 20 Mar 2025 18:10:00 +0100
Subject: [PATCH] [clang][bytecode] Implement __builtin_wmemchr

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 25 +++
 clang/test/AST/ByteCode/builtin-functions.cpp | 24 ++
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 3fa8fbc22ec03..57037b674feba 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2039,11 +2039,23 @@ static bool interp__builtin_memchr(InterpState &S, 
CodePtr OpPC,
 }
   }
 
-  uint64_t DesiredVal =
-  Desired.trunc(S.getASTContext().getCharWidth()).getZExtValue();
+  uint64_t DesiredVal;
+  if (ID == Builtin::BIwmemchr || ID == Builtin::BI__builtin_wmemchr ||
+  ID == Builtin::BIwcschr || ID == Builtin::BI__builtin_wcschr) {
+// wcschr and wmemchr are given a wchar_t to look for. Just use it.
+DesiredVal = Desired.getZExtValue();
+  } else {
+DesiredVal = 
Desired.trunc(S.getASTContext().getCharWidth()).getZExtValue();
+  }
+
   bool StopAtZero =
   (ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr);
 
+  PrimType ElemT =
+  IsRawByte
+  ? PT_Sint8
+  : *S.getContext().classify(Ptr.getFieldDesc()->getElemQualType());
+
   size_t Index = Ptr.getIndex();
   size_t Step = 0;
   for (;;) {
@@ -2053,7 +2065,10 @@ static bool interp__builtin_memchr(InterpState &S, 
CodePtr OpPC,
 if (!CheckLoad(S, OpPC, ElemPtr))
   return false;
 
-unsigned char V = static_cast(ElemPtr.deref());
+uint64_t V;
+INT_TYPE_SWITCH_NO_BOOL(
+ElemT, { V = static_cast(ElemPtr.deref().toUnsigned()); 
});
+
 if (V == DesiredVal) {
   S.Stk.push(ElemPtr);
   return true;
@@ -2556,11 +2571,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const Function *F,
   case Builtin::BI__builtin_memchr:
   case Builtin::BIstrchr:
   case Builtin::BI__builtin_strchr:
+  case Builtin::BIwmemchr:
+  case Builtin::BI__builtin_wmemchr:
 #if 0
   case Builtin::BIwcschr:
   case Builtin::BI__builtin_wcschr:
-  case Builtin::BImemchr:
-  case Builtin::BI__builtin_wmemchr:
 #endif
   case Builtin::BI__builtin_char_memchr:
 if (!interp__builtin_memchr(S, OpPC, Frame, F, Call))
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 11ff48bfa7102..3dd348031fec1 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -20,6 +20,7 @@ extern "C" {
   extern size_t wcslen(const wchar_t *p);
   extern void *memchr(const void *s, int c, size_t n);
   extern char *strchr(const char *s, int c);
+  extern wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
 }
 
 namespace strcmp {
@@ -1489,3 +1490,26 @@ namespace Strchr {
   constexpr bool a = !strchr("hello", 'h'); // both-error {{constant 
expression}} \
 // both-note {{non-constexpr 
function 'strchr' cannot be used in a constant expression}}
 }
+
+namespace WMemChr {
+  constexpr const wchar_t *kStr = L"abca\x\0dL";
+  constexpr wchar_t kFoo[] = {L'f', L'o', L'o'};
+
+  static_assert(__builtin_wmemchr(kStr, L'a', 0) == nullptr);
+  static_assert(__builtin_wmemchr(kStr, L'a', 1) == kStr);
+  static_assert(__builtin_wmemchr(kStr, L'\0', 5) == nullptr);
+  static_assert(__builtin_wmemchr(kStr, L'\0', 6) == kStr + 5);
+  static_assert(__builtin_wmemchr(kStr, L'\x', 8) == kStr + 4);
+  static_assert(__builtin_wmemchr(kFoo, L'x', 3) == nullptr);
+  static_assert(__builtin_wmemchr(kFoo, L'x', 4) == nullptr); // both-error 
{{not an integral constant}} \
+  // both-note 
{{dereferenced one-past-the-end}}
+  static_assert(__builtin_wmemchr(nullptr, L'x', 3) == nullptr); // both-error 
{{not an integral constant}} \
+ // both-note 
{{dereferenced null}}
+  static_assert(__builtin_wmemchr(nullptr, L'x', 0) == nullptr);
+
+  constexpr bool b = !wmemchr(L"hello", L'h', 3); // both-error {{constant 
expression}} \
+  // both-note {{non-constexpr 
function 'wmemchr' cannot be used in a constant expression}}
+
+  constexpr wchar_t kStr2[] = {L'f', L'o', L'\x', L'o'};
+  static_assert(__builtin_wmemchr(kStr2, L'\x', 4) == kStr2 + 2);
+}

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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-03-20 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -491,7 +503,7 @@ void NullabilityChecker::reportBugIfInvariantHolds(
 N = C.addTransition(OriginalState, N);
   }
 
-  reportBug(Msg, Error, CK, N, Region, C.getBugReporter(), ValueExpr);
+  reportBug(Msg, Error, Idx, N, Region, C.getBugReporter(), ValueExpr);

steakhal wrote:

This feels like a technical difficulty.
You could create a `bug(checker)` member fn that gives you the right BugType. 
Or a reference member to the right BugType.

I'll have a look at your current PR tomorrow to give you concrete suggestions.

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


[clang] [clang][bytecode] Implement __builtin_wmemchr (PR #132254)

2025-03-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


2 Files Affected:

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


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 3fa8fbc22ec03..57037b674feba 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2039,11 +2039,23 @@ static bool interp__builtin_memchr(InterpState &S, 
CodePtr OpPC,
 }
   }
 
-  uint64_t DesiredVal =
-  Desired.trunc(S.getASTContext().getCharWidth()).getZExtValue();
+  uint64_t DesiredVal;
+  if (ID == Builtin::BIwmemchr || ID == Builtin::BI__builtin_wmemchr ||
+  ID == Builtin::BIwcschr || ID == Builtin::BI__builtin_wcschr) {
+// wcschr and wmemchr are given a wchar_t to look for. Just use it.
+DesiredVal = Desired.getZExtValue();
+  } else {
+DesiredVal = 
Desired.trunc(S.getASTContext().getCharWidth()).getZExtValue();
+  }
+
   bool StopAtZero =
   (ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr);
 
+  PrimType ElemT =
+  IsRawByte
+  ? PT_Sint8
+  : *S.getContext().classify(Ptr.getFieldDesc()->getElemQualType());
+
   size_t Index = Ptr.getIndex();
   size_t Step = 0;
   for (;;) {
@@ -2053,7 +2065,10 @@ static bool interp__builtin_memchr(InterpState &S, 
CodePtr OpPC,
 if (!CheckLoad(S, OpPC, ElemPtr))
   return false;
 
-unsigned char V = static_cast(ElemPtr.deref());
+uint64_t V;
+INT_TYPE_SWITCH_NO_BOOL(
+ElemT, { V = static_cast(ElemPtr.deref().toUnsigned()); 
});
+
 if (V == DesiredVal) {
   S.Stk.push(ElemPtr);
   return true;
@@ -2556,11 +2571,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const Function *F,
   case Builtin::BI__builtin_memchr:
   case Builtin::BIstrchr:
   case Builtin::BI__builtin_strchr:
+  case Builtin::BIwmemchr:
+  case Builtin::BI__builtin_wmemchr:
 #if 0
   case Builtin::BIwcschr:
   case Builtin::BI__builtin_wcschr:
-  case Builtin::BImemchr:
-  case Builtin::BI__builtin_wmemchr:
 #endif
   case Builtin::BI__builtin_char_memchr:
 if (!interp__builtin_memchr(S, OpPC, Frame, F, Call))
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 11ff48bfa7102..3dd348031fec1 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -20,6 +20,7 @@ extern "C" {
   extern size_t wcslen(const wchar_t *p);
   extern void *memchr(const void *s, int c, size_t n);
   extern char *strchr(const char *s, int c);
+  extern wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
 }
 
 namespace strcmp {
@@ -1489,3 +1490,26 @@ namespace Strchr {
   constexpr bool a = !strchr("hello", 'h'); // both-error {{constant 
expression}} \
 // both-note {{non-constexpr 
function 'strchr' cannot be used in a constant expression}}
 }
+
+namespace WMemChr {
+  constexpr const wchar_t *kStr = L"abca\x\0dL";
+  constexpr wchar_t kFoo[] = {L'f', L'o', L'o'};
+
+  static_assert(__builtin_wmemchr(kStr, L'a', 0) == nullptr);
+  static_assert(__builtin_wmemchr(kStr, L'a', 1) == kStr);
+  static_assert(__builtin_wmemchr(kStr, L'\0', 5) == nullptr);
+  static_assert(__builtin_wmemchr(kStr, L'\0', 6) == kStr + 5);
+  static_assert(__builtin_wmemchr(kStr, L'\x', 8) == kStr + 4);
+  static_assert(__builtin_wmemchr(kFoo, L'x', 3) == nullptr);
+  static_assert(__builtin_wmemchr(kFoo, L'x', 4) == nullptr); // both-error 
{{not an integral constant}} \
+  // both-note 
{{dereferenced one-past-the-end}}
+  static_assert(__builtin_wmemchr(nullptr, L'x', 3) == nullptr); // both-error 
{{not an integral constant}} \
+ // both-note 
{{dereferenced null}}
+  static_assert(__builtin_wmemchr(nullptr, L'x', 0) == nullptr);
+
+  constexpr bool b = !wmemchr(L"hello", L'h', 3); // both-error {{constant 
expression}} \
+  // both-note {{non-constexpr 
function 'wmemchr' cannot be used in a constant expression}}
+
+  constexpr wchar_t kStr2[] = {L'f', L'o', L'\x', L'o'};
+  static_assert(__builtin_wmemchr(kStr2, L'\x', 4) == kStr2 + 2);
+}

``




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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

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

https://github.com/NagyDonat updated 
https://github.com/llvm/llvm-project/pull/132250

From d4878a62a69304dc2ae32902803f8c8efb1c69ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Thu, 20 Mar 2025 17:09:46 +0100
Subject: [PATCH 1/4] [NFC][analyzer] Multipart checker refactor 2:
 NullabilityChecker

Simplify `NullabilityChecker.cpp` with new multipart checker framework
introduced in 27099982da2f5a6c2d282d6b385e79d080669546. This is part of
a commit series that will perform analogous changes in all checker
classes that implement multiple user-facing checker parts (with separate
names).
---
 .../Checkers/NullabilityChecker.cpp   | 157 +-
 1 file changed, 81 insertions(+), 76 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
index 04472bb3895a7..8fe7d21ca7984 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -112,25 +112,38 @@ class NullabilityChecker
   void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
   const char *Sep) const override;
 
-  enum CheckKind {
-CK_NullPassedToNonnull,
-CK_NullReturnedFromNonnull,
-CK_NullableDereferenced,
-CK_NullablePassedToNonnull,
-CK_NullableReturnedFromNonnull,
-CK_NumCheckKinds
+  // FIXME: This enumeration of checker parts is extremely similar to the
+  // ErrorKind enum. It would be nice to unify them to simplify the code.
+  // FIXME: The modeling checker NullabilityBase is a dummy "empty checker
+  // part" that registers this checker class without enabling any of the real
+  // checker parts. As far as I understand no other checker references it, so
+  // it should be removed.
+  enum : CheckerPartIdx {
+NullabilityBase,
+NullPassedToNonnullChecker,
+NullReturnedFromNonnullChecker,
+NullableDereferencedChecker,
+NullablePassedToNonnullChecker,
+NullableReturnedFromNonnullChecker,
+NumCheckerParts
   };
 
-  bool ChecksEnabled[CK_NumCheckKinds] = {false};
-  CheckerNameRef CheckNames[CK_NumCheckKinds];
-  mutable std::unique_ptr BTs[CK_NumCheckKinds];
-
-  const std::unique_ptr &getBugType(CheckKind Kind) const {
-if (!BTs[Kind])
-  BTs[Kind].reset(new BugType(CheckNames[Kind], "Nullability",
-  categories::MemoryError));
-return BTs[Kind];
-  }
+  // FIXME: Currently the `Description` fields of these `BugType`s are all
+  // identical ("Nullability") -- they should be more descriptive than this.
+  // NOTE: NullabilityBase is a dummy checker part that does nothing, so its
+  // bug type is left empty.
+  BugType BugTypes[NumCheckerParts] = {
+  {this, NullabilityBase, "", ""},
+  {this, NullPassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableDereferencedChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullablePassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError}};
 
   // When set to false no nullability information will be tracked in
   // NullabilityMap. It is possible to catch errors like passing a null pointer
@@ -163,17 +176,16 @@ class NullabilityChecker
   ///
   /// When \p SuppressPath is set to true, no more bugs will be reported on 
this
   /// path by this checker.
-  void reportBugIfInvariantHolds(StringRef Msg, ErrorKind Error, CheckKind CK,
- ExplodedNode *N, const MemRegion *Region,
- CheckerContext &C,
+  void reportBugIfInvariantHolds(StringRef Msg, ErrorKind Error,
+ CheckerPartIdx Idx, ExplodedNode *N,
+ const MemRegion *Region, CheckerContext &C,
  const Stmt *ValueExpr = nullptr,
  bool SuppressPath = false) const;
 
-  void reportBug(StringRef Msg, ErrorKind Error, CheckKind CK, ExplodedNode *N,
- const MemRegion *Region, BugReporter &BR,
+  void reportBug(StringRef Msg, ErrorKind Error, CheckerPartIdx Idx,
+ ExplodedNode *N, const MemRegion *Region, BugReporter &BR,
  const Stmt *ValueExpr = nullptr) const {
-const std::unique_ptr &BT = getBugType(CK);
-auto R = std::make_unique(*BT, Msg, N);
+auto R = std::make_unique(BugTypes[Idx], Msg, N);
 if (Region) {
   R->markInteresting(Region);
   R->addVisitor(Region);
@@ -479,7 +491,7 @@ static bool checkInvariantViolation(ProgramStateRef State, 
ExplodedNode *N,
 }
 
 void NullabilityChecker::reportBugIfInvariantHolds(
-StringRef Msg, ErrorKind Error, CheckKind CK, ExplodedNode *N,
+StringRef M

[clang] [Docs] Document freestanding requirements (PR #132232)

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

AaronBallman wrote:

> This looks potentially-reasonable from the _Clang_ subproject POV, but from a 
> whole-project POV, I think we ought to actually provide a conforming 
> freestanding mode somehow, probably via llvm-libc.

+1

> So I'd kinda like to hear from llvm-libc folks what they're thinking here. 
> @jhuber6 @michaelrj-google any thoughts?

My understanding (and correct me if I'm wrong!) is that llvm-libc aims to 
provide both a hosted and a freestanding mode.

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


[clang] [llvm] Hlsl asint16 intrinsic (PR #131900)

2025-03-20 Thread via cfe-commits

https://github.com/metkarpoonam updated 
https://github.com/llvm/llvm-project/pull/131900

>From 7ef40ee7d88872dbee1345cbd822e4aed8a22626 Mon Sep 17 00:00:00 2001
From: Poonam Vilas Metkar 
Date: Tue, 18 Mar 2025 11:30:15 -0700
Subject: [PATCH 01/13] Add codegen tests, Sema tests, SPIR-V backend test
 case, and apply clang formatting

---
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 18 ++
 clang/test/CodeGenHLSL/builtins/asint16.hlsl  | 48 
 .../SemaHLSL/BuiltIns/asint16-errors.hlsl | 29 ++
 .../CodeGen/SPIRV/hlsl-intrinsics/asint16.ll  | 55 +++
 4 files changed, 150 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/builtins/asint16.hlsl
 create mode 100644 clang/test/SemaHLSL/BuiltIns/asint16-errors.hlsl
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/asint16.ll

diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index a48a8e998a015..e0366693deae0 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -80,6 +80,24 @@ void asuint(double3, out uint3, out uint3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
 void asuint(double4, out uint4, out uint4);
 
+//===--===//
+// asint16 builtins
+//===--===//
+
+/// \fn int16_t asint16(T Val)
+/// \brief Interprets the bit pattern of x as an 16-bit integer.
+/// \param Val The input value.
+#ifdef __HLSL_ENABLE_16_BIT
+
+template  constexpr vector asint16(vector 
V) {
+  return __detail::bit_cast(V);
+}
+
+template  constexpr int16_t asint16(T F) {
+  return __detail::bit_cast(F);
+}
+#endif
+
 
//===--===//
 // distance builtins
 
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/asint16.hlsl 
b/clang/test/CodeGenHLSL/builtins/asint16.hlsl
new file mode 100644
index 0..0cd6ee63fa078
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/asint16.hlsl
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple 
dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | 
FileCheck %s
+// CHECK: define {{.*}}test_ints{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+// CHECK-NOT: bitcast
+// CHECK: ret i16 [[VAL]]
+int16_t test_int(int16_t p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_uint{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret i16 [[VAL]]
+int16_t test_uint(uint16_t p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_half{{.*}}(half {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast half [[VAL]] to i16
+//CHECK : ret i16 [[RES]]
+int16_t test_half(half p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_int{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+int16_t4 test_vector_int(int16_t4 p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_uint{{.*}}(<4 x i16> {{.*}} 
[[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+int16_t4 test_vector_uint(uint16_t4 p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}fn{{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast <4 x half> [[VAL]] to <4 x i16>
+//CHECK: ret <4 x i16> [[RES]]
+int16_t4 fn(half4 p1)
+{
+return asint16(p1);
+}
\ No newline at end of file
diff --git a/clang/test/SemaHLSL/BuiltIns/asint16-errors.hlsl 
b/clang/test/SemaHLSL/BuiltIns/asint16-errors.hlsl
new file mode 100644
index 0..03a3e46bd1d46
--- /dev/null
+++ b/clang/test/SemaHLSL/BuiltIns/asint16-errors.hlsl
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.2-library %s -fnative-half-type -verify
+
+
+int16_t4 test_asint_too_many_arg(uint16_t p0, uint16_t p1)
+{
+return asint16(p0, p1);
+  // expected-error@-1 {{no matching function for call to 'asint16'}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not 
viable: requires single argument 'V', but 2 arguments were provided}}
+  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not 
viable: requires single argument 'F', but 2 arguments were provided}}
+}
+
+
+int16_t test_asint_int(int p1)
+{
+return asint16(p1);
+// expected-error@hlsl/hlsl_intrinsics.h:* {{no matching function for call 
to 'bit_cast'}}
+// expected-note@-2 {{in instantiation of function template specialization 
'hlsl::asint16'}}
+// expected-note@hlsl/hlsl_detail.h:* {{candidate template ignored: could 
not match 'vector' against 'int'}}
+// expected-note@hlsl/hlsl_detail.h:* {{candidate template ignored: 
substitution failure [with U = int16_t, T = int]: no type named 'Type'}}
+}
+
+int16_t test_asint_float(floa

[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-20 Thread Sam Elliott via cfe-commits

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


[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-20 Thread Sam Elliott via cfe-commits


@@ -25,8 +25,8 @@ addi a0, a1, 0
 # CHECK: # encoding:  [0xe0,0x1f]
 addi s0, sp, 1020
 
-# CHECK: .option arch, -c
-.option arch, -c
+# CHECK: .option arch, -c, -zca
+.option arch, -c, -zca

lenary wrote:

This is because your predicates need a little bit of work, I think

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


[clang] [llvm] [AARCH64][Neon] switch to using bitcasts in arm_neon.h where appropriate (PR #127043)

2025-03-20 Thread via cfe-commits

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


[clang] [llvm] [LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. (PR #130973)

2025-03-20 Thread Paul Walker via cfe-commits

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


[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-20 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 d0d33d2b5ba3369d4a5586234181055935965e49 
e147dd68477b7e5ec9e6363a45fd7568fe595b04 --extensions c,cpp -- 
clang/test/CodeGen/RISCV/riscv-func-attr-target.c 
clang/test/CodeGen/attr-target-clones-riscv.c 
clang/test/CodeGen/attr-target-version-riscv.c 
clang/test/CodeGenCXX/attr-target-clones-riscv.cpp 
clang/test/CodeGenCXX/attr-target-version-riscv.cpp 
llvm/lib/TargetParser/RISCVISAInfo.cpp 
llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp 
b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 292890bf2e..fb0f6943c9 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -863,8 +863,7 @@ void RISCVISAInfo::updateImplication() {
   }
 
   // Add Zcf if C and F are enabled on RV32.
-  if (XLen == 32 && Exts.count("c") && Exts.count("f") &&
-  !Exts.count("zcf")) {
+  if (XLen == 32 && Exts.count("c") && Exts.count("f") && !Exts.count("zcf")) {
 auto Version = findDefaultVersion("zcf");
 Exts["zcf"] = *Version;
   }
diff --git a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp 
b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
index bd117e8aa9..c66e9511ce 100644
--- a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
@@ -303,8 +303,10 @@ TEST(ParseArchString, 
AcceptsSupportedBaseISAsAndSetsXLenAndFLen) {
   EXPECT_TRUE(ExtsRV64GCV.at("zicsr") == (RISCVISAUtils::ExtensionVersion{2, 
0}));
   EXPECT_TRUE(ExtsRV64GCV.at("zifencei") ==
   (RISCVISAUtils::ExtensionVersion{2, 0}));
-  EXPECT_TRUE(ExtsRV64GCV.at("zmmul") == (RISCVISAUtils::ExtensionVersion{1, 
0}));
-  EXPECT_TRUE(ExtsRV64GCV.at("zaamo") == (RISCVISAUtils::ExtensionVersion{1, 
0}));
+  EXPECT_TRUE(ExtsRV64GCV.at("zmmul") ==
+  (RISCVISAUtils::ExtensionVersion{1, 0}));
+  EXPECT_TRUE(ExtsRV64GCV.at("zaamo") ==
+  (RISCVISAUtils::ExtensionVersion{1, 0}));
   EXPECT_TRUE(ExtsRV64GCV.at("zalrsc") ==
   (RISCVISAUtils::ExtensionVersion{1, 0}));
   EXPECT_TRUE(ExtsRV64GCV.at("zca") == (RISCVISAUtils::ExtensionVersion{1, 
0}));

``




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


[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)

2025-03-20 Thread Mohamed Emad via cfe-commits


@@ -750,11 +754,15 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
   Out.emplace_back(std::move(Table));
 
   if (I.DefLoc) {
-if (!CDCtx.RepositoryUrl)
-  Out.emplace_back(writeFileDefinition(*I.DefLoc));
-else
-  Out.emplace_back(
-  writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
+std::optional RepoUrl;
+std::optional RepoLinePrefix;
+
+if (CDCtx.RepositoryUrl)
+  RepoUrl = StringRef{*CDCtx.RepositoryUrl};
+if (CDCtx.RepositoryLinePrefix)
+  RepoLinePrefix = StringRef{*CDCtx.RepositoryLinePrefix};
+
+Out.emplace_back(writeFileDefinition(*I.DefLoc, RepoUrl, RepoLinePrefix));

hulxv wrote:

> Perhaps its better if WriteFileDefinition just takes StringRef arguments 
> instead of optional? Then instead of checking the optional, you 
> can either just use the StringRef as is or at worst check for empty(). Do you 
> think that would allow us to simplify this code?

Yup, I think that. it will be better

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


[clang] [llvm] [AARCH64][Neon] switch to using bitcasts in arm_neon.h where appropriate (PR #127043)

2025-03-20 Thread via cfe-commits


@@ -8747,28 +8752,32 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   return Builder.CreateBitCast(Result, ResultType, NameHint);
 }
 
-Value *CodeGenFunction::EmitAArch64CompareBuiltinExpr(
-Value *Op, llvm::Type *Ty, const CmpInst::Predicate Fp,
-const CmpInst::Predicate Ip, const Twine &Name) {
-  llvm::Type *OTy = Op->getType();
-
-  // FIXME: this is utterly horrific. We should not be looking at previous
-  // codegen context to find out what needs doing. Unfortunately TableGen
-  // currently gives us exactly the same calls for vceqz_f32 and vceqz_s32
-  // (etc).
-  if (BitCastInst *BI = dyn_cast(Op))
-OTy = BI->getOperand(0)->getType();
-
-  Op = Builder.CreateBitCast(Op, OTy);
-  if (OTy->getScalarType()->isFloatingPointTy()) {
-if (Fp == CmpInst::FCMP_OEQ)
-  Op = Builder.CreateFCmp(Fp, Op, Constant::getNullValue(OTy));
+Value *
+CodeGenFunction::EmitAArch64CompareBuiltinExpr(Value *Op, llvm::Type *Ty,
+   const CmpInst::Predicate Pred,
+   const Twine &Name) {
+
+  if (isa(Ty)) {
+// Vector types are cast to i8 vectors. Recover original type.
+Op = Builder.CreateBitCast(Op, Ty);
+  }
+
+  if (CmpInst::isFPPredicate(Pred)) {
+if (Pred == CmpInst::FCMP_OEQ)
+  Op = Builder.CreateFCmp(Pred, Op, Constant::getNullValue(Op->getType()));
 else
-  Op = Builder.CreateFCmpS(Fp, Op, Constant::getNullValue(OTy));
+  Op = Builder.CreateFCmpS(Pred, Op, 
Constant::getNullValue(Op->getType()));
   } else {
-Op = Builder.CreateICmp(Ip, Op, Constant::getNullValue(OTy));
+Op = Builder.CreateICmp(Pred, Op, Constant::getNullValue(Op->getType()));
   }
-  return Builder.CreateSExt(Op, Ty, Name);
+
+  llvm::Type *ResTy = Ty;

CarolineConcatto wrote:

Why do we need that for? I removed and could not see any failing tests.

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


[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-20 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

Thanks for the info, sorry this created trouble for you!

An option to turn this behavior off should be easy to add. It's however 
problematic if it lasts for more than one release because it's harder to 
deprecate later. 

It would be good to have a unit test of this case, would the one in the CERT 
check mentioned above be sufficient? 


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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

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


@@ -1394,35 +1403,34 @@ void NullabilityChecker::printState(raw_ostream &Out, 
ProgramStateRef State,
   }
 }
 
-void ento::registerNullabilityBase(CheckerManager &mgr) {
-  mgr.registerChecker();
-}
-
-bool ento::shouldRegisterNullabilityBase(const CheckerManager &mgr) {
-  return true;
-}
-
-#define REGISTER_CHECKER(name, trackingRequired)   
\
-  void ento::register##name##Checker(CheckerManager &mgr) {
\
-NullabilityChecker *checker = mgr.getChecker();
\
-checker->ChecksEnabled[NullabilityChecker::CK_##name] = true;  
\
-checker->CheckNames[NullabilityChecker::CK_##name] =   
\
-mgr.getCurrentCheckerName();   
\
-checker->NeedTracking = checker->NeedTracking || trackingRequired; 
\
-checker->NoDiagnoseCallsToSystemHeaders =  
\
-checker->NoDiagnoseCallsToSystemHeaders || 
\
-mgr.getAnalyzerOptions().getCheckerBooleanOption(  
\
-checker, "NoDiagnoseCallsToSystemHeaders", true);  
\
+// The checker group "nullability" consists of the checkers that are
+// implemented as the parts of the checker class `NullabilityChecker`. These
+// checkers share a checker option "nullability:NoDiagnoseCallsToSystemHeaders"
+// which semantically belongs to the whole group and not just one checker from
+// it. As this is a unique situation (I don't know about any other similar
+// group-level option) there is no mechanism to inject this group name from
+// e.g. Checkers.td, so I'm just hardcoding it here. (These are old stable
+// checkers, I don't think that their name will change.)

NagyDonat wrote:

Before this PR, the registration functions of the (real) checker parts actually 
tested the presence of the checker option 
`nullability.NullabilityBase:NoDiagnoseCallsToSystemHeaders`, where  
`nullability.NullabilityBase` was the hidden dummy checker part that was added 
as a prerequisite of all the "real" checker parts. (Note that -- ironically -- 
`registerNullabilityBase()` did _not_ check for the presence of this option 
which was nominally attached to it.)

This was working because in the checker option handling code specifying an 
option on the group level (e.g. saying 
`nullability:NoDiagnoseCallsToSystemHeaders=true`) is roughly equivalent to 
passing it to every checker within the group.

In commit 
https://github.com/llvm/llvm-project/pull/132250/commits/d490c74ea866107be4131bd6e694166e702ed8aa
 I'm turning this option into a "real" group-level option by passing the group 
name to `getCheckerBooleanOption`.

---

By the way the name of this option is really ugly --  it should be 
`DiagnoseCallsToSystemHeaders` with negated meaning -- but that's a problem for 
another commit.

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


[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-20 Thread Jesse Huang via cfe-commits

https://github.com/jaidTw updated 
https://github.com/llvm/llvm-project/pull/132259

>From e147dd68477b7e5ec9e6363a45fd7568fe595b04 Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Thu, 20 Mar 2025 10:34:14 -0700
Subject: [PATCH 1/2] [RISCV] Implement the implications of C extension

---
 .../CodeGen/RISCV/riscv-func-attr-target.c|  4 +--
 clang/test/CodeGen/attr-target-clones-riscv.c |  2 +-
 .../test/CodeGen/attr-target-version-riscv.c  |  2 +-
 .../CodeGenCXX/attr-target-clones-riscv.cpp   |  2 +-
 .../CodeGenCXX/attr-target-version-riscv.cpp  |  2 +-
 llvm/lib/Target/RISCV/RISCVFeatures.td| 16 +--
 llvm/lib/TargetParser/RISCVISAInfo.cpp| 13 +
 llvm/test/CodeGen/RISCV/attributes.ll | 28 ---
 llvm/test/MC/RISCV/attribute-arch.s   | 12 
 llvm/test/MC/RISCV/attribute.s|  2 +-
 llvm/test/MC/RISCV/option-arch.s  | 12 
 .../TargetParser/RISCVISAInfoTest.cpp | 19 +
 12 files changed, 71 insertions(+), 43 deletions(-)

diff --git a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c 
b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
index cd83876ec5f90..c5189d6aab28f 100644
--- a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
+++ b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
@@ -85,11 +85,11 @@ int test_vsetvlmax_e64m1() {
 // CHECK: attributes #2 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zifencei,+zmmul,-relax,-zfa"
 }
 // CHECK: attributes #3 = { 
{{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zaamo,+zalrsc,+zbb,+zicond,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zfa"
 }
 // Make sure we append negative features if we override the arch
-// CHECK: attributes #4 = { 
{{.*}}"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
+// CHECK: attributes #4 = { 
{{.*}}"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zca,+zcd,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
 // CHECK: attributes #5 = { 
{{.*}}"target-features"="+64bit,+m,+save-restore,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
 // CHECK: attributes #6 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zifencei,+zmmul,-relax,-zfa"
 }
 // CHECK: attributes #7 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+m,+save-restore,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
-// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
+// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zca,+zcd,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
 // CHECK: attributes #9 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32x,+zvl32b,-relax,-zbb,-zfa"
 }
 // CHECK: attributes #11 = { 
{{.*}}"target-features"="+64bit,+a,+f,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zvl32b,-relax,-zbb,-zfa"
 }
 // CHECK: attributes #12 = { 
{{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl32b,+zvl64b,-relax,-zbb,-zfa"
 }
diff --git a/clang/test/CodeGen/attr-target-clones-riscv.c 
b/clang/test/CodeGen/attr-target-clones-riscv.c
index 2e8018c707d96..642302ba9d229 100644
--- a/clang/test/CodeGen/attr-target-clones-riscv.c
+++ b/clang/test/CodeGen/attr-target-clones-riscv.c
@@ -370,7 +370,7 @@ int bar() { return foo1() + foo2() + foo3() + foo4() + 
foo5() + foo6() + foo7()
 // CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+i" }
 // CHECK: attributes #[[ATTR1]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+i,+m,+zmmul" }
 // CHECK: attributes #[[ATTR2]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+i,+zbb" }
-// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+c,+i,+zbb" }
+// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+c,+i,+zbb,+zca" }
 // CHECK: attributes #[[ATTR4]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+d,+f,+i,+v,+zbb,+zicsr,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b"
 }
 // CHECK: attributes

[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-20 Thread Craig Topper via cfe-commits


@@ -25,8 +25,8 @@ addi a0, a1, 0
 # CHECK: # encoding:  [0xe0,0x1f]
 addi s0, sp, 1020
 
-# CHECK: .option arch, -c
-.option arch, -c
+# CHECK: .option arch, -c, -zca
+.option arch, -c, -zca

topperc wrote:

Does just `.opt arch, -zca` work?

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


[clang] [llvm] [LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. (PR #130973)

2025-03-20 Thread Paul Walker via cfe-commits


@@ -473,6 +473,14 @@ std::optional Attribute::getVScaleRangeMax() 
const {
   return unpackVScaleRangeArgs(pImpl->getValueAsInt()).second;
 }
 
+unsigned Attribute::getVScaleValue() const {
+  std::optional VScale = getVScaleRangeMax();
+  if (VScale && *VScale == getVScaleRangeMin())
+return *VScale;
+
+  return 0;
+}

paulwalker-arm wrote:

Done.

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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

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


@@ -491,7 +503,7 @@ void NullabilityChecker::reportBugIfInvariantHolds(
 N = C.addTransition(OriginalState, N);
   }
 
-  reportBug(Msg, Error, CK, N, Region, C.getBugReporter(), ValueExpr);
+  reportBug(Msg, Error, Idx, N, Region, C.getBugReporter(), ValueExpr);

NagyDonat wrote:

> This feels like a technical difficulty. You could create a `bug(checker)` 
> member fn that gives you the right BugType.

The repeated code fragment is already very short: using bug types instead of 
indices means that I need to write `BugTypes[LongAndConvolutedNameChecker]` 
instead of plain `LongAndConvolutedNameChecker`. Introducing a method as you 
suggested wouldn't be a significant improvement 
`bug(LongAndConvolutedNameChecker)` is approximately the same as the array 
indexing.

Overall, I'm very close to indifferent in this question -- the stakes are 
negligible.

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


[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-20 Thread Jesse Huang via cfe-commits


@@ -25,8 +25,8 @@ addi a0, a1, 0
 # CHECK: # encoding:  [0xe0,0x1f]
 addi s0, sp, 1020
 
-# CHECK: .option arch, -c
-.option arch, -c
+# CHECK: .option arch, -c, -zca
+.option arch, -c, -zca

jaidTw wrote:

I tried but failed, seems like both are required

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


[clang] [llvm] Hlsl asint16 intrinsic (PR #131900)

2025-03-20 Thread Ashley Coleman via cfe-commits

https://github.com/V-FEXrt approved this pull request.


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


[clang] [llvm] [HLSL] Buffer handle globals should not be constants (PR #130231)

2025-03-20 Thread Justin Bogner via cfe-commits

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Andy Kaylor (andykaylor)


Changes

This change adds support for empty for-loops. This will be the infrastructre 
needed for complete for loops, but that depends on compare operations, which 
have not been upstreamed yet.

---

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


21 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h (+19) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRDialect.h (+1) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+162-2) 
- (added) clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.h (+34) 
- (added) clang/include/clang/CIR/Interfaces/CIRLoopOpInterface.td (+99) 
- (modified) clang/include/clang/CIR/Interfaces/CMakeLists.txt (+1) 
- (modified) clang/include/clang/CIR/MissingFeatures.h (+19-7) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExpr.cpp (+19) 
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+10) 
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.h (+15) 
- (modified) clang/lib/CIR/CodeGen/CIRGenStmt.cpp (+108-1) 
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+78) 
- (modified) clang/lib/CIR/Dialect/IR/CMakeLists.txt (+2) 
- (modified) clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp (+1-2) 
- (modified) clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp (+111-2) 
- (added) clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp (+63) 
- (modified) clang/lib/CIR/Interfaces/CMakeLists.txt (+2) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+17) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+10) 
- (added) clang/test/CIR/CodeGen/loop.cpp (+46) 
- (added) clang/test/CIR/Transforms/loop.cir (+29) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 32d1af677c62b..c6aea10d46b63 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -52,6 +52,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return cir::BoolAttr::get(getContext(), getBoolTy(), state);
   }
 
+  /// Create a for operation.
+  cir::ForOp createFor(
+  mlir::Location loc,
+  llvm::function_ref condBuilder,
+  llvm::function_ref bodyBuilder,
+  llvm::function_ref stepBuilder) 
{
+return create(loc, condBuilder, bodyBuilder, stepBuilder);
+  }
+
   mlir::TypedAttr getConstPtrAttr(mlir::Type type, int64_t value) {
 auto valueAttr = mlir::IntegerAttr::get(
 mlir::IntegerType::get(type.getContext(), 64), value);
@@ -158,6 +167,16 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 64),
   size.getQuantity());
   }
+
+  /// Create a loop condition.
+  cir::ConditionOp createCondition(mlir::Value condition) {
+return create(condition.getLoc(), condition);
+  }
+
+  /// Create a yield operation.
+  cir::YieldOp createYield(mlir::Location loc, mlir::ValueRange value = {}) {
+return create(loc, value);
+  }
 };
 
 } // namespace cir
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h 
b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
index 0684cf5034f5d..da3b41371b9ab 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h
@@ -29,6 +29,7 @@
 #include "clang/CIR/Dialect/IR/CIRAttrs.h"
 #include "clang/CIR/Dialect/IR/CIROpsDialect.h.inc"
 #include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+#include "clang/CIR/Interfaces/CIRLoopOpInterface.h"
 #include "clang/CIR/Interfaces/CIROpInterfaces.h"
 
 // TableGen'erated files for MLIR dialects require that a macro be defined when
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 352d72ff31a8a..d7d63e040a2ba 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -19,6 +19,7 @@ include "clang/CIR/Dialect/IR/CIRTypes.td"
 include "clang/CIR/Dialect/IR/CIRAttrs.td"
 
 include "clang/CIR/Interfaces/CIROpInterfaces.td"
+include "clang/CIR/Interfaces/CIRLoopOpInterface.td"
 
 include "mlir/IR/BuiltinAttributeInterfaces.td"
 include "mlir/IR/EnumAttr.td"
@@ -423,7 +424,7 @@ def StoreOp : CIR_Op<"store", [
 // ReturnOp
 
//===--===//
 
-def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp"]>,
+def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "ForOp"]>,
  Terminator]> {
   let summary = "Return from function";
   let description = [{
@@ -460,12 +461,57 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", 
"ScopeOp"]>,
   let hasVerifier = 1;
 }
 
+//===--===//
+/

[clang] [llvm] Hlsl asint16 intrinsic (PR #131900)

2025-03-20 Thread Farzon Lotfi via cfe-commits


@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple 
dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -O1 -o - | 
FileCheck %s
+
+// CHECK: define {{.*}}test_ints{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+// CHECK-NOT: bitcast
+// CHECK: ret i16 [[VAL]]
+int16_t test_int(int16_t p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_uint{{.*}}(i16 {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret i16 [[VAL]]
+int16_t test_uint(uint16_t p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_half{{.*}}(half {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast half [[VAL]] to i16
+//CHECK : ret i16 [[RES]]
+int16_t test_half(half p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_int{{.*}}(<4 x i16> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+int16_t4 test_vector_int(int16_t4 p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}test_vector_uint{{.*}}(<4 x i16> {{.*}} 
[[VAL:%.*]]){{.*}}
+//CHECK-NOT: bitcast
+//CHECK: ret <4 x i16> [[VAL]]
+int16_t4 test_vector_uint(uint16_t4 p0)
+{
+return asint16(p0);
+}
+
+//CHECK: define {{.*}}fn{{.*}}(<4 x half> {{.*}} [[VAL:%.*]]){{.*}}
+//CHECK: [[RES:%.*]] = bitcast <4 x half> [[VAL]] to <4 x i16>
+//CHECK: ret <4 x i16> [[RES]]

farzonl wrote:

could all the cases where we are doing a bitcast and then returning Res become 
`CHECK-NEXT` cases? Maybe atleast for the return checks?

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


[clang] [CIR] Fix unary op folding (PR #132269)

2025-03-20 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor created 
https://github.com/llvm/llvm-project/pull/132269

Unary ops had previously been omitted from the list of ops handled in the 
CIRCanonicalizePass. Although the incubator code doesn't use them directly, the 
mlir folding code does.

This change enables folding of unary ops by adding them to the list.

>From bee4e73e125c5643eb321ffef7b2b8e25f881267 Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Thu, 20 Mar 2025 11:23:02 -0700
Subject: [PATCH] [CIR] Fix unary op folding

Unary ops had previously been omitted from the list of ops handled in the
CIRCanonicalizePass. Although the incubator code doesn't use them directly,
the mlir folding code does.

This change enables folding of unary ops by adding them to the list.
---
 clang/include/clang/CIR/MissingFeatures.h| 1 -
 clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp | 7 +++
 clang/test/CIR/Transforms/canonicalize.cir   | 8 
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index d276af5686995..46780775dd4bd 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -110,7 +110,6 @@ struct MissingFeatures {
   static bool brCondOp() { return false; }
   static bool switchOp() { return false; }
   static bool tryOp() { return false; }
-  static bool unaryOp() { return false; }
   static bool selectOp() { return false; }
   static bool complexCreateOp() { return false; }
   static bool complexRealOp() { return false; }
diff --git a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp 
b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
index d32691dba1473..6cbaf26a0bf33 100644
--- a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
@@ -121,15 +121,14 @@ void CIRCanonicalizePass::runOnOperation() {
 assert(!cir::MissingFeatures::brCondOp());
 assert(!cir::MissingFeatures::switchOp());
 assert(!cir::MissingFeatures::tryOp());
-assert(!cir::MissingFeatures::unaryOp());
 assert(!cir::MissingFeatures::selectOp());
 assert(!cir::MissingFeatures::complexCreateOp());
 assert(!cir::MissingFeatures::complexRealOp());
 assert(!cir::MissingFeatures::complexImagOp());
 assert(!cir::MissingFeatures::callOp());
-// CastOp here is to perform a manual `fold` in
-// applyOpPatternsGreedily
-if (isa(op))
+// CastOp and UnaryOp are here to perform a manual `fold` in
+// applyOpPatternsGreedily.
+if (isa(op))
   ops.push_back(op);
   });
 
diff --git a/clang/test/CIR/Transforms/canonicalize.cir 
b/clang/test/CIR/Transforms/canonicalize.cir
index d61991aef6f01..c0c32627a1096 100644
--- a/clang/test/CIR/Transforms/canonicalize.cir
+++ b/clang/test/CIR/Transforms/canonicalize.cir
@@ -31,6 +31,14 @@ module {
   // CHECK-NEXT:   cir.return
   // CHECK-NEXT: }
 
+  cir.func @unary_not(%arg0: !cir.bool) -> !cir.bool {
+%0 = cir.unary(not, %arg0) : !cir.bool, !cir.bool
+%1 = cir.unary(not, %0) : !cir.bool, !cir.bool
+cir.return %1 : !cir.bool
+  }
+  // CHECK:  cir.func @unary_not(%arg0: !cir.bool) -> !cir.bool
+  // CHECK: cir.return %arg0 : !cir.bool
+
   cir.func @cast1(%arg0: !cir.bool) -> !cir.bool {
 %0 = cir.cast(bool_to_int, %arg0 : !cir.bool), !s32i
 %1 = cir.cast(int_to_bool, %0 : !s32i), !cir.bool

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


[clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132234)

2025-03-20 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang][ExprConst] Check record base classes for valid structs (PR #132270)

2025-03-20 Thread Erich Keane via cfe-commits

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

I think this looks fine.  

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


[clang] [CIR] Fix unary op folding (PR #132269)

2025-03-20 Thread Andy Kaylor via cfe-commits

andykaylor wrote:

@mmha This fixes the problem you noticed earlier.

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


[clang] [clang][ExprConst] Check record base classes for valid structs (PR #132270)

2025-03-20 Thread Erich Keane via cfe-commits


@@ -7385,8 +7385,13 @@ class APValueToBufferConverter {
   for (size_t I = 0, E = CXXRD->getNumBases(); I != E; ++I) {
 const CXXBaseSpecifier &BS = CXXRD->bases_begin()[I];
 CXXRecordDecl *BaseDecl = BS.getType()->getAsCXXRecordDecl();
+const APValue &Base = Val.getStructBase(I);
 
-if (!visitRecord(Val.getStructBase(I), BS.getType(),
+// Can happen in error cases.
+if (!Base.isStruct())

erichkeane wrote:

Curious what `Base` ends up being here?  Are we putting a NULL in here or 
something?

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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-20 Thread Alexander Richardson via cfe-commits

arichardson wrote:

This makes a lot of sense to me, just wondering why you chose 
`clang/lib/CodeGen/BuiltinTargets/` rather than 
`clang/lib/CodeGen/TargetBuiltins/`? The former shounds like it contains the 
list of all builtin targets, rather than the codegen for target-specific 
builtins.

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


[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-03-20 Thread Ziqing Luo via cfe-commits


@@ -436,9 +436,9 @@ class StdLibraryFunctionsChecker
llvm::raw_ostream &Out) const override;
 
 ValueConstraintPtr negate() const override {
-  NotNullBufferConstraint Tmp(*this);
+  BufferNullnessConstraint Tmp(*this);
   Tmp.CannotBeNull = !this->CannotBeNull;

ziqingluo-90 wrote:

Oh, I somehow thought the checker passes a pre-condition `C` only when 
`State->assume(C) && !State->assume(!C))` but the reality is it reports a 
violation only when `State->assume(!C) && !State->assume(C)`.

Yes, you are right. This is fine.   

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Andy Kaylor via cfe-commits


@@ -165,6 +165,25 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr 
*e) {
   return LValue();
 }
 
+mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *e) {

andykaylor wrote:

Even for C, we want to generate a cir.bool value. The classic codegen does the 
equivalent, generating IR that produces an `i1` value. For example: 
https://godbolt.org/z/3KjonvqK1

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Andy Kaylor via cfe-commits


@@ -52,6 +52,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return cir::BoolAttr::get(getContext(), getBoolTy(), state);
   }
 
+  /// Create a for operation.
+  cir::ForOp createFor(
+  mlir::Location loc,
+  llvm::function_ref condBuilder,

andykaylor wrote:

That's an excellent question. The incubator (and this PR) emits the 
initialization in front of the `for` op, but it does seem like it is something 
we would want more tightly associated with the `for` in the emitted CIR.

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Erich Keane via cfe-commits


@@ -280,3 +313,77 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const 
ReturnStmt &s) {
 
   return mlir::success();
 }
+
+mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
+  cir::ForOp forOp;
+
+  // TODO: pass in an array of attributes.
+  auto forStmtBuilder = [&]() -> mlir::LogicalResult {
+mlir::LogicalResult loopRes = mlir::success();
+// Evaluate the first part before the loop.
+if (s.getInit())
+  if (emitStmt(s.getInit(), /*useCurrentScope=*/true).failed())
+return mlir::failure();
+assert(!cir::MissingFeatures::loopInfoStack());
+// In the classic codegen, if there are any cleanups between here and the
+// loop-exit scope, a block is created to stage the loop exit. We probably
+// already do the right thing because of ScopeOp, but we need more testing
+// to be sure we handle all cases.
+assert(!cir::MissingFeatures::requiresCleanups());
+
+forOp = builder.createFor(
+getLoc(s.getSourceRange()),
+/*condBuilder=*/
+[&](mlir::OpBuilder &b, mlir::Location loc) {
+  assert(!cir::MissingFeatures::createProfileWeightsForLoop());
+  
assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
+  mlir::Value condVal;
+  if (s.getCond()) {
+// If the for statement has a condition scope,
+// emit the local variable declaration.
+if (s.getConditionVariable())
+  emitDecl(*s.getConditionVariable());
+// C99 6.8.5p2/p4: The first substatement is executed if the
+// expression compares unequal to 0. The condition must be a
+// scalar type.
+condVal = evaluateExprAsBool(s.getCond());

erichkeane wrote:

I'm surprised to see this unconditionally, this should come pre-casted in C++.

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Erich Keane via cfe-commits


@@ -165,6 +165,25 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr 
*e) {
   return LValue();
 }
 
+mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *e) {

erichkeane wrote:

Ah, I see.  So even 8-bit 'bool' type is getting converted.  It is a touch 
confusing to use `Bool` as the name for the CIR type representing an `i1`, and 
clang for `i8`, but Cest La Vie.

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


[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Erich Keane via cfe-commits


@@ -280,3 +313,77 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const 
ReturnStmt &s) {
 
   return mlir::success();
 }
+
+mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
+  cir::ForOp forOp;
+
+  // TODO: pass in an array of attributes.
+  auto forStmtBuilder = [&]() -> mlir::LogicalResult {
+mlir::LogicalResult loopRes = mlir::success();
+// Evaluate the first part before the loop.
+if (s.getInit())

erichkeane wrote:

Oh interesting... hrmph.  This is supposed to be in scope with the for IIRC, do 
we need to create a lexical scope here?

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


[clang] [Driver] Haiku address sanitizer support (PR #132335)

2025-03-20 Thread Brad Smith via cfe-commits

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


[clang] [Driver] Haiku address sanitizer support (PR #132335)

2025-03-20 Thread David CARLIER via cfe-commits

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


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


[clang] [Driver] Haiku address sanitizer support (PR #132335)

2025-03-20 Thread David CARLIER via cfe-commits


@@ -281,3 +286,11 @@ void Haiku::addLibCxxIncludePaths(const llvm::opt::ArgList 
&DriverArgs,
 Tool *Haiku::buildLinker() const { return new tools::haiku::Linker(*this); }
 
 bool Haiku::HasNativeLLVMSupport() const { return true; }
+
+SanitizerMask Haiku::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+
+  Res |= SanitizerKind::Address;

devnexen wrote:

ah alright then..

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


[clang] [clang-tools-extra] Reland: [clang] NFC: Clear some uses of MemberPointerType::getClass (PR #132317)

2025-03-20 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/132317

Relands Original PR: https://github.com/llvm/llvm-project/pull/131965
Addresses 
https://github.com/llvm/llvm-project/pull/131965#issuecomment-2741619498
* Fixes isIncompleteType for injected classes

This clears up some uses of getClass on MemberPointerType when
equivalent uses of getMostRecentCXXRecordDecl would be just as
simple or simpler.

This is split-off from a larger patch which removes getClass,
in order to facilitate review.

>From 52fe0380be295619f3c914e0ad4233d66dd7f361 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Tue, 18 Mar 2025 19:44:23 -0300
Subject: [PATCH 1/2] Reland: [clang] NFC: Clear some uses of
 MemberPointerType::getClass

Original PR: https://github.com/llvm/llvm-project/pull/131965
Addresses 
https://github.com/llvm/llvm-project/pull/131965#issuecomment-2741619498
* Fixes isIncompleteType for injected classes

This clears up some uses of getClass on MemberPointerType when
equivalent uses of getMostRecentCXXRecordDecl would be just as
simple or simpler.

This is split-off from a larger patch which removes getClass,
in order to facilitate review.
---
 ...arePointerToMemberVirtualFunctionCheck.cpp |  5 +-
 .../clang-tidy/utils/ExceptionAnalyzer.cpp|  4 +-
 clang/include/clang/AST/CanonicalType.h   |  2 +
 clang/include/clang/Sema/Sema.h   |  7 +--
 clang/lib/AST/ByteCode/Compiler.cpp   | 10 ++--
 clang/lib/AST/ExprConstant.cpp|  5 +-
 clang/lib/AST/MicrosoftMangle.cpp | 10 ++--
 clang/lib/AST/Type.cpp| 20 
 clang/lib/CodeGen/CGCXXABI.cpp|  5 +-
 clang/lib/CodeGen/CGClass.cpp |  7 ++-
 clang/lib/CodeGen/CGDebugInfo.cpp |  3 +-
 clang/lib/CodeGen/CGExprCXX.cpp   |  8 ++--
 clang/lib/CodeGen/CodeGenTypes.cpp|  2 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 11 +++--
 clang/lib/Sema/SemaDeclCXX.cpp| 48 +--
 clang/lib/Sema/SemaExprCXX.cpp| 32 +++--
 clang/lib/Sema/SemaLookup.cpp |  7 +--
 clang/lib/Sema/SemaOverload.cpp   | 37 +++---
 clang/lib/Sema/SemaStmt.cpp   |  3 +-
 19 files changed, 114 insertions(+), 112 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
 
b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
index 9d1d92b989bf1..a8a9e6bdcdff8 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
@@ -70,10 +70,7 @@ void ComparePointerToMemberVirtualFunctionCheck::check(
   // compare with variable which type is pointer to member function.
   llvm::SmallVector SameSignatureVirtualMethods{};
   const auto *MPT = cast(DRE->getType().getCanonicalType());
-  const Type *T = MPT->getClass();
-  if (T == nullptr)
-return;
-  const CXXRecordDecl *RD = T->getAsCXXRecordDecl();
+  const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
   if (RD == nullptr)
 return;
 
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 0fea7946a59f9..b66cc8512fad6 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -219,8 +219,8 @@ bool isQualificationConvertiblePointer(QualType From, 
QualType To,
 
 if (P1->isMemberPointerType())
   return P2->isMemberPointerType() &&
- P1->getAs()->getClass() ==
- P2->getAs()->getClass();
+ P1->getAs()->getMostRecentCXXRecordDecl() ==
+ P2->getAs()->getMostRecentCXXRecordDecl();
 
 if (P1->isConstantArrayType())
   return P2->isConstantArrayType() &&
diff --git a/clang/include/clang/AST/CanonicalType.h 
b/clang/include/clang/AST/CanonicalType.h
index 6699284d215bd..50d1ba1b8f63f 100644
--- a/clang/include/clang/AST/CanonicalType.h
+++ b/clang/include/clang/AST/CanonicalType.h
@@ -454,6 +454,8 @@ struct CanProxyAdaptor
   : public CanProxyBase {
   LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Type *, getClass)
+  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const CXXRecordDecl *,
+  getMostRecentCXXRecordDecl)
 };
 
 // CanProxyAdaptors for arrays are intentionally unimplemented because
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0befe615c4ee1..9724f0def743a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5769,10 +5769,11 @@ class Sema final : public SemaBase {
 
   /// Determine whether the type \p Derived is a C++ class that is
   /// derived from the type \p Base.
+  bool I

[clang] [Driver] Haiku address sanitizer support (PR #132335)

2025-03-20 Thread Brad Smith via cfe-commits


@@ -281,3 +286,11 @@ void Haiku::addLibCxxIncludePaths(const llvm::opt::ArgList 
&DriverArgs,
 Tool *Haiku::buildLinker() const { return new tools::haiku::Linker(*this); }
 
 bool Haiku::HasNativeLLVMSupport() const { return true; }
+
+SanitizerMask Haiku::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+
+  Res |= SanitizerKind::Address;

brad0 wrote:

There is a patch set in the haikuports recipe I am going to upstream.

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


  1   2   3   4   >