[clang] [analyzer] Harden security.cert.env.InvalidPtr checker fn matching (PR #88536)

2024-04-16 Thread Balazs Benics via cfe-commits


@@ -205,8 +210,12 @@ void InvalidPtrChecker::postPreviousReturnInvalidatingCall(
   CE, LCtx, CE->getType(), C.blockCount());
   State = State->BindExpr(CE, LCtx, RetVal);
 
+  const auto *SymRegOfRetVal =
+  dyn_cast_or_null(RetVal.getAsRegion());
+  if (!SymRegOfRetVal)
+return;
+
   // Remember to this region.
-  const auto *SymRegOfRetVal = cast(RetVal.getAsRegion());
   const MemRegion *MR = SymRegOfRetVal->getBaseRegion();

steakhal wrote:

Thanks!, I'll split it up.

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang] [llvm] [RISCV] Add generic CPUs for profiles (PR #84877)

2024-04-16 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

Ping.

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


[clang] [llvm] [RISCV] Add generic CPUs for profiles (PR #84877)

2024-04-16 Thread Pengcheng Wang via cfe-commits

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

>From ec68548a470d6d9032a900a725e95b92691657b2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Tue, 12 Mar 2024 14:28:09 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/test/Driver/riscv-cpus.c| 319 ++
 clang/test/Misc/target-invalid-cpu-note.c |   8 +-
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 224 ++-
 3 files changed, 539 insertions(+), 12 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba34..a285f0f9c41f54 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -302,3 +302,322 @@
 
 // RUN: not %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
 // MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
+
+// Check profile CPUs
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rvi20u32 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U32 %s
+// MCPU-GENERIC-RVI20U32: "-target-cpu" "generic-rvi20u32"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-abi" "ilp32"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rvi20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U64 %s
+// MCPU-GENERIC-RVI20U64: "-target-cpu" "generic-rvi20u64"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U64-SAME: "-target-abi" "lp64"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20U64 %s
+// MCPU-GENERIC-RVA20U64: "-target-cpu" "generic-rva20u64"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20U64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20s64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20S64 %s
+// MCPU-GENERIC-RVA20S64: "-target-cpu" "generic-rva20s64"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zifencei"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ssccptr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvala"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvecd"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svade"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svbare"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva22u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA22U64 %s
+// MCPU-GENERIC-RVA22U64: "-target-cpu" "generic-rva22u64"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zic64b"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbom"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbop"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" 

[clang] [llvm] [SPIRV][HLSL] map lerp to Fmix (PR #88976)

2024-04-16 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl updated 
https://github.com/llvm/llvm-project/pull/88976

>From 6d5a126dd2d6c88ab61549a2ac8f5879642393e5 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Tue, 16 Apr 2024 15:28:25 -0400
Subject: [PATCH 1/2] [SPIRV][HLSL] map lerp to Fmix

---
 clang/lib/CodeGen/CGBuiltin.cpp   |  4 +-
 clang/lib/CodeGen/CGHLSLRuntime.h |  1 +
 clang/test/CodeGenHLSL/builtins/lerp.hlsl | 96 ---
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  2 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp | 26 +
 .../CodeGen/SPIRV/hlsl-intrinsics/lerp.ll | 56 +++
 6 files changed, 147 insertions(+), 38 deletions(-)
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/lerp.ll

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9f95697f284c40..c7f63f71fbfcf7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18256,8 +18256,8 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 if (!E->getArg(0)->getType()->hasFloatingRepresentation())
   llvm_unreachable("lerp operand must have a float representation");
 return Builder.CreateIntrinsic(
-/*ReturnType=*/X->getType(), Intrinsic::dx_lerp,
-ArrayRef{X, Y, S}, nullptr, "dx.lerp");
+/*ReturnType=*/X->getType(), CGM.getHLSLRuntime().getLerpIntrinsic(),
+ArrayRef{X, Y, S}, nullptr, "hlsl.lerp");
   }
   case Builtin::BI__builtin_hlsl_elementwise_frac: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 506b364f5b2ec7..0abe39dedcb96f 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -74,6 +74,7 @@ class CGHLSLRuntime {
 
   GENERATE_HLSL_INTRINSIC_FUNCTION(All, all)
   GENERATE_HLSL_INTRINSIC_FUNCTION(Any, any)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(Lerp, lerp)
   GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
 
   
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/lerp.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
index 49cd04a10115ae..634b20be3a28d6 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
@@ -1,69 +1,92 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF
+// RUN:   --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
+// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
 
 
-// NATIVE_HALF: %dx.lerp = call half @llvm.dx.lerp.f16(half %0, half %1, half 
%2)
-// NATIVE_HALF: ret half %dx.lerp
-// NO_HALF: %dx.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, float 
%2)
-// NO_HALF: ret float %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call half @llvm.dx.lerp.f16(half %0, half 
%1, half %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call half @llvm.spv.lerp.f16(half %0, half 
%1, half %2)
+// NATIVE_HALF: ret half %hlsl.lerp
+// DXIL_NO_HALF: %hlsl.lerp = call float @llvm.dx.lerp.f32(float %0, float %1, 
float %2)
+// SPIR_NO_HALF: %hlsl.lerp = call float @llvm.spv.lerp.f32(float %0, float 
%1, float %2)
+// NO_HALF: ret float %hlsl.lerp
 half test_lerp_half(half p0) { return lerp(p0, p0, p0); }
 
-// NATIVE_HALF: %dx.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x half> %0, 
<2 x half> %1, <2 x half> %2)
-// NATIVE_HALF: ret <2 x half> %dx.lerp
-// NO_HALF: %dx.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> %0, <2 
x float> %1, <2 x float> %2)
-// NO_HALF: ret <2 x float> %dx.lerp
+// DXIL_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.dx.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// SPIR_NATIVE_HALF: %hlsl.lerp = call <2 x half> @llvm.spv.lerp.v2f16(<2 x 
half> %0, <2 x half> %1, <2 x half> %2)
+// NATIVE_HALF: ret <2 x half> %hlsl.lerp
+// DXIL_NO_HALF: %hlsl.lerp = call <2 x float> @llvm.dx.lerp.v2f32(<2 x float> 
%0, <2 x float> %1, <2 x float> %2)
+// SPIR_NO_HALF: %hlsl.lerp = call <2 x float> @llvm.spv.lerp.v2f32(<2 x 
float> %0, <2 x float> %1, <2 x float> 

