[clang] 43b4e5b - Use pushFullExprCleanup for deferred destroy (#88670)

2024-04-15 Thread via cfe-commits

Author: Utkarsh Saxena
Date: 2024-04-15T21:30:18+02:00
New Revision: 43b4e5b9bff1719a6d3628a3a805cfeb59adaf16

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

LOG: Use pushFullExprCleanup for deferred destroy (#88670)

Instead of directly pushing the `Destroy`, we should use
`pushFullExprCleanup` which handles conditional branches.
This fixes a backend crash due to
89ba7e183e6e2c64370ed1b963e54c06352211db.

Added minimized crash reproducer.

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 8bdafa7c569b08..3f05ebb561da57 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2216,8 +2216,11 @@ void CodeGenFunction::pushDestroyAndDeferDeactivation(
 void CodeGenFunction::pushDestroyAndDeferDeactivation(
 CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer,
 bool useEHCleanupForArray) {
-  pushCleanupAndDeferDeactivation(
-  cleanupKind, addr, type, destroyer, useEHCleanupForArray);
+  llvm::Instruction *DominatingIP =
+  Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy));
+  pushDestroy(cleanupKind, addr, type, destroyer, useEHCleanupForArray);
+  DeferredDeactivationCleanupStack.push_back(
+  {EHStack.stable_begin(), DominatingIP});
 }
 
 void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) {

diff  --git a/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp 
b/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
index ffde1bd6a724d8..95deee8bb1f1f2 100644
--- a/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
+++ b/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 --std=c++20 -triple x86_64-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 --std=c++20 -fexceptions -triple x86_64-linux-gnu 
-emit-llvm %s -o - | FileCheck -check-prefixes=EH %s
+// RUN: %clang_cc1 --std=c++20 -triple x86_64-linux-gnu -emit-llvm %s -o - | 
FileCheck -check-prefixes=NOEH,CHECK %s
 
 struct Printy {
   Printy(const char *name) : name(name) {}
@@ -349,6 +350,34 @@ void NewArrayInit() {
   // CHECK-NEXT:br label %return
 }
 
+void DestroyInConditionalCleanup() {
+  // EH-LABEL: DestroyInConditionalCleanupv()
+  // NOEH-LABEL: DestroyInConditionalCleanupv()
+  struct A {
+A() {}
+~A() {}
+  };
+
+  struct Value {
+Value(A) {}
+~Value() {}
+  };
+
+  struct V2 {
+Value K;
+Value V;
+  };
+  // Verify we use conditional cleanups.
+  (void)(foo() ? V2{A(), A()} : V2{A(), A()});
+  // NOEH:   cond.true:
+  // NOEH:  call void @_ZZ27DestroyInConditionalCleanupvEN1AC1Ev
+  // NOEH:  store ptr %{{.*}}, ptr %cond-cleanup.save
+
+  // EH:   cond.true:
+  // EH:invoke void @_ZZ27DestroyInConditionalCleanupvEN1AC1Ev
+  // EH:store ptr %{{.*}}, ptr %cond-cleanup.save
+}
+
 void ArrayInitWithContinue() {
   // CHECK-LABEL: @_Z21ArrayInitWithContinuev
   // Verify that we start to emit the array destructor.



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


[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)

2024-04-15 Thread Utkarsh Saxena via cfe-commits

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


[clang] [CUDA] Rename SM_32 to SM_32_ to work around AIX headers (PR #88779)

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

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/88779

>From dbf6a86930207a4baa787c4387ab83d30524b2aa Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 15 Apr 2024 14:12:15 -0500
Subject: [PATCH] [CUDA] Rename SM_32 to _SM_32 to work around AIX headers

Summary:
AIX headers define this, so we need to work around it. In the future
this will be removed but for now we should just rename it to avoid these
issues.
---
 clang/include/clang/Basic/Cuda.h | 8 +++-
 clang/lib/Basic/Cuda.cpp | 6 +++---
 clang/lib/Basic/Targets/NVPTX.cpp| 2 +-
 clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 2 +-
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 38f30543a0f662..ba0e4465a0f5a0 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -50,17 +50,15 @@ const char *CudaVersionToString(CudaVersion V);
 // Input is "Major.Minor"
 CudaVersion CudaStringToVersion(const llvm::Twine &S);
 
-// We have a name conflict with sys/mac.h on AIX
-#ifdef SM_32
-#undef SM_32
-#endif
 enum class CudaArch {
   UNUSED,
   UNKNOWN,
+  // TODO: Deprecate and remove GPU architectures older than sm_52.
   SM_20,
   SM_21,
   SM_30,
-  SM_32,
+  // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
+  SM_32_,
   SM_35,
   SM_37,
   SM_50,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 1b1da6a1356f2c..113483db5729b0 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -86,7 +86,7 @@ static const CudaArchToStringMap arch_names[] = {
 // clang-format off
 {CudaArch::UNUSED, "", ""},
 SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
-SM(30), SM(32), SM(35), SM(37),  // Kepler
+SM(30), {CudaArch::SM_32_, "sm_32", "compute_32"}, SM(35), SM(37),  // 
Kepler
 SM(50), SM(52), SM(53),  // Maxwell
 SM(60), SM(61), SM(62),  // Pascal
 SM(70), SM(72),  // Volta
@@ -186,7 +186,7 @@ CudaVersion MinVersionForCudaArch(CudaArch A) {
   case CudaArch::SM_20:
   case CudaArch::SM_21:
   case CudaArch::SM_30:
-  case CudaArch::SM_32:
+  case CudaArch::SM_32_:
   case CudaArch::SM_35:
   case CudaArch::SM_37:
   case CudaArch::SM_50:
@@ -231,7 +231,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) {
   case CudaArch::SM_21:
 return CudaVersion::CUDA_80;
   case CudaArch::SM_30:
-  case CudaArch::SM_32:
+  case CudaArch::SM_32_:
 return CudaVersion::CUDA_102;
   case CudaArch::SM_35:
   case CudaArch::SM_37:
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index b47c399fef6042..8ad9e6e5f58916 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -239,7 +239,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 return "210";
   case CudaArch::SM_30:
 return "300";
-  case CudaArch::SM_32:
+  case CudaArch::SM_32_:
 return "320";
   case CudaArch::SM_35:
 return "350";
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 59ba03c6b86253..eb716520e5ff56 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3466,7 +3466,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
   case CudaArch::SM_20:
   case CudaArch::SM_21:
   case CudaArch::SM_30:
-  case CudaArch::SM_32:
+  case CudaArch::SM_32_:
   case CudaArch::SM_35:
   case CudaArch::SM_37:
   case CudaArch::SM_50:

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


[clang] [CUDA] Rename SM_32 to SM_32_ to work around AIX headers (PR #88779)

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


@@ -86,7 +88,7 @@ static const CudaArchToStringMap arch_names[] = {
 // clang-format off
 {CudaArch::UNUSED, "", ""},
 SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
-SM(30), SM(32), SM(35), SM(37),  // Kepler
+SM(30), SM3(32, "compute_32"), SM(35), SM(37),  // Kepler

jhuber6 wrote:

Didn't do it originally becausei tm ake the formatting a little awkward, but 
I'll change it.

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


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae created 
https://github.com/llvm/llvm-project/pull/88781

This patch adds documentation for the root signature in HLSL.

For issue #55116

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+ 

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Xiang Li (python3kgae)


Changes

This patch adds documentation for the root signature in HLSL.

For issue #55116

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


1 Files Affected:

- (added) clang/docs/HLSL/RootSignature.rst (+291) 


``diff
diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FL

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Xiang Li (python3kgae)


Changes

This patch adds documentation for the root signature in HLSL.

For issue #55116

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


1 Files Affected:

- (added) clang/docs/HLSL/RootSignature.rst (+291) 


``diff
diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLA

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

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


@@ -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" %t/missing_tu.c 2>%t/missing_tu.errs

benlangmuir wrote:

> Since the scanner is intended to be run on actual compilation jobs, I think 
> it's even desirable removing stuff like "-fsyntax-only".

Changing -fsyntax-only to -c would make sense then, but it's weird to me to 
have linker steps in scanning unless that's specifically what you're testing.  
Anyway, since this one fails before it gets there I guess it doesn't matter, 
but I wouldn't want to see tests defaulting to linking.

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] [Modules] No transitive source location change (PR #86912)

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


@@ -2220,33 +2221,40 @@ class ASTReader
 return Sema::AlignPackInfo::getFromRawEncoding(Raw);
   }
 
+  using RawLocEncoding = SourceLocationEncoding::RawLocEncoding;
+
   /// Read a source location from raw form and return it in its
   /// originating module file's source location space.
-  SourceLocation ReadUntranslatedSourceLocation(SourceLocation::UIntTy Raw,
-LocSeq *Seq = nullptr) const {
+  std::pair
+  ReadUntranslatedSourceLocation(RawLocEncoding Raw,
+ LocSeq *Seq = nullptr) const {
 return SourceLocationEncoding::decode(Raw, Seq);
   }
 
   /// Read a source location from raw form.
-  SourceLocation ReadSourceLocation(ModuleFile &ModuleFile,
-SourceLocation::UIntTy Raw,
-LocSeq *Seq = nullptr) const {
-SourceLocation Loc = ReadUntranslatedSourceLocation(Raw, Seq);
-return TranslateSourceLocation(ModuleFile, Loc);
+  SourceLocation ReadSourceLocation(ModuleFile &MF, RawLocEncoding Raw,
+   LocSeq *Seq = nullptr) const {
+if (!MF.ModuleOffsetMap.empty())
+  ReadModuleOffsetMap(MF);
+
+auto [Loc, ModuleFileIndex] = ReadUntranslatedSourceLocation(Raw, Seq);
+ModuleFile *OwningModuleFile =
+ModuleFileIndex ? MF.DependentModules[ModuleFileIndex - 1] : &MF;

jansvoboda11 wrote:

Since the type of `ModuleFileIndex` is not obvious due to `auto`, I suggest 
comparing it to `0` explicitly.

```suggestion
ModuleFileIndex == 0 ? &MF : MF.DependentModules[ModuleFileIndex - 1];
```

Or maybe the element at index `0` in `DependentModules` could be `MF` itself to 
simplify this further?

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


[clang] b03dc7d - [Clang] Properly set the value category of dependent unary operators (#88740)

2024-04-15 Thread via cfe-commits

Author: cor3ntin
Date: 2024-04-15T21:38:10+02:00
New Revision: b03dc7d16251bf249b67e4db545353551727f646

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

LOG: [Clang] Properly  set the value category of dependent unary operators 
(#88740)

This fixes an assertion in Expr::Classify when a
trying to deduce a dependent dereference operator.

Fixes #88329

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/over/over.built/ast.cpp
clang/test/SemaCXX/overloaded-operator.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index de5fa99bff5dbe..dc108785f6cc99 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -537,6 +537,7 @@ Bug Fixes to C++ Support
 - Clang now correctly tracks type dependence of by-value captures in lambdas 
with an explicit
   object parameter.
   Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), 
(#GH86398), and (#GH86399).
+- Fix a crash when deducing ``auto`` from an invalid dereference (#GH88329).
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 675eb6ec05e78e..227ef564ba3e08 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14395,9 +14395,16 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
   ArrayRef ArgsArray(Args, NumArgs);
 
   if (Input->isTypeDependent()) {
+ExprValueKind VK = ExprValueKind::VK_PRValue;
+// [C++26][expr.unary.op][expr.pre.incr]
+// The * operator yields an lvalue of type
+// The pre/post increment operators yied an lvalue.
+if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
+  VK = VK_LValue;
+
 if (Fns.empty())
-  return UnaryOperator::Create(Context, Input, Opc, Context.DependentTy,
-   VK_PRValue, OK_Ordinary, OpLoc, false,
+  return UnaryOperator::Create(Context, Input, Opc, Context.DependentTy, 
VK,
+   OK_Ordinary, OpLoc, false,
CurFPFeatureOverrides());
 
 CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators
@@ -14406,7 +14413,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 if (Fn.isInvalid())
   return ExprError();
 return CXXOperatorCallExpr::Create(Context, Op, Fn.get(), ArgsArray,
-   Context.DependentTy, VK_PRValue, OpLoc,
+   Context.DependentTy, VK, OpLoc,
CurFPFeatureOverrides());
   }
 

diff  --git a/clang/test/CXX/over/over.built/ast.cpp 
b/clang/test/CXX/over/over.built/ast.cpp
index f76606b1f9869a..56a63431269f30 100644
--- a/clang/test/CXX/over/over.built/ast.cpp
+++ b/clang/test/CXX/over/over.built/ast.cpp
@@ -4,11 +4,11 @@ struct A{};
 
 template 
 auto Test(T* pt, U* pu) {
-  // CHECK: UnaryOperator {{.*}} '' prefix '*'
+  // CHECK: UnaryOperator {{.*}} '' lvalue prefix '*'
   // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
   (void)*pt;
 
-  // CHECK: UnaryOperator {{.*}} '' prefix '++'
+  // CHECK: UnaryOperator {{.*}} '' lvalue prefix '++'
   // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
   (void)(++pt);
 

diff  --git a/clang/test/SemaCXX/overloaded-operator.cpp 
b/clang/test/SemaCXX/overloaded-operator.cpp
index 49311625d7ab2d..cab21d67a002fe 100644
--- a/clang/test/SemaCXX/overloaded-operator.cpp
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -682,3 +682,13 @@ namespace nw{
   }
 }
 #endif
+
+#if __cplusplus >= 201703L
+namespace GH88329 {
+
+template  struct A {};
+template  A<*T> operator *() { return {}; }
+// expected-error@-1 {{overloaded 'operator*' must have at least one parameter 
of class or enumeration type}}
+}
+
+#endif



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


[clang] [Clang] Properly set the value category of dependent unary operators (PR #88740)

2024-04-15 Thread via cfe-commits

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


[clang] [Modules] No transitive source location change (PR #86912)

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


@@ -2220,33 +2221,40 @@ class ASTReader
 return Sema::AlignPackInfo::getFromRawEncoding(Raw);
   }
 
+  using RawLocEncoding = SourceLocationEncoding::RawLocEncoding;
+
   /// Read a source location from raw form and return it in its
   /// originating module file's source location space.
-  SourceLocation ReadUntranslatedSourceLocation(SourceLocation::UIntTy Raw,
-LocSeq *Seq = nullptr) const {
+  std::pair
+  ReadUntranslatedSourceLocation(RawLocEncoding Raw,
+ LocSeq *Seq = nullptr) const {
 return SourceLocationEncoding::decode(Raw, Seq);
   }
 
   /// Read a source location from raw form.
-  SourceLocation ReadSourceLocation(ModuleFile &ModuleFile,
-SourceLocation::UIntTy Raw,
-LocSeq *Seq = nullptr) const {
-SourceLocation Loc = ReadUntranslatedSourceLocation(Raw, Seq);
-return TranslateSourceLocation(ModuleFile, Loc);
+  SourceLocation ReadSourceLocation(ModuleFile &MF, RawLocEncoding Raw,
+   LocSeq *Seq = nullptr) const {
+if (!MF.ModuleOffsetMap.empty())
+  ReadModuleOffsetMap(MF);
+
+auto [Loc, ModuleFileIndex] = ReadUntranslatedSourceLocation(Raw, Seq);
+ModuleFile *OwningModuleFile =
+ModuleFileIndex ? MF.DependentModules[ModuleFileIndex - 1] : &MF;
+return TranslateSourceLocation(*OwningModuleFile, Loc);
   }
 
   /// Translate a source location from another module file's source
   /// location space into ours.
   SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile,
  SourceLocation Loc) const {
-if (!ModuleFile.ModuleOffsetMap.empty())
-  ReadModuleOffsetMap(ModuleFile);
-assert(ModuleFile.SLocRemap.find(Loc.getOffset()) !=
-   ModuleFile.SLocRemap.end() &&
-   "Cannot find offset to remap.");
-SourceLocation::IntTy Remap =
-ModuleFile.SLocRemap.find(Loc.getOffset())->second;
-return Loc.getLocWithOffset(Remap);
+if (Loc.isInvalid())
+  return Loc;
+
+// It implies that the Loc is already translated.
+if (SourceMgr.isLoadedSourceLocation(Loc))
+  return Loc;

jansvoboda11 wrote:

How can we get here with a `SourceLocation` that's already been translated?

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


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/88781

>From 0065f8eade1fc00bce560ceeba9431a4616615b9 Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Mon, 15 Apr 2024 12:23:46 -0700
Subject: [PATCH 1/2] [Doc][HLSL] Add documentation for root signature

This patch adds documentation for the root signature in HLSL.

For issue #55116
---
 clang/docs/HLSL/RootSignature.rst | 291 ++
 1 file changed, 291 insertions(+)
 create mode 100644 clang/docs/HLSL/RootSignature.rst

diff --git a/clang/docs/HLSL/RootSignature.rst 
b/clang/docs/HLSL/RootSignature.rst
new file mode 100644
index 00..259e93463f59bf
--- /dev/null
+++ b/clang/docs/HLSL/RootSignature.rst
@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | 

[clang] [clang][Index] Use canonical function parameter types in USRs (PR #68222)

2024-04-15 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/68222

>From 8022677bd92d4074ccaebda687f43066ce33d152 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 4 Oct 2023 10:06:28 -0400
Subject: [PATCH] [clang][Index] Use canonical function parameter types in USRs

---
 clang/lib/Index/USRGeneration.cpp | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Index/USRGeneration.cpp 
b/clang/lib/Index/USRGeneration.cpp
index 5acc86191f8f9c..31c4a3345c09d1 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -267,10 +267,13 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl 
*D) {
 Out << '>';
   }
 
+  QualType CanonicalType = D->getType().getCanonicalType();
   // Mangle in type information for the arguments.
-  for (auto *PD : D->parameters()) {
-Out << '#';
-VisitType(PD->getType());
+  if (const auto *FPT = CanonicalType->getAs()) {
+for (QualType PT : FPT->param_types()) {
+  Out << '#';
+  VisitType(PT);
+}
   }
   if (D->isVariadic())
 Out << '.';

___
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-15 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/88764

>From 0c6f6a7794b5bd3264632f54bc3bf56f1dfa118e Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Mon, 15 Apr 2024 10:27:44 -0700
Subject: [PATCH 1/2] [clang][deps] Support single-file mode for all formats

---
 clang/test/ClangScanDeps/error.cpp| 18 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp | 57 +++
 2 files changed, 23 insertions(+), 52 deletions(-)

diff --git a/clang/test/ClangScanDeps/error.cpp 
b/clang/test/ClangScanDeps/error.cpp
index 0095a6c900c3b3..99cfdb0b070892 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" %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" %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 compilation database
-// form specified command line after the positional parameter "--".
+/// Attempts to construct the compilation database from '-compilation-database'
+/// or from the arguments following the positional '--'.
 static std::unique_ptr
-getCompilationDataBase(int argc, char **argv, std::string &ErrorMessage) {
+getCompilationDatabase(int argc, char **argv, std::string &ErrorMessage) {
   ParseArgs(argc, argv);
 
+  if (!(CommandLine.empty() ^ CompilationDB.empty())) {
+llvm::errs() << "The compilation command line must be provided either via "
+"'-compilation-database' or after '--'.";
+return nullptr;
+  }
+
   if (!CompilationDB.empty())
 return too

[clang] [llvm] Move several vector intrinsics out of experimental namespace (PR #88748)

2024-04-15 Thread Thorsten Schütt via cfe-commits


@@ -18779,13 +18779,13 @@ This is an overloaded intrinsic.
 
 ::
 
-  declare <2 x i8> @llvm.experimental.vector.reverse.v2i8(<2 x i8> %a)
-  declare  
@llvm.experimental.vector.reverse.nxv4i32( %a)
+  declare <2 x i8> @llvm.vector.reverse.v2i8(<2 x i8> %a)
+  declare  @llvm.vector.reverse.nxv4i32( %a)
 
 Overview:
 "
 
-The '``llvm.experimental.vector.reverse.*``' intrinsics reverse a vector.
+The '``llvm.vector.reverse.*``' intrinsics reverse a vector.
 The intrinsic takes a single vector and returns a vector of matching type but
 with the original lane order reversed. These intrinsics work for both fixed
 and scalable vectors. While this intrinsic is marked as experimental the

tschuett wrote:

`this intrinsic is marked as experimental`

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


[clang] [llvm] Move several vector intrinsics out of experimental namespace (PR #88748)

2024-04-15 Thread Thorsten Schütt via cfe-commits


@@ -18914,13 +18914,13 @@ This is an overloaded intrinsic.
 
 ::
 
-  declare <2 x double> @llvm.experimental.vector.splice.v2f64(<2 x double> 
%vec1, <2 x double> %vec2, i32 %imm)
-  declare  
@llvm.experimental.vector.splice.nxv4i32( %vec1,  %vec2, i32 %imm)
+  declare <2 x double> @llvm.vector.splice.v2f64(<2 x double> %vec1, <2 x 
double> %vec2, i32 %imm)
+  declare  @llvm.vector.splice.nxv4i32( %vec1,  %vec2, i32 %imm)
 
 Overview:
 "
 
-The '``llvm.experimental.vector.splice.*``' intrinsics construct a vector by
+The '``llvm.vector.splice.*``' intrinsics construct a vector by

tschuett wrote:

`While this intrinsicis marked as experimental,`

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


[clang] [clang-format] New clang-format-indent-mode for Emacs (PR #78904)

2024-04-15 Thread Amy Grinn via cfe-commits

amygrinn wrote:

That's a great idea, I'll have to look into that more!

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


[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)

2024-04-15 Thread Erich Keane via cfe-commits

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


[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)

2024-04-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Needs a release note, probably int he 'potentially breaking changes' section? 

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


[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)

2024-04-15 Thread Erich Keane via cfe-commits


@@ -9315,6 +9330,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
   case ParsedAttr::AT_Error:
 handleErrorAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ExcludeFromExplicitInstantiation:

erichkeane wrote:

What is the previous 'handle' function?  Typically with decl attributes we need 
have an entry on this switch.

https://github.com/llvm/llvm-project/pull/88777
___
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-15 Thread Michael Spencer via cfe-commits

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

lgtm. Good to get rid of more unneeded differences between ways of doing 
modules.

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] [OpenMP] Remove 'minncta' attributes from NVPTX kernels (PR #88398)

2024-04-15 Thread Johannes Doerfert via cfe-commits

jdoerfert wrote:

LG, I misread the existing code in clang.


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


[clang] [llvm] [OpenMP] Remove 'minncta' attributes from NVPTX kernels (PR #88398)

2024-04-15 Thread Johannes Doerfert via cfe-commits

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

LG

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


[clang] 0287a5c - [OpenMP] Remove 'minncta' attributes from NVPTX kernels (#88398)

2024-04-15 Thread via cfe-commits

Author: Joseph Huber
Date: 2024-04-15T15:28:05-05:00
New Revision: 0287a5cc4e2a5ded1ae2e4079f91052e6a6b8d9b

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

LOG: [OpenMP] Remove 'minncta' attributes from NVPTX kernels (#88398)

Summary:
Currently we treat this attribute as a minimum number for the amount of
blocks scheduled on the kernel. However, the doucmentation states that
this applies to CTA's mapped onto a *single* SM. Currently we just set
it to the total number of blocks, which will almost always result in a
warning that the value is out of range and will be ignored. We don't
have a good way to automatically know how many CTAs can be put on a
single SM nor if we should do this, so we should probably leave this up
to users manually adding it.


https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#performance-tuning-directives-minnctapersm

Added: 


Modified: 
clang/test/OpenMP/ompx_attributes_codegen.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/test/OpenMP/ompx_attributes_codegen.cpp 
b/clang/test/OpenMP/ompx_attributes_codegen.cpp
index 6735972c6b1070..87eb2913537ba5 100644
--- a/clang/test/OpenMP/ompx_attributes_codegen.cpp
+++ b/clang/test/OpenMP/ompx_attributes_codegen.cpp
@@ -36,6 +36,5 @@ void func() {
 // NVIDIA: "omp_target_thread_limit"="45"
 // NVIDIA: "omp_target_thread_limit"="17"
 // NVIDIA: !{ptr @__omp_offloading[[HASH1:.*]]_l16, !"maxntidx", i32 20}
-// NVIDIA: !{ptr @__omp_offloading[[HASH2:.*]]_l18, !"minctasm", i32 90}
-// NVIDIA: !{ptr @__omp_offloading[[HASH2]]_l18, !"maxntidx", i32 45}
+// NVIDIA: !{ptr @__omp_offloading[[HASH2:.*]]_l18, !"maxntidx", i32 45}
 // NVIDIA: !{ptr @__omp_offloading[[HASH3:.*]]_l20, !"maxntidx", i32 17}

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 7fd8474c2ec890..4d2d352f7520b2 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4786,11 +4786,9 @@ OpenMPIRBuilder::readTeamBoundsForKernel(const Triple &, 
Function &Kernel) {
 
 void OpenMPIRBuilder::writeTeamsForKernel(const Triple &T, Function &Kernel,
   int32_t LB, int32_t UB) {
-  if (T.isNVPTX()) {
+  if (T.isNVPTX())
 if (UB > 0)
   updateNVPTXMetadata(Kernel, "maxclusterrank", UB, true);
-updateNVPTXMetadata(Kernel, "minctasm", LB, false);
-  }
   if (T.isAMDGPU())
 Kernel.addFnAttr("amdgpu-max-num-workgroups", llvm::utostr(LB) + ",1,1");
 



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


[clang] [llvm] [OpenMP] Remove 'minncta' attributes from NVPTX kernels (PR #88398)

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

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


[clang] [unused-includes][Serialization] Remove unused includes. NFC. (PR #88790)

2024-04-15 Thread Volodymyr Sapsai via cfe-commits

https://github.com/vsapsai created 
https://github.com/llvm/llvm-project/pull/88790

None

>From 72f8208752d188aa32e9989faecd7c4b11779eb9 Mon Sep 17 00:00:00 2001
From: Volodymyr Sapsai 
Date: Mon, 15 Apr 2024 13:22:48 -0700
Subject: [PATCH] [unused-includes][Serialization] Remove unused includes. NFC.

---
 clang/include/clang/Serialization/ModuleFileExtension.h | 1 -
 clang/lib/Serialization/ASTReader.cpp   | 1 -
 clang/lib/Serialization/ASTWriterDecl.cpp   | 1 -
 clang/lib/Serialization/ASTWriterStmt.cpp   | 1 -
 clang/lib/Serialization/GeneratePCH.cpp | 1 -
 clang/lib/Serialization/GlobalModuleIndex.cpp   | 1 -
 clang/lib/Serialization/ModuleFileExtension.cpp | 2 +-
 clang/lib/Serialization/PCHContainerOperations.cpp  | 2 --
 8 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/clang/include/clang/Serialization/ModuleFileExtension.h 
b/clang/include/clang/Serialization/ModuleFileExtension.h
index d7d456c8b5db8e..50ce401516275c 100644
--- a/clang/include/clang/Serialization/ModuleFileExtension.h
+++ b/clang/include/clang/Serialization/ModuleFileExtension.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_CLANG_SERIALIZATION_MODULEFILEEXTENSION_H
 #define LLVM_CLANG_SERIALIZATION_MODULEFILEEXTENSION_H
 
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/ExtensibleRTTI.h"
 #include "llvm/Support/HashBuilder.h"
 #include "llvm/Support/MD5.h"
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 8c4b460970ad2b..c68f093ebe63f6 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -31,7 +31,6 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/ODRDiagsEmitter.h"
-#include "clang/AST/ODRHash.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/RawCommentList.h"
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 276b6257f1d841..b8003ac2f95f8e 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -16,7 +16,6 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ODRHash.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/SourceManager.h"
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index e3816181e2b2b9..a736a7b0ef726c 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -19,7 +19,6 @@
 #include "clang/AST/ExprOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Lex/Token.h"
-#include "clang/Sema/DeclSpec.h"
 #include "clang/Serialization/ASTRecordWriter.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 using namespace clang;
diff --git a/clang/lib/Serialization/GeneratePCH.cpp 
b/clang/lib/Serialization/GeneratePCH.cpp
index 2fece29f34487e..bed74399098d7f 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -17,7 +17,6 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/SemaConsumer.h"
-#include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index dd4fc3e009050f..8a8c3cd4acb8e0 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -13,7 +13,6 @@
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "ASTReaderInternals.h"
 #include "clang/Basic/FileManager.h"
-#include "clang/Lex/HeaderSearch.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ModuleFile.h"
 #include "clang/Serialization/PCHContainerOperations.h"
diff --git a/clang/lib/Serialization/ModuleFileExtension.cpp 
b/clang/lib/Serialization/ModuleFileExtension.cpp
index 95fff41e0d7a85..729529b5fca18c 100644
--- a/clang/lib/Serialization/ModuleFileExtension.cpp
+++ b/clang/lib/Serialization/ModuleFileExtension.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 #include "clang/Serialization/ModuleFileExtension.h"
-#include "llvm/ADT/Hashing.h"
+
 using namespace clang;
 
 char ModuleFileExtension::ID = 0;
diff --git a/clang/lib/Serialization/PCHContainerOperations.cpp 
b/clang/lib/Serialization/PCHContainerOperations.cpp
index 56ca3394385b4f..4aedb7debcff28 100644
--- a/clang/lib/Serialization/PCHContainerOperations.cpp
+++ b/clang/lib/Serialization/PCHContainerOperations.cpp
@@ -12,8 +12,6 @@
 
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "clang/AST/ASTConsumer.h"
-#include "clang/Lex/Mo

[clang] [unused-includes][Serialization] Remove unused includes. NFC. (PR #88790)

2024-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Volodymyr Sapsai (vsapsai)


Changes



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


8 Files Affected:

- (modified) clang/include/clang/Serialization/ModuleFileExtension.h (-1) 
- (modified) clang/lib/Serialization/ASTReader.cpp (-1) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (-1) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (-1) 
- (modified) clang/lib/Serialization/GeneratePCH.cpp (-1) 
- (modified) clang/lib/Serialization/GlobalModuleIndex.cpp (-1) 
- (modified) clang/lib/Serialization/ModuleFileExtension.cpp (+1-1) 
- (modified) clang/lib/Serialization/PCHContainerOperations.cpp (-2) 


``diff
diff --git a/clang/include/clang/Serialization/ModuleFileExtension.h 
b/clang/include/clang/Serialization/ModuleFileExtension.h
index d7d456c8b5db8e..50ce401516275c 100644
--- a/clang/include/clang/Serialization/ModuleFileExtension.h
+++ b/clang/include/clang/Serialization/ModuleFileExtension.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_CLANG_SERIALIZATION_MODULEFILEEXTENSION_H
 #define LLVM_CLANG_SERIALIZATION_MODULEFILEEXTENSION_H
 
-#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/ExtensibleRTTI.h"
 #include "llvm/Support/HashBuilder.h"
 #include "llvm/Support/MD5.h"
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 8c4b460970ad2b..c68f093ebe63f6 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -31,7 +31,6 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/ODRDiagsEmitter.h"
-#include "clang/AST/ODRHash.h"
 #include "clang/AST/OpenACCClause.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/RawCommentList.h"
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 276b6257f1d841..b8003ac2f95f8e 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -16,7 +16,6 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ODRHash.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/SourceManager.h"
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index e3816181e2b2b9..a736a7b0ef726c 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -19,7 +19,6 @@
 #include "clang/AST/ExprOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Lex/Token.h"
-#include "clang/Sema/DeclSpec.h"
 #include "clang/Serialization/ASTRecordWriter.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 using namespace clang;
diff --git a/clang/lib/Serialization/GeneratePCH.cpp 
b/clang/lib/Serialization/GeneratePCH.cpp
index 2fece29f34487e..bed74399098d7f 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -17,7 +17,6 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/SemaConsumer.h"
-#include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index dd4fc3e009050f..8a8c3cd4acb8e0 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -13,7 +13,6 @@
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "ASTReaderInternals.h"
 #include "clang/Basic/FileManager.h"
-#include "clang/Lex/HeaderSearch.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ModuleFile.h"
 #include "clang/Serialization/PCHContainerOperations.h"
diff --git a/clang/lib/Serialization/ModuleFileExtension.cpp 
b/clang/lib/Serialization/ModuleFileExtension.cpp
index 95fff41e0d7a85..729529b5fca18c 100644
--- a/clang/lib/Serialization/ModuleFileExtension.cpp
+++ b/clang/lib/Serialization/ModuleFileExtension.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 #include "clang/Serialization/ModuleFileExtension.h"
-#include "llvm/ADT/Hashing.h"
+
 using namespace clang;
 
 char ModuleFileExtension::ID = 0;
diff --git a/clang/lib/Serialization/PCHContainerOperations.cpp 
b/clang/lib/Serialization/PCHContainerOperations.cpp
index 56ca3394385b4f..4aedb7debcff28 100644
--- a/clang/lib/Serialization/PCHContainerOperations.cpp
+++ b/clang/lib/Serialization/PCHContainerOperations.cpp
@@ -12,8 +12,6 @@
 
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "clang/AST/ASTConsumer.h"
-#include "clang/Lex/ModuleLoader.h"
-#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 

``




https://github.com/l

[clang] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

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

>From 6d9e979f09802b94310017901b5b6b58bfa05c1c Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Fri, 12 Apr 2024 00:21:02 +0100
Subject: [PATCH] Add AS 1 for Globals in the SPIR & SPIRV datalayout strings.

---
 clang/lib/Basic/Targets/SPIR.h   | 8 
 clang/test/CodeGen/target-data.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index e25991e3dfe821..9a4a8b501460b6 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -259,7 +259,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public 
SPIRTargetInfo {
 SizeType = TargetInfo::UnsignedInt;
 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -276,7 +276,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public 
SPIRTargetInfo {
 SizeType = TargetInfo::UnsignedLong;
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -336,7 +336,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public 
BaseSPIRVTargetInfo {
 SizeType = TargetInfo::UnsignedInt;
 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -357,7 +357,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public 
BaseSPIRVTargetInfo {
 SizeType = TargetInfo::UnsignedLong;
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index acff367d50eb91..c184f314f68f80 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -251,11 +251,11 @@
 
 // RUN: %clang_cc1 -triple spir-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SPIR
-// SPIR: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+// SPIR: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
 
 // RUN: %clang_cc1 -triple spir64-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SPIR64
-// SPIR64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+// SPIR64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
 
 // RUN: %clang_cc1 -triple bpfel -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=BPFEL

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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

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

>From 6d9e979f09802b94310017901b5b6b58bfa05c1c Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Fri, 12 Apr 2024 00:21:02 +0100
Subject: [PATCH 1/2] Add AS 1 for Globals in the SPIR & SPIRV datalayout
 strings.

---
 clang/lib/Basic/Targets/SPIR.h   | 8 
 clang/test/CodeGen/target-data.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index e25991e3dfe821..9a4a8b501460b6 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -259,7 +259,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public 
SPIRTargetInfo {
 SizeType = TargetInfo::UnsignedInt;
 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -276,7 +276,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public 
SPIRTargetInfo {
 SizeType = TargetInfo::UnsignedLong;
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -336,7 +336,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public 
BaseSPIRVTargetInfo {
 SizeType = TargetInfo::UnsignedInt;
 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -357,7 +357,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public 
BaseSPIRVTargetInfo {
 SizeType = TargetInfo::UnsignedLong;
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index acff367d50eb91..c184f314f68f80 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -251,11 +251,11 @@
 
 // RUN: %clang_cc1 -triple spir-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SPIR
-// SPIR: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+// SPIR: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
 
 // RUN: %clang_cc1 -triple spir64-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SPIR64
-// SPIR64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+// SPIR64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
 
 // RUN: %clang_cc1 -triple bpfel -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=BPFEL

>From cd2d855619372143d7ec33ea4d1330c0c0e8892d Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Mon, 15 Apr 2024 21:33:05 +0100
Subject: [PATCH 2/2] Handle the LLVM side of the SPIRV target.

---
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 
b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index fbf64f2b1dfb13..ae8baa3f119132 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -55,9 +55,9 @@ static std::string computeDataLayout(const Triple &TT) {
   // mean anything.
   if (Arch == Triple::spirv32)
 return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-   "v96:128-v192:256-v256:256-v512:512-v1024:1024";
+   "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1";
   return "e-i64:64-v16:16-v24:32-v32:32-v48:64-"
- "v96:128-v192:256-v256:256-v512:512-v1024:1024";
+ "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1";
 }
 
 static Reloc::Model getEffectiveRelocModel(std::optional RM) {

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


[clang] [clang][Index] Use canonical function parameter types in USRs (PR #68222)

2024-04-15 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/68222

>From 8022677bd92d4074ccaebda687f43066ce33d152 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 4 Oct 2023 10:06:28 -0400
Subject: [PATCH 1/2] [clang][Index] Use canonical function parameter types in
 USRs

---
 clang/lib/Index/USRGeneration.cpp | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Index/USRGeneration.cpp 
b/clang/lib/Index/USRGeneration.cpp
index 5acc86191f8f9c..31c4a3345c09d1 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -267,10 +267,13 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl 
*D) {
 Out << '>';
   }
 
+  QualType CanonicalType = D->getType().getCanonicalType();
   // Mangle in type information for the arguments.
-  for (auto *PD : D->parameters()) {
-Out << '#';
-VisitType(PD->getType());
+  if (const auto *FPT = CanonicalType->getAs()) {
+for (QualType PT : FPT->param_types()) {
+  Out << '#';
+  VisitType(PT);
+}
   }
   if (D->isVariadic())
 Out << '.';

>From 909ae49f65155b1fd6a6e2718fc0746875c296ef Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Mon, 15 Apr 2024 16:33:44 -0400
Subject: [PATCH 2/2] [FOLD] add test

---
 clang/test/Index/USR/func-type.cpp | 12 
 1 file changed, 12 insertions(+)

diff --git a/clang/test/Index/USR/func-type.cpp 
b/clang/test/Index/USR/func-type.cpp
index ff1cd37a7fc421..459a8cd6da5584 100644
--- a/clang/test/Index/USR/func-type.cpp
+++ b/clang/test/Index/USR/func-type.cpp
@@ -16,3 +16,15 @@ void Func( void (* (*)(int, int))(int, int) );
 // CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
 void Func( void (* (*)(int, int, int))(int) );
 // CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |
+
+// Functions with parameter types that only differ in top-level 
cv-qualification should generate the same USR.
+
+void f( const int );
+// CHECK: {{[0-9]+}}:6 | function/C | f | c:@F@f#I# |
+void f( int );
+// CHECK: {{[0-9]+}}:6 | function/C | f | c:@F@f#I# |
+
+void g( int );
+// CHECK: {{[0-9]+}}:6 | function/C | g | c:@F@g#I# |
+void g( const int );
+// CHECK: {{[0-9]+}}:6 | function/C | g | c:@F@g#I# |

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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx commented:

> Please also fix llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 

Done.

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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

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

>From 6d9e979f09802b94310017901b5b6b58bfa05c1c Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Fri, 12 Apr 2024 00:21:02 +0100
Subject: [PATCH 1/3] Add AS 1 for Globals in the SPIR & SPIRV datalayout
 strings.

---
 clang/lib/Basic/Targets/SPIR.h   | 8 
 clang/test/CodeGen/target-data.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index e25991e3dfe821..9a4a8b501460b6 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -259,7 +259,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public 
SPIRTargetInfo {
 SizeType = TargetInfo::UnsignedInt;
 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -276,7 +276,7 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public 
SPIRTargetInfo {
 SizeType = TargetInfo::UnsignedLong;
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -336,7 +336,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public 
BaseSPIRVTargetInfo {
 SizeType = TargetInfo::UnsignedInt;
 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
 resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -357,7 +357,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public 
BaseSPIRVTargetInfo {
 SizeType = TargetInfo::UnsignedLong;
 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
 resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-"
-"v96:128-v192:256-v256:256-v512:512-v1024:1024");
+"v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
   }
 
   void getTargetDefines(const LangOptions &Opts,
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index acff367d50eb91..c184f314f68f80 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -251,11 +251,11 @@
 
 // RUN: %clang_cc1 -triple spir-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SPIR
-// SPIR: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+// SPIR: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
 
 // RUN: %clang_cc1 -triple spir64-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=SPIR64
-// SPIR64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
+// SPIR64: target datalayout = 
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
 
 // RUN: %clang_cc1 -triple bpfel -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=BPFEL

>From cd2d855619372143d7ec33ea4d1330c0c0e8892d Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Mon, 15 Apr 2024 21:33:05 +0100
Subject: [PATCH 2/3] Handle the LLVM side of the SPIRV target.

---
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp 
b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index fbf64f2b1dfb13..ae8baa3f119132 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -55,9 +55,9 @@ static std::string computeDataLayout(const Triple &TT) {
   // mean anything.
   if (Arch == Triple::spirv32)
 return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
-   "v96:128-v192:256-v256:256-v512:512-v1024:1024";
+   "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1";
   return "e-i64:64-v16:16-v24:32-v32:32-v48:64-"
- "v96:128-v192:256-v256:256-v512:512-v1024:1024";
+ "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1";
 }
 
 static Reloc::Model getEffectiveRelocModel(std::optional RM) {

>From 4becde6726c331c2dfc8cd7fbaffe0efd735f997 Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Mon, 15 Apr 2024 21:34:12 +0100
Subject: [PATCH 3/3] Augment AutoUpgrade infra to handle legacy SPIR & SPIRV
 datalayouts.

---
 llvm/lib/IR/AutoUpgrade.cpp   |  9 ---
 .../Bitcode/DataLayoutUpgradeTest.cpp | 27 +++
 2 files changed, 3

[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx commented:

> > Thanks @AlexVlx for this change. This should work fine for 
> > SPIRV-LLVM-Translator (and SPIR-V backend). Adding @michalpaszkowski for 
> > input from SPIR-V backend side. Recently, this restriction on LLVM IR input 
> > to our translator was docuemnted: 
> > https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/docs/SPIRVRepresentationInLLVM.rst#global-variables
> >  _"A global variable resides in an address space, and the default address 
> > space in LLVM is zero. The SPIR-V storage class represented by the zero 
> > LLVM IR address spaces is Function. However, SPIR-V global variable 
> > declarations are OpVariable instructions whose Storage Class cannot be 
> > Function. This means that global variable declarations must always have an 
> > address space specified and that address space cannot be 0."_ So, your 
> > change will help to make the LLVM IR more suitable for the translator.
> 
> One quick pointer. I did notice a similar commit for the AMDGPU backend - 
> https://reviews.llvm.org/D84345 Here, there are some updates to the 
> llvm/lib/IR/AutoUpgrade.cpp. Do we need similar changes here?
> 
> Thanks

I've added AutoUpgrade support.

https://github.com/llvm/llvm-project/pull/88455
___
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-15 Thread Jan Svoboda via cfe-commits


@@ -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" %t/missing_tu.c 2>%t/missing_tu.errs

jansvoboda11 wrote:

I just tried double-checking what `%clang` expands to and I was wrong, it just 
expands to the Clang binary in the build directory, so I think I can remove the 
quote workaround.

However, both `"clang"` and `%clang` expand to `-cc1` invocations that refer to 
system directories: `-isystem /usr/local/include -internal-externc-isystem 
/usr/include`. It would be nice to have something that cleans these out (like 
`%clang_cc1` does), but I consider that out of scope for this patch. (Not 
functional change from in this aspect anyways.)

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] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)

2024-04-15 Thread Krystian Stasiowski via cfe-commits


@@ -9315,6 +9330,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
   case ParsedAttr::AT_Error:
 handleErrorAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ExcludeFromExplicitInstantiation:

sdkrystian wrote:

`exclude_from_explicit_instantiation` had no 'handle' function prior to this 
patch -- the only restriction was that it must be applied to the declaration of 
a variable, function, or class. 

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


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-04-15 Thread via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= ,
Pol Marcet =?utf-8?q?Sardà?= ,
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


sethp wrote:

That sounds right to me; the tasks I see are:

- [ ] Expanding the test cases for `__builtin_convertvector`
- [ ] Rewording the diagnostic for -1 in `__builtin_shufflevector`
- [ ] Rewording the comment for -1 in `__builtin_shufflevector`
- [ ] A stylistic change to `__builtin_convertvector`
- [ ] Considering adding a diagnostic for `__builtin_convertvector` in case we 
"fall through" to the bottom (which we think is currently impossible)
- [ ] ReleaseNotes.rst

Of those, I think the only one that isn't pretty much purely mechanical is 
whether or not we add the extra diagnostic. 

Let me know if I missed anything, or if there's anything I can do to help get 
this one over the finish line: thanks so much @Destroyerrrocket for all your 
work already!



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


[clang] [clang] Add flag to experiment with cold function attributes (PR #88793)

2024-04-15 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks created 
https://github.com/llvm/llvm-project/pull/88793

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

Original LLVM patch for this functionality: #69030

>From 52cd9974be908bf693832012e56e945e9e34f389 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Mon, 15 Apr 2024 20:40:43 +
Subject: [PATCH] [clang] Add flag to experiment with cold function attributes

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

Original LLVM patch for this functionality: #69030
---
 clang/lib/CodeGen/BackendUtil.cpp | 57 +++
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 6cc00b85664f41..22c3f8642ad8eb 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -104,6 +104,21 @@ static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
 cl::desc("Insert sanitizers on OptimizerEarlyEP."));
 
+// Experiment to mark cold functions as optsize/minsize/optnone.
+// TODO: remove once this is exposed as a proper driver flag.
+static cl::opt ClPGOColdFuncAttr(
+"pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), 
cl::Hidden,
+cl::desc(
+"Function attribute to apply to cold functions as determined by PGO"),
+cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default",
+  "Default (no attribute)"),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize",
+  "Mark cold functions with optsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize",
+  "Mark cold functions with minsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
+  "Mark cold functions with optnone.")));
+
 extern cl::opt ProfileCorrelate;
 
 // Re-link builtin bitcodes after optimization
@@ -768,42 +783,41 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
 "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling,
 /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
 auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
 : PGOOptions::NoCSAction;
-PGOOpt = PGOOptions(
-CodeGenOpts.ProfileInstrumentUsePath, "",
-CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, 
VFS,
-PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
+CodeGenOpts.ProfileRemappingFile,
+CodeGenOpts.MemoryProfileUsePath, VFS,
+PGOOptions::IRUse, CSAction, ClPGOColdFuncAttr,
+CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
 PGOOpt = PGOOptions(
 CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
 CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
 // -fmemory-profile-use (without any of the above options)
 PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
 // -fpseudo-probe-for-profiling
-PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
-PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling, true);
+PGOOpt =
+PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
+   PGOOptions::NoAction, PGOOptions::NoCSAction,
+   ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
 // -fdebug-info-for-

[clang] [unused-includes] PCHContainerOperations uses MemoryBufferRef, not MemoryBuffer. NFC. (PR #88794)

2024-04-15 Thread Volodymyr Sapsai via cfe-commits

https://github.com/vsapsai created 
https://github.com/llvm/llvm-project/pull/88794

None

>From b95289569d0441ff799282e125e4f9ad16969f12 Mon Sep 17 00:00:00 2001
From: Volodymyr Sapsai 
Date: Mon, 15 Apr 2024 13:44:54 -0700
Subject: [PATCH] [unused-includes] PCHContainerOperations uses
 MemoryBufferRef, not MemoryBuffer. NFC.

---
 clang/include/clang/Serialization/PCHContainerOperations.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Serialization/PCHContainerOperations.h 
b/clang/include/clang/Serialization/PCHContainerOperations.h
index ddfddf2dafadf9..c9a7e334ce6eb3 100644
--- a/clang/include/clang/Serialization/PCHContainerOperations.h
+++ b/clang/include/clang/Serialization/PCHContainerOperations.h
@@ -12,7 +12,7 @@
 #include "clang/Basic/Module.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include 
 
 namespace llvm {

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


[clang] [clang] Add flag to experiment with cold function attributes (PR #88793)

2024-04-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Arthur Eubanks (aeubanks)


Changes

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

Original LLVM patch for this functionality: #69030

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


1 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+35-22) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 6cc00b85664f41..22c3f8642ad8eb 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -104,6 +104,21 @@ static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
 cl::desc("Insert sanitizers on OptimizerEarlyEP."));
 
+// Experiment to mark cold functions as optsize/minsize/optnone.
+// TODO: remove once this is exposed as a proper driver flag.
+static cl::opt ClPGOColdFuncAttr(
+"pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), 
cl::Hidden,
+cl::desc(
+"Function attribute to apply to cold functions as determined by PGO"),
+cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default",
+  "Default (no attribute)"),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize",
+  "Mark cold functions with optsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize",
+  "Mark cold functions with minsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
+  "Mark cold functions with optnone.")));
+
 extern cl::opt ProfileCorrelate;
 
 // Re-link builtin bitcodes after optimization
@@ -768,42 +783,41 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
 "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling,
 /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
 auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
 : PGOOptions::NoCSAction;
-PGOOpt = PGOOptions(
-CodeGenOpts.ProfileInstrumentUsePath, "",
-CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, 
VFS,
-PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
+CodeGenOpts.ProfileRemappingFile,
+CodeGenOpts.MemoryProfileUsePath, VFS,
+PGOOptions::IRUse, CSAction, ClPGOColdFuncAttr,
+CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
 PGOOpt = PGOOptions(
 CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
 CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
 // -fmemory-profile-use (without any of the above options)
 PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
 // -fpseudo-probe-for-profiling
-PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
-PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling, true);
+PGOOpt =
+PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
+   PGOOptions::NoAction, PGOOptions::NoCSAction,
+   ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
 // -fdebug-info-for-profiling
 PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default, true);
+ClPGOColdFuncAttr, true);
 
   //

[clang] [unused-includes] PCHContainerOperations uses MemoryBufferRef, not MemoryBuffer. NFC. (PR #88794)

2024-04-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Volodymyr Sapsai (vsapsai)


Changes



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


1 Files Affected:

- (modified) clang/include/clang/Serialization/PCHContainerOperations.h (+1-1) 


``diff
diff --git a/clang/include/clang/Serialization/PCHContainerOperations.h 
b/clang/include/clang/Serialization/PCHContainerOperations.h
index ddfddf2dafadf9..c9a7e334ce6eb3 100644
--- a/clang/include/clang/Serialization/PCHContainerOperations.h
+++ b/clang/include/clang/Serialization/PCHContainerOperations.h
@@ -12,7 +12,7 @@
 #include "clang/Basic/Module.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include 
 
 namespace llvm {

``




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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

2024-04-15 Thread Arvind Sudarsanam via cfe-commits

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

Thanks for this change. LGTM

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


[clang] 69d861e - [clang] Move tailclipping to bitfield allocation (#87090)

2024-04-15 Thread via cfe-commits

Author: Nathan Sidwell
Date: 2024-04-15T16:55:58-04:00
New Revision: 69d861e1320119e9a02907155ca626b1db90ad93

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

LOG: [clang] Move tailclipping to bitfield allocation (#87090)

Move bitfield access clipping to bitfield access computation.

Added: 


Modified: 
clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
clang/test/CodeGen/bitfield-access-unit.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp 
b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 634a55fec5182e..868b1ab98e048a 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -41,10 +41,11 @@ namespace {
 ///   contains enough information to determine where the runs break.  Microsoft
 ///   and Itanium follow 
diff erent rules and use 
diff erent codepaths.
 /// * It is desired that, when possible, bitfields use the appropriate iN type
-///   when lowered to llvm types.  For example unsigned x : 24 gets lowered to
+///   when lowered to llvm types. For example unsigned x : 24 gets lowered to
 ///   i24.  This isn't always possible because i24 has storage size of 32 bit
-///   and if it is possible to use that extra byte of padding we must use
-///   [i8 x 3] instead of i24.  The function clipTailPadding does this.
+///   and if it is possible to use that extra byte of padding we must use [i8 x
+///   3] instead of i24. This is computed when accumulating bitfields in
+///   accumulateBitfields.
 ///   C++ examples that require clipping:
 ///   struct { int a : 24; char b; }; // a must be clipped, b goes at offset 3
 ///   struct A { int a : 24; ~A(); }; // a must be clipped because:
@@ -62,11 +63,7 @@ namespace {
 ///   that the tail padding is not used in the complete class.) However,
 ///   because LLVM reads from the complete type it can generate incorrect code
 ///   if we do not clip the tail padding off of the bitfield in the complete
-///   layout.  This introduces a somewhat awkward extra unnecessary clip stage.
-///   The location of the clip is stored internally as a sentinel of type
-///   SCISSOR.  If LLVM were updated to read base types (which it probably
-///   should because locations of things such as VBases are bogus in the llvm
-///   type anyway) then we could eliminate the SCISSOR.
+///   layout.
 /// * Itanium allows nearly empty primary virtual bases.  These bases don't get
 ///   get their own storage because they're laid out as part of another base
 ///   or at the beginning of the structure.  Determining if a VBase actually
@@ -200,9 +197,7 @@ struct CGRecordLowering {
  const CXXRecordDecl *Query) const;
   void calculateZeroInit();
   CharUnits calculateTailClippingOffset(bool isNonVirtualBaseType) const;
-  /// Lowers bitfield storage types to I8 arrays for bitfields with tail
-  /// padding that is or can potentially be used.
-  void clipTailPadding();
+  void checkBitfieldClipping() const;
   /// Determines if we need a packed llvm struct.
   void determinePacked(bool NVBaseType);
   /// Inserts padding everywhere it's needed.
@@ -305,7 +300,7 @@ void CGRecordLowering::lower(bool NVBaseType) {
   }
   llvm::stable_sort(Members);
   Members.push_back(StorageInfo(Size, getIntNType(8)));
-  clipTailPadding();
+  checkBitfieldClipping();
   determinePacked(NVBaseType);
   insertPadding();
   Members.pop_back();
@@ -531,6 +526,7 @@ CGRecordLowering::accumulateBitFields(bool 
isNonVirtualBaseType,
   // available padding characters.
   RecordDecl::field_iterator BestEnd = Begin;
   CharUnits BestEndOffset;
+  bool BestClipped; // Whether the representation must be in a byte array.
 
   for (;;) {
 // AtAlignedBoundary is true iff Field is the (potential) start of a new
@@ -593,10 +589,9 @@ CGRecordLowering::accumulateBitFields(bool 
isNonVirtualBaseType,
 // this is the best seen so far.
 BestEnd = Field;
 BestEndOffset = BeginOffset + AccessSize;
-if (Types.getCodeGenOpts().FineGrainedBitfieldAccesses)
-  // Fine-grained access, so no merging of spans.
-  InstallBest = true;
-else if (!BitSizeSinceBegin)
+// Assume clipped until proven not below.
+BestClipped = true;
+if (!BitSizeSinceBegin)
   // A zero-sized initial span -- this will install nothing and reset
   // for another.
   InstallBest = true;
@@ -624,6 +619,12 @@ CGRecordLowering::accumulateBitFields(bool 
isNonVirtualBaseType,
 // The access unit is not at a naturally aligned offset within the
 // structure.
 InstallBest = true;
+
+  if (InstallBest && BestEnd == Field)
+// We're installing the first span, whose clipping was presume

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMB

[clang] [clang] Move tailclipping to bitfield allocation (PR #87090)

2024-04-15 Thread Nathan Sidwell via cfe-commits

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


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and

damyanp wrote:

I wonder if it'd be helpful to show the runtime side of this?  Just by reading 
this, I think it's hard to understand what a root signature is, why I'd need to 
specify one, and what I'd do with one once I'd specified it.

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


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and

damyanp wrote:

> ... and verify ...

What sort of verifications does it do?

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


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMB

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMB

[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)

2024-04-15 Thread Erich Keane via cfe-commits


@@ -9315,6 +9330,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
   case ParsedAttr::AT_Error:
 handleErrorAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ExcludeFromExplicitInstantiation:

erichkeane wrote:

It still needs to be 'added' to the AST though?  Where was that happening?

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


[clang] [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (PR #88777)

2024-04-15 Thread Krystian Stasiowski via cfe-commits


@@ -9315,6 +9330,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
   case ParsedAttr::AT_Error:
 handleErrorAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ExcludeFromExplicitInstantiation:

sdkrystian wrote:

In the default case of the switch statement (line 9142, 
`AL.getInfo().handleDeclAttribute(S, D, AL)`)

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


[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

2024-04-15 Thread Fangrui Song via cfe-commits

MaskRay wrote:

I think I've addressed all comments and changed the patch to rebase on the 
improved tests.

@AaronBallman @tstellar Are you happy with the current version?

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


[clang] [clang][deps] Only bypass scanning VFS for the module cache (PR #88800)

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

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/88800

The scanning VFS doesn't cache stat failures of paths with no extension. This 
was originally implemented to avoid caching the non-existence of the modules 
cache directory that the modular scanner will eventually create if it does not 
exist.

However, this prevents caching of the non-existence of all directories and 
notably also header files from the standard C++ library, which can lead to 
sub-par performance.

This patch adds an API to the scanning VFS that allows clients to configure 
path prefix for which to bypass the scanning VFS and use the underlying VFS 
directly.

>From 6573ba3069a99092d6ebaa3096cf5c4c97eaeb8f Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Thu, 11 Apr 2024 14:44:55 -0700
Subject: [PATCH] [clang][deps] Only bypass scanning VFS for the module cache

The scanning VFS doesn't cache stat failures of paths with no extension. This 
was originally implemented to avoid caching the non-existence of the modules 
cache directory that the modular scanner will eventually create if it does not 
exist.

However, this prevents caching of the non-existence of all directories and 
notably also header files from the standard C++ library, which can lead to 
sub-par performance.

This patch adds an API to the scanning VFS that allows clients to configure 
path prefix for which to bypass the scanning VFS and use the underlying VFS 
directly.
---
 .../DependencyScanningFilesystem.h| 13 
 .../DependencyScanningFilesystem.cpp  | 16 --
 .../DependencyScanningWorker.cpp  | 32 ---
 .../DependencyScanningFilesystemTest.cpp  | 27 
 4 files changed, 67 insertions(+), 21 deletions(-)

diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
index f7b4510d7f7beb..d12814e7c9253e 100644
--- 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -353,6 +353,12 @@ class DependencyScanningWorkerFilesystem
 
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
 
+  /// Make it so that no paths bypass this VFS.
+  void resetBypassedPathPrefix() { BypassedPathPrefix.reset(); }
+  /// Set the prefix for paths that should bypass this VFS and go straight to
+  /// the underlying VFS.
+  void setBypassedPathPrefix(StringRef Prefix) { BypassedPathPrefix = Prefix; }
+
   /// Returns entry for the given filename.
   ///
   /// Attempts to use the local and shared caches first, then falls back to
@@ -450,12 +456,19 @@ class DependencyScanningWorkerFilesystem
 getUnderlyingFS().print(OS, Type, IndentLevel + 1);
   }
 
+  /// Whether this path should bypass this VFS and go straight to the 
underlying
+  /// VFS.
+  bool shouldBypass(StringRef Path) const;
+
   /// The global cache shared between worker threads.
   DependencyScanningFilesystemSharedCache &SharedCache;
   /// The local cache is used by the worker thread to cache file system queries
   /// locally instead of querying the global cache every time.
   DependencyScanningFilesystemLocalCache LocalCache;
 
+  /// Prefix of paths that should go straight to the underlying VFS.
+  std::optional BypassedPathPrefix;
+
   /// The working directory to use for making relative paths absolute before
   /// using them for cache lookups.
   llvm::ErrorOr WorkingDirForCacheLookup;
diff --git 
a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index 0cab17a3424406..4d738e4bea41a6 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -201,11 +201,8 @@ const CachedRealPath 
&DependencyScanningFilesystemSharedCache::CacheShard::
   return *StoredRealPath;
 }
 
-static bool shouldCacheStatFailures(StringRef Filename) {
-  StringRef Ext = llvm::sys::path::extension(Filename);
-  if (Ext.empty())
-return false; // This may be the module cache directory.
-  return true;
+bool DependencyScanningWorkerFilesystem::shouldBypass(StringRef Path) const {
+  return BypassedPathPrefix && Path.starts_with(*BypassedPathPrefix);
 }
 
 DependencyScanningWorkerFilesystem::DependencyScanningWorkerFilesystem(
@@ -244,8 +241,6 @@ DependencyScanningWorkerFilesystem::computeAndStoreResult(
   llvm::ErrorOr Stat =
   getUnderlyingFS().status(OriginalFilename);
   if (!Stat) {
-if (!shouldCacheStatFailures(OriginalFilename))
-  return Stat.getError();
 const auto &Entry =
 getOrEmplaceSharedEntryForFilename(FilenameForLookup, Stat.getError());
 return insertLocalEntryForFilename(FilenameForLookup, Entry);
@@ -291,7 +286,7 @@ DependencyScanningWorkerFilesys

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

2024-04-15 Thread via cfe-commits


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

cor3ntin wrote:

Maybe something like that would be cleaner

```cpp
 ConversionSequenceList allocateConversionSequences(unsigned NumConversions) {
  ImplicitConversionSequence *Conversions = 
Ctx.Allocate(NumConversions);
  std::uninitialized_default_construct(Conversions, Conversions + 
NumConversions);
  return ConversionSequenceList(Conversions, NumConversions);
}
```

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] Only bypass scanning VFS for the module cache (PR #88800)

2024-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)


Changes

The scanning VFS doesn't cache stat failures of paths with no extension. This 
was originally implemented to avoid caching the non-existence of the modules 
cache directory that the modular scanner will eventually create if it does not 
exist.

However, this prevents caching of the non-existence of all directories and 
notably also header files from the standard C++ library, which can lead to 
sub-par performance.

This patch adds an API to the scanning VFS that allows clients to configure 
path prefix for which to bypass the scanning VFS and use the underlying VFS 
directly.

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


4 Files Affected:

- (modified) 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h 
(+13) 
- (modified) 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp (+7-9) 
- (modified) clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
(+20-12) 
- (modified) 
clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp 
(+27) 


``diff
diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
index f7b4510d7f7beb..d12814e7c9253e 100644
--- 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -353,6 +353,12 @@ class DependencyScanningWorkerFilesystem
 
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
 
+  /// Make it so that no paths bypass this VFS.
+  void resetBypassedPathPrefix() { BypassedPathPrefix.reset(); }
+  /// Set the prefix for paths that should bypass this VFS and go straight to
+  /// the underlying VFS.
+  void setBypassedPathPrefix(StringRef Prefix) { BypassedPathPrefix = Prefix; }
+
   /// Returns entry for the given filename.
   ///
   /// Attempts to use the local and shared caches first, then falls back to
@@ -450,12 +456,19 @@ class DependencyScanningWorkerFilesystem
 getUnderlyingFS().print(OS, Type, IndentLevel + 1);
   }
 
+  /// Whether this path should bypass this VFS and go straight to the 
underlying
+  /// VFS.
+  bool shouldBypass(StringRef Path) const;
+
   /// The global cache shared between worker threads.
   DependencyScanningFilesystemSharedCache &SharedCache;
   /// The local cache is used by the worker thread to cache file system queries
   /// locally instead of querying the global cache every time.
   DependencyScanningFilesystemLocalCache LocalCache;
 
+  /// Prefix of paths that should go straight to the underlying VFS.
+  std::optional BypassedPathPrefix;
+
   /// The working directory to use for making relative paths absolute before
   /// using them for cache lookups.
   llvm::ErrorOr WorkingDirForCacheLookup;
diff --git 
a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index 0cab17a3424406..4d738e4bea41a6 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -201,11 +201,8 @@ const CachedRealPath 
&DependencyScanningFilesystemSharedCache::CacheShard::
   return *StoredRealPath;
 }
 
-static bool shouldCacheStatFailures(StringRef Filename) {
-  StringRef Ext = llvm::sys::path::extension(Filename);
-  if (Ext.empty())
-return false; // This may be the module cache directory.
-  return true;
+bool DependencyScanningWorkerFilesystem::shouldBypass(StringRef Path) const {
+  return BypassedPathPrefix && Path.starts_with(*BypassedPathPrefix);
 }
 
 DependencyScanningWorkerFilesystem::DependencyScanningWorkerFilesystem(
@@ -244,8 +241,6 @@ DependencyScanningWorkerFilesystem::computeAndStoreResult(
   llvm::ErrorOr Stat =
   getUnderlyingFS().status(OriginalFilename);
   if (!Stat) {
-if (!shouldCacheStatFailures(OriginalFilename))
-  return Stat.getError();
 const auto &Entry =
 getOrEmplaceSharedEntryForFilename(FilenameForLookup, Stat.getError());
 return insertLocalEntryForFilename(FilenameForLookup, Entry);
@@ -291,7 +286,7 @@ DependencyScanningWorkerFilesystem::status(const Twine 
&Path) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
-  if (Filename.ends_with(".pcm"))
+  if (shouldBypass(Filename))
 return getUnderlyingFS().status(Path);
 
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
@@ -362,7 +357,7 @@ DependencyScanningWorkerFilesystem::openFileForRead(const 
Twine &Path) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
-  if (Filename.ends_with(".pcm"))
+  if (shouldBypass(Filename))
 return getUnderlyingFS().openFileForRead(Path);
 
   llv

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

2024-04-15 Thread Orlando Cazalet-Hyams via cfe-commits

OCHyams wrote:

> But perhaps at least you could add named accessors to DIDerivedType for the 
> template params, same as DIGlobalVariable/DICompositeType have?

Done. I couldn't add an assert (`getTag() == dwarf::DW_TAG_template_alias`) 
without including `Dwarf.h`. I've chosen to not do that as it looks like its 
been avoided (but possibly just not really needed here before), but I'd be 
happy to add it if the extra compile time isn't worth worrying about.

> (oh, and in case anyone hasn't mentioned it already - this would generally be 
> committed in smaller pieces upstream - adding the LLVM functionality first, 
> then adding clang patches that use that functionality)

Sure, no problem, I'll open separate pull requests once this has been accepted 
then.

---

I think I've addressed all the concerns raised now except for the variadic 
issue I mentioned, which I'll look at tomorrow.

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] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-15 Thread Johannes Doerfert via cfe-commits

https://github.com/jdoerfert commented:

This patch is huge, and just skimming over it shows various places that could 
be split off, and others that should not make it to the review stage (commented 
out code).
Please update.

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


[clang] [llvm] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-15 Thread Johannes Doerfert via cfe-commits


@@ -145,6 +145,8 @@ static bool 
isValidWorkshareLoopScheduleType(OMPScheduleType SchedType) {
 }
 #endif
 
+Function *GLOBAL_ReductionFunc = nullptr;

jdoerfert wrote:

We should (almost) never have globals flying around. What is going on here?

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


[clang] [llvm] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-15 Thread Johannes Doerfert via cfe-commits


@@ -99,14 +100,20 @@ class OpenMPIRBuilderConfig {
   /// expanded.
   std::optional IsGPU;
 
-  // Flag for specifying if offloading is mandatory.
+  /// Flag for specifying if LLVMUsed information should be emitted.
+  std::optional EmitLLVMUsed;

jdoerfert wrote:

This is a generic sounding flag that guards a very very specific thing.
Is there ever a use case where the flag is not set (and it is checked)?

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


[clang] [llvm] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-15 Thread Johannes Doerfert via cfe-commits

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


[clang] [llvm] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-15 Thread Johannes Doerfert via cfe-commits


@@ -607,15 +621,17 @@ class OpenMPIRBuilder {
   /// Generator for '#omp barrier'
   ///
   /// \param Loc The location where the barrier directive was encountered.
-  /// \param DK The kind of directive that caused the barrier.
+  /// \param Kind The kind of directive that caused the barrier.
   /// \param ForceSimpleCall Flag to force a simple (=non-cancellation) 
barrier.
   /// \param CheckCancelFlag Flag to indicate a cancel barrier return value
   ///should be checked and acted upon.
+  /// \param ThreadID Optional parameter to pass in any existing ThreadID 
value.
   ///
   /// \returns The insertion point after the barrier.
-  InsertPointTy createBarrier(const LocationDescription &Loc, omp::Directive 
DK,
-  bool ForceSimpleCall = false,
-  bool CheckCancelFlag = true);
+  InsertPointTy createBarrier(const LocationDescription &Loc,
+  omp::Directive Kind, bool ForceSimpleCall = 
false,
+  bool CheckCancelFlag = true,
+  Value *ThreadID = nullptr);

jdoerfert wrote:

What has this to do with reductions? Either make it a pre-commit or just don't 
introduce this concept of "existing ThreadID values" again. Most (>90%) of the 
runtime functions that take a thread ID don't use it anyway. It's leftover from 
the old runtime.

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


[clang] [llvm] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-15 Thread Johannes Doerfert via cfe-commits


@@ -2096,15 +2102,1408 @@ OpenMPIRBuilder::createSection(const 
LocationDescription &Loc,
   /*IsCancellable*/ true);
 }
 
-/// Create a function with a unique name and a "void (i8*, i8*)" signature in
-/// the given module and return it.
-Function *getFreshReductionFunc(Module &M) {
+static OpenMPIRBuilder::InsertPointTy getInsertPointAfterInstr(Instruction *I) 
{
+  BasicBlock::iterator IT(I);
+  IT++;
+  return OpenMPIRBuilder::InsertPointTy(I->getParent(), IT);
+}
+
+void OpenMPIRBuilder::emitUsed(StringRef Name,
+   std::vector &List) {
+  if (List.empty())
+return;
+
+  // Convert List to what ConstantArray needs.
+  SmallVector UsedArray;
+  UsedArray.resize(List.size());
+  for (unsigned I = 0, E = List.size(); I != E; ++I)
+UsedArray[I] = ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+cast(&*List[I]), Builder.getPtrTy());
+
+  if (UsedArray.empty())
+return;
+  ArrayType *ATy = ArrayType::get(Builder.getPtrTy(), UsedArray.size());
+
+  auto *GV = new GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage,
+ConstantArray::get(ATy, UsedArray), Name);
+
+  GV->setSection("llvm.metadata");
+}
+
+Value *OpenMPIRBuilder::getGPUThreadID() {
+  return Builder.CreateCall(
+  getOrCreateRuntimeFunction(M,
+ 
OMPRTL___kmpc_get_hardware_thread_id_in_block),
+  {});
+}
+
+Value *OpenMPIRBuilder::getGPUWarpSize() {
+  return Builder.CreateCall(
+  getOrCreateRuntimeFunction(M, OMPRTL___kmpc_get_warp_size), {});
+}
+
+Value *OpenMPIRBuilder::getNVPTXWarpID() {
+  unsigned LaneIDBits = Log2_32(Config.getGridValue().GV_Warp_Size);
+  return Builder.CreateAShr(getGPUThreadID(), LaneIDBits, "nvptx_warp_id");
+}
+
+Value *OpenMPIRBuilder::getNVPTXLaneID() {
+  unsigned LaneIDBits = Log2_32(Config.getGridValue().GV_Warp_Size);
+  assert(LaneIDBits < 32 && "Invalid LaneIDBits size in NVPTX device.");
+  unsigned LaneIDMask = ~0u >> (32u - LaneIDBits);
+  return Builder.CreateAnd(getGPUThreadID(), Builder.getInt32(LaneIDMask),
+   "nvptx_lane_id");
+}
+
+Value *OpenMPIRBuilder::castValueToType(InsertPointTy AllocaIP, Value *From,
+Type *ToType) {
+  Type *FromType = From->getType();
+  uint64_t FromSize = M.getDataLayout().getTypeStoreSize(FromType);
+  uint64_t ToSize = M.getDataLayout().getTypeStoreSize(ToType);
+  assert(FromSize > 0 && "From size must be greater than zero");
+  assert(ToSize > 0 && "To size must be greater than zero");
+  if (FromType == ToType)
+return From;
+  if (FromSize == ToSize)
+return Builder.CreateBitCast(From, ToType);
+  if (ToType->isIntegerTy() && FromType->isIntegerTy())
+return Builder.CreateIntCast(From, ToType, /*isSigned*/ true);
+  InsertPointTy SaveIP = Builder.saveIP();
+  Builder.restoreIP(AllocaIP);
+  Value *CastItem = Builder.CreateAlloca(ToType);
+  Builder.restoreIP(SaveIP);
+
+  Value *ValCastItem = Builder.CreatePointerBitCastOrAddrSpaceCast(
+  CastItem, FromType->getPointerTo());
+  Builder.CreateStore(From, ValCastItem);
+  return Builder.CreateLoad(ToType, CastItem);
+}
+
+Value *OpenMPIRBuilder::createRuntimeShuffleFunction(InsertPointTy AllocaIP,
+ Value *Element,
+ Type *ElementType,
+ Value *Offset) {
+  uint64_t Size = M.getDataLayout().getTypeStoreSize(ElementType);
+  assert(Size <= 8 && "Unsupported bitwidth in shuffle instruction");
+
+  // Cast all types to 32- or 64-bit values before calling shuffle routines.
+  Type *CastTy = Builder.getIntNTy(Size <= 4 ? 32 : 64);
+  Value *ElemCast = castValueToType(AllocaIP, Element, CastTy);
+  Value *WarpSize =
+  Builder.CreateIntCast(getGPUWarpSize(), Builder.getInt16Ty(), true);
+  Function *ShuffleFunc = getOrCreateRuntimeFunctionPtr(
+  Size <= 4 ? RuntimeFunction::OMPRTL___kmpc_shuffle_int32
+: RuntimeFunction::OMPRTL___kmpc_shuffle_int64);
+  Value *WarpSizeCast =
+  Builder.CreateIntCast(WarpSize, Builder.getInt16Ty(), /*isSigned=*/true);
+  Value *ShuffleCall =
+  Builder.CreateCall(ShuffleFunc, {ElemCast, Offset, WarpSizeCast});
+  return castValueToType(AllocaIP, ShuffleCall, CastTy);
+}
+
+void OpenMPIRBuilder::shuffleAndStore(InsertPointTy AllocaIP, Value *SrcAddr,
+  Value *DstAddr, Type *ElemType,
+  Value *Offset, Type *ReductionArrayTy) {
+  uint64_t Size = M.getDataLayout().getTypeStoreSize(ElemType);
+  // Create the loop over the big sized data.
+  // ptr = (void*)Elem;
+  // ptrEnd = (void*) Elem + 1;
+  // Step = 8;
+  // while (ptr + Step < ptrEnd)
+  //   shuffle((int64_t)*ptr);
+  // Step = 4;
+  // while (ptr + Step < ptrEnd)
+  //   shuffle((int32_t)*ptr);
+  // ...
+  Type *IndexTy

[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

2024-04-15 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> I think I've addressed all comments and changed the patch to rebase on the 
> improved tests.
> 
> @AaronBallman @tstellar Are you happy with the current version?

Please file an issue for this:

> I added microsoftDemangle tests to show the current behavior.
> Since the feature that demangles to the function name without parameters (f3 
> instead of f3(int)) appears to be missing, I cannot > address 
> -Wunused-function false positives for microsoftDemangle with reasonable time 
> complexity.

and file a second one to come back and fix this issue once we can demangle with 
parameters.

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


[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

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

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

LGTM

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


[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

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

https://github.com/tstellar commented:

I'm fine with this as long as @AaronBallman approves.

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


[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

2024-04-15 Thread Aaron Ballman via cfe-commits

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

LG enough TM, thank you @MaskRay!

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


[clang] 6331024 - [clang/DependencyScanning/ModuleDepCollector] Refactor part of `makeCommonInvocationForModuleBuild` into its own function (#88447)

2024-04-15 Thread via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2024-04-15T15:05:55-07:00
New Revision: 63310243537ba8830f3533a5d93e7b04b10d6c9e

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

LOG: [clang/DependencyScanning/ModuleDepCollector] Refactor part of 
`makeCommonInvocationForModuleBuild` into its own function (#88447)

The new function is about clearing out benign codegen options and can be
applied for PCH invocations as well.

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/removed-args.c

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 081899cc2c8503..da51292296a90f 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -308,6 +308,11 @@ class ModuleDepCollector final : public 
DependencyCollector {
 ModuleDeps &Deps);
 };
 
+/// Resets codegen options that don't affect modules/PCH.
+void resetBenignCodeGenOptions(frontend::ActionKind ProgramAction,
+   const LangOptions &LangOpts,
+   CodeGenOptions &CGOpts);
+
 } // end namespace dependencies
 } // end namespace tooling
 } // end namespace clang

diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 94ccbd3351b09d..e19f19b2528c15 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -154,6 +154,26 @@ void 
ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
   }
 }
 
+void dependencies::resetBenignCodeGenOptions(frontend::ActionKind 
ProgramAction,
+ const LangOptions &LangOpts,
+ CodeGenOptions &CGOpts) {
+  // TODO: Figure out better way to set options to their default value.
+  if (ProgramAction == frontend::GenerateModule) {
+CGOpts.MainFileName.clear();
+CGOpts.DwarfDebugFlags.clear();
+  }
+  if (ProgramAction == frontend::GeneratePCH ||
+  (ProgramAction == frontend::GenerateModule && !LangOpts.ModulesCodegen)) 
{
+CGOpts.DebugCompilationDir.clear();
+CGOpts.CoverageCompilationDir.clear();
+CGOpts.CoverageDataFile.clear();
+CGOpts.CoverageNotesFile.clear();
+CGOpts.ProfileInstrumentUsePath.clear();
+CGOpts.SampleProfileFile.clear();
+CGOpts.ProfileRemappingFile.clear();
+  }
+}
+
 static CowCompilerInvocation
 makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
   CI.resetNonModularOptions();
@@ -167,18 +187,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
   // LLVM options are not going to affect the AST
   CI.getFrontendOpts().LLVMArgs.clear();
 
-  // TODO: Figure out better way to set options to their default value.
-  CI.getCodeGenOpts().MainFileName.clear();
-  CI.getCodeGenOpts().DwarfDebugFlags.clear();
-  if (!CI.getLangOpts().ModulesCodegen) {
-CI.getCodeGenOpts().DebugCompilationDir.clear();
-CI.getCodeGenOpts().CoverageCompilationDir.clear();
-CI.getCodeGenOpts().CoverageDataFile.clear();
-CI.getCodeGenOpts().CoverageNotesFile.clear();
-CI.getCodeGenOpts().ProfileInstrumentUsePath.clear();
-CI.getCodeGenOpts().SampleProfileFile.clear();
-CI.getCodeGenOpts().ProfileRemappingFile.clear();
-  }
+  resetBenignCodeGenOptions(frontend::GenerateModule, CI.getLangOpts(),
+CI.getCodeGenOpts());
 
   // Map output paths that affect behaviour to "-" so their existence is in the
   // context hash. The final path will be computed in addOutputPaths.
@@ -342,6 +352,8 @@ static bool needsModules(FrontendInputFile FIF) {
 
 void ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
   CI.clearImplicitModuleBuildOptions();
+  resetBenignCodeGenOptions(CI.getFrontendOpts().ProgramAction,
+CI.getLangOpts(), CI.getCodeGenOpts());
 
   if (llvm::any_of(CI.getFrontendOpts().Inputs, needsModules)) {
 Preprocessor &PP = ScanInstance.getPreprocessor();

diff  --git a/clang/test/ClangScanDeps/removed-args.c 
b/clang/test/ClangScanDeps/removed-args.c
index f49e4ead82f7bf..3e108f0549450c 100644
--- a/clang/test/ClangScanDeps/removed-args.c
+++ b/clang/test/ClangScanDeps/removed-args.c
@@ -93,3 +93,31 @@
 // CHECK-NOT:  "-fmodules-prune-interval=
 // CHECK-NOT:  "-fmodules-prune-after=
 // CHECK:],
+
+// Check for removed args for PCH invocati

[clang] [clang/DependencyScanning/ModuleDepCollector] Refactor part of `makeCommonInvocationForModuleBuild` into its own function (PR #88447)

2024-04-15 Thread Argyrios Kyrtzidis via cfe-commits

https://github.com/akyrtzi closed 
https://github.com/llvm/llvm-project/pull/88447
___
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-15 Thread Matheus Izvekov via cfe-commits


@@ -1070,57 +1077,24 @@ class Sema;
 };
 
   private:
-SmallVector Candidates;
-llvm::SmallPtrSet Functions;
-
-// Allocator for ConversionSequenceLists. We store the first few of these
-// inline to avoid allocation for small sets.
-llvm::BumpPtrAllocator SlabAllocator;
+ASTContext &Ctx;
+SmallVector Candidates;
+llvm::SmallPtrSet Functions;

mizvekov wrote:

pre-existing small nit, for consistency:
```suggestion
SmallVector Candidates;
SmallPtrSet Functions;
```

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] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Yeoul Na via cfe-commits


@@ -592,6 +592,16 @@ class AttrSubjectMatcherAggregateRule 
{
 
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
+// Late Attribute parsing mode enum
+class LateAttrParseKind  {
+  int Kind = val;
+}
+def LateAttrParseNever : LateAttrParseKind<0>; // Never late parsed
+def LateAttrParseAlways: LateAttrParseKind<1>; // Always late parsed
+// Late parsed if `-fexperimental-late-parse-attributes` is on and parsed
+// normally if off.
+def LateAttrParseExperimentalOnly : LateAttrParseKind<2>;

rapidsna wrote:

I'd propose slightly different semantics for `LateAttrParseAlways` and 
`LateAttrParseExperimentalOnly`, and renaming accordingly. 

Before this patch, if an attribute was marked `LateParsed=1`, it meant late 
parsing is enabled for C++ and at the declaration attributes position. However, 
the same attribute was not late parsed when it is compiled for C.

Therefore, having `LateParsed=1` mean "always late parsed" would be misleading. 
Instead, it should be something like `LateAttrParseStandard` to indicate the 
attribute will be late parsed in a conventional way, for C++ on the declaration 
attribute positions.

Then, `LateParsed=2` should capture the experimental (extended) semantics to 
enable late parsing for C on both the decl and type attribute positions (in the 
future), which would be controlled by `-fexperimental-late-parse-attributes`. 
When the flag is disabled, it should fall back to the same behavior as 
`LateParsed=1`. For `counted_by` which is a C only attribute, it means no late 
parsing would enabled because it will be compiled only for C.

Consider `guarded_by`, which is marked `LateParsed=1` and is also available for 
C++. Let's say we adopt `LateAttrParseExperimental` for `guarded_by`.  With the 
flag, the code below will compile for C (though that is a lie because a naked 
field reference doesn't work for C atm 
https://github.com/llvm/llvm-project/issues/20777, but that's a separate issue 
and let's assume we've somehow resolved that issue).

```
struct guarded_int {
  int value __attribute__((guarded_by(m));
  struct mutex m;
};
```

Without the flag, it won't be late parsed for C, but it should continue to be 
late parsed for C++ on the decl attribute positions like before.

https://github.com/llvm/llvm-project/pull/88596
___
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-15 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] 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'}}
 }

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


[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-15 Thread Doug Wyatt via cfe-commits


@@ -4429,6 +4434,284 @@ class FunctionNoProtoType : public FunctionType, public 
llvm::FoldingSetNode {
   }
 };
 
+// 
--
+
+class Decl;
+class CXXMethodDecl;
+class FunctionTypeEffectsRef;
+class FunctionTypeEffectSet;
+
+/*
+  TODO: Idea about how to move most of the FunctionEffect business out of
+  Type.h, thus removing these forward declarations.
+
+  - Keep FunctionEffect itself here but make it more minimal. Don't define 
flags
+  or any behaviors, just the Kind and an accessor.
+  - Keep FunctionEffectCondExpr here.
+  - Make FunctionProtoType and ExtProtoInfo use only ArrayRef
+  and ArrayRef.
+  - Somewhere in Sema, define ExtFunctionEffect, which holds a FunctionEffect
+and has all the behavior-related methods.
+  - There too, define the containers. FunctionTypeEffectsRef can have a
+  constructor or factory method that initializes itself from a
+  FunctionProtoType.
+*/

dougsonos wrote:

This outlines an idea for removing most of the new bits from Type.h and putting 
them somewhere under Sema where they'd make more sense.

https://github.com/llvm/llvm-project/pull/84983
___
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-15 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 test_suppres

[clang] [lld] [llvm] Rename -macosx_version_min to -macosx_version_min (PR #88810)

2024-04-15 Thread Leland Jansen via cfe-commits

https://github.com/lelandjansen created 
https://github.com/llvm/llvm-project/pull/88810

`-macosx_version_min` has been renamed to `-macos_version_min`.



>From 9635f7deb47e7989383a6c01bdd445cba3e9670a Mon Sep 17 00:00:00 2001
From: Leland Jansen 
Date: Mon, 15 Apr 2024 15:05:56 -0700
Subject: [PATCH] Rename -macosx_version_min to -macosx_version_min

---
 clang/lib/Driver/ToolChains/Darwin.cpp |  4 ++--
 clang/test/Driver/darwin-ld-platform-version-macos.c   |  4 ++--
 .../Driver/darwin-ld-platform-version-target-version.c |  4 ++--
 clang/test/Driver/darwin-ld.c  |  8 
 clang/test/Driver/darwin-sdkroot.c |  2 +-
 clang/test/Driver/darwin-zippered-target-version.c | 10 +-
 clang/test/Driver/target-triple-deployment.c   |  6 +++---
 lld/test/MachO/silent-ignore.s |  2 +-
 llvm/test/tools/dsymutil/X86/alias.test|  2 +-
 llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test |  2 +-
 llvm/test/tools/dsymutil/X86/swift-dwarf-loc.test  |  2 +-
 llvm/test/tools/dsymutil/null-die.test |  2 +-
 llvm/test/tools/llvm-objdump/MachO/LLVM-bundle.test|  2 +-
 llvm/test/tools/lto/hide-linkonce-odr.ll   |  2 +-
 14 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index caf6c4a444fdce..a42a31337304f8 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3143,7 +3143,7 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
 CmdArgs.push_back("-maccatalyst_version_min");
   else {
 assert(isTargetMacOS() && "unexpected target");
-CmdArgs.push_back("-macosx_version_min");
+CmdArgs.push_back("-macos_version_min");
   }
 
   VersionTuple MinTgtVers = 
getEffectiveTriple().getMinimumSupportedOSVersion();
@@ -3154,7 +3154,7 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
 assert(isTargetMacOSBased() && "unexpected target");
 VersionTuple VariantTargetVersion;
 if (TargetVariantTriple->isMacOSX()) {
-  CmdArgs.push_back("-macosx_version_min");
+  CmdArgs.push_back("-macos_version_min");
   TargetVariantTriple->getMacOSXVersion(VariantTargetVersion);
 } else {
   assert(TargetVariantTriple->isiOS() &&
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 355df8dfc1bc20..41636a50111e99 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -34,12 +34,12 @@
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW_1 %s
 
-// LINKER-OLD: "-macosx_version_min" "10.13.0"
+// LINKER-OLD: "-macos_version_min" "10.13.0"
 // LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
 
 // ARM64_NEW: "-platform_version" "macos" "11.0.0" "10.14"
 // ARM64_NEW_1: "-platform_version" "macos" "11.1.0" "10.14"
-// ARM64_OLD: "-macosx_version_min" "11.0.0"
+// ARM64_OLD: "-macos_version_min" "11.0.0"
 
 // RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
diff --git a/clang/test/Driver/darwin-ld-platform-version-target-version.c 
b/clang/test/Driver/darwin-ld-platform-version-target-version.c
index cc88e015f82c5b..0728af8a9785c1 100644
--- a/clang/test/Driver/darwin-ld-platform-version-target-version.c
+++ b/clang/test/Driver/darwin-ld-platform-version-target-version.c
@@ -26,5 +26,5 @@
 // ARM64_NEW-INV: "-platform_version" "macos" "11.0.0" "10.15"
 // ARM64_NEW-INV-SAME: "-platform_version" "mac catalyst" "14.0.0" "13.1"
 
-// ARM64_OLD: "-maccatalyst_version_min" "14.0.0" "-macosx_version_min" 
"11.0.0"
-// ARM64_OLD-INV:  "-macosx_version_min" "11.0.0" "-maccatalyst_version_min" 
"14.0.0"
+// ARM64_OLD: "-maccatalyst_version_min" "14.0.0" "-macos_version_min" "11.0.0"
+// ARM64_OLD-INV:  "-macos_version_min" "11.0.0" "-maccatalyst_version_min" 
"14.0.0"
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index f0ca411430cc78..716041429aca5c 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -140,15 +140,15 @@
 // RUN: %clang -target x86_64-apple-macosx10.7 -fuse-ld= -mlinker-version=400 
-### %t.o 2>> %t.log
 // RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
 // LINK_VERSION_MIN: {{ld(.exe)?"}}
-// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
+// LINK_VERSION_MIN: "-macos_version_min" "10.6.0"
 // LINK_VERSION_MIN: {{ld(.exe)?"}}
-// LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
+// LINK_VERSION_MIN: "-macos_version_min" "10.7.0"
 
 // RUN: %clang -target x86_64-apple-ios13.1-macabi -fuse-ld= 
-mlinker-version=400 -### %t.o 2>> %t.log
 // RUN: FileCheck -check-prefix=LINK_VERSION_MIN_MACABI %s < %t.log
 // LINK_VERSION_MIN_MACABI: {{ld(.exe)?"}}
 // LINK_VERSION_MIN_MACABI: "-maccatalyst_version_min" "13.1.0"

[clang] [lld] [llvm] Rename -macosx_version_min to -macosx_version_min (PR #88810)

2024-04-15 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [lld] [llvm] Rename -macosx_version_min to -macosx_version_min (PR #88810)

2024-04-15 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Leland Jansen (lelandjansen)


Changes

`-macosx_version_min` has been renamed to `-macos_version_min`.



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


14 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+2-2) 
- (modified) clang/test/Driver/darwin-ld-platform-version-macos.c (+2-2) 
- (modified) clang/test/Driver/darwin-ld-platform-version-target-version.c 
(+2-2) 
- (modified) clang/test/Driver/darwin-ld.c (+4-4) 
- (modified) clang/test/Driver/darwin-sdkroot.c (+1-1) 
- (modified) clang/test/Driver/darwin-zippered-target-version.c (+5-5) 
- (modified) clang/test/Driver/target-triple-deployment.c (+3-3) 
- (modified) lld/test/MachO/silent-ignore.s (+1-1) 
- (modified) llvm/test/tools/dsymutil/X86/alias.test (+1-1) 
- (modified) llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test (+1-1) 
- (modified) llvm/test/tools/dsymutil/X86/swift-dwarf-loc.test (+1-1) 
- (modified) llvm/test/tools/dsymutil/null-die.test (+1-1) 
- (modified) llvm/test/tools/llvm-objdump/MachO/LLVM-bundle.test (+1-1) 
- (modified) llvm/test/tools/lto/hide-linkonce-odr.ll (+1-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index caf6c4a444fdce..a42a31337304f8 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3143,7 +3143,7 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
 CmdArgs.push_back("-maccatalyst_version_min");
   else {
 assert(isTargetMacOS() && "unexpected target");
-CmdArgs.push_back("-macosx_version_min");
+CmdArgs.push_back("-macos_version_min");
   }
 
   VersionTuple MinTgtVers = 
getEffectiveTriple().getMinimumSupportedOSVersion();
@@ -3154,7 +3154,7 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
 assert(isTargetMacOSBased() && "unexpected target");
 VersionTuple VariantTargetVersion;
 if (TargetVariantTriple->isMacOSX()) {
-  CmdArgs.push_back("-macosx_version_min");
+  CmdArgs.push_back("-macos_version_min");
   TargetVariantTriple->getMacOSXVersion(VariantTargetVersion);
 } else {
   assert(TargetVariantTriple->isiOS() &&
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 355df8dfc1bc20..41636a50111e99 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -34,12 +34,12 @@
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=ARM64_NEW_1 %s
 
-// LINKER-OLD: "-macosx_version_min" "10.13.0"
+// LINKER-OLD: "-macos_version_min" "10.13.0"
 // LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
 
 // ARM64_NEW: "-platform_version" "macos" "11.0.0" "10.14"
 // ARM64_NEW_1: "-platform_version" "macos" "11.1.0" "10.14"
-// ARM64_OLD: "-macosx_version_min" "11.0.0"
+// ARM64_OLD: "-macos_version_min" "11.0.0"
 
 // RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
diff --git a/clang/test/Driver/darwin-ld-platform-version-target-version.c 
b/clang/test/Driver/darwin-ld-platform-version-target-version.c
index cc88e015f82c5b..0728af8a9785c1 100644
--- a/clang/test/Driver/darwin-ld-platform-version-target-version.c
+++ b/clang/test/Driver/darwin-ld-platform-version-target-version.c
@@ -26,5 +26,5 @@
 // ARM64_NEW-INV: "-platform_version" "macos" "11.0.0" "10.15"
 // ARM64_NEW-INV-SAME: "-platform_version" "mac catalyst" "14.0.0" "13.1"
 
-// ARM64_OLD: "-maccatalyst_version_min" "14.0.0" "-macosx_version_min" 
"11.0.0"
-// ARM64_OLD-INV:  "-macosx_version_min" "11.0.0" "-maccatalyst_version_min" 
"14.0.0"
+// ARM64_OLD: "-maccatalyst_version_min" "14.0.0" "-macos_version_min" "11.0.0"
+// ARM64_OLD-INV:  "-macos_version_min" "11.0.0" "-maccatalyst_version_min" 
"14.0.0"
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index f0ca411430cc78..716041429aca5c 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -140,15 +140,15 @@
 // RUN: %clang -target x86_64-apple-macosx10.7 -fuse-ld= -mlinker-version=400 
-### %t.o 2>> %t.log
 // RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
 // LINK_VERSION_MIN: {{ld(.exe)?"}}
-// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
+// LINK_VERSION_MIN: "-macos_version_min" "10.6.0"
 // LINK_VERSION_MIN: {{ld(.exe)?"}}
-// LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
+// LINK_VERSION_MIN: "-macos_version_min" "10.7.0"
 
 // RUN: %clang -target x86_64-apple-ios13.1-macabi -fuse-ld= 
-mlinker-version=400 -### %t.o 2>> %t.log
 // RUN: FileCheck -check-prefix=LINK_VERSION_MIN_MACABI %s < %t.log
 // LINK_VERSION_MIN_MACABI: {{ld(.exe)?"}}
 // LINK_VERSION_MIN_MACABI: "-maccatalyst_version_min" "13.1.0"
-// LINK_VERSION_MIN_MACABI-NOT: macosx_version_min
+// LINK_VERSION_MIN_MACABI-NOT: macos_version_min
 // LINK_VERSI

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

2024-04-15 Thread via cfe-commits

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


[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-15 Thread Doug Wyatt via cfe-commits

dougsonos wrote:

I worked out an idea for moving much of the FunctionEffect plumbing out of 
Type.h, into somewhere under Sema (probably new files because Sema.h is huge). 
It's outlined in a comment in Type.h.

Initial support for an optional conditional expression attached to an effect is 
now in place. It's a separate array of trailing objects on the 
FunctionProtoType. The "set" objects hold parallel arrays of effects and 
conditions and for usability, iterate through them in unison. The attribute 
parser doesn't yet populate the conditions, and template instantiation doesn't 
yet try to evaluate and eliminate them. I think the code to do this could live 
in the effect set if it were under Sema (as I just described).

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


[clang] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Dan Liew via cfe-commits


@@ -1822,28 +1822,101 @@ void WriteSemanticSpellingSwitch(const std::string 
&VarName,
   OS << "  }\n";
 }
 
+enum class LateAttrParseKind { Never = 0, Always = 1, ExperimentalOnly = 2 };
+
+static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
+  // This function basically does
+  // `Attr->getValueAsDef("LateParsed")->getValueAsInt("Mode")` but does
+  // a bunch of sanity checking to ensure that
+  // `LateAttrParseMode` in `Attr.td` is in sync with the `LateAttrParseKind`
+  // enum in this source file.
+
+  static constexpr StringRef LateParsedStr = "LateParsed";
+  static constexpr StringRef LateAttrParseKindStr = "LateAttrParseKind";
+  static constexpr StringRef KindFieldStr = "Kind";
+
+  auto *LAPK = Attr->getValueAsDef(LateParsedStr);
+
+  // Typecheck the `LateParsed` field.
+  SmallVector SuperClasses;
+  LAPK->getDirectSuperClasses(SuperClasses);
+  if (SuperClasses.size() != 1)
+PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
+  "`should only have one super class");
+
+  if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0)
+PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
+  "`should only have type `" +
+  llvm::Twine(LateAttrParseKindStr) +
+  "` but found type `" +
+  SuperClasses[0]->getName() + "`");
+
+  // Get Kind and verify the enum name matches the name in `Attr.td`.
+  unsigned Kind = LAPK->getValueAsInt(KindFieldStr);
+  switch (LateAttrParseKind(Kind)) {
+#define CASE(X)
\
+  case LateAttrParseKind::X:   
\
+if (LAPK->getName().compare("LateAttrParse" #X) != 0) {
\
+  PrintFatalError(Attr,
\
+  "Field `" + llvm::Twine(LateParsedStr) + "` set to `" +  
\
+  LAPK->getName() +
\
+  "` but this converts to `LateAttrParseKind::" +  
\
+  llvm::Twine(#X) + "`");  
\
+}  
\
+return LateAttrParseKind::X;
+
+CASE(Never)
+CASE(Always)
+CASE(ExperimentalOnly)
+#undef CASE
+  }
+
+  // The Kind value is completely invalid
+  auto KindValueStr = llvm::utostr(Kind);
+  PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "` set to `" +
+LAPK->getName() + "` has unexpected `" +
+llvm::Twine(KindFieldStr) + "` value of " +
+KindValueStr);
+}
+
 // Emits the LateParsed property for attributes.
-static void emitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream 
&OS) {
-  OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n";
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+static void emitClangAttrLateParsedListImpl(RecordKeeper &Records,
+raw_ostream &OS,
+LateAttrParseKind LateParseMode) {
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
 
   for (const auto *Attr : Attrs) {
-bool LateParsed = Attr->getValueAsBit("LateParsed");
+auto LateParsed = getLateAttrParseKind(Attr);

delcypher wrote:

Do you mean something like...

```
for (const auto *Attr : Attrs) {
  if (LateAttrParseKind LateParsed = getLateAttrParseKind(Attr); LateParsed == 
LateParseMode) {
 // All these lines have to be indented now.
  }
}
```

?

If so I'm not really a fan of this. This forces a bunch of lines to be indented 
which weren't before. I much prefer to avoid that when possible to avoid the 
"pyramid-of-doom".

Or did you mean something else?

Absolutely with you on the use of `auto` here. I'll fix that.

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


[clang] [lld] [llvm] Rename -macosx_version_min to -macosx_version_min (PR #88810)

2024-04-15 Thread J. Ryan Stinnett via cfe-commits

jryans wrote:

Perhaps good to edit the PR title, it mentions the same flag twice at the 
moment.

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


[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMB

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,291 @@
+
+HLSL Root Signatures
+
+
+.. contents::
+   :local:
+
+Usage
+=
+
+In HLSL, the `root signature
+`_
+defines what types of resources are bound to the graphics pipeline.
+
+A root signature can be specified in HLSL as a `string
+`_.
+The string contains a collection of comma-separated clauses that describe root
+signature constituent components.
+
+There are two mechanisms to compile an HLSL root signature. First, it is
+possible to attach a root signature string to a particular shader via the
+RootSignature attribute (in the following example, using the main entry
+point):
+
+.. code-block::
+
+#define RS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
+  "DENY_VERTEX_SHADER_ROOT_ACCESS), " \
+  "CBV(b0, space = 1, flags = DATA_STATIC), " \
+  "SRV(t0), " \
+  "UAV(u0), " \
+  "DescriptorTable( CBV(b1), " \
+  " SRV(t1, numDescriptors = 8, " \
+  " flags = DESCRIPTORS_VOLATILE), " \
+  " UAV(u1, numDescriptors = unbounded, " \
+  " flags = DESCRIPTORS_VOLATILE)), " \
+  "DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \
+  "RootConstants(num32BitConstants=3, b10), " \
+  "StaticSampler(s1)," \
+  "StaticSampler(s2, " \
+  "  addressU = TEXTURE_ADDRESS_CLAMP, " \
+  "  filter = FILTER_MIN_MAG_MIP_LINEAR )"
+
+[RootSignature(MyRS)]
+float4 main(float4 coord : COORD) : SV_Target
+{
+…
+}
+
+The compiler will create and verify the root signature blob for the shader and
+embed it alongside the shader byte code into the shader blob.
+
+The other mechanism is to create a standalone root signature blob, perhaps to
+reuse it with a large set of shaders, saving space. The name of the define
+string is specified via the usual -E argument. For example:
+
+.. code-block:: sh
+
+  dxc.exe -T rootsig_1_1 MyRS1.hlsl -E MyRS1 -Fo MyRS1.fxo
+
+Note that the root signature string define can also be passed on the command
+line, e.g, -D MyRS1=”…”.
+
+Root signature could also used in form of StateObject like this:
+
+.. code-block::
+
+  GlobalRootSignature MyGlobalRootSignature =
+  {
+  "DescriptorTable(UAV(u0))," // Output texture
+  "SRV(t0),"  // Acceleration structure
+  "CBV(b0),"  // Scene constants
+  "DescriptorTable(SRV(t1, numDescriptors = 2))"  // Static index and 
vertex buffers.
+  };
+
+  LocalRootSignature MyLocalRootSignature =
+  {
+  "RootConstants(num32BitConstants = 4, b1)"  // Cube constants
+  };
+
+
+Root Signature Grammar
+==
+
+.. code-block:: peg
+
+RootSignature : (RootElement(,RootElement)?)?
+
+RootElement : RootFlags | RootConstants | RootCBV | RootSRV | RootUAV |
+  DescriptorTable | StaticSampler
+
+RootFlags : 'RootFlags' '(' (RootFlag(|RootFlag)?)? ')'
+
+RootFlag : 'ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT' |
+   'DENY_VERTEX_SHADER_ROOT_ACCESS'
+
+RootConstants : 'RootConstants' '(' 'num32BitConstants' '=' NUMBER ','
+   bReg (',' 'space' '=' NUMBER)?
+   (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+RootCBV : 'CBV' '(' bReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootSRV : 'SRV' '(' tReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+RootUAV : 'UAV' '(' uReg (',' 'space' '=' NUMBER)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+DescriptorTable : 'DescriptorTable' '(' (DTClause(|DTClause)?)?
+  (',' 'visibility' '=' SHADER_VISIBILITY)? ')'
+
+DTClause : CBV | SRV | UAV | Sampler
+
+CBV : 'CBV' '(' bReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+SRV : 'SRV' '(' tReg (',' 'numDescriptors' '=' NUMBER)?
+(',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+UAV : 'UAV' '(' uReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMBER)?
+  (',' 'offset' '=' DESCRIPTOR_RANGE_OFFSET)?
+  (',' 'flags' '=' DATA_FLAGS)? ')'
+
+Sampler : 'Sampler' '(' sReg (',' 'numDescriptors' '=' NUMBER)?
+  (',' 'space' '=' NUMB

[clang] [Doc][HLSL] Add documentation for root signature (PR #88781)

2024-04-15 Thread Damyan Pepper via cfe-commits

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

See other comments.

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


[clang] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Dan Liew via cfe-commits

https://github.com/delcypher updated 
https://github.com/llvm/llvm-project/pull/88596

>From db0483ab298cbfee2a76844e4b0f63c3ae0ff68a Mon Sep 17 00:00:00 2001
From: Dan Liew 
Date: Fri, 12 Apr 2024 17:36:19 -0700
Subject: [PATCH 1/2] [Attributes] Support Attributes being declared as only
 supporting late parsing when passing an experimental feature flag

This patch changes the `LateParsed` field of `Attr` in `Attr.td` to be
an instantiation of the new `LateAttrParseKind` class. The instation can be one 
of the following:

* `LateAttrParsingNever` - Corresponds with the false value of `LateParsed` 
prior to this patch (the default for an attribute).
* `LateAttrParsingAlways` - Corresponds with the true value of `LateParsed` 
prior to this patch.
* `LateAttrParsingExperimentalOnly` - A new mode described below.

`LateAttrParsingExperimentalOnly` means that the attribute will be late
parsed if the new the `ExperimentalLateParseAttributes` language option (also 
introduced in
this patch) is enabled and will **not** be late parsed if the language
option is disabled.

The new `ExperimentalLateParseAttributes` language option is controlled
by a new driver and frontend flag
(`-fexperimental-late-parse-attributes`). A driver test is included to
check that the driver passes the flag to CC1.

In this patch the `LateAttrParsingExperimentalOnly` is not adopted by
any attribute so `-fexperimental-late-pase-attributes` and the
corresponding language option currently have no effect on compilation.
This is why this patch does not include any test cases that test
`LateAttrParsingExperimentalOnly`'s behavior.

The motivation for this patch is to be able to late parse the new
`counted_by` attribute but only do so when a feature flag is passed.
This was discussed during the [bounds-safety 
RFC](https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safety/70854/68).

Adoption of `LateAttrParsingExperimentalOnly` for the `counted_by`
attributed will be handled separately in another patch (likely
https://github.com/llvm/llvm-project/pull/87596).
---
 clang/include/clang/Basic/Attr.td |  46 +++---
 clang/include/clang/Basic/LangOptions.def |   1 +
 clang/include/clang/Driver/Options.td |   7 +
 clang/include/clang/Parse/Parser.h|   4 +
 clang/lib/Driver/ToolChains/Clang.cpp |   3 +
 clang/lib/Parse/ParseDecl.cpp |  19 ++-
 .../experimental-late-parse-attributes.c  |  12 ++
 clang/utils/TableGen/ClangAttrEmitter.cpp | 133 +++---
 8 files changed, 188 insertions(+), 37 deletions(-)
 create mode 100644 clang/test/Driver/experimental-late-parse-attributes.c

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dc87a8c6f022dc..597a8fb11e51b8 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -592,6 +592,16 @@ class AttrSubjectMatcherAggregateRule 
{
 
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
+// Late Attribute parsing mode enum
+class LateAttrParseKind  {
+  int Kind = val;
+}
+def LateAttrParseNever : LateAttrParseKind<0>; // Never late parsed
+def LateAttrParseAlways: LateAttrParseKind<1>; // Always late parsed
+// Late parsed if `-fexperimental-late-parse-attributes` is on and parsed
+// normally if off.
+def LateAttrParseExperimentalOnly : LateAttrParseKind<2>;
+
 class Attr {
   // The various ways in which an attribute can be spelled in source
   list Spellings;
@@ -603,8 +613,8 @@ class Attr {
   list Accessors = [];
   // Specify targets for spellings.
   list TargetSpecificSpellings = [];
-  // Set to true for attributes with arguments which require delayed parsing.
-  bit LateParsed = 0;
+  // Specifies the late parsing kind.
+  LateAttrParseKind LateParsed = LateAttrParseNever;
   // Set to false to prevent an attribute from being propagated from a template
   // to the instantiation.
   bit Clone = 1;
@@ -3173,7 +3183,7 @@ def DiagnoseIf : InheritableAttr {
   BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
   DeclArgument];
   let InheritEvenIfAlreadyPresent = 1;
-  let LateParsed = 1;
+  let LateParsed = LateAttrParseAlways;
   let AdditionalMembers = [{
 bool isError() const { return diagnosticType == DT_Error; }
 bool isWarning() const { return diagnosticType == DT_Warning; }
@@ -3472,7 +3482,7 @@ def AssertCapability : InheritableAttr {
   let Spellings = [Clang<"assert_capability", 0>,
Clang<"assert_shared_capability", 0>];
   let Subjects = SubjectList<[Function]>;
-  let LateParsed = 1;
+  let LateParsed = LateAttrParseAlways;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
   let InheritEvenIfAlreadyPresent = 1;
@@ -3488,7 +3498,7 @@ def AcquireCapability : InheritableAttr {
GNU<"exclusive_lock_function">,
GNU<"shared_lock_function">];
   let Subjects = SubjectList<[Function]>;
-  let LateParsed = 1;
+  let LateP

[clang] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Dan Liew via cfe-commits


@@ -1822,28 +1822,101 @@ void WriteSemanticSpellingSwitch(const std::string 
&VarName,
   OS << "  }\n";
 }
 
+enum class LateAttrParseKind { Never = 0, Always = 1, ExperimentalOnly = 2 };
+
+static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
+  // This function basically does
+  // `Attr->getValueAsDef("LateParsed")->getValueAsInt("Mode")` but does
+  // a bunch of sanity checking to ensure that
+  // `LateAttrParseMode` in `Attr.td` is in sync with the `LateAttrParseKind`
+  // enum in this source file.
+
+  static constexpr StringRef LateParsedStr = "LateParsed";
+  static constexpr StringRef LateAttrParseKindStr = "LateAttrParseKind";
+  static constexpr StringRef KindFieldStr = "Kind";
+
+  auto *LAPK = Attr->getValueAsDef(LateParsedStr);
+
+  // Typecheck the `LateParsed` field.
+  SmallVector SuperClasses;
+  LAPK->getDirectSuperClasses(SuperClasses);
+  if (SuperClasses.size() != 1)
+PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
+  "`should only have one super class");
+
+  if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0)
+PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
+  "`should only have type `" +
+  llvm::Twine(LateAttrParseKindStr) +
+  "` but found type `" +
+  SuperClasses[0]->getName() + "`");
+
+  // Get Kind and verify the enum name matches the name in `Attr.td`.
+  unsigned Kind = LAPK->getValueAsInt(KindFieldStr);
+  switch (LateAttrParseKind(Kind)) {
+#define CASE(X)
\
+  case LateAttrParseKind::X:   
\
+if (LAPK->getName().compare("LateAttrParse" #X) != 0) {
\
+  PrintFatalError(Attr,
\
+  "Field `" + llvm::Twine(LateParsedStr) + "` set to `" +  
\
+  LAPK->getName() +
\
+  "` but this converts to `LateAttrParseKind::" +  
\
+  llvm::Twine(#X) + "`");  
\
+}  
\
+return LateAttrParseKind::X;
+
+CASE(Never)
+CASE(Always)
+CASE(ExperimentalOnly)
+#undef CASE
+  }
+
+  // The Kind value is completely invalid
+  auto KindValueStr = llvm::utostr(Kind);
+  PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "` set to `" +
+LAPK->getName() + "` has unexpected `" +
+llvm::Twine(KindFieldStr) + "` value of " +
+KindValueStr);
+}
+
 // Emits the LateParsed property for attributes.
-static void emitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream 
&OS) {
-  OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n";
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+static void emitClangAttrLateParsedListImpl(RecordKeeper &Records,
+raw_ostream &OS,
+LateAttrParseKind LateParseMode) {
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
 
   for (const auto *Attr : Attrs) {
-bool LateParsed = Attr->getValueAsBit("LateParsed");
+auto LateParsed = getLateAttrParseKind(Attr);

delcypher wrote:

Nevermind. I realized what you meant. I've resolved it.

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


[clang] [lld] [llvm] Rename -macosx_version_min to -macos_version_min (PR #88810)

2024-04-15 Thread Leland Jansen via cfe-commits

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


[clang] [lld] [llvm] Rename -macosx_version_min to -macos_version_min (PR #88810)

2024-04-15 Thread Leland Jansen via cfe-commits

lelandjansen wrote:

> Perhaps good to edit the PR title, it mentions the same flag twice at the 
> moment.

Good catch. Thank you.

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


[clang] [flang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-15 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

9f43a41db37253685c5ed428c215528eb92bbd43
1693009679313282afbed38778dd3fad62641e1b

Landed as the above commits.

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


[clang] [flang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-15 Thread YunQiang Su via cfe-commits

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


[clang] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Dan Liew via cfe-commits

https://github.com/delcypher updated 
https://github.com/llvm/llvm-project/pull/88596

>From db0483ab298cbfee2a76844e4b0f63c3ae0ff68a Mon Sep 17 00:00:00 2001
From: Dan Liew 
Date: Fri, 12 Apr 2024 17:36:19 -0700
Subject: [PATCH 1/3] [Attributes] Support Attributes being declared as only
 supporting late parsing when passing an experimental feature flag

This patch changes the `LateParsed` field of `Attr` in `Attr.td` to be
an instantiation of the new `LateAttrParseKind` class. The instation can be one 
of the following:

* `LateAttrParsingNever` - Corresponds with the false value of `LateParsed` 
prior to this patch (the default for an attribute).
* `LateAttrParsingAlways` - Corresponds with the true value of `LateParsed` 
prior to this patch.
* `LateAttrParsingExperimentalOnly` - A new mode described below.

`LateAttrParsingExperimentalOnly` means that the attribute will be late
parsed if the new the `ExperimentalLateParseAttributes` language option (also 
introduced in
this patch) is enabled and will **not** be late parsed if the language
option is disabled.

The new `ExperimentalLateParseAttributes` language option is controlled
by a new driver and frontend flag
(`-fexperimental-late-parse-attributes`). A driver test is included to
check that the driver passes the flag to CC1.

In this patch the `LateAttrParsingExperimentalOnly` is not adopted by
any attribute so `-fexperimental-late-pase-attributes` and the
corresponding language option currently have no effect on compilation.
This is why this patch does not include any test cases that test
`LateAttrParsingExperimentalOnly`'s behavior.

The motivation for this patch is to be able to late parse the new
`counted_by` attribute but only do so when a feature flag is passed.
This was discussed during the [bounds-safety 
RFC](https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safety/70854/68).

Adoption of `LateAttrParsingExperimentalOnly` for the `counted_by`
attributed will be handled separately in another patch (likely
https://github.com/llvm/llvm-project/pull/87596).
---
 clang/include/clang/Basic/Attr.td |  46 +++---
 clang/include/clang/Basic/LangOptions.def |   1 +
 clang/include/clang/Driver/Options.td |   7 +
 clang/include/clang/Parse/Parser.h|   4 +
 clang/lib/Driver/ToolChains/Clang.cpp |   3 +
 clang/lib/Parse/ParseDecl.cpp |  19 ++-
 .../experimental-late-parse-attributes.c  |  12 ++
 clang/utils/TableGen/ClangAttrEmitter.cpp | 133 +++---
 8 files changed, 188 insertions(+), 37 deletions(-)
 create mode 100644 clang/test/Driver/experimental-late-parse-attributes.c

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dc87a8c6f022dc..597a8fb11e51b8 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -592,6 +592,16 @@ class AttrSubjectMatcherAggregateRule 
{
 
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
+// Late Attribute parsing mode enum
+class LateAttrParseKind  {
+  int Kind = val;
+}
+def LateAttrParseNever : LateAttrParseKind<0>; // Never late parsed
+def LateAttrParseAlways: LateAttrParseKind<1>; // Always late parsed
+// Late parsed if `-fexperimental-late-parse-attributes` is on and parsed
+// normally if off.
+def LateAttrParseExperimentalOnly : LateAttrParseKind<2>;
+
 class Attr {
   // The various ways in which an attribute can be spelled in source
   list Spellings;
@@ -603,8 +613,8 @@ class Attr {
   list Accessors = [];
   // Specify targets for spellings.
   list TargetSpecificSpellings = [];
-  // Set to true for attributes with arguments which require delayed parsing.
-  bit LateParsed = 0;
+  // Specifies the late parsing kind.
+  LateAttrParseKind LateParsed = LateAttrParseNever;
   // Set to false to prevent an attribute from being propagated from a template
   // to the instantiation.
   bit Clone = 1;
@@ -3173,7 +3183,7 @@ def DiagnoseIf : InheritableAttr {
   BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
   DeclArgument];
   let InheritEvenIfAlreadyPresent = 1;
-  let LateParsed = 1;
+  let LateParsed = LateAttrParseAlways;
   let AdditionalMembers = [{
 bool isError() const { return diagnosticType == DT_Error; }
 bool isWarning() const { return diagnosticType == DT_Warning; }
@@ -3472,7 +3482,7 @@ def AssertCapability : InheritableAttr {
   let Spellings = [Clang<"assert_capability", 0>,
Clang<"assert_shared_capability", 0>];
   let Subjects = SubjectList<[Function]>;
-  let LateParsed = 1;
+  let LateParsed = LateAttrParseAlways;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
   let InheritEvenIfAlreadyPresent = 1;
@@ -3488,7 +3498,7 @@ def AcquireCapability : InheritableAttr {
GNU<"exclusive_lock_function">,
GNU<"shared_lock_function">];
   let Subjects = SubjectList<[Function]>;
-  let LateParsed = 1;
+  let LateP

[clang] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Dan Liew via cfe-commits


@@ -592,6 +592,46 @@ class AttrSubjectMatcherAggregateRule 
{
 
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
+// Late Attribute parsing mode enum

delcypher wrote:

@rapidsna I renamed the `LateAttrParseKind` definitions and updated the 
comments explaining the semantics. Does this look right to you?

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


[clang] [Attributes] Support Attributes being declared as only supporting late parsing when passing an experimental feature flag (PR #88596)

2024-04-15 Thread Dan Liew via cfe-commits


@@ -592,6 +592,46 @@ class AttrSubjectMatcherAggregateRule 
{
 
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
+// Late Attribute parsing mode enum
+class LateAttrParseKind  {
+  int Kind = val;
+}
+
+// Never late parsed
+def LateAttrParseNever : LateAttrParseKind<0>;
+
+// Standard late attribute parsing
+//
+// This is language dependent. For example:
+//
+// * For C++ enables late parsing of a declaration attributes
+// * For C does not enable late parsing of attributes
+//
+def LateAttrParseStandard: LateAttrParseKind<1>;
+
+// Experimental extension to standard late attribute parsing
+//
+// This extension behaves like `LateAttrParseStandard` but allows
+// late parsing attributes in more contexts.
+//
+// This extension changes behavior depending on whether the
+// `-fexperimental-late-parse-attributes`
+// (`LangOpts.ExperimentalLateParseAttributes`) flag is enabled.
+//
+// * If the flag is disabled then the attribute is parsed just like
+//   `LateAttrParseStandard`.
+//
+// * If the flag is enabled and if the attribute is being used in a context
+//   supported by this extension it will be late parsed. Otherwise the 
attribute
+//   will be parsed just like `LateAttrParseStandard`.
+//
+// Currently this extension extends `LateAttrParseStandard` by allowing:
+//
+// * For C, late parsing of the `counted_by` as a type or decl attribute.
+//   (TODO: Not implemented yet).

delcypher wrote:

@rapidsna Maybe I should drop this bit because of the `TODO`?

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


[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-04-15 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/87933

>From 9fba6da7cb1ffbc7d46b69c6ac0cfd15a89c4b56 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Mon, 8 Apr 2024 01:38:23 +0800
Subject: [PATCH 1/2] [Clang] Support lifetime extension of temporary created
 by aggregate initialization using a default member initializer

Signed-off-by: yronglin 
---
 .../clang/Basic/DiagnosticSemaKinds.td|  6 ---
 clang/lib/Sema/SemaExpr.cpp   | 16 
 clang/lib/Sema/SemaInit.cpp   | 39 +--
 .../Analysis/lifetime-extended-regions.cpp|  2 +-
 clang/test/CXX/drs/dr16xx.cpp |  2 -
 clang/test/CXX/drs/dr18xx.cpp |  5 +--
 clang/test/CXX/special/class.temporary/p6.cpp | 20 ++
 clang/test/SemaCXX/constexpr-default-arg.cpp  |  4 +-
 clang/test/SemaCXX/eval-crashes.cpp   |  6 +--
 9 files changed, 62 insertions(+), 38 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a1dda2d2461c31..ba779e83d2afd4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10010,12 +10010,6 @@ def warn_new_dangling_initializer_list : Warning<
   "the allocated initializer list}0 "
   "will be destroyed at the end of the full-expression">,
   InGroup;
-def warn_unsupported_lifetime_extension : Warning<
-  "lifetime extension of "
-  "%select{temporary|backing array of initializer list}0 created "
-  "by aggregate initialization using a default member initializer "
-  "is not yet supported; lifetime of %select{temporary|backing array}0 "
-  "will end at the end of the full-expression">, InGroup;
 
 // For non-floating point, expressions of the form x == x or x != x
 // should result in a warning, since these always evaluate to a constant.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8db4fffeecfe35..b2e0f2a2a60113 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6338,10 +6338,9 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation 
CallLoc,
 Res = Immediate.TransformInitializer(Param->getInit(),
  /*NotCopy=*/false);
   });
-  if (Res.isInvalid())
-return ExprError();
-  Res = ConvertParamDefaultArgument(Param, Res.get(),
-Res.get()->getBeginLoc());
+  if (Res.isUsable())
+Res = ConvertParamDefaultArgument(Param, Res.get(),
+  Res.get()->getBeginLoc());
   if (Res.isInvalid())
 return ExprError();
   Init = Res.get();
@@ -6377,7 +6376,7 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation 
Loc, FieldDecl *Field) {
   Expr *Init = nullptr;
 
   bool NestedDefaultChecking = isCheckingDefaultArgumentOrInitializer();
-
+  bool InLifetimeExtendingContext = isInLifetimeExtendingContext();
   EnterExpressionEvaluationContext EvalContext(
   *this, ExpressionEvaluationContext::PotentiallyEvaluated, Field);
 
@@ -6412,11 +6411,14 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation 
Loc, FieldDecl *Field) {
   ImmediateCallVisitor V(getASTContext());
   if (!NestedDefaultChecking)
 V.TraverseDecl(Field);
-  if (V.HasImmediateCalls) {
+  if (V.HasImmediateCalls || InLifetimeExtendingContext) {
 ExprEvalContexts.back().DelayedDefaultInitializationContext = {Loc, Field,
CurContext};
 ExprEvalContexts.back().IsCurrentlyCheckingDefaultArgumentOrInitializer =
 NestedDefaultChecking;
+// Pass down lifetime extending flag, and collect temporaries in
+// CreateMaterializeTemporaryExpr when we rewrite the call argument.
+keepInLifetimeExtendingContext();
 
 EnsureImmediateInvocationInDefaultArgs Immediate(*this);
 ExprResult Res;
@@ -6424,7 +6426,7 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation 
Loc, FieldDecl *Field) {
   Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
/*CXXDirectInit=*/false);
 });
-if (!Res.isInvalid())
+if (Res.isUsable())
   Res = ConvertMemberDefaultInitExpression(Field, Res.get(), Loc);
 if (Res.isInvalid()) {
   Field->setInvalidDecl();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index a75e9925a43146..842412cd674d8c 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -710,6 +710,26 @@ void InitListChecker::FillInEmptyInitForField(unsigned 
Init, FieldDecl *Field,
   if (VerifyOnly)
 return;
 
+  // Enter a lifetime extension context, then we can support lifetime
+  // extension of temporary created by aggregate initialization using a
+  // default member initializer (DR1815 https://wg21.link/CWG1815).
+  //
+  

[clang] [AST][RecoveryExpr] Fix a crash on c89/c90 invalid InitListExpr (#88008) (PR #88014)

2024-04-15 Thread Ding Fei via cfe-commits


@@ -13805,29 +13804,24 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized.
 // This is true even in C++ for OpenCL.
 } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init);

danix800 wrote:

No, this defaults to `diag::err_init_element_not_constant`.

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


[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

2024-04-15 Thread Fangrui Song via cfe-commits

MaskRay wrote:

> > I think I've addressed all comments and changed the patch to rebase on the 
> > improved tests.
> > @AaronBallman @tstellar Are you happy with the current version?
> 
> Please file an issue for this:
> 
> > I added microsoftDemangle tests to show the current behavior.
> > Since the feature that demangles to the function name without parameters 
> > (f3 instead of f3(int)) appears to be missing, I cannot > address 
> > -Wunused-function false positives for microsoftDemangle with reasonable 
> > time complexity.
> 
> and file a second one to come back and fix this issue once we can demangle 
> with parameters.

Created #88823 and #88825 

Thanks!

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


[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)

2024-04-15 Thread Qizhi Hu via cfe-commits

jcsxky wrote:

> Ah, I had missed (thanks github review tool!) that the 'ImplicitObjectMember' 
> part already existed. Sorry for that.

Never mind! Partly because I didn't make it more clear due to my poor 
expression .

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


[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)

2024-04-15 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/85198

>From 0076d87897371f3467c49818a7789cedda27e485 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Thu, 14 Mar 2024 16:32:36 +0800
Subject: [PATCH] [Clang][Sema] Fix issue on requires expression with templated
 base class member function

---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaExpr.cpp|  3 ++-
 clang/test/SemaCXX/PR84020.cpp | 23 +++
 3 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/PR84020.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dc108785f6cc99..76701dc723b6c3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -538,6 +538,7 @@ Bug Fixes to C++ Support
   object parameter.
   Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), 
(#GH86398), and (#GH86399).
 - Fix a crash when deducing ``auto`` from an invalid dereference (#GH88329).
+- Fix a crash in requires expression with templated base class member 
function. Fixes (#GH84020).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 24f354f1c72498..189764cb4b6b08 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7739,7 +7739,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, 
NamedDecl *NDecl,
   }
 
   if (CXXMethodDecl *Method = dyn_cast_or_null(FDecl))
-if (Method->isImplicitObjectMemberFunction())
+if (!isa(CurContext) &&
+Method->isImplicitObjectMemberFunction())
   return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
<< Fn->getSourceRange() << 0);
 
diff --git a/clang/test/SemaCXX/PR84020.cpp b/clang/test/SemaCXX/PR84020.cpp
new file mode 100644
index 00..8ea5dcc4527ae7
--- /dev/null
+++ b/clang/test/SemaCXX/PR84020.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++23 -verify %s
+// expected-no-diagnostics
+
+struct B {
+template 
+void foo();
+
+void bar();
+};
+
+template 
+struct A : T {
+auto foo() {
+static_assert(requires { T::template foo(); });
+static_assert(requires { T::bar(); });
+}
+};
+
+int main() {
+A a;
+a.foo();
+}

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


[clang] [Sema] Mark alias/ifunc targets used and consider mangled names (PR #87130)

2024-04-15 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/87130

>From 23422a0b3af3e070fed5ae86ed0f67acec066c0a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Fri, 29 Mar 2024 17:48:14 -0700
Subject: [PATCH 1/3] =?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.5-bogner
---
 clang/lib/Sema/CMakeLists.txt |  1 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 31 +--
 clang/test/AST/ast-dump-attr-json.cpp |  1 +
 clang/test/Sema/alias-unused.c| 30 +-
 4 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index e8bff07ced0cfa..7657536fabd1eb 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Core
+  Demangle
   FrontendHLSL
   FrontendOpenMP
   MC
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index f25f3afd0f4af2..8ed5242f325e5e 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -42,6 +42,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/Assumptions.h"
 #include "llvm/MC/MCSectionMachO.h"
 #include "llvm/Support/Error.h"
@@ -1980,6 +1981,23 @@ static void handleWeakRefAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL));
 }
 
+// Mark alias/ifunc target as used. For C++, we look up the demangled name
+// ignoring parameters. This should handle the majority of use cases while
+// leaveing false positives for namespace scope names and false negatives in
+// the presence of overloads.
+static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL,
+StringRef Str) {
+  char *Demangled = llvm::itaniumDemangle(Str, /*ParseParams=*/false);
+  if (Demangled)
+Str = Demangled;
+  const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
+  LookupResult LR(S, target, Sema::LookupOrdinaryName);
+  if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+for (NamedDecl *ND : LR)
+  ND->markUsed(S.Context);
+  free(Demangled);
+}
+
 static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   StringRef Str;
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
@@ -1992,6 +2010,7 @@ static void handleIFuncAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 return;
   }
 
+  markUsedForAliasOrIfunc(S, D, AL, Str);
   D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
 }
 
@@ -2026,17 +2045,7 @@ static void handleAliasAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
   }
 
-  // Mark target used to prevent unneeded-internal-declaration warnings.
-  if (!S.LangOpts.CPlusPlus) {
-// FIXME: demangle Str for C++, as the attribute refers to the mangled
-// linkage name, not the pre-mangled identifier.
-const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
-LookupResult LR(S, target, Sema::LookupOrdinaryName);
-if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
-  for (NamedDecl *ND : LR)
-ND->markUsed(S.Context);
-  }
-
+  markUsedForAliasOrIfunc(S, D, AL, Str);
   D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str));
 }
 
diff --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 051c2956abfdf7..883e584bfedf07 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -46,6 +46,7 @@ __thread __attribute__ ((tls_model ("local-exec"))) int 
tls_model_var;
 // CHECK-NEXT:"tokLen": 11
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
+// CHECK-NEXT:  "isUsed": true,
 // CHECK-NEXT:  "name": "global_decl",
 // CHECK-NEXT:  "mangledName": "global_decl",
 // CHECK-NEXT:  "type": {
diff --git a/clang/test/Sema/alias-unused.c b/clang/test/Sema/alias-unused.c
index de9fc8cc737662..030b5737a93a21 100644
--- a/clang/test/Sema/alias-unused.c
+++ b/clang/test/Sema/alias-unused.c
@@ -1,7 +1,35 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x 
c -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunused -x c -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunused -x c++ -verify %s
+
+#ifdef __cplusplus
+extern "C" {
+#else
 // expected-no-diagnostics
+#endif
 static int f(void) { return 42; }
 int g(void) __attribute__((alias("f")));
 
 static int foo [] = { 42, 0xDEAD };
 extern typeof(foo) bar __attribute__((unused, alias("foo")));
+
+static int (*resolver(void))(void) { return f; }
+int ifunc(void) __attribute__((ifunc("resolver")));
+
+#ifdef __cplusplus
+}
+
+/// We demangle alias/ifunc target and mark all found functions as used.
+static int f1

<    1   2   3   4   5   >