[clang] [clang] Distinguish unresolved templates in UnresolvedLookupExpr (PR #89019)

2024-04-16 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/89019

None

>From e510a76d231de0e22ba52584a80f18deb6af91c6 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 17 Apr 2024 12:24:56 +0800
Subject: [PATCH] [clang] Distinguish unresolved templates in
 UnresolvedLookupExpr

---
 clang/include/clang/AST/ASTContext.h  |  3 +-
 clang/include/clang/AST/BuiltinTypes.def  |  2 +
 .../include/clang/Serialization/ASTBitCodes.h |  4 +-
 clang/lib/AST/ASTContext.cpp  |  3 +
 clang/lib/AST/NSAPI.cpp   |  1 +
 clang/lib/AST/Type.cpp|  3 +
 clang/lib/AST/TypeLoc.cpp |  1 +
 clang/lib/Sema/SemaExpr.cpp   | 19 +
 clang/lib/Sema/SemaTemplate.cpp   | 11 ++-
 clang/lib/Serialization/ASTCommon.cpp |  3 +
 clang/lib/Serialization/ASTReader.cpp |  3 +
 clang/test/SemaCXX/PR62533.cpp|  2 +-
 clang/test/SemaTemplate/template-id-expr.cpp  | 71 +++
 13 files changed, 120 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 28f8d67811f0a2..e9a22f04cfe764 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1116,7 +1116,8 @@ class ASTContext : public RefCountedBase {
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
   CanQualType VoidPtrTy, NullPtrTy;
-  CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy;
+  CanQualType DependentTy, OverloadTy, BoundMemberTy, UnresolvedTemplateTy,
+  UnknownAnyTy;
   CanQualType BuiltinFnTy;
   CanQualType PseudoObjectTy, ARCUnbridgedCastTy;
   CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy;
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f127191..eb72bf0f866247 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -285,6 +285,8 @@ PLACEHOLDER_TYPE(Overload, OverloadTy)
 //   x->foo   # if only contains non-static members
 PLACEHOLDER_TYPE(BoundMember, BoundMemberTy)
 
+PLACEHOLDER_TYPE(UnresolvedTemplate, UnresolvedTemplateTy)
+
 // The type of an expression which refers to a pseudo-object,
 // such as those introduced by Objective C's @property or
 // VS.NET's __property declarations.  A placeholder type.  The
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 500098dd3dab1d..a0feb3a317611e 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1099,6 +1099,8 @@ enum PredefinedTypeIDs {
 // \brief WebAssembly reference types with auto numeration
 #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
+
+  PREDEF_TYPE_UNRESOLVED_TEMPLATE,
   // Sentinel value. Considered a predefined type but not useable as one.
   PREDEF_TYPE_LAST_ID
 };
@@ -1108,7 +1110,7 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 502;
+const unsigned NUM_PREDEF_TYPE_IDS = 503;
 
 // Ensure we do not overrun the predefined types we reserved
 // in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 6ce233704a5885..e9fba116cff559 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1306,6 +1306,9 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
,
   // Placeholder type for bound members.
   InitBuiltinType(BoundMemberTy,   BuiltinType::BoundMember);
 
+  // Placeholder type for unresolved templates.
+  InitBuiltinType(UnresolvedTemplateTy, BuiltinType::UnresolvedTemplate);
+
   // Placeholder type for pseudo-objects.
   InitBuiltinType(PseudoObjectTy,  BuiltinType::PseudoObject);
 
diff --git a/clang/lib/AST/NSAPI.cpp b/clang/lib/AST/NSAPI.cpp
index ecc56c13fb7573..4e09b27b0f76cd 100644
--- a/clang/lib/AST/NSAPI.cpp
+++ b/clang/lib/AST/NSAPI.cpp
@@ -454,6 +454,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
   case BuiltinType::BoundMember:
+  case BuiltinType::UnresolvedTemplate:
   case BuiltinType::Dependent:
   case BuiltinType::Overload:
   case BuiltinType::UnknownAny:
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index cb22c91a12aa89..4751d73184262f 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3381,6 +3381,8 @@ StringRef BuiltinType::getName(const PrintingPolicy 
) const {
 return "";
   case BoundMember:
 return "";
+  case UnresolvedTemplate:
+return "";
   case PseudoObject:
 return "";
   case Dependent:
@@ -4673,6 +4675,7 @@ bool 

[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp approved this pull request.

LGTM.

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Craig Topper via cfe-commits

topperc wrote:

> Can you add it to RVA23 profile?
> 
> https://github.com/llvm/llvm-project/blob/f71e25bb669d662f98823d6d81b3f918538c9239/llvm/lib/Support/RISCVISAInfo.cpp#L250-L284

It's an optional extension so I don't think it should be in the RVA23 profile.

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

> Can you add it to RVA23 profile?
> 
> https://github.com/llvm/llvm-project/blob/f71e25bb669d662f98823d6d81b3f918538c9239/llvm/lib/Support/RISCVISAInfo.cpp#L250-L284

Never mind, it's an optional extension.

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

Can you add it to RVA23 profile?
https://github.com/llvm/llvm-project/blob/f71e25bb669d662f98823d6d81b3f918538c9239/llvm/lib/Support/RISCVISAInfo.cpp#L250-L284

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


[clang] [polly] [clang-format] Revert breaking stream operators to previous default (PR #89016)

2024-04-16 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 5964c944bfe74cee2872cddb66eff22866cdb6ee 
930f422681b3a4f248afc094d3af98952cd7d386 -- clang/lib/Format/TokenAnnotator.cpp 
clang/unittests/Format/FormatTest.cpp 
clang/unittests/Format/TokenAnnotatorTest.cpp 
polly/lib/Analysis/DependenceInfo.cpp polly/lib/Analysis/ScopBuilder.cpp
``





View the diff from clang-format here.


``diff
diff --git a/polly/lib/Analysis/DependenceInfo.cpp 
b/polly/lib/Analysis/DependenceInfo.cpp
index a530fa7b58..9ee004fbac 100644
--- a/polly/lib/Analysis/DependenceInfo.cpp
+++ b/polly/lib/Analysis/DependenceInfo.cpp
@@ -951,8 +951,8 @@ public:
   bool runOnScop(Scop ) override {
 DependenceInfo  = getAnalysis();
 
-OS << "Printing analysis '" << P.getPassName() << "' for "
-   << "region: '" << S.getRegion().getNameStr() << "' in function '"
+OS << "Printing analysis '" << P.getPassName() << "' for " << "region: '"
+   << S.getRegion().getNameStr() << "' in function '"
<< S.getFunction().getName() << "':\n";
 P.printScop(OS, S);
 
diff --git a/polly/lib/Analysis/ScopBuilder.cpp 
b/polly/lib/Analysis/ScopBuilder.cpp
index a34f293152..214e4d360d 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -2715,10 +2715,9 @@ void ScopBuilder::addUserContext() {
 if (NameContext != NameUserContext) {
   std::string SpaceStr = stringFromIslObj(Space, "null");
   errs() << "Error: the name of dimension " << i
- << " provided in -polly-context "
- << "is '" << NameUserContext << "', but the name in the computed "
- << "context is '" << NameContext
- << "'. Due to this name mismatch, "
+ << " provided in -polly-context " << "is '" << NameUserContext
+ << "', but the name in the computed " << "context is '"
+ << NameContext << "'. Due to this name mismatch, "
  << "the -polly-context option is ignored. Please provide "
  << "the context in the parameter space: " << SpaceStr << ".\n";
   return;

``




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


[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)

2024-04-16 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

> Please turn off [Keep my email addresses 
> private](https://github.com/settings/emails) setting in your account.

Done.

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


[clang] [polly] [clang-format] Revert breaking stream operators to previous default (PR #89016)

2024-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Reverts commit d68826dfbd98, which changes the previous default behavior of 
always breaking before a stream insertion operator `` if both operands 
are string literals.

Also reverts the related commits 27f547968cce and bf05be5b87fc.

See the discussion in #88483.

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


5 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+2-6) 
- (modified) clang/unittests/Format/FormatTest.cpp (+1-6) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (-9) 
- (modified) polly/lib/Analysis/DependenceInfo.cpp (+2-2) 
- (modified) polly/lib/Analysis/ScopBuilder.cpp (+4-3) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 628f70417866c3..80e5605fb5778d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5595,12 +5595,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
,
 return true;
   if (Left.IsUnterminatedLiteral)
 return true;
-  // FIXME: Breaking after newlines seems useful in general. Turn this into an
-  // option and recognize more cases like endl etc, and break independent of
-  // what comes after operator lessless.
-  if (Right.is(tok::lessless) && Right.Next &&
-  Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
-  Left.TokenText.ends_with("\\n\"")) {
+  if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
+  Right.Next->is(tok::string_literal)) {
 return true;
   }
   if (Right.is(TT_RequiresClause)) {
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 4906b3350b5b22..bc61b9c089e922 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27339,12 +27339,6 @@ TEST_F(FormatTest, 
PPDirectivesAndCommentsInBracedInit) {
getLLVMStyleWithColumns(30));
 }
 
-TEST_F(FormatTest, StreamOutputOperator) {
-  verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
-  verifyFormat("std::cout << \"foo\\n\"\n"
-   "  << \"bar\";");
-}
-
 TEST_F(FormatTest, BreakAdjacentStringLiterals) {
   constexpr StringRef Code{
   "return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
@@ -27359,6 +27353,7 @@ TEST_F(FormatTest, BreakAdjacentStringLiterals) {
   Style.BreakAdjacentStringLiterals = false;
   verifyFormat(Code, Style);
 }
+
 } // namespace
 } // namespace test
 } // namespace format
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index da02ced8c7a949..a71b6806476956 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2841,15 +2841,6 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_BRACE_KIND(Tokens[16], BK_BracedInit);
 }
 
-TEST_F(TokenAnnotatorTest, StreamOperator) {
-  auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
-  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
-  EXPECT_FALSE(Tokens[1]->MustBreakBefore);
-  EXPECT_FALSE(Tokens[3]->MustBreakBefore);
-  // Only break between string literals if the former ends with \n.
-  EXPECT_TRUE(Tokens[5]->MustBreakBefore);
-}
-
 TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {
   auto Tokens = annotate("auto foo() -> enum En {}");
   ASSERT_EQ(Tokens.size(), 10u) << Tokens;
diff --git a/polly/lib/Analysis/DependenceInfo.cpp 
b/polly/lib/Analysis/DependenceInfo.cpp
index 9ee004fbac9e53..a530fa7b58fa6e 100644
--- a/polly/lib/Analysis/DependenceInfo.cpp
+++ b/polly/lib/Analysis/DependenceInfo.cpp
@@ -951,8 +951,8 @@ class DependenceInfoPrinterLegacyPass final : public 
ScopPass {
   bool runOnScop(Scop ) override {
 DependenceInfo  = getAnalysis();
 
-OS << "Printing analysis '" << P.getPassName() << "' for " << "region: '"
-   << S.getRegion().getNameStr() << "' in function '"
+OS << "Printing analysis '" << P.getPassName() << "' for "
+   << "region: '" << S.getRegion().getNameStr() << "' in function '"
<< S.getFunction().getName() << "':\n";
 P.printScop(OS, S);
 
diff --git a/polly/lib/Analysis/ScopBuilder.cpp 
b/polly/lib/Analysis/ScopBuilder.cpp
index 214e4d360d6bbb..a34f2931527255 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -2715,9 +2715,10 @@ void ScopBuilder::addUserContext() {
 if (NameContext != NameUserContext) {
   std::string SpaceStr = stringFromIslObj(Space, "null");
   errs() << "Error: the name of dimension " << i
- << " provided in -polly-context " << "is '" << NameUserContext
- << "', but the name in the computed " << "context is '"
- << NameContext << "'. Due to this name mismatch, "
+ << " provided in -polly-context "
+ << "is '" << NameUserContext << 

[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Andrey Ali Khan Bolshakov via cfe-commits

https://github.com/bolshakov-a updated 
https://github.com/llvm/llvm-project/pull/1

>From a025b2a45c2a66595c111262dd43c0890f0d54b6 Mon Sep 17 00:00:00 2001
From: Bolshakov 
Date: Tue, 16 Apr 2024 14:21:40 +0300
Subject: [PATCH 1/2] [Coverage] Handle array decomposition correctly

`ArrayInitLoopExpr` AST node has two occurences of its as-written
initializing expression in its subexpressions through a non-unique
`OpaqueValueExpr`. It causes double-visiting of the initializing
expression if not handled explicitly, as discussed in #85837.
---
 clang/lib/CodeGen/CoverageMappingGen.cpp |  4 
 clang/test/CoverageMapping/decomposition.cpp | 15 +++
 2 files changed, 19 insertions(+)
 create mode 100644 clang/test/CoverageMapping/decomposition.cpp

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 71215da362d3d0..569fd489dc8baa 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -2171,6 +2171,10 @@ struct CounterCoverageMappingBuilder
 // propagate counts into them.
   }
 
+  void VisitArrayInitLoopExpr(const ArrayInitLoopExpr *AILE) {
+Visit(AILE->getCommonExpr()->getSourceExpr());
+  }
+
   void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
 // Just visit syntatic expression as this is what users actually write.
 VisitStmt(POE->getSyntacticForm());
diff --git a/clang/test/CoverageMapping/decomposition.cpp 
b/clang/test/CoverageMapping/decomposition.cpp
new file mode 100644
index 00..31bd6cae2c4dec
--- /dev/null
+++ b/clang/test/CoverageMapping/decomposition.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only %s | FileCheck %s
+
+// CHECK-LABEL:   _Z19array_decompositioni:
+// CHECK-NEXT:  File 0, [[@LINE+6]]:32 -> {{[0-9]+}}:2 = #0
+// CHECK-NEXT:  File 0, [[@LINE+8]]:20 -> [[@LINE+8]]:25 = #0
+// CHECK-NEXT:  Branch,File 0, [[@LINE+7]]:20 -> [[@LINE+7]]:25 = #1, 
(#0 - #1)
+// CHECK-NEXT:  Gap,File 0, [[@LINE+6]]:27 -> [[@LINE+6]]:28 = #1
+// CHECK-NEXT:  File 0, [[@LINE+5]]:28 -> [[@LINE+5]]:29 = #1
+// CHECK-NEXT:  File 0, [[@LINE+4]]:32 -> [[@LINE+4]]:33 = (#0 - #1)
+int array_decomposition(int i) {
+  int a[] = {1, 2, 3};
+  int b[] = {4, 5, 6};
+  auto [x, y, z] = i > 0 ? a : b;
+  return x + y + z;
+}

>From 2936ef132db8908fa65293ceba6884f80c871c93 Mon Sep 17 00:00:00 2001
From: Bolshakov 
Date: Wed, 17 Apr 2024 07:10:25 +0300
Subject: [PATCH 2/2] Fix up running test on Windows

---
 clang/test/CoverageMapping/decomposition.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CoverageMapping/decomposition.cpp 
b/clang/test/CoverageMapping/decomposition.cpp
index 31bd6cae2c4dec..601ea630faeec9 100644
--- a/clang/test/CoverageMapping/decomposition.cpp
+++ b/clang/test/CoverageMapping/decomposition.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only %s | FileCheck %s
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple 
%itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
 
 // CHECK-LABEL:   _Z19array_decompositioni:
 // CHECK-NEXT:  File 0, [[@LINE+6]]:32 -> {{[0-9]+}}:2 = #0

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


[clang] [polly] [clang-format] Revert breaking stream operators to previous default (PR #89016)

2024-04-16 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/89016

Reverts commit d68826dfbd98, which changes the previous default behavior of 
always breaking before a stream insertion operator `<<` if both operands are 
string literals.

Also reverts the related commits 27f547968cce and bf05be5b87fc.

See the discussion in #88483.

>From 930f422681b3a4f248afc094d3af98952cd7d386 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 16 Apr 2024 20:51:45 -0700
Subject: [PATCH] [clang-format] Revert breaking stream operators to previous
 default

Reverts commit d68826dfbd98, which changes the previous default behavior of
always breaking before a stream insertion operator `<<` if both operands are
string literals.

Also reverts the related commits 27f547968cce and bf05be5b87fc.

See the discussion in #88483.
---
 clang/lib/Format/TokenAnnotator.cpp   | 8 ++--
 clang/unittests/Format/FormatTest.cpp | 7 +--
 clang/unittests/Format/TokenAnnotatorTest.cpp | 9 -
 polly/lib/Analysis/DependenceInfo.cpp | 4 ++--
 polly/lib/Analysis/ScopBuilder.cpp| 7 ---
 5 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 628f70417866c3..80e5605fb5778d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5595,12 +5595,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
,
 return true;
   if (Left.IsUnterminatedLiteral)
 return true;
-  // FIXME: Breaking after newlines seems useful in general. Turn this into an
-  // option and recognize more cases like endl etc, and break independent of
-  // what comes after operator lessless.
-  if (Right.is(tok::lessless) && Right.Next &&
-  Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
-  Left.TokenText.ends_with("\\n\"")) {
+  if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
+  Right.Next->is(tok::string_literal)) {
 return true;
   }
   if (Right.is(TT_RequiresClause)) {
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 4906b3350b5b22..bc61b9c089e922 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27339,12 +27339,6 @@ TEST_F(FormatTest, 
PPDirectivesAndCommentsInBracedInit) {
getLLVMStyleWithColumns(30));
 }
 
-TEST_F(FormatTest, StreamOutputOperator) {
-  verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
-  verifyFormat("std::cout << \"foo\\n\"\n"
-   "  << \"bar\";");
-}
-
 TEST_F(FormatTest, BreakAdjacentStringLiterals) {
   constexpr StringRef Code{
   "return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
@@ -27359,6 +27353,7 @@ TEST_F(FormatTest, BreakAdjacentStringLiterals) {
   Style.BreakAdjacentStringLiterals = false;
   verifyFormat(Code, Style);
 }
+
 } // namespace
 } // namespace test
 } // namespace format
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index da02ced8c7a949..a71b6806476956 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2841,15 +2841,6 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_BRACE_KIND(Tokens[16], BK_BracedInit);
 }
 
-TEST_F(TokenAnnotatorTest, StreamOperator) {
-  auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
-  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
-  EXPECT_FALSE(Tokens[1]->MustBreakBefore);
-  EXPECT_FALSE(Tokens[3]->MustBreakBefore);
-  // Only break between string literals if the former ends with \n.
-  EXPECT_TRUE(Tokens[5]->MustBreakBefore);
-}
-
 TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {
   auto Tokens = annotate("auto foo() -> enum En {}");
   ASSERT_EQ(Tokens.size(), 10u) << Tokens;
diff --git a/polly/lib/Analysis/DependenceInfo.cpp 
b/polly/lib/Analysis/DependenceInfo.cpp
index 9ee004fbac9e53..a530fa7b58fa6e 100644
--- a/polly/lib/Analysis/DependenceInfo.cpp
+++ b/polly/lib/Analysis/DependenceInfo.cpp
@@ -951,8 +951,8 @@ class DependenceInfoPrinterLegacyPass final : public 
ScopPass {
   bool runOnScop(Scop ) override {
 DependenceInfo  = getAnalysis();
 
-OS << "Printing analysis '" << P.getPassName() << "' for " << "region: '"
-   << S.getRegion().getNameStr() << "' in function '"
+OS << "Printing analysis '" << P.getPassName() << "' for "
+   << "region: '" << S.getRegion().getNameStr() << "' in function '"
<< S.getFunction().getName() << "':\n";
 P.printScop(OS, S);
 
diff --git a/polly/lib/Analysis/ScopBuilder.cpp 
b/polly/lib/Analysis/ScopBuilder.cpp
index 214e4d360d6bbb..a34f2931527255 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -2715,9 +2715,10 @@ void ScopBuilder::addUserContext() {
 if (NameContext != NameUserContext) {
 

[clang] [polly] [clang-format] Revert breaking stream operators to previous default (PR #89016)

2024-04-16 Thread Owen Pan via cfe-commits

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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

I don't see any difference on your example (with `main()` and function 
definitions added) with and without my patch neither in the dumped coverage 
mapping nor in the output of `llvm-cov show ... --show-branches=count 
--show-expansions -show-line-counts-or-regions` command. If the coverage 
mapping works with code regions, it looks quite natural that an implicit code 
(`foo()` call inside `f()` in the sample) has no corresponding region and hence 
no mapping (except macro expansions).

Maybe, @hyp can clarify?

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


[clang] [clang][deps] Add `-o` flag to specify output path (PR #88767)

2024-04-16 Thread Jan Svoboda via cfe-commits

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


[clang] 6a4eaf9 - [clang][deps] Add `-o` flag to specify output path (#88767)

2024-04-16 Thread via cfe-commits

Author: Jan Svoboda
Date: 2024-04-16T19:49:07-07:00
New Revision: 6a4eaf9b33d8091b7d09b2a30a3fc8993a01db31

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

LOG: [clang][deps] Add `-o` flag to specify output path (#88767)

This makes it possible to pass "-o /dev/null" to `clang-scan-deps` and
skip some potentially expensive work, making timings less noisy. Also
removes the need for stream redirection.

Added: 


Modified: 
clang/test/ClangScanDeps/module-format.c
clang/tools/clang-scan-deps/ClangScanDeps.cpp
clang/tools/clang-scan-deps/Opts.td

Removed: 




diff  --git a/clang/test/ClangScanDeps/module-format.c 
b/clang/test/ClangScanDeps/module-format.c
index 001a011ae0b597..0a6abec80dd909 100644
--- a/clang/test/ClangScanDeps/module-format.c
+++ b/clang/test/ClangScanDeps/module-format.c
@@ -16,7 +16,7 @@
 // RUN: rm -f %t/cdb_pch.json
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json
 // RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format 
experimental-full \
-// RUN:   -module-files-dir %t/build > %t/result_pch.json
+// RUN:   -module-files-dir %t/build -o %t/result_pch.json
 
 // Explicitly build the PCH:
 //

diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 94510515cd4403..f42af7e330e17a 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -72,6 +72,7 @@ enum ResourceDirRecipeKind {
   RDRK_InvokeCompiler,
 };
 
+static std::string OutputFileName = "-";
 static ScanningMode ScanMode = ScanningMode::DependencyDirectivesScan;
 static ScanningOutputFormat Format = ScanningOutputFormat::Make;
 static ScanningOptimizations OptimizeArgs;
@@ -175,6 +176,9 @@ static void ParseArgs(int argc, char **argv) {
   if (const llvm::opt::Arg *A = Args.getLastArg(OPT_module_files_dir_EQ))
 ModuleFilesDir = A->getValue();
 
+  if (const llvm::opt::Arg *A = Args.getLastArg(OPT_o))
+OutputFileName = A->getValue();
+
   EagerLoadModules = Args.hasArg(OPT_eager_load_pcm);
 
   if (const llvm::opt::Arg *A = Args.getLastArg(OPT_j)) {
@@ -419,6 +423,11 @@ class FullDeps {
   }
 
   void printFullOutput(raw_ostream ) {
+// Skip sorting modules and constructing the JSON object if the output
+// cannot be observed anyway. This makes timings less noisy.
+if ( == ::nulls())
+  return;
+
 // Sort the modules by name to get a deterministic order.
 std::vector ModuleIDs;
 for (auto & : Modules)
@@ -849,8 +858,25 @@ int clang_scan_deps_main(int argc, char **argv, const 
llvm::ToolContext &) {
   });
 
   SharedStream Errs(llvm::errs());
-  // Print out the dependency results to STDOUT by default.
-  SharedStream DependencyOS(llvm::outs());
+
+  std::optional FileOS;
+  llvm::raw_ostream  = [&]() -> llvm::raw_ostream & {
+if (OutputFileName == "-")
+  return llvm::outs();
+
+if (OutputFileName == "/dev/null")
+  return llvm::nulls();
+
+std::error_code EC;
+FileOS.emplace(OutputFileName, EC);
+if (EC) {
+  llvm::errs() << "Failed to open output file '" << OutputFileName
+   << "': " << llvm::errorCodeToError(EC) << '\n';
+  std::exit(1);
+}
+return *FileOS;
+  }();
+  SharedStream DependencyOS(ThreadUnsafeDependencyOS);
 
   std::vector Inputs =
   AdjustingCompilations->getAllCompileCommands();
@@ -991,9 +1017,9 @@ int clang_scan_deps_main(int argc, char **argv, const 
llvm::ToolContext &) {
   HadErrors = true;
 
   if (Format == ScanningOutputFormat::Full)
-FD->printFullOutput(llvm::outs());
+FD->printFullOutput(ThreadUnsafeDependencyOS);
   else if (Format == ScanningOutputFormat::P1689)
-PD.printDependencies(llvm::outs());
+PD.printDependencies(ThreadUnsafeDependencyOS);
 
   return HadErrors;
 }

diff  --git a/clang/tools/clang-scan-deps/Opts.td 
b/clang/tools/clang-scan-deps/Opts.td
index 5cd5d1a9fb37bc..4837ce6f070d73 100644
--- a/clang/tools/clang-scan-deps/Opts.td
+++ b/clang/tools/clang-scan-deps/Opts.td
@@ -11,6 +11,8 @@ multiclass Eq {
 def help : Flag<["--"], "help">, HelpText<"Display this help">;
 def version : Flag<["--"], "version">, HelpText<"Display the version">;
 
+def o : Arg<"o", "Destination of the primary output">;
+
 defm mode : Eq<"mode", "The preprocessing mode used to compute the 
dependencies">;
 
 defm format : Eq<"format", "The output format for the dependencies">;
@@ -37,4 +39,4 @@ def verbose : F<"v", "Use verbose output">;
 
 def round_trip_args : F<"round-trip-args", "verify that command-line arguments 
are canonical by parsing and re-serializing">;
 
-def DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>;
\ No newline at end of file
+def DASH_DASH : Option<["--"], "", 

[clang] [clang][deps] Support single-file mode for all formats (PR #88764)

2024-04-16 Thread Jan Svoboda via cfe-commits

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


[clang] eafd515 - [clang][deps] Support single-file mode for all formats (#88764)

2024-04-16 Thread via cfe-commits

Author: Jan Svoboda
Date: 2024-04-16T19:47:52-07:00
New Revision: eafd515ecaaa100623eebc7fa4d7c36a361bf708

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

LOG: [clang][deps] Support single-file mode for all formats (#88764)

The `clang-scan-deps` tool can be used for fast scanning of batches of
compilation commands passed in via the `-compilation-database` option.
This gets awkward in our tests where we have to resort to using
`.in`/`.template` JSON files and running them through `sed` in order to
embed LIT's `%t` variable into them. However, most of our tests only
need to pass single compilation command, so this dance is entirely
unnecessary.

This patch makes sure the existing "per-file" mode (where the
compilation command is passed in-line after the `--` argument) works for
all output formats, not only `P1689`.

Added: 


Modified: 
clang/test/ClangScanDeps/error.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git a/clang/test/ClangScanDeps/error.cpp 
b/clang/test/ClangScanDeps/error.cpp
index 0095a6c900c3b3..593dbf35edca52 100644
--- a/clang/test/ClangScanDeps/error.cpp
+++ b/clang/test/ClangScanDeps/error.cpp
@@ -1,23 +1,10 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 
-//--- missing_tu.json.in
-[{
-  "directory": "DIR",
-  "command": "clang -fsyntax-only DIR/missing_tu.c",
-  "file": "DIR/missing_tu.c"
-}]
-//--- missing_header.json.in
-[{
-  "directory": "DIR",
-  "command": "clang -fsyntax-only DIR/missing_header.c",
-  "file": "DIR/missing_header.c"
-}]
 //--- missing_header.c
 #include "missing.h"
 
-// RUN: sed -e "s|DIR|%/t|g" %t/missing_tu.json.in > %t/missing_tu.json
-// RUN: not clang-scan-deps -compilation-database %t/missing_tu.json 
2>%t/missing_tu.errs
+// RUN: not clang-scan-deps -- %clang -c %t/missing_tu.c 2>%t/missing_tu.errs
 // RUN: echo EOF >> %t/missing_tu.errs
 // RUN: cat %t/missing_tu.errs | sed 's:\?:/:g' | FileCheck %s 
--check-prefix=CHECK-MISSING-TU -DPREFIX=%/t
 // CHECK-MISSING-TU: Error while scanning dependencies for 
[[PREFIX]]/missing_tu.c
@@ -26,8 +13,7 @@
 // CHECK-MISSING-TU-NEXT: error:
 // CHECK-MISSING-TU-NEXT: EOF
 
-// RUN: sed -e "s|DIR|%/t|g" %t/missing_header.json.in > %t/missing_header.json
-// RUN: not clang-scan-deps -compilation-database %t/missing_header.json 
2>%t/missing_header.errs
+// RUN: not clang-scan-deps -- %clang -c %t/missing_header.c 
2>%t/missing_header.errs
 // RUN: echo EOF >> %t/missing_header.errs
 // RUN: cat %t/missing_header.errs | sed 's:\?:/:g' | FileCheck %s 
--check-prefix=CHECK-MISSING-HEADER -DPREFIX=%/t
 // CHECK-MISSING-HEADER: Error while scanning dependencies for 
[[PREFIX]]/missing_header.c

diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index eaa76dd43e41dd..94510515cd4403 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -98,8 +98,8 @@ static bool RoundTripArgs = DoRoundTripDefault;
 static void ParseArgs(int argc, char **argv) {
   ScanDepsOptTable Tbl;
   llvm::StringRef ToolName = argv[0];
-  llvm::BumpPtrAllocator A;
-  llvm::StringSaver Saver{A};
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver{Alloc};
   llvm::opt::InputArgList Args =
   Tbl.parseArgs(argc, argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
 llvm::errs() << Msg << '\n';
@@ -186,14 +186,8 @@ static void ParseArgs(int argc, char **argv) {
 }
   }
 
-  if (const llvm::opt::Arg *A = Args.getLastArg(OPT_compilation_database_EQ)) {
+  if (const llvm::opt::Arg *A = Args.getLastArg(OPT_compilation_database_EQ))
 CompilationDB = A->getValue();
-  } else if (Format != ScanningOutputFormat::P1689) {
-llvm::errs() << ToolName
- << ": for the --compiilation-database option: must be "
-"specified at least once!";
-std::exit(1);
-  }
 
   if (const llvm::opt::Arg *A = Args.getLastArg(OPT_module_name_EQ))
 ModuleName = A->getValue();
@@ -225,9 +219,8 @@ static void ParseArgs(int argc, char **argv) {
 
   RoundTripArgs = Args.hasArg(OPT_round_trip_args);
 
-  if (auto *A = Args.getLastArgNoClaim(OPT_DASH_DASH))
-CommandLine.insert(CommandLine.end(), A->getValues().begin(),
-   A->getValues().end());
+  if (const llvm::opt::Arg *A = Args.getLastArgNoClaim(OPT_DASH_DASH))
+CommandLine.assign(A->getValues().begin(), A->getValues().end());
 }
 
 class SharedStream {
@@ -694,38 +687,28 @@ static std::string 
getModuleCachePath(ArrayRef Args) {
   return std::string(Path);
 }
 
-// getCompilationDataBase - If -compilation-database is set, load the
-// compilation database from the specified file. Otherwise if the we're
-// generating P1689 format, trying to generate the 

[clang] e6ecff8 - [C++20] [Modules] Add Release Notes and Documents for Reduced BMI

2024-04-16 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-04-17T10:42:48+08:00
New Revision: e6ecff8d95b9175e70e0d43e14c2975c8f69d718

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

LOG: [C++20] [Modules] Add Release Notes and Documents for Reduced BMI

See
https://discourse.llvm.org/t/rfc-c-20-modules-introduce-thin-bmi-and-decls-hash/74755,
https://github.com/llvm/llvm-project/pull/75894 and
https://github.com/llvm/llvm-project/pull/85050 for the background.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3752b6ce157600..efc32212f300cf 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -214,6 +214,9 @@ New Compiler Flags
   This diagnostic can be disabled to make ``-Wmissing-field-initializers`` 
behave
   like it did before Clang 18.x. Fixes #GH56628
 
+- ``-fexperimental-modules-reduced-bmi`` enables the Reduced BMI for C++20 
named modules.
+  See the document of standard C++ modules for details.
+
 Deprecated Compiler Flags
 -
 

diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index c5478bba45f389..8d5529d5d37db5 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -520,6 +520,112 @@ is attached to the global module fragments. For example:
 
 Now the linkage name of ``NS::foo()`` will be ``_ZN2NS3fooEv``.
 
+Reduced BMI
+---
+
+To support the 2 phase compilation model, Clang chose to put everything needed 
to
+produce an object into the BMI. But every consumer of the BMI, except itself, 
doesn't
+need such informations. It makes the BMI to larger and so may introduce 
unnecessary
+dependencies into the BMI. To mitigate the problem, we decided to reduce the 
information
+contained in the BMI.
+
+To be clear, we call the default BMI as Full BMI and the new introduced BMI as 
Reduced
+BMI.
+
+Users can use ``-fexperimental-modules-reduced-bmi`` flag to enable the 
Reduced BMI.
+
+For one phase compilation model (CMake implements this model), with
+``-fexperimental-modules-reduced-bmi``, the generated BMI will be Reduced BMI 
automatically.
+(The output path of the BMI is specified by ``-fmodule-output=`` as usual one 
phase
+compilation model).
+
+It is still possible to support Reduced BMI in two phase compilation model. 
With
+``-fexperimental-modules-reduced-bmi``, ``--precompile`` and 
``-fmodule-output=`` specified,
+the generated BMI specified by ``-o`` will be full BMI and the BMI specified by
+``-fmodule-output=`` will be Reduced BMI. The dependency graph may be:
+
+.. code-block:: none
+
+  module-unit.cppm --> module-unit.full.pcm -> module-unit.o
+|
+-> module-unit.reduced.pcm -> consumer1.cpp
+   -> consumer2.cpp
+   -> ...
+   -> consumer_n.cpp
+
+We don't emit diagnostics if ``-fexperimental-modules-reduced-bmi`` is used 
with a non-module
+unit. This design helps the end users of one phase compilation model to 
perform experiments
+early without asking for the help of build systems. The users of build systems 
which supports
+two phase compilation model still need helps from build systems.
+
+Within Reduced BMI, we won't write unreachable entities from GMF, definitions 
of non-inline
+functions and non-inline variables. This may not be a transparent change.
+`[module.global.frag]ex2 
`_ may be a good
+example:
+
+.. code-block:: c++
+
+  // foo.h
+  namespace N {
+struct X {};
+int d();
+int e();
+inline int f(X, int = d()) { return e(); }
+int g(X);
+int h(X);
+  }
+
+  // M.cppm
+  module;
+  #include "foo.h"
+  export module M;
+  template int use_f() {
+N::X x;   // N::X, N, and :: are decl-reachable from 
use_f
+return f(x, 123); // N::f is decl-reachable from use_f,
+  // N::e is indirectly decl-reachable from 
use_f
+  //   because it is decl-reachable from N::f, 
and
+  // N::d is decl-reachable from use_f
+  //   because it is decl-reachable from N::f
+  //   even though it is not used in this call
+  }
+  template int use_g() {
+N::X x;   // N::X, N, and :: are decl-reachable from 
use_g
+return g((T(), x));   // N::g is not decl-reachable from use_g
+  }
+  template int use_h() {
+N::X x;

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Jon Chesterfield via cfe-commits


@@ -0,0 +1,1056 @@
+//===-- ExpandVariadicsPass.cpp *- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is an optimization pass for variadic functions. If called from codegen,
+// it can serve as the implementation of variadic functions for a given target.
+//
+// The strategy is to turn the ... part of a varidic function into a va_list
+// and fix up the call sites. This is completely effective if the calling
+// convention can declare that to be the right thing, e.g. on GPUs or where
+// the application is wholly statically linked. In the usual case, it will
+// replace known calls to known variadic functions with calls that are amenable
+// to inlining and other optimisations.
+//
+// The target-dependent parts are in class VariadicABIInfo. Enabling a new
+// target means adding a case to VariadicABIInfo::create() along with tests.
+// This will be especially simple if the va_list representation is a char*.
+//
+// The majority of the plumbing is splitting the variadic function into a
+// single basic block that packs the variadic arguments into a va_list and
+// a second function that does the work of the original. The target specific
+// part is packing arguments into a contiguous buffer that the clang expansion
+// of va_arg will do the right thing with.
+//
+// The aggregate effect is to unblock other transforms, most critically the
+// general purpose inliner. Known calls to variadic functions become zero cost.
+//
+// Consistency with clang is primarily tested by emitting va_arg using clang
+// then expanding the variadic functions using this pass, followed by trying
+// to constant fold the functions to no-ops.
+//
+// Target specific behaviour is tested in IR - mainly checking that values are
+// put into positions in call frames that make sense for that particular 
target.
+//
+//===--===//
+
+#include "llvm/Transforms/IPO/ExpandVariadics.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
+
+#include 
+
+#define DEBUG_TYPE "expand-variadics"
+
+using namespace llvm;
+
+cl::opt ExpandVariadicsModeOption(
+DEBUG_TYPE "-override", cl::desc("Override the behaviour of " DEBUG_TYPE),
+cl::init(ExpandVariadicsMode::unspecified),
+cl::values(clEnumValN(ExpandVariadicsMode::unspecified, "unspecified",
+  "Use the implementation defaults"),
+   clEnumValN(ExpandVariadicsMode::disable, "disable",
+  "Disable the pass entirely"),
+   clEnumValN(ExpandVariadicsMode::optimize, "optimize",
+  "Optimise without changing ABI"),
+   clEnumValN(ExpandVariadicsMode::lowering, "lowering",
+  "Change variadic calling convention")));
+
+namespace {
+
+// Module implements getFunction() which returns nullptr on missing declaration
+// and getOrInsertFunction which creates one when absent. Intrinsics.h
+// implements getDeclaration which creates one when missing. This should be
+// changed to be consistent with Module()'s naming. Implementing as a local
+// function here in the meantime to decouple from that process.
+Function *getPreexistingDeclaration(Module *M, Intrinsic::ID id,
+ArrayRef Tys = std::nullopt) {
+  auto *FT = Intrinsic::getType(M->getContext(), id, Tys);
+  return M->getFunction(Tys.empty() ? Intrinsic::getName(id)
+: Intrinsic::getName(id, Tys, M, FT));
+}
+
+// Lots of targets use a void* pointed at a buffer for va_list.
+// Some use more complicated iterator constructs. Type erase that
+// so the rest of the pass can operation on either.
+// Virtual functions where different targets want different behaviour,
+// normal where all implemented targets presently have the same.
+struct VAListInterface {
+  virtual ~VAListInterface() {}
+
+  // Whether a valist instance is passed by value or by address
+  // I.e. does it need to be alloca'ed and stored into, or can
+  // it be passed directly in a SSA register
+  virtual bool passedInSSARegister() = 0;
+
+  // The type of a va_list iterator object
+  virtual Type *vaListType(LLVMContext ) = 0;
+
+  // The type of a va_list as a function argument as lowered by C
+  

[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Kito Cheng via cfe-commits

https://github.com/kito-cheng approved this pull request.

LGTM

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Jesse Huang via cfe-commits

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Jesse Huang via cfe-commits


@@ -119,6 +119,7 @@ on support follow.
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Zacas`` Supported (`See note <#riscv-zacas-note>`__)
+ ``Zama16b``   Supported

jaidTw wrote:

Am I supposed to add the extension name into the list in 
`riscv-profiles-extensions-note`?
Seems like not a extensions are listes there

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


[clang] [clang-tools-extra] [clang analysis] ExprMutationAnalyzer support recursive forwarding reference (PR #88843)

2024-04-16 Thread Congcong Cai via cfe-commits

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


[clang] f40f4fc - [clang analysis] ExprMutationAnalyzer support recursive forwarding reference (#88843)

2024-04-16 Thread via cfe-commits

Author: Congcong Cai
Date: 2024-04-17T09:57:30+08:00
New Revision: f40f4fcee506deacda0594362509ee7dddcf5e37

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

LOG: [clang analysis] ExprMutationAnalyzer support recursive forwarding 
reference (#88843)

Reapply for #88765.
Partially fixes: #60895.

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
index 2fa7cd0baf98f6..c507043c367a86 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -85,10 +85,10 @@ void UnnecessaryValueParamCheck::check(const 
MatchFinder::MatchResult ) {
 
   TraversalKindScope RAII(*Result.Context, TK_AsIs);
 
-  FunctionParmMutationAnalyzer  =
-  MutationAnalyzers.try_emplace(Function, *Function, *Result.Context)
-  .first->second;
-  if (Analyzer.isMutated(Param))
+  FunctionParmMutationAnalyzer *Analyzer =
+  FunctionParmMutationAnalyzer::getFunctionParmMutationAnalyzer(
+  *Function, *Result.Context, MutationAnalyzerCache);
+  if (Analyzer->isMutated(Param))
 return;
 
   const bool IsConstQualified =
@@ -169,7 +169,7 @@ void UnnecessaryValueParamCheck::storeOptions(
 }
 
 void UnnecessaryValueParamCheck::onEndOfTranslationUnit() {
-  MutationAnalyzers.clear();
+  MutationAnalyzerCache.clear();
 }
 
 void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl ,

diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
index 1872e3bc9bf29c..7250bffd20b2f9 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
@@ -37,8 +37,7 @@ class UnnecessaryValueParamCheck : public ClangTidyCheck {
   void handleMoveFix(const ParmVarDecl , const DeclRefExpr ,
  const ASTContext );
 
-  llvm::DenseMap
-  MutationAnalyzers;
+  ExprMutationAnalyzer::Memoized MutationAnalyzerCache;
   utils::IncludeInserter Inserter;
   const std::vector AllowedTypes;
 };

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 4dfbd8ca49ab9b..7095c56fe6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -221,6 +221,10 @@ Changes in existing checks
   ` check by replacing the local
   option `HeaderFileExtensions` by the global option of the same name.
 
+- Improved :doc:`misc-const-correctness
+  ` check by avoiding infinite 
recursion
+  for recursive forwarding reference.
+
 - Improved :doc:`misc-definitions-in-headers
   ` check by replacing the local
   option `HeaderFileExtensions` by the global option of the same name.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
index 9da468128743e9..248374a71dd40b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
@@ -58,3 +58,18 @@ void concatenate3(Args... args)
 (..., (stream << args));
 }
 } // namespace gh70323
+
+namespace gh60895 {
+
+template  void f1(T &);
+template  void f2(T &);
+template  void f1(T &) { f2(a); }
+template  void f2(T &) { f1(a); }
+void f() {
+  int x = 0;
+  // CHECK-MESSAGES:[[@LINE-1]]:3: warning: variable 'x' of type 'int' can be 
declared 'const'
+  // CHECK-FIXES: int const x = 0;
+  f1(x);
+}
+
+} // namespace gh60895

diff  --git a/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h 
b/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
index 1ceef944fbc34e..117173ba9a0958 100644
--- a/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
+++ b/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
@@ -8,11 +8,9 @@
 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_EXPRMUTATIONANALYZER_H
 #define LLVM_CLANG_ANALYSIS_ANALYSES_EXPRMUTATIONANALYZER_H
 
-#include 
-
-#include "clang/AST/AST.h"
 #include 

[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Jesse Huang via cfe-commits

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

>From 59b52163ff321d39128006c37ee38380ef5f9eec Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Thu, 11 Apr 2024 23:05:23 -0700
Subject: [PATCH 1/4] [RISCV] Support Zama16b1p0

This patch adds the support for Zama16b, which has been added to
RVA23U64 optional extensions recently
---
 clang/test/Preprocessor/riscv-target-features.c | 7 +++
 llvm/lib/Support/RISCVISAInfo.cpp   | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td  | 7 +++
 llvm/test/CodeGen/RISCV/attributes.ll   | 4 
 llvm/test/MC/RISCV/attribute-arch.s | 3 +++
 llvm/unittests/Support/RISCVISAInfoTest.cpp | 1 +
 6 files changed, 23 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index ec7764bb538189..21ad0b4e3d762c 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -79,6 +79,7 @@
 // CHECK-NOT: __riscv_za128rs {{.*$}}
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zacas {{.*$}}
+// CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -704,6 +705,12 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
 
+// RUN: %clang --target=riscv32 -march=rv32izama16b -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s
+// RUN: %clang --target=riscv64 -march=rv64izama16b  -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s
+// CHECK-ZAMA16B-EXT: __riscv_zama16b  100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32izawrs -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZAWRS-EXT %s
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 7a19d24d1ff483..e047da1f9eeb3c 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -119,6 +119,7 @@ static const RISCVSupportedExtension SupportedExtensions[] 
= {
 {"za128rs", {1, 0}},
 {"za64rs", {1, 0}},
 {"zacas", {1, 0}},
+{"zama16b", {1, 0}},
 {"zawrs", {1, 0}},
 
 {"zba", {1, 0}},
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 794455aa730400..84d3176deeb952 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -208,6 +208,13 @@ def HasStdExtAOrZalrsc
  "'A' (Atomic Instructions) or "
  "'Zalrsc' (Load-Reserved/Store-Conditional)">;
 
+def FeatureStdExtZama16b
+: SubtargetFeature<"zama16b", "HasStdExtZama16b", "true",
+   "'Zama16b' (Atomic 16-byte misaligned loads, stores and 
AMOs)">;
+def HasStdExtZama16b : Predicate<"Subtarget->hasStdExtZama16b()">,
+   AssemblerPredicate<(all_of FeatureStdExtZama16b),
+   "'Zama16b' (Atomic 16-byte misaligned loads, stores 
and AMOs)">;
+
 def FeatureStdExtZawrs : SubtargetFeature<"zawrs", "HasStdExtZawrs", "true",
   "'Zawrs' (Wait on Reservation Set)">;
 def HasStdExtZawrs : Predicate<"Subtarget->hasStdExtZawrs()">,
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index 2326599bf35136..080783fdeec024 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -115,6 +115,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zacas %s -o - | FileCheck 
--check-prefix=RV32ZACAS %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalasr %s -o - | FileCheck 
--check-prefix=RV32ZALASR %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalrsc %s -o - | FileCheck 
--check-prefix=RV32ZALRSC %s
+; RUN: llc -mtriple=riscv32 -mattr=+zama16b %s -o - | FileCheck 
--check-prefixes=CHECK,RV32ZAMA16B %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfilp %s -o - | FileCheck 
--check-prefix=RV32ZICFILP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zabha %s -o - | FileCheck 
--check-prefix=RV32ZABHA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-ssnpm  %s -o - | FileCheck 
--check-prefix=RV32SSNPM %s
@@ -199,6 +200,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+xtheadvdot %s -o - | FileCheck 
--check-prefixes=CHECK,RV64XTHEADVDOT %s
 ; RUN: llc -mtriple=riscv64 -mattr=+za64rs %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZA64RS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+za128rs %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZA128RS %s
+; RUN: llc -mtriple=riscv64 -mattr=+zama16b %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZAMA16B %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zawrs %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZAWRS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-ztso %s -o - | FileCheck 

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,1056 @@
+//===-- ExpandVariadicsPass.cpp *- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is an optimization pass for variadic functions. If called from codegen,
+// it can serve as the implementation of variadic functions for a given target.
+//
+// The strategy is to turn the ... part of a varidic function into a va_list
+// and fix up the call sites. This is completely effective if the calling
+// convention can declare that to be the right thing, e.g. on GPUs or where
+// the application is wholly statically linked. In the usual case, it will
+// replace known calls to known variadic functions with calls that are amenable
+// to inlining and other optimisations.
+//
+// The target-dependent parts are in class VariadicABIInfo. Enabling a new
+// target means adding a case to VariadicABIInfo::create() along with tests.
+// This will be especially simple if the va_list representation is a char*.
+//
+// The majority of the plumbing is splitting the variadic function into a
+// single basic block that packs the variadic arguments into a va_list and
+// a second function that does the work of the original. The target specific
+// part is packing arguments into a contiguous buffer that the clang expansion
+// of va_arg will do the right thing with.
+//
+// The aggregate effect is to unblock other transforms, most critically the
+// general purpose inliner. Known calls to variadic functions become zero cost.
+//
+// Consistency with clang is primarily tested by emitting va_arg using clang
+// then expanding the variadic functions using this pass, followed by trying
+// to constant fold the functions to no-ops.
+//
+// Target specific behaviour is tested in IR - mainly checking that values are
+// put into positions in call frames that make sense for that particular 
target.
+//
+//===--===//
+
+#include "llvm/Transforms/IPO/ExpandVariadics.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
+
+#include 
+
+#define DEBUG_TYPE "expand-variadics"
+
+using namespace llvm;
+
+cl::opt ExpandVariadicsModeOption(
+DEBUG_TYPE "-override", cl::desc("Override the behaviour of " DEBUG_TYPE),
+cl::init(ExpandVariadicsMode::unspecified),
+cl::values(clEnumValN(ExpandVariadicsMode::unspecified, "unspecified",
+  "Use the implementation defaults"),
+   clEnumValN(ExpandVariadicsMode::disable, "disable",
+  "Disable the pass entirely"),
+   clEnumValN(ExpandVariadicsMode::optimize, "optimize",
+  "Optimise without changing ABI"),
+   clEnumValN(ExpandVariadicsMode::lowering, "lowering",
+  "Change variadic calling convention")));
+
+namespace {
+
+// Module implements getFunction() which returns nullptr on missing declaration
+// and getOrInsertFunction which creates one when absent. Intrinsics.h
+// implements getDeclaration which creates one when missing. This should be
+// changed to be consistent with Module()'s naming. Implementing as a local
+// function here in the meantime to decouple from that process.
+Function *getPreexistingDeclaration(Module *M, Intrinsic::ID id,
+ArrayRef Tys = std::nullopt) {
+  auto *FT = Intrinsic::getType(M->getContext(), id, Tys);
+  return M->getFunction(Tys.empty() ? Intrinsic::getName(id)
+: Intrinsic::getName(id, Tys, M, FT));
+}
+
+// Lots of targets use a void* pointed at a buffer for va_list.
+// Some use more complicated iterator constructs. Type erase that
+// so the rest of the pass can operation on either.
+// Virtual functions where different targets want different behaviour,
+// normal where all implemented targets presently have the same.
+struct VAListInterface {
+  virtual ~VAListInterface() {}
+
+  // Whether a valist instance is passed by value or by address
+  // I.e. does it need to be alloca'ed and stored into, or can
+  // it be passed directly in a SSA register
+  virtual bool passedInSSARegister() = 0;
+
+  // The type of a va_list iterator object
+  virtual Type *vaListType(LLVMContext ) = 0;
+
+  // The type of a va_list as a function argument as lowered by C
+  

[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Kito Cheng via cfe-commits


@@ -119,6 +119,7 @@ on support follow.
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Zacas`` Supported (`See note <#riscv-zacas-note>`__)
+ ``Zama16b``   Supported

kito-cheng wrote:

```suggestion
 ``Zama16b``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
```

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


[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Jon Chesterfield via cfe-commits


@@ -0,0 +1,1056 @@
+//===-- ExpandVariadicsPass.cpp *- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is an optimization pass for variadic functions. If called from codegen,
+// it can serve as the implementation of variadic functions for a given target.
+//
+// The strategy is to turn the ... part of a varidic function into a va_list
+// and fix up the call sites. This is completely effective if the calling
+// convention can declare that to be the right thing, e.g. on GPUs or where
+// the application is wholly statically linked. In the usual case, it will
+// replace known calls to known variadic functions with calls that are amenable
+// to inlining and other optimisations.
+//
+// The target-dependent parts are in class VariadicABIInfo. Enabling a new
+// target means adding a case to VariadicABIInfo::create() along with tests.
+// This will be especially simple if the va_list representation is a char*.
+//
+// The majority of the plumbing is splitting the variadic function into a
+// single basic block that packs the variadic arguments into a va_list and
+// a second function that does the work of the original. The target specific
+// part is packing arguments into a contiguous buffer that the clang expansion
+// of va_arg will do the right thing with.
+//
+// The aggregate effect is to unblock other transforms, most critically the
+// general purpose inliner. Known calls to variadic functions become zero cost.
+//
+// Consistency with clang is primarily tested by emitting va_arg using clang
+// then expanding the variadic functions using this pass, followed by trying
+// to constant fold the functions to no-ops.
+//
+// Target specific behaviour is tested in IR - mainly checking that values are
+// put into positions in call frames that make sense for that particular 
target.
+//
+//===--===//
+
+#include "llvm/Transforms/IPO/ExpandVariadics.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
+
+#include 
+
+#define DEBUG_TYPE "expand-variadics"
+
+using namespace llvm;
+
+cl::opt ExpandVariadicsModeOption(
+DEBUG_TYPE "-override", cl::desc("Override the behaviour of " DEBUG_TYPE),
+cl::init(ExpandVariadicsMode::unspecified),
+cl::values(clEnumValN(ExpandVariadicsMode::unspecified, "unspecified",
+  "Use the implementation defaults"),
+   clEnumValN(ExpandVariadicsMode::disable, "disable",
+  "Disable the pass entirely"),
+   clEnumValN(ExpandVariadicsMode::optimize, "optimize",
+  "Optimise without changing ABI"),
+   clEnumValN(ExpandVariadicsMode::lowering, "lowering",
+  "Change variadic calling convention")));
+
+namespace {
+
+// Module implements getFunction() which returns nullptr on missing declaration
+// and getOrInsertFunction which creates one when absent. Intrinsics.h
+// implements getDeclaration which creates one when missing. This should be
+// changed to be consistent with Module()'s naming. Implementing as a local
+// function here in the meantime to decouple from that process.
+Function *getPreexistingDeclaration(Module *M, Intrinsic::ID id,
+ArrayRef Tys = std::nullopt) {
+  auto *FT = Intrinsic::getType(M->getContext(), id, Tys);
+  return M->getFunction(Tys.empty() ? Intrinsic::getName(id)
+: Intrinsic::getName(id, Tys, M, FT));
+}
+
+// Lots of targets use a void* pointed at a buffer for va_list.
+// Some use more complicated iterator constructs. Type erase that
+// so the rest of the pass can operation on either.
+// Virtual functions where different targets want different behaviour,
+// normal where all implemented targets presently have the same.
+struct VAListInterface {
+  virtual ~VAListInterface() {}
+
+  // Whether a valist instance is passed by value or by address
+  // I.e. does it need to be alloca'ed and stored into, or can
+  // it be passed directly in a SSA register
+  virtual bool passedInSSARegister() = 0;
+
+  // The type of a va_list iterator object
+  virtual Type *vaListType(LLVMContext ) = 0;
+
+  // The type of a va_list as a function argument as lowered by C
+  

[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Jesse Huang via cfe-commits

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

>From 59b52163ff321d39128006c37ee38380ef5f9eec Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Thu, 11 Apr 2024 23:05:23 -0700
Subject: [PATCH 1/3] [RISCV] Support Zama16b1p0

This patch adds the support for Zama16b, which has been added to
RVA23U64 optional extensions recently
---
 clang/test/Preprocessor/riscv-target-features.c | 7 +++
 llvm/lib/Support/RISCVISAInfo.cpp   | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td  | 7 +++
 llvm/test/CodeGen/RISCV/attributes.ll   | 4 
 llvm/test/MC/RISCV/attribute-arch.s | 3 +++
 llvm/unittests/Support/RISCVISAInfoTest.cpp | 1 +
 6 files changed, 23 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index ec7764bb538189..21ad0b4e3d762c 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -79,6 +79,7 @@
 // CHECK-NOT: __riscv_za128rs {{.*$}}
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zacas {{.*$}}
+// CHECK-NOT: __riscv_zama16b {{.*$}}
 // CHECK-NOT: __riscv_zawrs {{.*$}}
 // CHECK-NOT: __riscv_zba {{.*$}}
 // CHECK-NOT: __riscv_zbb {{.*$}}
@@ -704,6 +705,12 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
 
+// RUN: %clang --target=riscv32 -march=rv32izama16b -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s
+// RUN: %clang --target=riscv64 -march=rv64izama16b  -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s
+// CHECK-ZAMA16B-EXT: __riscv_zama16b  100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32izawrs -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZAWRS-EXT %s
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 7a19d24d1ff483..e047da1f9eeb3c 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -119,6 +119,7 @@ static const RISCVSupportedExtension SupportedExtensions[] 
= {
 {"za128rs", {1, 0}},
 {"za64rs", {1, 0}},
 {"zacas", {1, 0}},
+{"zama16b", {1, 0}},
 {"zawrs", {1, 0}},
 
 {"zba", {1, 0}},
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 794455aa730400..84d3176deeb952 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -208,6 +208,13 @@ def HasStdExtAOrZalrsc
  "'A' (Atomic Instructions) or "
  "'Zalrsc' (Load-Reserved/Store-Conditional)">;
 
+def FeatureStdExtZama16b
+: SubtargetFeature<"zama16b", "HasStdExtZama16b", "true",
+   "'Zama16b' (Atomic 16-byte misaligned loads, stores and 
AMOs)">;
+def HasStdExtZama16b : Predicate<"Subtarget->hasStdExtZama16b()">,
+   AssemblerPredicate<(all_of FeatureStdExtZama16b),
+   "'Zama16b' (Atomic 16-byte misaligned loads, stores 
and AMOs)">;
+
 def FeatureStdExtZawrs : SubtargetFeature<"zawrs", "HasStdExtZawrs", "true",
   "'Zawrs' (Wait on Reservation Set)">;
 def HasStdExtZawrs : Predicate<"Subtarget->hasStdExtZawrs()">,
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index 2326599bf35136..080783fdeec024 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -115,6 +115,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zacas %s -o - | FileCheck 
--check-prefix=RV32ZACAS %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalasr %s -o - | FileCheck 
--check-prefix=RV32ZALASR %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalrsc %s -o - | FileCheck 
--check-prefix=RV32ZALRSC %s
+; RUN: llc -mtriple=riscv32 -mattr=+zama16b %s -o - | FileCheck 
--check-prefixes=CHECK,RV32ZAMA16B %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfilp %s -o - | FileCheck 
--check-prefix=RV32ZICFILP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zabha %s -o - | FileCheck 
--check-prefix=RV32ZABHA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-ssnpm  %s -o - | FileCheck 
--check-prefix=RV32SSNPM %s
@@ -199,6 +200,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+xtheadvdot %s -o - | FileCheck 
--check-prefixes=CHECK,RV64XTHEADVDOT %s
 ; RUN: llc -mtriple=riscv64 -mattr=+za64rs %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZA64RS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+za128rs %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZA128RS %s
+; RUN: llc -mtriple=riscv64 -mattr=+zama16b %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZAMA16B %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zawrs %s -o - | FileCheck 
--check-prefixes=CHECK,RV64ZAWRS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-ztso %s -o - | FileCheck 

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Jon Chesterfield via cfe-commits


@@ -154,11 +154,20 @@ llvm::Value 
*CodeGen::emitRoundPointerUpToAlignment(CodeGenFunction ,
 llvm::Value *Ptr,
 CharUnits Align) {
   // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align;
+  Ptr = CGF.Builder.CreateAddrSpaceCast(Ptr, CGF.AllocaInt8PtrTy,
+Ptr->getName() + ".addrcast");

JonChesterfield wrote:

This might not be the right place for it - amdgpu passes a pointer in 
addrspace(5) which then hits an assert with the current implementation. The 
va_* intrinsics specify an address space now which should permit a cleaner 
answer, though I'm seeing p0 used from clang for targets where it shouldn't be. 
That's on the WIP part.

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


[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Eli Friedman via cfe-commits


@@ -0,0 +1,1056 @@
+//===-- ExpandVariadicsPass.cpp *- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is an optimization pass for variadic functions. If called from codegen,
+// it can serve as the implementation of variadic functions for a given target.
+//
+// The strategy is to turn the ... part of a varidic function into a va_list
+// and fix up the call sites. This is completely effective if the calling
+// convention can declare that to be the right thing, e.g. on GPUs or where
+// the application is wholly statically linked. In the usual case, it will
+// replace known calls to known variadic functions with calls that are amenable
+// to inlining and other optimisations.
+//
+// The target-dependent parts are in class VariadicABIInfo. Enabling a new
+// target means adding a case to VariadicABIInfo::create() along with tests.
+// This will be especially simple if the va_list representation is a char*.
+//
+// The majority of the plumbing is splitting the variadic function into a
+// single basic block that packs the variadic arguments into a va_list and
+// a second function that does the work of the original. The target specific
+// part is packing arguments into a contiguous buffer that the clang expansion
+// of va_arg will do the right thing with.
+//
+// The aggregate effect is to unblock other transforms, most critically the
+// general purpose inliner. Known calls to variadic functions become zero cost.
+//
+// Consistency with clang is primarily tested by emitting va_arg using clang
+// then expanding the variadic functions using this pass, followed by trying
+// to constant fold the functions to no-ops.
+//
+// Target specific behaviour is tested in IR - mainly checking that values are
+// put into positions in call frames that make sense for that particular 
target.
+//
+//===--===//
+
+#include "llvm/Transforms/IPO/ExpandVariadics.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
+
+#include 
+
+#define DEBUG_TYPE "expand-variadics"
+
+using namespace llvm;
+
+cl::opt ExpandVariadicsModeOption(
+DEBUG_TYPE "-override", cl::desc("Override the behaviour of " DEBUG_TYPE),
+cl::init(ExpandVariadicsMode::unspecified),
+cl::values(clEnumValN(ExpandVariadicsMode::unspecified, "unspecified",
+  "Use the implementation defaults"),
+   clEnumValN(ExpandVariadicsMode::disable, "disable",
+  "Disable the pass entirely"),
+   clEnumValN(ExpandVariadicsMode::optimize, "optimize",
+  "Optimise without changing ABI"),
+   clEnumValN(ExpandVariadicsMode::lowering, "lowering",
+  "Change variadic calling convention")));
+
+namespace {
+
+// Module implements getFunction() which returns nullptr on missing declaration
+// and getOrInsertFunction which creates one when absent. Intrinsics.h
+// implements getDeclaration which creates one when missing. This should be
+// changed to be consistent with Module()'s naming. Implementing as a local
+// function here in the meantime to decouple from that process.
+Function *getPreexistingDeclaration(Module *M, Intrinsic::ID id,
+ArrayRef Tys = std::nullopt) {
+  auto *FT = Intrinsic::getType(M->getContext(), id, Tys);
+  return M->getFunction(Tys.empty() ? Intrinsic::getName(id)
+: Intrinsic::getName(id, Tys, M, FT));
+}
+
+// Lots of targets use a void* pointed at a buffer for va_list.
+// Some use more complicated iterator constructs. Type erase that
+// so the rest of the pass can operation on either.
+// Virtual functions where different targets want different behaviour,
+// normal where all implemented targets presently have the same.
+struct VAListInterface {
+  virtual ~VAListInterface() {}
+
+  // Whether a valist instance is passed by value or by address
+  // I.e. does it need to be alloca'ed and stored into, or can
+  // it be passed directly in a SSA register
+  virtual bool passedInSSARegister() = 0;
+
+  // The type of a va_list iterator object
+  virtual Type *vaListType(LLVMContext ) = 0;
+
+  // The type of a va_list as a function argument as lowered by C
+  

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Eli Friedman via cfe-commits


@@ -154,11 +154,20 @@ llvm::Value 
*CodeGen::emitRoundPointerUpToAlignment(CodeGenFunction ,
 llvm::Value *Ptr,
 CharUnits Align) {
   // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align;
+  Ptr = CGF.Builder.CreateAddrSpaceCast(Ptr, CGF.AllocaInt8PtrTy,
+Ptr->getName() + ".addrcast");

efriedma-quic wrote:

I can sort of guess why you're doing this, but probably you want to rename the 
method so it's clear why it's specialized this way.

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


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-16 Thread Vitaly Buka via cfe-commits

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


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

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


[clang] d0f718e - Revert "Improve stack usage to increase recursive initialization depth" (#89006)

2024-04-16 Thread via cfe-commits

Author: Vitaly Buka
Date: 2024-04-16T17:47:17-07:00
New Revision: d0f718e06848774a4e9d0b253cf75c1408b5f41a

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

LOG: Revert "Improve stack usage to increase recursive initialization depth" 
(#89006)

Reverts llvm/llvm-project#88546

Leak and performance regression.
Details in #88546

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Initialization.h
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4aedfafcb26aea..3752b6ce157600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -203,12 +203,6 @@ Non-comprehensive list of changes in this release
 - ``__typeof_unqual__`` is available in all C modes as an extension, which 
behaves
   like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.
 
-- Improved stack usage with C++ initialization code. This allows significantly
-  more levels of recursive initialization before reaching stack exhaustion
-  limits. This will positively impact recursive template instantiation code,
-  but should also reduce memory overhead for initializations in general.
-  Fixes #GH88330
-
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and

diff  --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 1ceacf0f49f568..2072cd8d1c3ef8 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1134,7 +1134,7 @@ class InitializationSequence {
   OverloadingResult FailedOverloadResult;
 
   /// The candidate set created when initialization failed.
-  std::unique_ptr FailedCandidateSet;
+  OverloadCandidateSet FailedCandidateSet;
 
   /// The incomplete type that caused a failure.
   QualType FailedIncompleteType;
@@ -1403,9 +1403,7 @@ class InitializationSequence {
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
   OverloadCandidateSet () {
-assert(FailedCandidateSet &&
-   "this should have been allocated in the constructor!");
-return *FailedCandidateSet;
+return FailedCandidateSet;
   }
 
   /// Get the overloading result, for when the initialization

diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e6f88bbf7c4f47..76311b00d2fc58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -875,8 +874,7 @@ class Sema;
 ConversionFixItGenerator Fix;
 
 /// Viable - True to indicate that this overload candidate is viable.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Viable : 1;
+bool Viable : 1;
 
 /// Whether this candidate is the best viable function, or tied for being
 /// the best viable function.
@@ -885,14 +883,12 @@ class Sema;
 /// was part of the ambiguity kernel: the minimal non-empty set of viable
 /// candidates such that all elements of the ambiguity kernel are better
 /// than all viable candidates not in the ambiguity kernel.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Best : 1;
+bool Best : 1;
 
 /// IsSurrogate - True to indicate that this candidate is a
 /// surrogate for a conversion to a function pointer or reference
 /// (C++ [over.call.object]).
-LLVM_PREFERRED_TYPE(bool)
-unsigned IsSurrogate : 1;
+bool IsSurrogate : 1;
 
 /// IgnoreObjectArgument - True to indicate that the first
 /// argument's conversion, which for this function represents the
@@ -901,20 +897,18 @@ class Sema;
 /// implicit object argument is just a placeholder) or a
 /// non-static member function when the call doesn't have an
 /// object argument.
-LLVM_PREFERRED_TYPE(bool)
-unsigned IgnoreObjectArgument : 1;
+bool IgnoreObjectArgument : 1;
 
 /// True if the candidate was found using ADL.
-LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
-unsigned IsADLCandidate : 1;
+CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
-LLVM_PREFERRED_TYPE(OverloadFailureKind)
-unsigned FailureKind : 5;
+/// Actually an OverloadFailureKind.
+unsigned char FailureKind;
 
 /// The number of call arguments that were explicitly provided,
 /// to be used while performing partial ordering of 

[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> I would not run clang-format on the revert

Done. Reverted to github generated 1d59298

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Craig Topper via cfe-commits

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

Need to update RISCVUsage.rst

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


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

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

>From 1d59298cd9ed21e1ac860d64f965514a577f45bb Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 16 Apr 2024 17:23:47 -0700
Subject: [PATCH 1/2] Revert "Improve stack usage to increase recursive
 initialization depth (#88546)"

This reverts commit 4082a7554521572a65a5a0008c4661a534df659d.
---
 clang/docs/ReleaseNotes.rst   |  6 --
 clang/include/clang/Sema/Initialization.h |  6 +-
 clang/include/clang/Sema/Overload.h   | 70 +--
 clang/lib/Sema/SemaInit.cpp   | 26 -
 clang/lib/Sema/SemaOverload.cpp   | 21 ---
 5 files changed, 75 insertions(+), 54 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4aedfafcb26aea..3752b6ce157600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -203,12 +203,6 @@ Non-comprehensive list of changes in this release
 - ``__typeof_unqual__`` is available in all C modes as an extension, which 
behaves
   like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.
 
-- Improved stack usage with C++ initialization code. This allows significantly
-  more levels of recursive initialization before reaching stack exhaustion
-  limits. This will positively impact recursive template instantiation code,
-  but should also reduce memory overhead for initializations in general.
-  Fixes #GH88330
-
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
diff --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 1ceacf0f49f568..2072cd8d1c3ef8 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1134,7 +1134,7 @@ class InitializationSequence {
   OverloadingResult FailedOverloadResult;
 
   /// The candidate set created when initialization failed.
-  std::unique_ptr FailedCandidateSet;
+  OverloadCandidateSet FailedCandidateSet;
 
   /// The incomplete type that caused a failure.
   QualType FailedIncompleteType;
@@ -1403,9 +1403,7 @@ class InitializationSequence {
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
   OverloadCandidateSet () {
-assert(FailedCandidateSet &&
-   "this should have been allocated in the constructor!");
-return *FailedCandidateSet;
+return FailedCandidateSet;
   }
 
   /// Get the overloading result, for when the initialization
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e6f88bbf7c4f47..76311b00d2fc58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -875,8 +874,7 @@ class Sema;
 ConversionFixItGenerator Fix;
 
 /// Viable - True to indicate that this overload candidate is viable.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Viable : 1;
+bool Viable : 1;
 
 /// Whether this candidate is the best viable function, or tied for being
 /// the best viable function.
@@ -885,14 +883,12 @@ class Sema;
 /// was part of the ambiguity kernel: the minimal non-empty set of viable
 /// candidates such that all elements of the ambiguity kernel are better
 /// than all viable candidates not in the ambiguity kernel.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Best : 1;
+bool Best : 1;
 
 /// IsSurrogate - True to indicate that this candidate is a
 /// surrogate for a conversion to a function pointer or reference
 /// (C++ [over.call.object]).
-LLVM_PREFERRED_TYPE(bool)
-unsigned IsSurrogate : 1;
+bool IsSurrogate : 1;
 
 /// IgnoreObjectArgument - True to indicate that the first
 /// argument's conversion, which for this function represents the
@@ -901,20 +897,18 @@ class Sema;
 /// implicit object argument is just a placeholder) or a
 /// non-static member function when the call doesn't have an
 /// object argument.
-LLVM_PREFERRED_TYPE(bool)
-unsigned IgnoreObjectArgument : 1;
+bool IgnoreObjectArgument : 1;
 
 /// True if the candidate was found using ADL.
-LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
-unsigned IsADLCandidate : 1;
+CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
-LLVM_PREFERRED_TYPE(OverloadFailureKind)
-unsigned FailureKind : 5;
+/// Actually an OverloadFailureKind.
+unsigned char FailureKind;
 
 /// The number of call arguments that were explicitly provided,
 /// to be used while performing partial ordering of function templates.
@@ -978,9 +972,7 @@ class Sema;
   

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Jon Chesterfield (JonChesterfield)


Changes

Rewrite calls to variadic functions into calls to an equivalent non-variadic 
function.

This makes calls to known variadic functions a zero cost abstraction. The GPUs 
use it as a backend implementation.

The pass runs for implemented targets on known functions at O1 or above. For 
targets using it as codegen it runs from the backend on known and unknown 
functions. Interacts well with inlining so is scheduled shortly before the 
inliner.

Relative to the abandoned pull/81058, this is the whole end to end transform as 
opposed to a subset for easier review. The feedback on that is applied, in 
particular this makes no attempt to detect existing va_list functions, so in 
some cases it'll make the IR worse in a fashion that the inliner completely 
reverts. The ABI abstraction is reworked to be more orthogonal which hopefully 
makes it clear that the switch isn't worth scattering across the target classes.

Marked WIP because vector types in structs on X64 might be misbehaving. Still 
testing this - it's solid enough to build a working clang and libxml2 and 
should meet the use cases in gpu libc and I'll put a patch up for the rocm CI - 
but would like more test coverage and probably another architecture implemented 
before landing.

---

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


36 Files Affected:

- (modified) clang/lib/CodeGen/ABIInfoImpl.cpp (+11-2) 
- (modified) clang/lib/CodeGen/Targets/AMDGPU.cpp (+7-1) 
- (modified) clang/lib/CodeGen/Targets/NVPTX.cpp (+7-1) 
- (added) clang/test/CodeGen/expand-variadic-call.c (+314) 
- (added) clang/test/CodeGen/variadic-wrapper-removal.c (+85) 
- (added) clang/test/CodeGenCXX/inline-then-fold-variadics.cpp (+247) 
- (modified) llvm/include/llvm/InitializePasses.h (+1) 
- (added) llvm/include/llvm/Transforms/IPO/ExpandVariadics.h (+43) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+4) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+3) 
- (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+4) 
- (modified) llvm/lib/Transforms/IPO/CMakeLists.txt (+1) 
- (added) llvm/lib/Transforms/IPO/ExpandVariadics.cpp (+1056) 
- (added) llvm/test/CodeGen/AMDGPU/expand-variadic-call.ll (+499) 
- (modified) llvm/test/CodeGen/AMDGPU/llc-pipeline.ll (+5) 
- (modified) llvm/test/CodeGen/AMDGPU/unsupported-calls.ll (-19) 
- (added) llvm/test/CodeGen/NVPTX/expand-variadic-call.ll (+468) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-i386-darwin.ll (+449) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-i386-linux.ll (+449) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-i686-msvc.ll (+467) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-x64-darwin.ll (+688) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-x64-linux.ll (+688) 
- (modified) llvm/test/Other/new-pm-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll 
(+1-1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll (+1) 
- (added) llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-outliner.ll 
(+86) 
- (added) 
llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-linkage.ll 
(+225) 
- (added) 
llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-simple.ll (+121) 
- (modified) llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn (+1) 


``diff
diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp 
b/clang/lib/CodeGen/ABIInfoImpl.cpp
index 3e34d82cb399ba..c4a1829ab8863f 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -154,11 +154,20 @@ llvm::Value 
*CodeGen::emitRoundPointerUpToAlignment(CodeGenFunction ,
 llvm::Value *Ptr,
 CharUnits Align) {
   // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align;
+  Ptr = CGF.Builder.CreateAddrSpaceCast(Ptr, CGF.AllocaInt8PtrTy,
+Ptr->getName() + ".addrcast");
   llvm::Value *RoundUp = CGF.Builder.CreateConstInBoundsGEP1_32(
   CGF.Builder.getInt8Ty(), Ptr, Align.getQuantity() - 1);
+
+  // ptrmask is sensitive to the bitwidth of the mask
+  unsigned IndexTypeSize =
+  CGF.CGM.getDataLayout().getIndexTypeSizeInBits(RoundUp->getType());
+  llvm::IntegerType *MaskType =
+  

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Jon Chesterfield (JonChesterfield)


Changes

Rewrite calls to variadic functions into calls to an equivalent non-variadic 
function.

This makes calls to known variadic functions a zero cost abstraction. The GPUs 
use it as a backend implementation.

The pass runs for implemented targets on known functions at O1 or above. For 
targets using it as codegen it runs from the backend on known and unknown 
functions. Interacts well with inlining so is scheduled shortly before the 
inliner.

Relative to the abandoned pull/81058, this is the whole end to end transform as 
opposed to a subset for easier review. The feedback on that is applied, in 
particular this makes no attempt to detect existing va_list functions, so in 
some cases it'll make the IR worse in a fashion that the inliner completely 
reverts. The ABI abstraction is reworked to be more orthogonal which hopefully 
makes it clear that the switch isn't worth scattering across the target classes.

Marked WIP because vector types in structs on X64 might be misbehaving. Still 
testing this - it's solid enough to build a working clang and libxml2 and 
should meet the use cases in gpu libc and I'll put a patch up for the rocm CI - 
but would like more test coverage and probably another architecture implemented 
before landing.

---

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


36 Files Affected:

- (modified) clang/lib/CodeGen/ABIInfoImpl.cpp (+11-2) 
- (modified) clang/lib/CodeGen/Targets/AMDGPU.cpp (+7-1) 
- (modified) clang/lib/CodeGen/Targets/NVPTX.cpp (+7-1) 
- (added) clang/test/CodeGen/expand-variadic-call.c (+314) 
- (added) clang/test/CodeGen/variadic-wrapper-removal.c (+85) 
- (added) clang/test/CodeGenCXX/inline-then-fold-variadics.cpp (+247) 
- (modified) llvm/include/llvm/InitializePasses.h (+1) 
- (added) llvm/include/llvm/Transforms/IPO/ExpandVariadics.h (+43) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+4) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+3) 
- (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+4) 
- (modified) llvm/lib/Transforms/IPO/CMakeLists.txt (+1) 
- (added) llvm/lib/Transforms/IPO/ExpandVariadics.cpp (+1056) 
- (added) llvm/test/CodeGen/AMDGPU/expand-variadic-call.ll (+499) 
- (modified) llvm/test/CodeGen/AMDGPU/llc-pipeline.ll (+5) 
- (modified) llvm/test/CodeGen/AMDGPU/unsupported-calls.ll (-19) 
- (added) llvm/test/CodeGen/NVPTX/expand-variadic-call.ll (+468) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-i386-darwin.ll (+449) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-i386-linux.ll (+449) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-i686-msvc.ll (+467) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-x64-darwin.ll (+688) 
- (added) llvm/test/CodeGen/X86/expand-variadic-call-x64-linux.ll (+688) 
- (modified) llvm/test/Other/new-pm-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll 
(+1-1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll (+1) 
- (added) llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-outliner.ll 
(+86) 
- (added) 
llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-linkage.ll 
(+225) 
- (added) 
llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-simple.ll (+121) 
- (modified) llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn (+1) 


``diff
diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp 
b/clang/lib/CodeGen/ABIInfoImpl.cpp
index 3e34d82cb399ba..c4a1829ab8863f 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -154,11 +154,20 @@ llvm::Value 
*CodeGen::emitRoundPointerUpToAlignment(CodeGenFunction ,
 llvm::Value *Ptr,
 CharUnits Align) {
   // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align;
+  Ptr = CGF.Builder.CreateAddrSpaceCast(Ptr, CGF.AllocaInt8PtrTy,
+Ptr->getName() + ".addrcast");
   llvm::Value *RoundUp = CGF.Builder.CreateConstInBoundsGEP1_32(
   CGF.Builder.getInt8Ty(), Ptr, Align.getQuantity() - 1);
+
+  // ptrmask is sensitive to the bitwidth of the mask
+  unsigned IndexTypeSize =
+  CGF.CGM.getDataLayout().getIndexTypeSizeInBits(RoundUp->getType());
+  llvm::IntegerType *MaskType =
+  

[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-16 Thread Richard Smith via cfe-commits


@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor ,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor , Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

zygoloid wrote:

Yes, that sounds great, thank you. In our case, it's not that the module map 
files are unused, it's that we specify the same `-fmodule-map-file=` flag to 
all of our compilations, and so we *usually* get the information from a `.pcm` 
file rather than from the module map file, and it turns out that pruning out 
the repeated module maps make a rather large difference to our source location 
address space usage :)

All that said, we have some other ideas for how to address the problems we're 
seeing with source location address space usage. Maybe we can get to a point 
where we're not relying on this at all -- I think this patch is probably the 
right behavior, even though I think it's contributing to a regression for us, 
so I think this new behavior should be the default, and we can clean up the 
flag once we don't need it any more.

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


[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Vitaly Buka via cfe-commits


@@ -1163,12 +1136,7 @@ class Sema;
 ConversionSequenceList
 allocateConversionSequences(unsigned NumConversions) {
   ImplicitConversionSequence *Conversions =
-  slabAllocate(NumConversions);
-
-  // Construct the new objects.
-  for (unsigned I = 0; I != NumConversions; ++I)
-new ([I]) ImplicitConversionSequence();
-
+  new ImplicitConversionSequence[NumConversions];

vitalybuka wrote:

Seems unusual to keep ownership in ArrayRef.
Could we make ConversionSequenceList just a std::vector if it owns the memory?

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


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 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 8c9d814b66f7df274de41225575817188fbeed4f 
1d59298cd9ed21e1ac860d64f965514a577f45bb -- 
clang/include/clang/Sema/Initialization.h clang/include/clang/Sema/Overload.h 
clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaOverload.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 2072cd8d1c..0cae6d353d 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1402,9 +1402,7 @@ public:
 
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
-  OverloadCandidateSet () {
-return FailedCandidateSet;
-  }
+  OverloadCandidateSet () { return FailedCandidateSet; }
 
   /// Get the overloading result, for when the initialization
   /// sequence failed due to a bad overload.
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 76311b00d2..a49cc6778d 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -972,7 +972,8 @@ class Sema;
   private:
 friend class OverloadCandidateSet;
 OverloadCandidate()
-: IsSurrogate(false), IsADLCandidate(CallExpr::NotADL), 
RewriteKind(CRK_None) {}
+: IsSurrogate(false), IsADLCandidate(CallExpr::NotADL),
+  RewriteKind(CRK_None) {}
   };
 
   /// OverloadCandidateSet - A set of overload candidates, used in C++
@@ -1095,8 +1096,7 @@ class Sema;
 /// instead.
 /// FIXME: Now that this only allocates ImplicitConversionSequences, do we
 /// want to un-generalize this?
-template 
-T *slabAllocate(unsigned N) {
+template  T *slabAllocate(unsigned N) {
   // It's simpler if this doesn't need to consider alignment.
   static_assert(alignof(T) == alignof(void *),
 "Only works for pointer-aligned types.");
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index fb7a80ab02..6afcc56c73 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -9749,7 +9749,8 @@ bool InitializationSequence::Diagnose(Sema ,
   break;
 
 case OR_No_Viable_Function: {
-  auto Cands = FailedCandidateSet.CompleteCandidates(S, OCD_AllCandidates, 
Args);
+  auto Cands =
+  FailedCandidateSet.CompleteCandidates(S, OCD_AllCandidates, Args);
   if (!S.RequireCompleteType(Kind.getLocation(),
  DestType.getNonReferenceType(),
   diag::err_typecheck_nonviable_condition_incomplete,
@@ -9764,8 +9765,8 @@ bool InitializationSequence::Diagnose(Sema ,
 }
 case OR_Deleted: {
   OverloadCandidateSet::iterator Best;
-  OverloadingResult Ovl
-= FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
+  OverloadingResult Ovl =
+  FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
 
   StringLiteral *Msg = Best->Function->getDeletedMessage();
   S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
@@ -10013,8 +10014,8 @@ bool InitializationSequence::Diagnose(Sema ,
 
   case OR_Deleted: {
 OverloadCandidateSet::iterator Best;
-OverloadingResult Ovl
-  = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
+OverloadingResult Ovl =
+FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
 if (Ovl != OR_Deleted) {
   S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
   << DestType << ArgsRange;
@@ -10093,8 +10094,8 @@ bool InitializationSequence::Diagnose(Sema ,
 S.Diag(Kind.getLocation(), diag::err_selected_explicit_constructor)
   << Args[0]->getSourceRange();
 OverloadCandidateSet::iterator Best;
-OverloadingResult Ovl
-  = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
+OverloadingResult Ovl =
+FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
 (void)Ovl;
 assert(Ovl == OR_Success && "Inconsistent overload resolution");
 CXXConstructorDecl *CtorDecl = cast(Best->Function);

``




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


[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

have ideas about leak, but not sure what to do with perf regression and #88330

Proposing revert https://github.com/llvm/llvm-project/pull/89006 

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


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)


Changes

Reverts llvm/llvm-project#88546

Leak and performance regression.
Details in #88546

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


5 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-6) 
- (modified) clang/include/clang/Sema/Initialization.h (+2-4) 
- (modified) clang/include/clang/Sema/Overload.h (+51-19) 
- (modified) clang/lib/Sema/SemaInit.cpp (+12-14) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+10-11) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4aedfafcb26aea..3752b6ce157600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -203,12 +203,6 @@ Non-comprehensive list of changes in this release
 - ``__typeof_unqual__`` is available in all C modes as an extension, which 
behaves
   like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.
 
-- Improved stack usage with C++ initialization code. This allows significantly
-  more levels of recursive initialization before reaching stack exhaustion
-  limits. This will positively impact recursive template instantiation code,
-  but should also reduce memory overhead for initializations in general.
-  Fixes #GH88330
-
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
diff --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 1ceacf0f49f568..2072cd8d1c3ef8 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1134,7 +1134,7 @@ class InitializationSequence {
   OverloadingResult FailedOverloadResult;
 
   /// The candidate set created when initialization failed.
-  std::unique_ptr FailedCandidateSet;
+  OverloadCandidateSet FailedCandidateSet;
 
   /// The incomplete type that caused a failure.
   QualType FailedIncompleteType;
@@ -1403,9 +1403,7 @@ class InitializationSequence {
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
   OverloadCandidateSet () {
-assert(FailedCandidateSet &&
-   "this should have been allocated in the constructor!");
-return *FailedCandidateSet;
+return FailedCandidateSet;
   }
 
   /// Get the overloading result, for when the initialization
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e6f88bbf7c4f47..76311b00d2fc58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -875,8 +874,7 @@ class Sema;
 ConversionFixItGenerator Fix;
 
 /// Viable - True to indicate that this overload candidate is viable.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Viable : 1;
+bool Viable : 1;
 
 /// Whether this candidate is the best viable function, or tied for being
 /// the best viable function.
@@ -885,14 +883,12 @@ class Sema;
 /// was part of the ambiguity kernel: the minimal non-empty set of viable
 /// candidates such that all elements of the ambiguity kernel are better
 /// than all viable candidates not in the ambiguity kernel.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Best : 1;
+bool Best : 1;
 
 /// IsSurrogate - True to indicate that this candidate is a
 /// surrogate for a conversion to a function pointer or reference
 /// (C++ [over.call.object]).
-LLVM_PREFERRED_TYPE(bool)
-unsigned IsSurrogate : 1;
+bool IsSurrogate : 1;
 
 /// IgnoreObjectArgument - True to indicate that the first
 /// argument's conversion, which for this function represents the
@@ -901,20 +897,18 @@ class Sema;
 /// implicit object argument is just a placeholder) or a
 /// non-static member function when the call doesn't have an
 /// object argument.
-LLVM_PREFERRED_TYPE(bool)
-unsigned IgnoreObjectArgument : 1;
+bool IgnoreObjectArgument : 1;
 
 /// True if the candidate was found using ADL.
-LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
-unsigned IsADLCandidate : 1;
+CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
-LLVM_PREFERRED_TYPE(OverloadFailureKind)
-unsigned FailureKind : 5;
+/// Actually an OverloadFailureKind.
+unsigned char FailureKind;
 
 /// The number of call arguments that were explicitly provided,
 /// to be used while performing partial ordering of function templates.
@@ -978,9 +972,7 @@ class Sema;
   private:
 friend class OverloadCandidateSet;
 OverloadCandidate()
-: IsSurrogate(false),
-  IsADLCandidate(static_cast(CallExpr::NotADL)),
-  

[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/89006

Reverts llvm/llvm-project#88546

Leak and performance regression.
Details in #88546

>From 1d59298cd9ed21e1ac860d64f965514a577f45bb Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 16 Apr 2024 17:23:47 -0700
Subject: [PATCH] Revert "Improve stack usage to increase recursive
 initialization depth (#88546)"

This reverts commit 4082a7554521572a65a5a0008c4661a534df659d.
---
 clang/docs/ReleaseNotes.rst   |  6 --
 clang/include/clang/Sema/Initialization.h |  6 +-
 clang/include/clang/Sema/Overload.h   | 70 +--
 clang/lib/Sema/SemaInit.cpp   | 26 -
 clang/lib/Sema/SemaOverload.cpp   | 21 ---
 5 files changed, 75 insertions(+), 54 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4aedfafcb26aea..3752b6ce157600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -203,12 +203,6 @@ Non-comprehensive list of changes in this release
 - ``__typeof_unqual__`` is available in all C modes as an extension, which 
behaves
   like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.
 
-- Improved stack usage with C++ initialization code. This allows significantly
-  more levels of recursive initialization before reaching stack exhaustion
-  limits. This will positively impact recursive template instantiation code,
-  but should also reduce memory overhead for initializations in general.
-  Fixes #GH88330
-
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
diff --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 1ceacf0f49f568..2072cd8d1c3ef8 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1134,7 +1134,7 @@ class InitializationSequence {
   OverloadingResult FailedOverloadResult;
 
   /// The candidate set created when initialization failed.
-  std::unique_ptr FailedCandidateSet;
+  OverloadCandidateSet FailedCandidateSet;
 
   /// The incomplete type that caused a failure.
   QualType FailedIncompleteType;
@@ -1403,9 +1403,7 @@ class InitializationSequence {
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
   OverloadCandidateSet () {
-assert(FailedCandidateSet &&
-   "this should have been allocated in the constructor!");
-return *FailedCandidateSet;
+return FailedCandidateSet;
   }
 
   /// Get the overloading result, for when the initialization
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e6f88bbf7c4f47..76311b00d2fc58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -875,8 +874,7 @@ class Sema;
 ConversionFixItGenerator Fix;
 
 /// Viable - True to indicate that this overload candidate is viable.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Viable : 1;
+bool Viable : 1;
 
 /// Whether this candidate is the best viable function, or tied for being
 /// the best viable function.
@@ -885,14 +883,12 @@ class Sema;
 /// was part of the ambiguity kernel: the minimal non-empty set of viable
 /// candidates such that all elements of the ambiguity kernel are better
 /// than all viable candidates not in the ambiguity kernel.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Best : 1;
+bool Best : 1;
 
 /// IsSurrogate - True to indicate that this candidate is a
 /// surrogate for a conversion to a function pointer or reference
 /// (C++ [over.call.object]).
-LLVM_PREFERRED_TYPE(bool)
-unsigned IsSurrogate : 1;
+bool IsSurrogate : 1;
 
 /// IgnoreObjectArgument - True to indicate that the first
 /// argument's conversion, which for this function represents the
@@ -901,20 +897,18 @@ class Sema;
 /// implicit object argument is just a placeholder) or a
 /// non-static member function when the call doesn't have an
 /// object argument.
-LLVM_PREFERRED_TYPE(bool)
-unsigned IgnoreObjectArgument : 1;
+bool IgnoreObjectArgument : 1;
 
 /// True if the candidate was found using ADL.
-LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
-unsigned IsADLCandidate : 1;
+CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
-LLVM_PREFERRED_TYPE(OverloadFailureKind)
-unsigned FailureKind : 5;
+/// Actually an OverloadFailureKind.
+unsigned char FailureKind;
 
 /// The number of call arguments that were explicitly provided,
 /// to be used while performing 

[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-16 Thread Jan Svoboda via cfe-commits

jansvoboda11 wrote:

As a test, maybe you could probe the resulting PCM with `-module-file-info`.

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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-16 Thread Ian Anderson via cfe-commits

ian-twilightcoder wrote:

@ilya-biryukov can you check that this fixes your running out of source 
location space problem please?

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


[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Nikita Popov via cfe-commits

nikic wrote:

This change seems to cause significant compile-time regressions for C++ code 
(https://llvm-compile-time-tracker.com/compare.php?from=184ba038ac1d444980b3e554b0057f3f30c516ab=4082a7554521572a65a5a0008c4661a534df659d=instructions%3Au).

Probably most damning are the times for the clang build itself 
(https://llvm-compile-time-tracker.com/compare_clang.php?from=184ba038ac1d444980b3e554b0057f3f30c516ab=4082a7554521572a65a5a0008c4661a534df659d=instructions%3Au=interestingness)
 where files like X86ISelDAGToDAG.cpp regress by >3% even in an optimized build.

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


[clang] [clang][deps] Support single-file mode for all formats (PR #88764)

2024-04-16 Thread Ben Langmuir via cfe-commits

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


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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Kito Cheng via cfe-commits

kito-cheng wrote:

`llvm/docs/RISCVUsage.rst` need update 

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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-16 Thread Ian Anderson via cfe-commits

ian-twilightcoder wrote:

I don't really know a great way to write a test for this. If someone could 
point me at a similar existing test or has an idea how to write a new test that 
would be much appreciated.

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)

2024-04-16 Thread Ian Anderson via cfe-commits


@@ -1403,94 +1421,146 @@ bool 
HeaderSearch::isFileMultipleIncludeGuarded(FileEntryRef File) const {
 void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 ModuleMap::ModuleHeaderRole Role,
 bool isCompilingModuleHeader) {
-  bool isModularHeader = ModuleMap::isModular(Role);
-
   // Don't mark the file info as non-external if there's nothing to change.
   if (!isCompilingModuleHeader) {
-if (!isModularHeader)
+if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
 if (HFI && HFI->isModuleHeader)
   return;
   }
 
   auto  = getFileInfo(FE);
-  HFI.isModuleHeader |= isModularHeader;
+  HFI.mergeModuleMembership(Role);
   HFI.isCompilingModuleHeader |= isCompilingModuleHeader;

ian-twilightcoder wrote:

https://github.com/llvm/llvm-project/pull/89005 and thank you!!

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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ian Anderson (ian-twilightcoder)


Changes

HeaderSearch::MarkFileModuleHeader is no longer properly checking for 
no-changes, and so creates a new HeaderFileInfo for every `textual header`, 
causes PCM use to go ballistic.

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


1 Files Affected:

- (modified) clang/lib/Lex/HeaderSearch.cpp (+9-1) 


``diff
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 0632882b296146..9409b97ba0e64a 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef 
HeaderSearch::LookupSubframeworkHeader(
 // File Info Management.
 
//===--===//
 
+static bool
+headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI,
+  ModuleMap::ModuleHeaderRole Role) {
+  return (HFI->isModuleHeader == ModuleMap::isModular(Role)) &&
+ (HFI->isTextualModuleHeader ==
+  ((Role & ModuleMap::TextualHeader) != 0));
+}
+
 static void mergeHeaderFileInfoModuleBits(HeaderFileInfo ,
   bool isModuleHeader,
   bool isTextualModuleHeader) {
@@ -1432,7 +1440,7 @@ void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
-if (HFI && HFI->isModuleHeader)
+if (HFI && headerFileInfoModuleBitsMatchRole(HFI, Role))
   return;
   }
 

``




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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-16 Thread Ian Anderson via cfe-commits

https://github.com/ian-twilightcoder created 
https://github.com/llvm/llvm-project/pull/89005

HeaderSearch::MarkFileModuleHeader is no longer properly checking for 
no-changes, and so creates a new HeaderFileInfo for every `textual header`, 
causes PCM use to go ballistic.

>From f45cb72cb9c70d714bdc071ac51dff1a5e11502b Mon Sep 17 00:00:00 2001
From: Ian Anderson 
Date: Tue, 16 Apr 2024 17:08:28 -0700
Subject: [PATCH] [clang][modules] HeaderSearch::MarkFileModuleHeader creates
 extra HeaderFileInfo, breaks PCM reuse

HeaderSearch::MarkFileModuleHeader is no longer properly checking for 
no-changes, and so creates a new HeaderFileInfo for every `textual header`, 
causes PCM use to go ballistic.
---
 clang/lib/Lex/HeaderSearch.cpp | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 0632882b296146..9409b97ba0e64a 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef 
HeaderSearch::LookupSubframeworkHeader(
 // File Info Management.
 
//===--===//
 
+static bool
+headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI,
+  ModuleMap::ModuleHeaderRole Role) {
+  return (HFI->isModuleHeader == ModuleMap::isModular(Role)) &&
+ (HFI->isTextualModuleHeader ==
+  ((Role & ModuleMap::TextualHeader) != 0));
+}
+
 static void mergeHeaderFileInfoModuleBits(HeaderFileInfo ,
   bool isModuleHeader,
   bool isTextualModuleHeader) {
@@ -1432,7 +1440,7 @@ void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
-if (HFI && HFI->isModuleHeader)
+if (HFI && headerFileInfoModuleBitsMatchRole(HFI, Role))
   return;
   }
 

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


[clang] [CMake][Release] Disable PGO (PR #88465)

2024-04-16 Thread Tom Stellard via cfe-commits

tstellar wrote:

PR is here: https://github.com/llvm/llvm-project/pull/89000

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


[clang] [ARM64EC] Fix arm_neon.h on ARM64EC. (PR #88572)

2024-04-16 Thread Eli Friedman via cfe-commits

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


[clang] 8c9f45e - [ARM64EC] Fix arm_neon.h on ARM64EC. (#88572)

2024-04-16 Thread via cfe-commits

Author: Eli Friedman
Date: 2024-04-16T17:08:02-07:00
New Revision: 8c9f45e2decbb68dbf83794f98291b53f59390f8

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

LOG: [ARM64EC] Fix arm_neon.h on ARM64EC. (#88572)

Since 97fe519d, in ARM64EC mode, we don't define `__aarch64__`. Fix
various preprocessor guards to account for this.

Added: 


Modified: 
clang/include/clang/Basic/arm_fp16.td
clang/include/clang/Basic/arm_neon.td
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_fp16.td 
b/clang/include/clang/Basic/arm_fp16.td
index cb2a09303e8e12..d36b4617bef5d2 100644
--- a/clang/include/clang/Basic/arm_fp16.td
+++ b/clang/include/clang/Basic/arm_fp16.td
@@ -14,7 +14,7 @@
 include "arm_neon_incl.td"
 
 // ARMv8.2-A FP16 intrinsics.
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "fullfp16" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"fullfp16" in {
 
   // Negate
   def VNEGSH  : SInst<"vneg", "11", "Sh">;

diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 7edac5afafaa99..6d655c39360d3b 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -605,11 +605,11 @@ def VQDMULL_LANE  : SOpInst<"vqdmull_lane", "(>Q)..I", 
"si", OP_QDMULL_LN>;
 def VQDMULH_N : SOpInst<"vqdmulh_n", "..1", "siQsQi", OP_QDMULH_N>;
 def VQRDMULH_N: SOpInst<"vqrdmulh_n", "..1", "siQsQi", OP_QRDMULH_N>;
 
-let ArchGuard = "!defined(__aarch64__)" in {
+let ArchGuard = "!defined(__aarch64__) && !defined(__arm64ec__)" in {
 def VQDMULH_LANE  : SOpInst<"vqdmulh_lane", "..qI", "siQsQi", OP_QDMULH_LN>;
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
-let ArchGuard = "defined(__aarch64__)" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)" in {
 def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
 def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
@@ -686,7 +686,7 @@ multiclass REINTERPRET_CROSS_TYPES {
 
 // E.3.31 Vector reinterpret cast operations
 def VREINTERPRET : 
REINTERPRET_CROSS_SELF<"csilUcUsUiUlhfPcPsQcQsQiQlQUcQUsQUiQUlQhQfQPcQPs"> {
-  let ArchGuard = "!defined(__aarch64__)";
+  let ArchGuard = "!defined(__aarch64__) && !defined(__arm64ec__)";
   let BigEndianSafe = 1;
 }
 
@@ -714,7 +714,7 @@ def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">;
 

 // AArch64 Intrinsics
 
-let ArchGuard = "defined(__aarch64__)" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)" in {
 
 

 // Load/Store
@@ -1091,14 +1091,14 @@ let isLaneQ = 1 in {
 def VQDMULH_LANEQ  : SInst<"vqdmulh_laneq", "..QI", "siQsQi">;
 def VQRDMULH_LANEQ : SInst<"vqrdmulh_laneq", "..QI", "siQsQi">;
 }
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "v8.1a" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"v8.1a" in {
 def VQRDMLAH_LANEQ : SOpInst<"vqrdmlah_laneq", "...QI", "siQsQi", 
OP_QRDMLAH_LN> {
   let isLaneQ = 1;
 }
 def VQRDMLSH_LANEQ : SOpInst<"vqrdmlsh_laneq", "...QI", "siQsQi", 
OP_QRDMLSH_LN> {
   let isLaneQ = 1;
 }
-} // ArchGuard = "defined(__aarch64__)", TargetGuard = "v8.1a"
+} // ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"v8.1a"
 
 // Note: d type implemented by SCALAR_VMULX_LANE
 def VMULX_LANE : IOpInst<"vmulx_lane", "..qI", "fQfQd", OP_MULX_LN>;
@@ -1143,7 +1143,7 @@ def SHA256H2 : SInst<"vsha256h2", "", "QUi">;
 def SHA256SU1 : SInst<"vsha256su1", "", "QUi">;
 }
 
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "sha3" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"sha3" in {
 def BCAX : SInst<"vbcax", "", "QUcQUsQUiQUlQcQsQiQl">;
 def EOR3 : SInst<"veor3", "", "QUcQUsQUiQUlQcQsQiQl">;
 def RAX1 : SInst<"vrax1", "...", "QUl">;
@@ -1153,14 +1153,14 @@ def XAR :  SInst<"vxar", "...I", "QUl">;
 }
 }
 
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "sha3" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"sha3" in {
 def SHA512SU0 : SInst<"vsha512su0", "...", "QUl">;
 def SHA512su1 : SInst<"vsha512su1", "", "QUl">;
 def SHA512H : SInst<"vsha512h", "", "QUl">;
 def SHA512H2 : SInst<"vsha512h2", "", "QUl">;
 }
 
-let ArchGuard = "defined(__aarch64__)", TargetGuard = "sm4" in {
+let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = 
"sm4" in {
 def SM3SS1 : SInst<"vsm3ss1", "", "QUi">;
 def SM3TT1A : SInst<"vsm3tt1a", "I", "QUi">;
 def SM3TT1B 

[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

A new memory leak https://lab.llvm.org/buildbot/#/builders/5/builds/42694

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


[clang] [llvm] [RISCV] Support Zama16b1p0 (PR #88474)

2024-04-16 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #83124)

2024-04-16 Thread via cfe-commits

Sterling-Augustine wrote:

Unless the original test was subtly broken, the forward fix in 
0a789ea8a829da345e46d8224d73b2ddaba6969f seems erroneous.

The forward fix changes the test to have a different declaration of `new`. But 
I would not expect this original change to require source-code level changes. 
Or was that intended?

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


[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)

2024-04-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Looks like automation didn't trigger for some reason... but quoting the 
automated message that's supposed to trigger:

> ⚠️ We detected that you are using a GitHub private e-mail address to 
> contribute to the repo.
> Please turn off [Keep my email addresses 
> private](https://github.com/settings/emails) setting in your account.
> See [LLVM 
> Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
>  for more information.

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)

2024-04-16 Thread Ian Anderson via cfe-commits


@@ -1403,94 +1421,146 @@ bool 
HeaderSearch::isFileMultipleIncludeGuarded(FileEntryRef File) const {
 void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 ModuleMap::ModuleHeaderRole Role,
 bool isCompilingModuleHeader) {
-  bool isModularHeader = ModuleMap::isModular(Role);
-
   // Don't mark the file info as non-external if there's nothing to change.
   if (!isCompilingModuleHeader) {
-if (!isModularHeader)
+if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
 if (HFI && HFI->isModuleHeader)
   return;
   }
 
   auto  = getFileInfo(FE);
-  HFI.isModuleHeader |= isModularHeader;
+  HFI.mergeModuleMembership(Role);
   HFI.isCompilingModuleHeader |= isCompilingModuleHeader;

ian-twilightcoder wrote:

Ohhh. So I need to be checking the `getExistingFileInfo` to see if 
`isModuleHeader` and `isTextualModuleHeader` match the given `ModuleHeaderRole`?

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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Say you have:

```
int foo();
struct A { A(); A(const A&, int = foo()); };
struct B { A a[10]; };
void f(const B& b) { B bb = b; }
```

We want to visit the call to foo(), I think?

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


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-16 Thread Jan Svoboda via cfe-commits


@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor ,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor , Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

jansvoboda11 wrote:

I wasn't aware that you're passing unused module map files to the compiler. In 
that case I can introduce a separate flag to control this functionality and 
only disable the computation of affecting module maps for our flavor of 
explicit modules where this is a no-op. Sounds good?

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


[clang] [clang-cl] [Driver] Fix clang-cl driver supported colon options (PR #88216)

2024-04-16 Thread Max Winkler via cfe-commits

MaxEW707 wrote:

> Thank you for polishing this corner of the driver interface! It's interesting 
> that they have an alternative separate spelling. I always felt like the 
> /Fopath.cpp pattern was a bit unreadable.

Thanks for the review. I will need you to commit on my behalf. I think its 
about time I figure out what conditions I need to meet in-order to get commit 
after approval rights.

`/Fopath.cpp` is super unreadable. Unfortunately, I don't remember when the 
colon spelling came into existence but anything from VS2017 definitely has the 
colon alternative spelling.

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-16 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast commented:

See inline comments for rationale re: scoping to LD -> IE only (and not 
performing IE -> LD).

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-16 Thread Hubert Tong via cfe-commits


@@ -3362,6 +3362,64 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue 
Op,
   return LowerGlobalTLSAddressLinux(Op, DAG);
 }
 
+/// updateForAIXShLibTLSModelOpt - Helper to initialize TLS model opt settings,
+/// and then apply the update.
+static void updateForAIXShLibTLSModelOpt(TLSModel::Model ,
+ SelectionDAG ,
+ const TargetMachine ) {
+  // Initialize TLS model opt setting lazily:
+  // (1) Use initial-exec for single TLS var references within current 
function.
+  // (2) Use local-dynamic for multiple TLS var references within current
+  // function.
+  PPCFunctionInfo *FuncInfo =
+  DAG.getMachineFunction().getInfo();
+  if (!FuncInfo->isAIXFuncUseInitDone()) {
+SmallPtrSet TLSGV;
+// Iterate over all instructions within current function, collect all TLS
+// global variables (global variables taken as the first parameter to
+// Intrinsic::threadlocal_address).
+const Function  = DAG.getMachineFunction().getFunction();
+for (Function::const_iterator BI = Func.begin(), BE = Func.end(); BI != BE;
+ ++BI)
+  for (BasicBlock::const_iterator II = BI->begin(), IE = BI->end();
+   II != IE; ++II)
+if (II->getOpcode() == Instruction::Call)
+  if (const CallInst *CI = dyn_cast(&*II))
+if (Function *CF = CI->getCalledFunction())
+  if (CF->isDeclaration() &&
+  CF->getIntrinsicID() == Intrinsic::threadlocal_address)
+if (const GlobalValue *GV =
+dyn_cast(II->getOperand(0))) {
+  TLSModel::Model GVModel = TM.getTLSModel(GV);
+  if (GVModel == TLSModel::InitialExec ||

hubert-reinterpretcast wrote:

We should only count the number of `local-dynamic` accesses.

Rationale:
The option can be taken as providing the information that the shared object is 
loaded with the executable (not `dlopen`ed later). In that case, all variables 
accessed using the `local-dynamic` model can be accessed using `initial-exec`; 
however, there would still be variables accessed using `initial-exec` that 
cannot be accessed using `local-dynamic`.

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-16 Thread Hubert Tong via cfe-commits


@@ -3362,6 +3362,64 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue 
Op,
   return LowerGlobalTLSAddressLinux(Op, DAG);
 }
 
+/// updateForAIXShLibTLSModelOpt - Helper to initialize TLS model opt settings,
+/// and then apply the update.
+static void updateForAIXShLibTLSModelOpt(TLSModel::Model ,
+ SelectionDAG ,
+ const TargetMachine ) {
+  // Initialize TLS model opt setting lazily:
+  // (1) Use initial-exec for single TLS var references within current 
function.
+  // (2) Use local-dynamic for multiple TLS var references within current
+  // function.
+  PPCFunctionInfo *FuncInfo =
+  DAG.getMachineFunction().getInfo();
+  if (!FuncInfo->isAIXFuncUseInitDone()) {
+SmallPtrSet TLSGV;
+// Iterate over all instructions within current function, collect all TLS
+// global variables (global variables taken as the first parameter to
+// Intrinsic::threadlocal_address).
+const Function  = DAG.getMachineFunction().getFunction();
+for (Function::const_iterator BI = Func.begin(), BE = Func.end(); BI != BE;
+ ++BI)
+  for (BasicBlock::const_iterator II = BI->begin(), IE = BI->end();
+   II != IE; ++II)
+if (II->getOpcode() == Instruction::Call)
+  if (const CallInst *CI = dyn_cast(&*II))
+if (Function *CF = CI->getCalledFunction())
+  if (CF->isDeclaration() &&
+  CF->getIntrinsicID() == Intrinsic::threadlocal_address)
+if (const GlobalValue *GV =
+dyn_cast(II->getOperand(0))) {
+  TLSModel::Model GVModel = TM.getTLSModel(GV);
+  if (GVModel == TLSModel::InitialExec ||
+  GVModel == TLSModel::LocalDynamic)
+TLSGV.insert(GV);
+}
+
+unsigned TLSGVCnt = TLSGV.size();
+LLVM_DEBUG(dbgs() << format("TLSGV count:%d\n", TLSGVCnt));
+if (TLSGVCnt == 1)
+  FuncInfo->setAIXFuncUseTLSIE();
+else if (TLSGVCnt > 1)
+  FuncInfo->setAIXFuncUseTLSLD();

hubert-reinterpretcast wrote:

We should need to set only one thing (to represent "use IE instead of LD"). The 
threshold number should not be repeated in more than one place.

Additionally, the threshold number may need to be increased (tests via 
experiments).

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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-16 Thread Hubert Tong via cfe-commits

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


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-16 Thread Richard Smith via cfe-commits


@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor ,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor , Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

zygoloid wrote:

Hm, I see that adding this check was the whole point of the patch. I don't 
think this works -- it's not feasible for the build system to know whether a 
module map file would affect a compilation or not.

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


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-16 Thread Richard Smith via cfe-commits


@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor ,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor , Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;

zygoloid wrote:

I don't think this is correct -- we can know about non-affecting module map 
files because they were specified on the command line using 
`-fmodule-map-file=` and either weren't actually used or (as happens in our 
case) we got the same information from a PCM file and so didn't need the module 
map file.

I think this check is a regression; can it be removed?

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)

2024-04-16 Thread Richard Smith via cfe-commits


@@ -1403,94 +1421,146 @@ bool 
HeaderSearch::isFileMultipleIncludeGuarded(FileEntryRef File) const {
 void HeaderSearch::MarkFileModuleHeader(FileEntryRef FE,
 ModuleMap::ModuleHeaderRole Role,
 bool isCompilingModuleHeader) {
-  bool isModularHeader = ModuleMap::isModular(Role);
-
   // Don't mark the file info as non-external if there's nothing to change.
   if (!isCompilingModuleHeader) {
-if (!isModularHeader)
+if ((Role & ModuleMap::ExcludedHeader))
   return;
 auto *HFI = getExistingFileInfo(FE);
 if (HFI && HFI->isModuleHeader)
   return;
   }
 
   auto  = getFileInfo(FE);
-  HFI.isModuleHeader |= isModularHeader;
+  HFI.mergeModuleMembership(Role);
   HFI.isCompilingModuleHeader |= isCompilingModuleHeader;

zygoloid wrote:

It looks to me like we're now calling `getFileInfo(FE)` even in cases where the 
info doesn't change, for a textual header. I think that's what's causing the 
regression we're seeing -- we're now considering a repeatedly-used module map 
file to be affecting, even though it isn't, because we end up with a local 
`HeaderFileInfo` instead of an imported one.

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


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #88902)

2024-04-16 Thread Nico Weber via cfe-commits


@@ -1,5 +1,5 @@
-// RUN: %clang -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
-// Issue no: 41441
+// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm 
-o - %s | FileCheck %s
+
 #include 

nico wrote:

Thanks!

https://github.com/llvm/llvm-project/pull/88902
___
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] Add new check `modernize-use-designated-initializers` (PR #80541)

2024-04-16 Thread Sam McCall via cfe-commits
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= ,
Danny =?utf-8?q?Mösch?= 
Message-ID:
In-Reply-To: 


sam-mccall wrote:

TL;DR: sounds like I should revert the removals/deps in clangd, and let you 
decide how to structure clang-tidy's copy of the code?

`tidy::utils` as a dep has a conceptual layering problem, and a few practical 
ones: it brings in a pile of dependencies that aren't otherwise in the no-tidy 
build (effect: much longer build times), and it sets the wrong expectations 
around performance: that meeting the batch-latency requirements of clang-tidy 
is sufficient, rather than the interactive-latency requirements of clangd. (Not 
a theoretical concern: clangd's *deliberate* deps on clang-tidy have had 
multiple unacceptable performance regressions in the past, which is the cost of 
taking the dep, but not one that needs paying here).

> This were main reason, why it were avoided, as there were no unit tests for 
> this code on clangd side.

This wasn't a library in its own right on the clangd side. If it's a library 
with multiple clients, it needs tests so problems with the library can be 
distinguished from problems with the clients. (I think it would have been nice 
to have fine-grained unittests anyway, but we didn't).

> Why is it such a big deal that a revert needs to be considered?

It's not a big deal, but I thought the most likely fix was to move this into a 
separate library with tests, I wasn't sure if anyone wanted to take that on in 
a hurry, and wanted to get back to a good state.

If tidy owners are happier with just cloning the code, I can revert just the 
changes to clangd.

I would suggest moving the code out out tidy/utils and into the check if that's 
the only place it's going to be tested, but that's up to you.

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


[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)

2024-04-16 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/88595

>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 1/4] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/test/Sema/format-strings-scanf.c   | 2 +-
 clang/test/Sema/format-strings-signedness.c  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774d2b53a38252..4ba27d62208da4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning<
 def warn_format_conversion_argument_type_mismatch : Warning<
   "format specifies type %0 but the argument has "
   "%select{type|underlying type}2 %1">,
-  InGroup;
+  InGroup;
 def warn_format_conversion_argument_type_mismatch_pedantic : Extension<
   warn_format_conversion_argument_type_mismatch.Summary>,
   InGroup;
@@ -9840,7 +9840,7 @@ def 
warn_format_conversion_argument_type_mismatch_confusion : Warning<
 def warn_format_argument_needs_cast : Warning<
   "%select{values of type|enum values with underlying type}2 '%0' should not "
   "be used as format arguments; add an explicit cast to %1 instead">,
-  InGroup;
+  InGroup;
 def warn_format_argument_needs_cast_pedantic : Warning<
   warn_format_argument_needs_cast.Summary>,
   InGroup, DefaultIgnore;
diff --git a/clang/test/Sema/format-strings-scanf.c 
b/clang/test/Sema/format-strings-scanf.c
index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644
--- a/clang/test/Sema/format-strings-scanf.c
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 
-Wno-format-pedantic %s
 
 #include 
 typedef __SIZE_TYPE__ size_t;
diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index d5a8140d9ef8a0..ccd4d72c2d2635 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -12,8 +12,8 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
 // Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify=okay %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify=okay %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
 
 int printf(const char *restrict format, ...);
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) {
 void test_suppress(int x)
 {
 #pragma GCC diagnostic ignored "-Wformat"
-printf("%u", x);
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
 }

>From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 2/4] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.

Fixes #81647
---
 clang/test/Sema/format-strings-signedness.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index ccd4d72c2d2635..a06884cb9fe090 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -11,7 +11,7 @@
 // (gcc compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
-// Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
+// Verify that -Wformat-signedness with -Wno-format are still reported (gcc 
compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
@@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) {
   printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning
 }
 
-// Verify that we can suppress a -Wformat-signedness warning by ignoring
+// Verify that we can not suppress a -Wformat-signedness warning by ignoring
 // -Wformat (gcc compat).
 void 

[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)

2024-04-16 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/88595

>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 1/3] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/test/Sema/format-strings-scanf.c   | 2 +-
 clang/test/Sema/format-strings-signedness.c  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774d2b53a38252..4ba27d62208da4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning<
 def warn_format_conversion_argument_type_mismatch : Warning<
   "format specifies type %0 but the argument has "
   "%select{type|underlying type}2 %1">,
-  InGroup;
+  InGroup;
 def warn_format_conversion_argument_type_mismatch_pedantic : Extension<
   warn_format_conversion_argument_type_mismatch.Summary>,
   InGroup;
@@ -9840,7 +9840,7 @@ def 
warn_format_conversion_argument_type_mismatch_confusion : Warning<
 def warn_format_argument_needs_cast : Warning<
   "%select{values of type|enum values with underlying type}2 '%0' should not "
   "be used as format arguments; add an explicit cast to %1 instead">,
-  InGroup;
+  InGroup;
 def warn_format_argument_needs_cast_pedantic : Warning<
   warn_format_argument_needs_cast.Summary>,
   InGroup, DefaultIgnore;
diff --git a/clang/test/Sema/format-strings-scanf.c 
b/clang/test/Sema/format-strings-scanf.c
index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644
--- a/clang/test/Sema/format-strings-scanf.c
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 
-Wno-format-pedantic %s
 
 #include 
 typedef __SIZE_TYPE__ size_t;
diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index d5a8140d9ef8a0..ccd4d72c2d2635 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -12,8 +12,8 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
 // Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify=okay %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify=okay %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
 
 int printf(const char *restrict format, ...);
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) {
 void test_suppress(int x)
 {
 #pragma GCC diagnostic ignored "-Wformat"
-printf("%u", x);
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
 }

>From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 2/3] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.

Fixes #81647
---
 clang/test/Sema/format-strings-signedness.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index ccd4d72c2d2635..a06884cb9fe090 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -11,7 +11,7 @@
 // (gcc compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
-// Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
+// Verify that -Wformat-signedness with -Wno-format are still reported (gcc 
compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
@@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) {
   printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning
 }
 
-// Verify that we can suppress a -Wformat-signedness warning by ignoring
+// Verify that we can not suppress a -Wformat-signedness warning by ignoring
 // -Wformat (gcc compat).
 void 

[clang] Allow struct q{int q;~q();} (#88597) (PR #88673)

2024-04-16 Thread via cfe-commits

https://github.com/nabijaczleweli updated 
https://github.com/llvm/llvm-project/pull/88673

From 05545c8cc2ef2751128f1906933151fb09e37b65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= 
Date: Mon, 15 Apr 2024 03:52:50 +0200
Subject: [PATCH 1/2] Allow struct q{int q;~q();} (#88597)

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 --
 clang/lib/Sema/SemaExprCXX.cpp   | 5 ++---
 clang/test/CXX/class/class.mem/p13.cpp   | 1 -
 clang/test/SemaCXX/GH59446.cpp   | 1 -
 clang/test/SemaCXX/constructor.cpp   | 5 ++---
 5 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5ec0218aedfe86..c8c3f2de81f82a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2187,8 +2187,6 @@ def err_undeclared_destructor_name : Error<
   "undeclared identifier %0 in destructor name">;
 def err_destructor_name : Error<
   "expected the class name after '~' to name the enclosing class">;
-def err_destructor_name_nontype : Error<
-  "identifier %0 after '~' in destructor name does not name a type">;
 def err_destructor_expr_mismatch : Error<
   "identifier %0 in object destruction expression does not name the type "
   "%1 of the object being destroyed">;
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 25f23a3abf1718..69d4a6d51ecafb 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -448,9 +448,8 @@ ParsedType Sema::getDestructorName(const IdentifierInfo ,
   Diag(NameLoc, diag::err_destructor_expr_nontype)
   <<  << MakeFixItHint();
 }
-  } else {
-Diag(NameLoc, SearchType.isNull() ? diag::err_destructor_name_nontype
-  : diag::err_destructor_expr_mismatch)
+  } else if (!SearchType.isNull()) {
+Diag(NameLoc, diag::err_destructor_expr_mismatch)
 <<  << SearchType << MakeFixItHint();
   }
 
diff --git a/clang/test/CXX/class/class.mem/p13.cpp 
b/clang/test/CXX/class/class.mem/p13.cpp
index d947586c419400..1a3173ddfa474c 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -112,5 +112,4 @@ template struct Dtemplate_with_ctors : B {
 template struct CtorDtorName : B {
   using B::CtorDtorName; // expected-error {{member 'CtorDtorName' has the 
same name as its class}} expected-note {{non-type declaration found by 
destructor name lookup}}
   CtorDtorName();
-  ~CtorDtorName(); // expected-error {{identifier 'CtorDtorName' after '~' in 
destructor name does not name a type}}
 };
diff --git a/clang/test/SemaCXX/GH59446.cpp b/clang/test/SemaCXX/GH59446.cpp
index b85a57abb9fa57..c0c1c40265f8be 100644
--- a/clang/test/SemaCXX/GH59446.cpp
+++ b/clang/test/SemaCXX/GH59446.cpp
@@ -8,5 +8,4 @@ namespace N {
   }
   void f(X *x) { // expected-error {{no template named 'X'; did you mean 
'N::X'}}
 x->N::X::~X(); // expected-error 2 {{implicit instantiation of 
undefined template 'GH59446::N::X'}}
-// expected-error@-1 {{identifier 'X' after '~' in 
destructor name does not name a type}}
 } // expected-error {{expected '}'}}
diff --git a/clang/test/SemaCXX/constructor.cpp 
b/clang/test/SemaCXX/constructor.cpp
index abd7dbe18a0e6a..64683675805924 100644
--- a/clang/test/SemaCXX/constructor.cpp
+++ b/clang/test/SemaCXX/constructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 typedef int INT;
 
 class Foo {
@@ -14,7 +14,7 @@ class Foo {
   static Foo(short, short); // expected-error{{constructor cannot be declared 
'static'}}
   virtual Foo(double); // expected-error{{constructor cannot be declared 
'virtual'}}
   Foo(long) const; // expected-error{{'const' qualifier is not allowed on a 
constructor}}
-  
+
   int Foo(int, int); // expected-error{{constructor cannot have a return type}}
 
   volatile Foo(float); // expected-error{{constructor cannot have a return 
type}}
@@ -94,5 +94,4 @@ namespace PR38286 {
   template struct B;
   template void B::f() {} // expected-error {{out-of-line 
definition of 'f' from class 'B'}}
   template struct C; // expected-note {{non-type declaration found}}
-  template C::~C() {} // expected-error {{identifier 'C' after 
'~' in destructor name does not name a type}}
 }

From 0d8b4fe52595db3c43d3fbc4039c7965c05f3ac3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= 
Date: Wed, 17 Apr 2024 00:37:35 +0200
Subject: [PATCH 2/2] ?

---
 clang/test/CXX/class/class.mem/p13.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CXX/class/class.mem/p13.cpp 
b/clang/test/CXX/class/class.mem/p13.cpp
index 1a3173ddfa474c..afccdc57114a12 100644
--- a/clang/test/CXX/class/class.mem/p13.cpp
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -110,6 +110,6 @@ template 

[clang] Carving out -Wformat warning about scoped enums into a subwarning (PR #88595)

2024-04-16 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/88595

>From 29d2d19c9dea9e3f818a34c97f95bd7c93b9433b Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 1/2] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 ++--
 clang/test/Sema/format-strings-scanf.c   | 2 +-
 clang/test/Sema/format-strings-signedness.c  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774d2b53a38252..4ba27d62208da4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9827,7 +9827,7 @@ def warn_scanf_nonzero_width : Warning<
 def warn_format_conversion_argument_type_mismatch : Warning<
   "format specifies type %0 but the argument has "
   "%select{type|underlying type}2 %1">,
-  InGroup;
+  InGroup;
 def warn_format_conversion_argument_type_mismatch_pedantic : Extension<
   warn_format_conversion_argument_type_mismatch.Summary>,
   InGroup;
@@ -9840,7 +9840,7 @@ def 
warn_format_conversion_argument_type_mismatch_confusion : Warning<
 def warn_format_argument_needs_cast : Warning<
   "%select{values of type|enum values with underlying type}2 '%0' should not "
   "be used as format arguments; add an explicit cast to %1 instead">,
-  InGroup;
+  InGroup;
 def warn_format_argument_needs_cast_pedantic : Warning<
   warn_format_argument_needs_cast.Summary>,
   InGroup, DefaultIgnore;
diff --git a/clang/test/Sema/format-strings-scanf.c 
b/clang/test/Sema/format-strings-scanf.c
index eb5b8ec36bf7a4..9bdc46bfeebc3b 100644
--- a/clang/test/Sema/format-strings-scanf.c
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat-nonliteral %s
 
 // Test that -Wformat=0 works:
-// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -Werror -Wformat=0 
-Wno-format-pedantic %s
 
 #include 
 typedef __SIZE_TYPE__ size_t;
diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index d5a8140d9ef8a0..ccd4d72c2d2635 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -12,8 +12,8 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
 // Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify=okay %s
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify=okay %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
 
 int printf(const char *restrict format, ...);
@@ -218,5 +218,5 @@ void test_printf_unsigned_priX16(uint16_t x) {
 void test_suppress(int x)
 {
 #pragma GCC diagnostic ignored "-Wformat"
-printf("%u", x);
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
 }

>From 46e8d902d92b71e9bad2321321eed3de489e837f Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Sat, 13 Apr 2024 00:53:38 +
Subject: [PATCH 2/2] Carving out -Wformat warning about scoped enums into a
 subwarning

Make it part of -Wformat-pedantic.

Fixes #81647
---
 clang/test/Sema/format-strings-signedness.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Sema/format-strings-signedness.c 
b/clang/test/Sema/format-strings-signedness.c
index ccd4d72c2d2635..a06884cb9fe090 100644
--- a/clang/test/Sema/format-strings-signedness.c
+++ b/clang/test/Sema/format-strings-signedness.c
@@ -11,7 +11,7 @@
 // (gcc compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -Wformat 
-verify=okay %s
 
-// Verify that -Wformat-signedness with -Wno-format are not reported (gcc 
compat).
+// Verify that -Wformat-signedness with -Wno-format are still reported (gcc 
compat).
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wformat-signedness -Wno-format -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only 
-Wno-format -Wformat-signedness -verify %s
 // okay-no-diagnostics
@@ -213,7 +213,7 @@ void test_printf_unsigned_priX16(uint16_t x) {
   printf("PRIX16: %" "X" /*PRIX16*/ "\n", x); // no-warning
 }
 
-// Verify that we can suppress a -Wformat-signedness warning by ignoring
+// Verify that we can not suppress a -Wformat-signedness warning by ignoring
 // -Wformat (gcc compat).
 void 

[clang] [compiler-rt] [llvm] [FMV] Remove useless features according the latest ACLE spec. (PR #88965)

2024-04-16 Thread Jon Roelofs via cfe-commits


@@ -67,57 +67,42 @@ enum CPUFeatures {
   FEAT_FP,
   FEAT_SIMD,
   FEAT_CRC,
-  FEAT_SHA1,
   FEAT_SHA2,
   FEAT_SHA3,
   FEAT_AES,
-  FEAT_PMULL,
   FEAT_FP16,
-  FEAT_DIT,
   FEAT_DPB,
   FEAT_DPB2,
   FEAT_JSCVT,
   FEAT_FCMA,
   FEAT_RCPC,
   FEAT_RCPC2,
   FEAT_FRINTTS,
-  FEAT_DGH,
   FEAT_I8MM,
   FEAT_BF16,
-  FEAT_EBF16,
   FEAT_RPRES,
   FEAT_SVE,
-  FEAT_SVE_BF16,
-  FEAT_SVE_EBF16,
-  FEAT_SVE_I8MM,
   FEAT_SVE_F32MM,
   FEAT_SVE_F64MM,
   FEAT_SVE2,
   FEAT_SVE_AES,
-  FEAT_SVE_PMULL128,
   FEAT_SVE_BITPERM,
   FEAT_SVE_SHA3,
   FEAT_SVE_SM4,
   FEAT_SME,
   FEAT_MEMTAG,
-  FEAT_MEMTAG2,
-  FEAT_MEMTAG3,
   FEAT_SB,
   FEAT_PREDRES,
   FEAT_SSBS,
-  FEAT_SSBS2,
-  FEAT_BTI,
   FEAT_LS64,
-  FEAT_LS64_V,
-  FEAT_LS64_ACCDATA,
   FEAT_WFXT,
   FEAT_SME_F64,
   FEAT_SME_I64,
   FEAT_SME2,
   FEAT_RCPC3,
   FEAT_MOPS,
   FEAT_MAX,
-  FEAT_EXT = 62, // Reserved to indicate presence of additional features field

jroelofs wrote:

Did any implementation ship `__aarch64_cpu_features` in a way that would make 
this an ABI break? We (Apple) talked about putting these in libSystem, and now 
I am glad we did not. It's okay to change/reorder them if it is a private 
implementation detail between the compiler and compiler-rt that is shipped with 
it, but as soon as they're part of an ABI, this list must become append only.

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


[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)

2024-04-16 Thread Artem Chikin via cfe-commits

https://github.com/artemcm updated 
https://github.com/llvm/llvm-project/pull/88977

>From 04e826688a504e141f3407567616bcf5cce9e2cc Mon Sep 17 00:00:00 2001
From: Artem Chikin 
Date: Wed, 20 Dec 2023 10:56:42 -0800
Subject: [PATCH] [NFC] Parameterize Initialization of 'clang::CodeGenerator'
 on a TargetInfo instance which may differ from the one in the ASTContext

As per https://github.com/apple/swift/pull/65930, Swift compiler's built-in 
Clang instance may require to perform type-checking against one OS version and 
compilation/code-generation against an earlier version. This change allows 
Swift to configure it's built-in Clang code-generator with a custom 
'TargetInfo'.
---
 clang/include/clang/AST/ASTConsumer.h |  5 
 clang/lib/CodeGen/CodeGenModule.cpp   | 29 +--
 clang/lib/CodeGen/CodeGenModule.h |  3 +-
 clang/lib/CodeGen/ModuleBuilder.cpp   | 21 +-
 .../ObjectFilePCHContainerOperations.cpp  |  5 ++--
 5 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/clang/include/clang/AST/ASTConsumer.h 
b/clang/include/clang/AST/ASTConsumer.h
index ebcd8059284d8d..774d19565e57b0 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -26,6 +26,7 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
+  class TargetInfo;
 
 /// ASTConsumer - This is an abstract interface that should be implemented by
 /// clients that read ASTs.  This abstraction layer allows the client to be
@@ -46,6 +47,10 @@ class ASTConsumer {
   /// ASTContext.
   virtual void Initialize(ASTContext ) {}
 
+  /// Initialize - This is called to initialize the consumer, providing the
+  /// ASTContext.
+  virtual void Initialize(ASTContext , const TargetInfo 
) {}
+
   /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
   /// called by the parser to process every top-level Decl*.
   ///
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0c447b20cef40d..8380b71ababe5b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -333,14 +333,13 @@ CodeGenModule::CodeGenModule(ASTContext ,
  IntrusiveRefCntPtr FS,
  const HeaderSearchOptions ,
  const PreprocessorOptions ,
- const CodeGenOptions , llvm::Module ,
- DiagnosticsEngine ,
+ const CodeGenOptions , const TargetInfo ,
+ llvm::Module , DiagnosticsEngine ,
  CoverageSourceInfo *CoverageInfo)
 : Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
   PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
-  Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
-  VMContext(M.getContext()), Types(*this), VTables(*this),
-  SanitizerMD(new SanitizerMetadata(*this)) {
+  Target(CGTI), ABI(createCXXABI(*this)), VMContext(M.getContext()),
+  Types(*this), VTables(*this), SanitizerMD(new SanitizerMetadata(*this)) {
 
   // Initialize the type cache.
   llvm::LLVMContext  = M.getContext();
@@ -353,20 +352,18 @@ CodeGenModule::CodeGenModule(ASTContext ,
   BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
   FloatTy = llvm::Type::getFloatTy(LLVMContext);
   DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
-  PointerWidthInBits = C.getTargetInfo().getPointerWidth(LangAS::Default);
+  PointerWidthInBits = Target.getPointerWidth(LangAS::Default);
   PointerAlignInBytes =
-  C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(LangAS::Default))
+  C.toCharUnitsFromBits(Target.getPointerAlign(LangAS::Default))
   .getQuantity();
   SizeSizeInBytes =
-
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
-  IntAlignInBytes =
-C.toCharUnitsFromBits(C.getTargetInfo().getIntAlign()).getQuantity();
-  CharTy =
-llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getCharWidth());
-  IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
-  IntPtrTy = llvm::IntegerType::get(LLVMContext,
-C.getTargetInfo().getMaxPointerWidth());
-  Int8PtrTy = llvm::PointerType::get(LLVMContext, 0);
+  C.toCharUnitsFromBits(Target.getMaxPointerWidth()).getQuantity();
+  IntAlignInBytes = C.toCharUnitsFromBits(Target.getIntAlign()).getQuantity();
+  CharTy = llvm::IntegerType::get(LLVMContext, Target.getCharWidth());
+  IntTy = llvm::IntegerType::get(LLVMContext, Target.getIntWidth());
+  IntPtrTy = llvm::IntegerType::get(LLVMContext, Target.getMaxPointerWidth());
+  Int8PtrTy = Int8Ty->getPointerTo(0);
+  Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
   const llvm::DataLayout  = M.getDataLayout();
   AllocaInt8PtrTy =
   llvm::PointerType::get(LLVMContext, DL.getAllocaAddrSpace());
diff --git 

[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)

2024-04-16 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

Could you merge it please?

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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

Honestly, I'm not very familiar with code coverage technique, but it seems to 
me that only explicitly written code is relevant for that. "Common expression" 
is exactly the explicitly written part. "Subexpression" is an implicitly 
generated per-element initializer which refers to the "common expression" 
(hence, without this patch, the counters for the conditional operator from the 
test are duplicated despite it is executed only once per function call). Which 
observable drawbacks do you expect from not visiting the implicit parts of the 
initializer?

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


[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)

2024-04-16 Thread Ian Anderson via cfe-commits

ian-twilightcoder wrote:

+ @Bigcheese and @jansvoboda11 as I think they know this area of the code better

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)

2024-04-16 Thread Michael Buch via cfe-commits

Michael137 wrote:

Btw, as a follow-up to this patch should we check that this is compatible with 
dsymutil (i.e., running `dsymutil --verify`)? I suspect it might need a fixup 
(given LLDB doesn't even support this tag)

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)

2024-04-16 Thread Ian Anderson via cfe-commits

ian-twilightcoder wrote:

> To get back to my previous point about the semantics implemented by this 
> patch being unfortunate -- the upshot is that, now:
> 
> ```
> #include 
> #define NDEBUG
> #import 
> ```

It would be nice if we could make this work without modules too. `#pragma many` 
or something would do that, but I fear we'd have compatibility issues if we 
added a pragma that's only supported by clang to a bunch of system headers.

> This doesn't make sense: with modules disabled, everything is textual -- to 
> say that "textual header" in a modulemap should make a header somehow "more" 
> textual than the default non-modular behavior is weird.

With modules disabled, everything isn't textual - it's effectively excluded. 
`textual` was probably not the best name for that keyword in the module map.

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


[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)

2024-04-16 Thread Ian Anderson via cfe-commits

ian-twilightcoder wrote:

Wall of text incoming... Sorry but our documentation in this area is poor, so I 
feel like I need to spell out the assumptions behind this change.

First of all, this _should_ be a relatively minor change that should affect a 
very limited set of circumstances.
1. Only `#import` should be affected, not `#include`.
2. Only headers marked `textual header` in a module map should be affected, 
nothing else.
3. Headers that use `#pragma once` or have header guards should not be affected.
4. Module map reading should not be affected.

That should end up being a rather narrow change, and if something else got 
affected I'd like to know what and fix it.


`#import` is already treated differently if modules are enabled. This adds 
another case to the special treatment, but doesn't introduce that fact that 
sometimes `#import`ed headers will be re-entered when building with modules. We 
can say we don't like `#import` behaving differently when modules are enabled. 
However, it's not going to be any harder to undo this special treatment than it 
will to undo the other ones, if we ever care enough to try, so I don't think 
this is such an egregious change.

`textual header`s are already treated differently as well. To better define 
that, there are 4 different types of headers in a clang modules world.

1. Headers covered by a `header` statement in a module map - ye olde standard 
include-once header.
2. Headers covered by a `textual header` statement in a module map - usually 
headers that are intended to be included multiple times. Generally these are X 
macro generator headers, or special headers like  or clang's 
 and  which are designed to have different behavior based 
on the preprocessor environment of the includer.
3. Headers covered by an `exclude header` statement in a module map - headers 
that can't be used in a module. Sometimes these are just obsolete headers, and 
sometimes it's headers that have dependencies that can't be used in a module.
4. Headers that are not listed in any module map. These are essentially the 
same thing as excluded headers.

There's a semantic difference between textual and excluded headers. Textual 
headers are anointed to be safe to use in modules, and excluded headers are not 
supposed to be included from any modular header. (If I had my way, 
`-Wnon-modular-include-in-module` would default to an error much like 
`-Wmodule-import-in-extern-c` does, but that can be a soap box for another 
day.) Textual headers are already treated differently from excluded headers in 
a few ways, such as they respect `[no_undeclared_includes]`/`use`, while 
excluded headers don't.

All this to say that `#import`ed headers are already treated different when 
modules are enabled, and textual headers are already treated different than 
excluded headers. I think it's fine to tweak this different treatment, 
especially since it's solving a real world problem that occurs in a fully 
modularized system. I also think it's preferable to focus the change down to 
the very specific problem, which is `#import`ed textual headers, instead of 
trying to fix all of the submodule visibility problems we can think of.

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


[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)

2024-04-16 Thread Richard Smith via cfe-commits

zygoloid wrote:

Have you tried changing the behavior of the existing `-fmodule-map-file=` to 
load the file after we load module files? If so, what kinds of things do you 
see breaking or changing? If we can avoid it, I think it would be better to 
only have a single mode here, and loading the module files first seems to make 
a lot of sense given that they can make it unnecessary to load the module map 
files at all.

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)

2024-04-16 Thread Michael Buch via cfe-commits


@@ -1332,6 +1332,54 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
   auto PP = getPrintingPolicy();
   Ty->getTemplateName().print(OS, PP, TemplateName::Qualified::None);
 
+  SourceLocation Loc = AliasDecl->getLocation();
+
+  if (CGM.getCodeGenOpts().DebugTemplateAlias) {
+// TemplateSpecializationType doesn't know if its template args are
+// being substituted into a parameter pack. We can find out if that's
+// the case now by inspecting the TypeAliasTemplateDecl template
+// parameters. Insert Ty's template args into SpecArgs, bundling args
+// passed to a parameter pack into a TemplateArgument::Pack.
+SmallVector SpecArgs;
+{
+  ArrayRef SubstArgs = Ty->template_arguments();
+  for (const NamedDecl *P : TD->getTemplateParameters()->asArray()) {
+if (P->isParameterPack()) {
+  SpecArgs.push_back(TemplateArgument(SubstArgs));
+  break;
+}
+// Skip defaulted args.
+if (SubstArgs.empty()) {
+  // If SubstArgs is now empty (we're taking from it each iteration) 
and
+  // this template parameter isn't a pack, then that should mean we're
+  // using default values for the remaining template parameters.
+  break;

Michael137 wrote:

Does this mean we won't be emitting the defaulted template arguments as part of 
the `DW_TAG_template_alias`? Would be good to add a test case for defaulted 
arguments, so this logic is exercised (if you haven't already)

Also minor nit, is this logic getting sufficiently long to warrant a separate 
helper function?

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


[clang] d19bd05 - Clang Release Notes: Fix reST formatting

2024-04-16 Thread via cfe-commits

Author: Hubert Tong
Date: 2024-04-16T17:26:55-04:00
New Revision: d19bd05c79ad3b1a2c3cb439c3fc60825f66bed7

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

LOG: Clang Release Notes: Fix reST formatting

Fix a use of inline code markup to have a non-word character after the ending 
delimiter as required by reST.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e6c345a2f5c0f5..4aedfafcb26aea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -68,7 +68,7 @@ AST Dumping Potentially Breaking Changes
 
 Clang Frontend Potentially Breaking Changes
 ---
-- Removed support for constructing on-stack ``TemplateArgumentList``s; 
interfaces should instead
+- Removed support for constructing on-stack ``TemplateArgumentList``\ s; 
interfaces should instead
   use ``ArrayRef`` to pass template arguments. Transitioning 
internal uses to
   ``ArrayRef`` reduces AST memory usage by 0.4% when 
compiling clang, and is
   expected to show similar improvements on other workloads.



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


[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I don't think this works correctly?  You need to evaluate both the 
getCommonExpr(), and the getSubExpr().

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


[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)

2024-04-16 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

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


[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)

2024-04-16 Thread Michael Spencer via cfe-commits


@@ -26,123 +26,132 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
-
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext ) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. 
This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext ) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client 
to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(VarDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
-
-  /// Callback involved at the end of a translation unit to
-  /// notify the consumer that a vtable for the given C++ class is
-  /// required.
-  ///
-  /// \param RD The class whose vtable was used.
-  virtual void HandleVTable(CXXRecordDecl *RD) {}
-
-  /// If the consumer is interested in entities getting modified after
-  /// their initial creation, it should return a pointer to
-  /// an ASTMutationListener here.
-  virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
-
-  /// If the consumer is interested in entities being deserialized from
-  /// AST files, it should return a pointer to a ASTDeserializationListener 
here
-  virtual ASTDeserializationListener *GetASTDeserializationListener() {
-return nullptr;
-  }
-
-  /// PrintStats - If desired, print any statistics.
-  virtual void PrintStats() {}
-
-  /// This callback is called for each function if the 

[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)

2024-04-16 Thread Michael Spencer via cfe-commits


@@ -26,123 +26,132 @@ namespace clang {
   class VarDecl;
   class FunctionDecl;
   class ImportDecl;
-
-/// ASTConsumer - This is an abstract interface that should be implemented by
-/// clients that read ASTs.  This abstraction layer allows the client to be
-/// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
-class ASTConsumer {
-  /// Whether this AST consumer also requires information about
-  /// semantic analysis.
-  bool SemaConsumer = false;
-
-  friend class SemaConsumer;
-
-public:
-  ASTConsumer() = default;
-
-  virtual ~ASTConsumer() {}
-
-  /// Initialize - This is called to initialize the consumer, providing the
-  /// ASTContext.
-  virtual void Initialize(ASTContext ) {}
-
-  /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
-  /// called by the parser to process every top-level Decl*.
-  ///
-  /// \returns true to continue parsing, or false to abort parsing.
-  virtual bool HandleTopLevelDecl(DeclGroupRef D);
-
-  /// This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
-
-  /// HandleInterestingDecl - Handle the specified interesting declaration. 
This
-  /// is called by the AST reader when deserializing things that might interest
-  /// the consumer. The default implementation forwards to HandleTopLevelDecl.
-  virtual void HandleInterestingDecl(DeclGroupRef D);
-
-  /// HandleTranslationUnit - This method is called when the ASTs for entire
-  /// translation unit have been parsed.
-  virtual void HandleTranslationUnit(ASTContext ) {}
-
-  /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
-  /// (e.g. struct, union, enum, class) is completed.  This allows the client 
to
-  /// hack on the type, which can occur at any point in the file (because these
-  /// can be defined in declspecs).
-  virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
-  /// This callback is invoked the first time each TagDecl is required to
-  /// be complete.
-  virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {}
-
-  /// Invoked when a function is implicitly instantiated.
-  /// Note that at this point it does not have a body, its body is
-  /// instantiated at the end of the translation unit and passed to
-  /// HandleTopLevelDecl.
-  virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {}
-
-  /// Handle the specified top-level declaration that occurred inside
-  /// and ObjC container.
-  /// The default implementation ignored them.
-  virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D);
-
-  /// Handle an ImportDecl that was implicitly created due to an
-  /// inclusion directive.
-  /// The default implementation passes it to HandleTopLevelDecl.
-  virtual void HandleImplicitImportDecl(ImportDecl *D);
-
-  /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given tentative definition should be
-  /// completed.
-  ///
-  /// The variable declaration itself will be a tentative
-  /// definition. If it had an incomplete array type, its type will
-  /// have already been changed to an array of size 1. However, the
-  /// declaration remains a tentative definition and has not been
-  /// modified by the introduction of an implicit zero initializer.
-  virtual void CompleteTentativeDefinition(VarDecl *D) {}
-
-  /// CompleteExternalDeclaration - Callback invoked at the end of a 
translation
-  /// unit to notify the consumer that the given external declaration should be
-  /// completed.
-  virtual void CompleteExternalDeclaration(VarDecl *D) {}
-
-  /// Callback invoked when an MSInheritanceAttr has been attached to a
-  /// CXXRecordDecl.
-  virtual void AssignInheritanceModel(CXXRecordDecl *RD) {}
-
-  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this
-  // variable has been instantiated.
-  virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {}
-
-  /// Callback involved at the end of a translation unit to
-  /// notify the consumer that a vtable for the given C++ class is
-  /// required.
-  ///
-  /// \param RD The class whose vtable was used.
-  virtual void HandleVTable(CXXRecordDecl *RD) {}
-
-  /// If the consumer is interested in entities getting modified after
-  /// their initial creation, it should return a pointer to
-  /// an ASTMutationListener here.
-  virtual ASTMutationListener *GetASTMutationListener() { return nullptr; }
-
-  /// If the consumer is interested in entities being deserialized from
-  /// AST files, it should return a pointer to a ASTDeserializationListener 
here
-  virtual ASTDeserializationListener *GetASTDeserializationListener() {
-return nullptr;
-  }
-
-  /// PrintStats - If desired, print any statistics.
-  virtual void PrintStats() {}
-
-  /// This callback is called for each function if the 

[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)

2024-04-16 Thread Paul T Robinson via cfe-commits


@@ -310,6 +310,24 @@ namespace llvm {
  DINode::DIFlags Flags = DINode::FlagZero,
  DINodeArray Annotations = nullptr);
 
+/// Create debugging information entry for a template alias.
+/// \param Ty  Original type.
+/// \param NameAlias name.
+/// \param FileFile where this type is defined.
+/// \param LineNo  Line number.
+/// \param Context The surrounding context for the alias.
+/// \param TParams The template arguments.
+/// \param AlignInBits Alignment. (optional)
+/// \param Flags   Flags to describe inheritance attribute (optional),
+///e.g. private.

pogo59 wrote:

Flags is also (optional)

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


[clang] [llvm] [Clang] Emit DW_TAG_template_alias for template aliases (PR #87623)

2024-04-16 Thread Paul T Robinson via cfe-commits


@@ -465,3 +465,15 @@
 // MANGLED_TEMP_NAMES: error: unknown argument 
'-gsimple-template-names=mangled'; did you mean '-Xclang 
-gsimple-template-names=mangled'
 // RUN: %clang -### -target x86_64 -c -g %s 2>&1 | FileCheck 
--check-prefix=FULL_TEMP_NAMES 
--implicit-check-not=debug-forward-template-params %s
 // FULL_TEMP_NAMES-NOT: -gsimple-template-names
+
+ Test -g[no-]template-alias (enabled by default with SCE debugger tuning). 
Requires DWARFv5.
+// RUN: %clang -### -target x86_64 -c -gdwarf-5 -gsce %s 2>&1 | FileCheck %s 
--check-prefixes=TEMPLATE-ALIAS

pogo59 wrote:

Huh Coulda sworn that was changed... okay.

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


  1   2   3   4   5   >