[clang] Adding `asuint` implementation to hlsl (PR #107292)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` 
running on `suse-gary-m68k-cross` while building `clang` at step 5 "ninja check 
1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
  511 | class Sema final : public SemaBase {
  |   ^~~~
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Sema/Sema.h:511:7:
 warning: ‘clang::Sema’ declared with greater visibility than the type of its 
field ‘clang::Sema::TentativeDefinitions’ [-Wattributes]
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Sema/Sema.h:511:7:
 warning: ‘clang::Sema’ declared with greater visibility than the type of its 
field ‘clang::Sema::ExtVectorDecls’ [-Wattributes]
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include/clang/Sema/Sema.h:511:7:
 warning: ‘clang::Sema’ declared with greater visibility than the type of its 
field ‘clang::Sema::DelegatingCtorDecls’ [-Wattributes]
[300/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
[301/1128] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
[302/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ASTSelectionTest.cpp.o
[303/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
[304/1128] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
FAILED: tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/unittests/AST
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/AST
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googletest/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googlemock/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull 
-Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros 
-fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD 
-MT tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o -MF 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o.d -o 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o -c 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/AST/ASTImporterTest.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[305/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/LookupTest.cpp.o
[306/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RangeSelectorTest.cpp.o
[307/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Attr.cpp.o
[308/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/QualTypeNamesTest.cpp.o
[309/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ImplicitCtor.cpp.o
[310/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/ImplicitCtorInitializer.cpp.o
[311/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/Class.cpp.o
[312/1128] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTests/DeclRefExpr.cpp.o
[313/1128

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

2024-10-10 Thread Vyacheslav Levytskyy via cfe-commits


@@ -1,12 +1,14 @@
 ; This test aims to check ability to support "Arithmetic with Overflow" 
intrinsics
 ; in the special case when those intrinsics are being generated by the 
CodeGenPrepare;
-; pass during translations with optimization (note -O3 in llc arguments).
+; pass during translations with optimization (note -disable-lsr, to inhibit
+; strength reduction pre-empting with a more preferable match for this pattern
+; in llc arguments).
 
-; RUN: llc -O3 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
-; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv32-unknown-unknown %s -o - 
-filetype=obj | spirv-val %}
+; RUN: llc -O3 -disable-lsr -mtriple=spirv32-unknown-unknown %s -o - | 
FileCheck %s

VyacheslavLevytskyy wrote:

In this case you lose coverage, because

> Correctly selecting / lowering them should be independent of whether they 
> were implicitly inserted by some optimisation pass, or explicitly inserted by 
> the user.

it's a nice idea, I agree with you, but it's somewhat detached. There are two 
different conditions: (1) those intrinsics are present already and explicitly 
accessible for processing by SPIRV Backend code, and (2) those intrinsics 
appear during later passes and not accessible for processing. This test case is 
related to the very concrete improvement.


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


[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread via cfe-commits

https://github.com/T-Tie updated 
https://github.com/llvm/llvm-project/pull/111837

>From 2c193cb89f5071ec89ccbe7df363bbff70dda85e Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:11:39 +0800
Subject: [PATCH 1/8] Update riscv-target-features.c double-trap

---
 .../test/Preprocessor/riscv-target-features.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 05a8534ba13da1..d25f96b66a052a 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -29,6 +29,7 @@
 // CHECK-NOT: __riscv_smaia {{.*$}}
 // CHECK-NOT: __riscv_smcdeleg {{.*$}}
 // CHECK-NOT: __riscv_smcsrind {{.*$}}
+// CHECK-NOT: __riscv_smdbltrp {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
@@ -37,6 +38,7 @@
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
 // CHECK-NOT: __riscv_sscsrind {{.*$}}
+// CHECK-NOT: __riscv_ssdbltrp {{.*$}}
 // CHECK-NOT: __riscv_ssqosid{{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
@@ -1425,6 +1427,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
 // CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMDBLTRP-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismdbltrp1p0 -E -dM %s \
+// RUN:   -o   | FileCheck --check-prefix=CHECK-SMDBLTRP-EXT %s
+// CHECK-SMDBLTRP-EXT: __riscv_smdbltrp  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32issdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSDBLTRP-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64issdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSDBLTRP-EXT %s
+// CHECK-SSDBLTRP-EXT: __riscv_ssdbltrp  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_ssqosid1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSQOSID-EXT %s

>From 03563c6c388449381d6bbbf5d13ed598a4a3f42d Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:14:59 +0800
Subject: [PATCH 2/8] Update RISCVUsage.rst double-trap

---
 llvm/docs/RISCVUsage.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5736f3807f131b..4780c20416c165 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -128,6 +128,7 @@ on support follow.
  ``Smaia`` Supported
  ``Smcdeleg``  Supported
  ``Smcsrind``  Supported
+ ``Smdbltrp``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
@@ -136,6 +137,7 @@ on support follow.
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscsrind``  Supported
+ ``Ssdbltrp``  Supported
  ``Ssqosid``   Assembly Support
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)

>From 4d01bb39314e83a56cccdf0dc7c226c48afe46c1 Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:17:46 +0800
Subject: [PATCH 3/8] Update RISCVFeatures.td double-trap

---
 llvm/lib/Target/RISCV/RISCVFeatures.td | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 3d0e1dae801d39..fc93f7c3e1fea1 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -927,6 +927,13 @@ def FeatureStdExtSscsrind
 : RISCVExtension<"sscsrind", 1, 0,
  "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
 
+def FeatureStdExtSmdbltrp
+: RISCVExtension<"smdbltrp", 1, 0,
+ "'Smdbltrp' (Double Trap Machine Level)">;
+def FeatureStdExtSsdbltrp
+: RISCVExtension<"ssdbltrp", 1, 0,
+ "'Ssdbltrp' (Double Trap Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;

>From e2e6b8deaf8f45ae1a39c68df9bc324772da9eb9 Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:23:17 +0800
Subject: [PATCH 4/8] Update attributes.ll double-trap

---
 llvm/test/CodeGen/RISCV/attributes.ll | 8 
 1 file changed, 8 insertions(+)

diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread via cfe-commits

https://github.com/T-Tie updated 
https://github.com/llvm/llvm-project/pull/111837

>From 2c193cb89f5071ec89ccbe7df363bbff70dda85e Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:11:39 +0800
Subject: [PATCH 1/9] Update riscv-target-features.c double-trap

---
 .../test/Preprocessor/riscv-target-features.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 05a8534ba13da1..d25f96b66a052a 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -29,6 +29,7 @@
 // CHECK-NOT: __riscv_smaia {{.*$}}
 // CHECK-NOT: __riscv_smcdeleg {{.*$}}
 // CHECK-NOT: __riscv_smcsrind {{.*$}}
+// CHECK-NOT: __riscv_smdbltrp {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
@@ -37,6 +38,7 @@
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
 // CHECK-NOT: __riscv_sscsrind {{.*$}}
+// CHECK-NOT: __riscv_ssdbltrp {{.*$}}
 // CHECK-NOT: __riscv_ssqosid{{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
@@ -1425,6 +1427,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
 // CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMDBLTRP-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismdbltrp1p0 -E -dM %s \
+// RUN:   -o   | FileCheck --check-prefix=CHECK-SMDBLTRP-EXT %s
+// CHECK-SMDBLTRP-EXT: __riscv_smdbltrp  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32issdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSDBLTRP-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64issdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSDBLTRP-EXT %s
+// CHECK-SSDBLTRP-EXT: __riscv_ssdbltrp  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_ssqosid1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSQOSID-EXT %s

>From 03563c6c388449381d6bbbf5d13ed598a4a3f42d Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:14:59 +0800
Subject: [PATCH 2/9] Update RISCVUsage.rst double-trap

---
 llvm/docs/RISCVUsage.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5736f3807f131b..4780c20416c165 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -128,6 +128,7 @@ on support follow.
  ``Smaia`` Supported
  ``Smcdeleg``  Supported
  ``Smcsrind``  Supported
+ ``Smdbltrp``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
@@ -136,6 +137,7 @@ on support follow.
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscsrind``  Supported
+ ``Ssdbltrp``  Supported
  ``Ssqosid``   Assembly Support
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)

>From 4d01bb39314e83a56cccdf0dc7c226c48afe46c1 Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:17:46 +0800
Subject: [PATCH 3/9] Update RISCVFeatures.td double-trap

---
 llvm/lib/Target/RISCV/RISCVFeatures.td | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 3d0e1dae801d39..fc93f7c3e1fea1 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -927,6 +927,13 @@ def FeatureStdExtSscsrind
 : RISCVExtension<"sscsrind", 1, 0,
  "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
 
+def FeatureStdExtSmdbltrp
+: RISCVExtension<"smdbltrp", 1, 0,
+ "'Smdbltrp' (Double Trap Machine Level)">;
+def FeatureStdExtSsdbltrp
+: RISCVExtension<"ssdbltrp", 1, 0,
+ "'Ssdbltrp' (Double Trap Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;

>From e2e6b8deaf8f45ae1a39c68df9bc324772da9eb9 Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:23:17 +0800
Subject: [PATCH 4/9] Update attributes.ll double-trap

---
 llvm/test/CodeGen/RISCV/attributes.ll | 8 
 1 file changed, 8 insertions(+)

diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll

[clang] [clang] When checking for covariant return types, make sure the poiners or references are to *classes* (PR #111856)

2024-10-10 Thread Boaz Brickner via cfe-commits

https://github.com/bricknerb updated 
https://github.com/llvm/llvm-project/pull/111856

>From 786d31e2657964e578cd1fdf2006b0fb3b19fab6 Mon Sep 17 00:00:00 2001
From: Boaz Brickner 
Date: Thu, 10 Oct 2024 15:15:23 +
Subject: [PATCH 1/2] [clang] When checking for covariant return types, make
 sure the pointers or references are to *classes*.

https://eel.is/c++draft/class.virtual#8.1

This prevents overriding methods with non class return types that have less 
cv-qualification.
---
 clang/lib/Sema/SemaDeclCXX.cpp  |  4 ++--
 clang/test/SemaCXX/virtual-override.cpp | 10 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9cb2ed02a3f764..6195b62b8afa16 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18273,7 +18273,7 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
   }
 
   // The return types aren't either both pointers or references to a class 
type.
-  if (NewClassTy.isNull()) {
+  if (NewClassTy.isNull() || !NewClassTy->isStructureOrClassType()) {
 Diag(New->getLocation(),
  diag::err_different_return_type_for_overriding_virtual_function)
 << New->getDeclName() << NewTy << OldTy
@@ -18296,7 +18296,7 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
   diag::err_covariant_return_incomplete,
   New->getDeclName()))
 return true;
-}
+  }
 
 // Check if the new class derives from the old class.
 if (!IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) {
diff --git a/clang/test/SemaCXX/virtual-override.cpp 
b/clang/test/SemaCXX/virtual-override.cpp
index 72abfc3cf51e1f..6008b8ed063f20 100644
--- a/clang/test/SemaCXX/virtual-override.cpp
+++ b/clang/test/SemaCXX/virtual-override.cpp
@@ -289,3 +289,13 @@ namespace PR8168 {
 static void foo() {} // expected-error{{'static' member function 'foo' 
overrides a virtual function}}
   };
 }
+
+namespace T13 {
+  struct A {
+virtual const int *f() const; // expected-note{{overridden virtual 
function is here}}
+  };
+
+  struct B : A {
+int *f() const override; // expected-error{{virtual function 'f' has a 
different return type ('int *') than the function it overrides (which has 
return type 'const int *')}}
+  };
+}

>From 027a985f2ca2bbe007db751af4fdbb5d8f12959d Mon Sep 17 00:00:00 2001
From: Boaz Brickner 
Date: Fri, 11 Oct 2024 05:29:05 +
Subject: [PATCH 2/2] Fix indentation.

---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 6195b62b8afa16..75d010dc4e04d8 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18296,7 +18296,7 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
   diag::err_covariant_return_incomplete,
   New->getDeclName()))
 return true;
-  }
+}
 
 // Check if the new class derives from the old class.
 if (!IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) {

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


[clang] [clang] When checking for covariant return types, make sure the poiners or references are to *classes* (PR #111856)

2024-10-10 Thread Boaz Brickner via cfe-commits

https://github.com/bricknerb updated 
https://github.com/llvm/llvm-project/pull/111856

>From 786d31e2657964e578cd1fdf2006b0fb3b19fab6 Mon Sep 17 00:00:00 2001
From: Boaz Brickner 
Date: Thu, 10 Oct 2024 15:15:23 +
Subject: [PATCH 1/2] [clang] When checking for covariant return types, make
 sure the pointers or references are to *classes*.

https://eel.is/c++draft/class.virtual#8.1

This prevents overriding methods with non class return types that have less 
cv-qualification.
---
 clang/lib/Sema/SemaDeclCXX.cpp  |  4 ++--
 clang/test/SemaCXX/virtual-override.cpp | 10 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9cb2ed02a3f764..6195b62b8afa16 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18273,7 +18273,7 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
   }
 
   // The return types aren't either both pointers or references to a class 
type.
-  if (NewClassTy.isNull()) {
+  if (NewClassTy.isNull() || !NewClassTy->isStructureOrClassType()) {
 Diag(New->getLocation(),
  diag::err_different_return_type_for_overriding_virtual_function)
 << New->getDeclName() << NewTy << OldTy
@@ -18296,7 +18296,7 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
   diag::err_covariant_return_incomplete,
   New->getDeclName()))
 return true;
-}
+  }
 
 // Check if the new class derives from the old class.
 if (!IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) {
diff --git a/clang/test/SemaCXX/virtual-override.cpp 
b/clang/test/SemaCXX/virtual-override.cpp
index 72abfc3cf51e1f..6008b8ed063f20 100644
--- a/clang/test/SemaCXX/virtual-override.cpp
+++ b/clang/test/SemaCXX/virtual-override.cpp
@@ -289,3 +289,13 @@ namespace PR8168 {
 static void foo() {} // expected-error{{'static' member function 'foo' 
overrides a virtual function}}
   };
 }
+
+namespace T13 {
+  struct A {
+virtual const int *f() const; // expected-note{{overridden virtual 
function is here}}
+  };
+
+  struct B : A {
+int *f() const override; // expected-error{{virtual function 'f' has a 
different return type ('int *') than the function it overrides (which has 
return type 'const int *')}}
+  };
+}

>From 027a985f2ca2bbe007db751af4fdbb5d8f12959d Mon Sep 17 00:00:00 2001
From: Boaz Brickner 
Date: Fri, 11 Oct 2024 05:29:05 +
Subject: [PATCH 2/2] Fix indentation.

---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 6195b62b8afa16..75d010dc4e04d8 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18296,7 +18296,7 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
   diag::err_covariant_return_incomplete,
   New->getDeclName()))
 return true;
-  }
+}
 
 // Check if the new class derives from the old class.
 if (!IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) {

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


[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread via cfe-commits

https://github.com/T-Tie updated 
https://github.com/llvm/llvm-project/pull/111837

>From 2c193cb89f5071ec89ccbe7df363bbff70dda85e Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:11:39 +0800
Subject: [PATCH 1/9] Update riscv-target-features.c double-trap

---
 .../test/Preprocessor/riscv-target-features.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 05a8534ba13da1..d25f96b66a052a 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -29,6 +29,7 @@
 // CHECK-NOT: __riscv_smaia {{.*$}}
 // CHECK-NOT: __riscv_smcdeleg {{.*$}}
 // CHECK-NOT: __riscv_smcsrind {{.*$}}
+// CHECK-NOT: __riscv_smdbltrp {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
@@ -37,6 +38,7 @@
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
 // CHECK-NOT: __riscv_sscsrind {{.*$}}
+// CHECK-NOT: __riscv_ssdbltrp {{.*$}}
 // CHECK-NOT: __riscv_ssqosid{{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
@@ -1425,6 +1427,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
 // CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMDBLTRP-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismdbltrp1p0 -E -dM %s \
+// RUN:   -o   | FileCheck --check-prefix=CHECK-SMDBLTRP-EXT %s
+// CHECK-SMDBLTRP-EXT: __riscv_smdbltrp  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32issdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSDBLTRP-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64issdbltrp1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSDBLTRP-EXT %s
+// CHECK-SSDBLTRP-EXT: __riscv_ssdbltrp  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32i_ssqosid1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSQOSID-EXT %s

>From 03563c6c388449381d6bbbf5d13ed598a4a3f42d Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:14:59 +0800
Subject: [PATCH 2/9] Update RISCVUsage.rst double-trap

---
 llvm/docs/RISCVUsage.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5736f3807f131b..4780c20416c165 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -128,6 +128,7 @@ on support follow.
  ``Smaia`` Supported
  ``Smcdeleg``  Supported
  ``Smcsrind``  Supported
+ ``Smdbltrp``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
@@ -136,6 +137,7 @@ on support follow.
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscsrind``  Supported
+ ``Ssdbltrp``  Supported
  ``Ssqosid``   Assembly Support
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)

>From 4d01bb39314e83a56cccdf0dc7c226c48afe46c1 Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:17:46 +0800
Subject: [PATCH 3/9] Update RISCVFeatures.td double-trap

---
 llvm/lib/Target/RISCV/RISCVFeatures.td | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 3d0e1dae801d39..fc93f7c3e1fea1 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -927,6 +927,13 @@ def FeatureStdExtSscsrind
 : RISCVExtension<"sscsrind", 1, 0,
  "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
 
+def FeatureStdExtSmdbltrp
+: RISCVExtension<"smdbltrp", 1, 0,
+ "'Smdbltrp' (Double Trap Machine Level)">;
+def FeatureStdExtSsdbltrp
+: RISCVExtension<"ssdbltrp", 1, 0,
+ "'Ssdbltrp' (Double Trap Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;

>From e2e6b8deaf8f45ae1a39c68df9bc324772da9eb9 Mon Sep 17 00:00:00 2001
From: T-Tie <160845405+t-...@users.noreply.github.com>
Date: Thu, 10 Oct 2024 21:23:17 +0800
Subject: [PATCH 4/9] Update attributes.ll double-trap

---
 llvm/test/CodeGen/RISCV/attributes.ll | 8 
 1 file changed, 8 insertions(+)

diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll

[clang] Enable matrices in HLSL (PR #111415)

2024-10-10 Thread Greg Roth via cfe-commits


@@ -17,12 +17,12 @@ void add(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
   // expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float 
__attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 
'float __attribute__((matrix_type(5, 10)))')}}
 
   a = b + &c;
-  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' 
(aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  
__attribute__((matrix_type(10, 5)))*'))}}
-  // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  
__attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' 
(aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float 
* __attribute__((matrix_type(10, 5)))'))}}

pow2clk wrote:

Another oddity in how pointers to matrices were printed before was a double 
space between the type and the attribute. It's minor, but it suggested 
something was missing there.

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


[clang] Add arrangeCXXMethodCall to the CodeGenABITypes interface. (PR #111597)

2024-10-10 Thread Hiroshi Yamauchi via cfe-commits

https://github.com/hjyamauchi updated 
https://github.com/llvm/llvm-project/pull/111597

>From 98f58ce20a610388fd38bac2864b4e8afcf1b463 Mon Sep 17 00:00:00 2001
From: Hiroshi Yamauchi 
Date: Thu, 10 Oct 2024 13:50:01 -0700
Subject: [PATCH] Add arrangeCXXMethodCall to the CodeGenABITypes interface.

Also add ExtParameterInfos to the argument list of
arrangeFreeFunctionCall.
---
 clang/include/clang/CodeGen/CodeGenABITypes.h | 24 ++
 clang/lib/CodeGen/CodeGenABITypes.cpp | 25 +--
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h 
b/clang/include/clang/CodeGen/CodeGenABITypes.h
index 9cbc5a8a2a3f41..836fdd75477c76 100644
--- a/clang/include/clang/CodeGen/CodeGenABITypes.h
+++ b/clang/include/clang/CodeGen/CodeGenABITypes.h
@@ -75,11 +75,25 @@ const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule 
&CGM,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
-const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
-  CanQualType returnType,
-  ArrayRef argTypes,
-  FunctionType::ExtInfo info,
-  RequiredArgs args);
+const CGFunctionInfo &
+arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType,
+ ArrayRef argTypes, FunctionType::ExtInfo 
info,
+ ArrayRef paramInfos,
+ RequiredArgs args);
+
+const CGFunctionInfo &arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args);
+
+// An overload with an empty `paramInfos`
+inline const CGFunctionInfo &
+arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType,
+ArrayRef argTypes,
+FunctionType::ExtInfo info, RequiredArgs args) {
+  return arrangeFreeFunctionCall(CGM, returnType, argTypes, info, {}, args);
+}
 
 /// Returns the implicit arguments to add to a complete, non-delegating C++
 /// constructor call.
diff --git a/clang/lib/CodeGen/CodeGenABITypes.cpp 
b/clang/lib/CodeGen/CodeGenABITypes.cpp
index a6073e1188d6fa..3f10d68f8c5d45 100644
--- a/clang/lib/CodeGen/CodeGenABITypes.cpp
+++ b/clang/lib/CodeGen/CodeGenABITypes.cpp
@@ -59,14 +59,23 @@ CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
-const CGFunctionInfo &
-CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
- CanQualType returnType,
- ArrayRef argTypes,
- FunctionType::ExtInfo info,
- RequiredArgs args) {
-  return CGM.getTypes().arrangeLLVMFunctionInfo(returnType, FnInfoOpts::None,
-argTypes, info, {}, args);
+const CGFunctionInfo &CodeGen::arrangeCXXMethodCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::IsInstanceMethod, argTypes, info, paramInfos,
+  args);
+}
+
+const CGFunctionInfo &CodeGen::arrangeFreeFunctionCall(
+CodeGenModule &CGM, CanQualType returnType, ArrayRef argTypes,
+FunctionType::ExtInfo info,
+ArrayRef paramInfos,
+RequiredArgs args) {
+  return CGM.getTypes().arrangeLLVMFunctionInfo(
+  returnType, FnInfoOpts::None, argTypes, info, paramInfos, args);
 }
 
 ImplicitCXXConstructorArgs

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


[clang] [RISCV] Implement Clang Builtins for XCVmac Extension in CV32E40P (PR #110623)

2024-10-10 Thread Paolo Savini via cfe-commits


@@ -0,0 +1,111 @@
+/*=== riscv_corev_mac.h - CORE-V multiply accumulate intrinsics ===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+
+#ifndef __RISCV_COREV_MAC_H
+#define __RISCV_COREV_MAC_H
+
+#include 
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#if defined(__riscv_xcvmac)
+
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_mac_mac(long a, long b,

PaoloS02 wrote:

That was to follow the RISC-V C API headers specification according to which we 
should use `long` for types that correspond to the `XLEN` like `int`

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


[clang] [llvm] [HLSL] implement elementwise firstbithigh hlsl builtin (PR #111082)

2024-10-10 Thread Justin Bogner via cfe-commits

bogner wrote:

> > Despite all of this, DXC does indeed support 16- and 64-bit overloads, as 
> > seen here: https://hlsl.godbolt.org/z/qbc17xz35
> > Note that the return type of the operation is not overloaded - all of the 
> > overloads of this function return uint.
> 
> Why is the return type not overloaded? Isn't it overloaded for countbits 
> which is a similar function.

The return type for countbits is also not overloaded: 
https://hlsl.godbolt.org/z/oGYhsjEGc - in fact none of the operations that use 
the `unaryBits` operation class are overloaded on the return type.

The code we're generating with clang for countbits right now actually just 
looks like it's wrong. It doesn't match what DXC does at all: 
https://hlsl.godbolt.org/z/K8n3j5o3K

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


[libcxx] [libcxxabi] [libunwind] [runtimes] Always define cxx_shared, cxx_static & other targets (PR #80007)

2024-10-10 Thread Paul Kirth via cfe-commits

ilovepi wrote:

> Also, this is another reminder that we would benefit from having Fuchsia 
> builders in the pre-commit CI. We've asked before and we'll keep asking until 
> we get them: Fuchsia is amongst the last platform that frequently reports 
> errors but doesn't provide us with any pre-commit visibility.

Agreed. I'd also like us to be in that situation. 

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-10 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/111203

>From f545a14e11556c91d10b14617e3588fe5eae6d42 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Fri, 4 Oct 2024 12:21:51 -0700
Subject: [PATCH 1/4] [HLSL] Collect explicit resource binding information
 (part 1)

- Do not create resource binding attribute if it is not valid
- Store basic resource binding information on HLSLResourceBindingAttr
- Move UDT type checking to to ActOnVariableDeclarator

Part 1 of #110719
---
 clang/include/clang/Basic/Attr.td |  29 +++
 clang/include/clang/Sema/SemaHLSL.h   |   2 +
 clang/lib/Sema/SemaDecl.cpp   |   3 +
 clang/lib/Sema/SemaHLSL.cpp   | 227 --
 .../resource_binding_attr_error_udt.hlsl  |   8 +-
 5 files changed, 188 insertions(+), 81 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fbcbf0ed416416..668c599da81390 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4588,6 +4588,35 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  const FieldDecl *ResourceField = nullptr;
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+
+  void setBinding(RegisterType RT, unsigned SlotNum, unsigned SpaceNum) {
+RegType = RT;
+SlotNumber = SlotNum;
+SpaceNumber = SpaceNum;
+  }
+  void setResourceField(const FieldDecl *FD) {
+ResourceField = FD;
+  }
+  const FieldDecl *getResourceField() {
+return ResourceField;
+  }
+  RegisterType getRegisterType() {
+return RegType;
+  }
+  unsigned getSlotNumber() {
+return SlotNumber;
+  }
+  unsigned getSpaceNumber() {
+return SpaceNumber;
+  }
+  }];
 }
 
 def HLSLPackOffset: HLSLAnnotationAttr {
diff --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index fa957abc9791af..018e7ea5901a2b 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -28,6 +28,7 @@ class AttributeCommonInfo;
 class IdentifierInfo;
 class ParsedAttr;
 class Scope;
+class VarDecl;
 
 // FIXME: This can be hidden (as static function in SemaHLSL.cpp) once we no
 // longer need to create builtin buffer types in HLSLExternalSemaSource.
@@ -62,6 +63,7 @@ class SemaHLSL : public SemaBase {
   const Attr *A, llvm::Triple::EnvironmentType Stage,
   std::initializer_list AllowedStages);
   void DiagnoseAvailabilityViolations(TranslationUnitDecl *TU);
+  void ProcessResourceBindingOnDecl(VarDecl *D);
 
   QualType handleVectorBinOpConversion(ExprResult &LHS, ExprResult &RHS,
QualType LHSType, QualType RHSType,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2bf610746bc317..8e27a5e068e702 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7876,6 +7876,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   // Handle attributes prior to checking for duplicates in MergeVarDecl
   ProcessDeclAttributes(S, NewVD, D);
 
+  if (getLangOpts().HLSL)
+HLSL().ProcessResourceBindingOnDecl(NewVD);
+
   // FIXME: This is probably the wrong location to be doing this and we should
   // probably be doing this for more attributes (especially for function
   // pointer attributes such as format, warn_unused_result, etc.). Ideally
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index fbcba201a351a6..568a8de30c1fc5 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -41,9 +41,7 @@
 
 using namespace clang;
 using llvm::dxil::ResourceClass;
-
-enum class RegisterType { SRV, UAV, CBuffer, Sampler, C, I, Invalid };
-
+using RegisterType = HLSLResourceBindingAttr::RegisterType;
 static RegisterType getRegisterType(ResourceClass RC) {
   switch (RC) {
   case ResourceClass::SRV:
@@ -985,44 +983,43 @@ SemaHLSL::TakeLocForHLSLAttribute(const 
HLSLAttributedResourceType *RT) {
   return LocInfo;
 }
 
-// get the record decl from a var decl that we expect
-// represents a resource
-static CXXRecordDecl *getRecordDeclFromVarDecl(VarDecl *VD) {
-  const Type *Ty = VD->getType()->getPointeeOrArrayElementType();
-  assert(Ty && "Resource must have an element type.");
-
-  if (Ty->isBuiltinType())
-return nullptr;
-
-  CXXRecordDecl *TheRecordDecl = Ty->getAsCXXRecordDecl();
-  assert(TheRecordDecl && "Resource should have a resource type declaration.");
-  return TheRecordDecl;
-}
-
+// Returns handle type of a resource, if the VarDecl is a resource
+// or an array of resources
 static const HLSLAttributedResourceType *
-findAttr

[clang] [clang-format] Make bitwise and imply requires clause (PR #110942)

2024-10-10 Thread Owen Pan via cfe-commits


@@ -1296,6 +1296,21 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   Tokens = annotate("bool x = t && requires(Foo x) { x.foo(); };");
   ASSERT_EQ(Tokens.size(), 25u) << Tokens;
   EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresExpression);
+
+  // Second function definition is required due to lookahead
+  Tokens = annotate("void f() & requires(n == 1) {}\nvoid g();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
+  Tokens = annotate("void f() & requires(n || h) {}\nvoid g();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);

owenca wrote:

Delete?

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


[clang] [clang-format] Make bitwise and imply requires clause (PR #110942)

2024-10-10 Thread Owen Pan via cfe-commits


@@ -1296,6 +1296,21 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   Tokens = annotate("bool x = t && requires(Foo x) { x.foo(); };");
   ASSERT_EQ(Tokens.size(), 25u) << Tokens;
   EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresExpression);
+
+  // Second function definition is required due to lookahead
+  Tokens = annotate("void f() & requires(n == 1) {}\nvoid g();");

owenca wrote:

```suggestion
  Tokens = annotate("void f() &\n"
"  requires(n == 1)\n"
"{}");
```
IMO this is enough for checking the annotation part.

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


[clang] [clang-format] Make bitwise and imply requires clause (PR #110942)

2024-10-10 Thread Owen Pan via cfe-commits


@@ -1296,6 +1296,21 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   Tokens = annotate("bool x = t && requires(Foo x) { x.foo(); };");
   ASSERT_EQ(Tokens.size(), 25u) << Tokens;
   EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresExpression);
+
+  // Second function definition is required due to lookahead
+  Tokens = annotate("void f() & requires(n == 1) {}\nvoid g();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
+  Tokens = annotate("void f() & requires(n || h) {}\nvoid g();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
+  Tokens = annotate("bool x = t && requires(F x) { x.foo(); };");
+  ASSERT_EQ(Tokens.size(), 25u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresExpression);

owenca wrote:

Delete? Otherwise, we should check that the `&&` is annotated correctly.

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


[clang] [clang-format] Make bitwise and imply requires clause (PR #110942)

2024-10-10 Thread Owen Pan via cfe-commits

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


[clang] 0bc02b9 - [Clang] Instantiate Typedefs referenced by type alias deduction guides (#111804)

2024-10-10 Thread via cfe-commits

Author: Younan Zhang
Date: 2024-10-11T10:31:27+08:00
New Revision: 0bc02b999a9686ba240b7a68d3f1cbbf037d2170

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

LOG: [Clang] Instantiate Typedefs referenced by type alias deduction guides 
(#111804)

TypedefNameDecl referenced by a synthesized CTAD guide for type aliases
was not transformed previously, resulting in a substitution failure in
BuildDeductionGuideForTypeAlias() when substituting into the
right-hand-side deduction guide.

This patch fixes it in the way we have been doing since
https://reviews.llvm.org/D80743. We transform all the function
parameters, parenting referenced TypedefNameDecls with the
CXXDeductionGuideDecl. Then we instantiate these declarations in
FindInstantiatedDecl() as we build up the eventual deduction guide,
using the mechanism introduced in D80743

Fixes #111508

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeductionGuide.cpp
clang/test/SemaCXX/cxx20-ctad-type-alias.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 545da21183c3c4..2d3e58548fb7ac 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -70,8 +70,8 @@ class ExtractTypeForDeductionGuide
   ExtractTypeForDeductionGuide(
   Sema &SemaRef,
   llvm::SmallVectorImpl &MaterializedTypedefs,
-  ClassTemplateDecl *NestedPattern,
-  const MultiLevelTemplateArgumentList *OuterInstantiationArgs)
+  ClassTemplateDecl *NestedPattern = nullptr,
+  const MultiLevelTemplateArgumentList *OuterInstantiationArgs = nullptr)
   : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs),
 NestedPattern(NestedPattern),
 OuterInstantiationArgs(OuterInstantiationArgs) {
@@ -1228,10 +1228,25 @@ FunctionTemplateDecl 
*DeclareAggregateDeductionGuideForTypeAlias(
   getRHSTemplateDeclAndArgs(SemaRef, AliasTemplate).first;
   if (!RHSTemplate)
 return nullptr;
+
+  llvm::SmallVector TypedefDecls;
+  llvm::SmallVector NewParamTypes;
+  ExtractTypeForDeductionGuide TypeAliasTransformer(SemaRef, TypedefDecls);
+  for (QualType P : ParamTypes) {
+QualType Type = TypeAliasTransformer.TransformType(P);
+if (Type.isNull())
+  return nullptr;
+NewParamTypes.push_back(Type);
+  }
+
   auto *RHSDeductionGuide = SemaRef.DeclareAggregateDeductionGuideFromInitList(
-  RHSTemplate, ParamTypes, Loc);
+  RHSTemplate, NewParamTypes, Loc);
   if (!RHSDeductionGuide)
 return nullptr;
+
+  for (TypedefNameDecl *TD : TypedefDecls)
+TD->setDeclContext(RHSDeductionGuide->getTemplatedDecl());
+
   return BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate,
  RHSDeductionGuide, Loc);
 }

diff  --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp 
b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
index 5392573fcdb9d5..675c32a81f1ae8 100644
--- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
+++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
@@ -481,3 +481,16 @@ struct Out {
 Out::B out(100); // deduced to Out::A;
 static_assert(__is_same(decltype(out), Out::A));
 }
+
+namespace GH111508 {
+
+template  struct S {
+  using T = V;
+  T Data;
+};
+
+template  using Alias = S;
+
+Alias A(42);
+
+} // namespace GH111508



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


[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-10 Thread Younan Zhang via cfe-commits

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


[clang] [compiler-rt] [libcxx] [llvm] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)

2024-10-10 Thread via cfe-commits

https://github.com/serge-sans-paille updated 
https://github.com/llvm/llvm-project/pull/111434

>From 894cc0a4624fdf9409b9f448276d6c70a365c046 Mon Sep 17 00:00:00 2001
From: serge-sans-paille 
Date: Mon, 7 Oct 2024 15:30:24 +0200
Subject: [PATCH 1/4] [clang] Warn about memset/memcpy to NonTriviallyCopyable
 types

This implements a warning that's similar to what GCC does in that
context: both memcpy and memset require their first and second operand
to be trivially copyable, let's warn if that's not the case.
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 .../clang/Basic/DiagnosticSemaKinds.td|  4 ++
 clang/lib/Sema/SemaChecking.cpp   | 14 
 clang/test/SemaCXX/constexpr-string.cpp   |  6 ++
 clang/test/SemaCXX/warn-memaccess.cpp | 70 +++
 5 files changed, 98 insertions(+)
 create mode 100644 clang/test/SemaCXX/warn-memaccess.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 583c1e6b4215c5..6b5b2d980fbcb5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -258,6 +258,10 @@ Modified Compiler Flags
   the ``promoted`` algorithm for complex division when possible rather than the
   less basic (limited range) algorithm.
 
+- The ``-Wnontrivial-memaccess`` warning has been updated to also warn about
+  passing non-trivially-copyable parameter to ``memcpy``, ``memset`` and 
similar
+  functions for which it is a documented undefined behavior.
+
 Removed Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 536211a6da335b..2b5251bc6685e7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -790,6 +790,10 @@ def warn_cstruct_memaccess : Warning<
   "%1 call is a pointer to record %2 that is not trivial to "
   "%select{primitive-default-initialize|primitive-copy}3">,
   InGroup;
+def warn_cxxstruct_memaccess : Warning<
+  "%select{destination for|source of|first operand of|second operand of}0 call 
to "
+  "%1 is a pointer to non-trivially copyable type %2">,
+  InGroup;
 def note_nontrivial_field : Note<
   "field is non-trivial to %select{copy|default-initialize}0">;
 def err_non_trivial_c_union_in_invalid_context : Error<
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2bcb930acdcb57..38cd16e3e81466 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -8899,18 +8899,32 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
   << ArgIdx << FnName << PointeeTy
   << Call->getCallee()->getSourceRange());
 else if (const auto *RT = PointeeTy->getAs()) {
+
+  bool IsTriviallyCopyableCXXRecord =
+  RT->desugar().isTriviallyCopyableType(Context);
+
   if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
   RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
 DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
 PDiag(diag::warn_cstruct_memaccess)
 << ArgIdx << FnName << PointeeTy << 0);
 SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *this);
+  } else if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
+ !IsTriviallyCopyableCXXRecord) {
+DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
+PDiag(diag::warn_cxxstruct_memaccess)
+<< ArgIdx << FnName << PointeeTy);
   } else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
  RT->getDecl()->isNonTrivialToPrimitiveCopy()) {
 DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
 PDiag(diag::warn_cstruct_memaccess)
 << ArgIdx << FnName << PointeeTy << 1);
 SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *this);
+  } else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
+ !IsTriviallyCopyableCXXRecord) {
+DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
+PDiag(diag::warn_cxxstruct_memaccess)
+<< ArgIdx << FnName << PointeeTy);
   } else {
 continue;
   }
diff --git a/clang/test/SemaCXX/constexpr-string.cpp 
b/clang/test/SemaCXX/constexpr-string.cpp
index c456740ef7551f..31fa98f8a972a7 100644
--- a/clang/test/SemaCXX/constexpr-string.cpp
+++ b/clang/test/SemaCXX/constexpr-string.cpp
@@ -603,12 +603,16 @@ namespace MemcpyEtc {
   };
   constexpr bool test_nontrivial_memcpy() { // expected-error {{never produces 
a constant}}
 NonTrivial arr[3] = {};
+// expected-warning@+2 {{source of call to '__builtin_memcpy' is a pointer 
to non-trivially copyable type 'NonTrivial'}}
+// expected-note@+1 {{explicitly cast the pointer to silence this warning}}
 __bu

[clang-tools-extra] [clang-tidy] insert ``static`` keyword in correct position for misc-use-internal-linkage (PR #108792)

2024-10-10 Thread Danny Mösch via cfe-commits


@@ -128,6 +128,10 @@ Changes in existing checks
   ` check to avoid
   false positive for C++23 deducing this.
 
+- Improved :doc:`misc-use-internal-linkage
+  ` check to insert ``static`` 
keyword
+  before type qualifier such as ``const``, ``volatile``.

SimplyDanny wrote:

```suggestion
  before type qualifiers such as ``const`` and ``volatile``.
```


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


[clang-tools-extra] [clang-tidy] insert ``static`` keyword in correct position for misc-use-internal-linkage (PR #108792)

2024-10-10 Thread Danny Mösch via cfe-commits

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


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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread via cfe-commits


@@ -141,6 +141,22 @@ enum NodeType : unsigned {
   VALL_NONZERO,
   VANY_NONZERO,
 
+  // Floating point approximate reciprocal operation
+  FRECIPE_S,

tangaac wrote:

We can't.
Each target-dependent ISD corresponds to a specific instruction in the backend.
Other instructions such as IOCSRRD,  IOCSRWR  have 4 different types of ISD: 
```c++
  IOCSRRD_B,
  IOCSRRD_W,
  IOCSRRD_H,
  IOCSRRD_D,
  IOCSRWR_B,
  IOCSRWR_H,
  IOCSRWR_W,
  IOCSRWR_D,
```


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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -251,6 +251,16 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
 } else /*-mno-lasx*/
   Features.push_back("-lasx");
   }
+
+  // Select frecipe feature determined by -m[no-]frecipe.
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_mfrecipe, options::OPT_mno_frecipe)) {
+// -mno-frecipe conflicts with -mfrecipe.

SixWeining wrote:

-mno-frecipe doesn't conflict with -mfrecipe. They can appear together but the 
last one wins. You can remove this comment.

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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -5902,6 +5914,92 @@ Register 
LoongArchTargetLowering::getExceptionSelectorRegister(
   return LoongArch::R5;
 }
 
+//===--===//
+// Target Optimization Hooks
+//===--===//
+
+static int getEstimateRefinementSteps(EVT VT,
+  const LoongArchSubtarget &Subtarget) {
+  // Feature FRECIPE instrucions relative accuracy is 2^-14.
+  // IEEE float has 23 digits and double has 52 digits.
+  int RefinementSteps = VT.getScalarType() == MVT::f64 ? 2 : 1;
+  return RefinementSteps;
+}
+
+SDValue LoongArchTargetLowering::getSqrtEstimate(SDValue Operand,
+ SelectionDAG &DAG, int 
Enabled,
+ int &RefinementSteps,
+ bool &UseOneConstNR,
+ bool Reciprocal) const {
+  if (Subtarget.hasFrecipe()) {
+SDLoc DL(Operand);
+EVT VT = Operand.getValueType();
+unsigned Opcode;
+
+if (VT == MVT::f32) {
+  Opcode = LoongArchISD::FRSQRTE_S;
+} else if (VT == MVT::f64 && Subtarget.hasBasicD()) {
+  Opcode = LoongArchISD::FRSQRTE_D;
+} else if (VT == MVT::v4f32 && Subtarget.hasExtLSX()) {
+  Opcode = LoongArchISD::VFRSQRTE_S;
+} else if (VT == MVT::v2f64 && Subtarget.hasExtLSX()) {
+  Opcode = LoongArchISD::VFRSQRTE_D;
+} else if (VT == MVT::v8f32 && Subtarget.hasExtLASX()) {
+  Opcode = LoongArchISD::XVFRSQRTE_S;
+} else if (VT == MVT::v4f64 && Subtarget.hasExtLASX()) {
+  Opcode = LoongArchISD::XVFRSQRTE_D;
+} else {
+  return SDValue();
+}
+
+UseOneConstNR = false;
+if (RefinementSteps == ReciprocalEstimate::Unspecified)
+  RefinementSteps = getEstimateRefinementSteps(VT, Subtarget);
+
+SDValue Estimate = DAG.getNode(Opcode, DL, VT, Operand);
+if (Reciprocal) {

SixWeining wrote:

Useless `{}`.

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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -141,6 +141,22 @@ enum NodeType : unsigned {
   VALL_NONZERO,
   VANY_NONZERO,
 
+  // Floating point approximate reciprocal operation
+  FRECIPE_S,

SixWeining wrote:

Can we only define two generic nodes (FRECIPE / FRSQRTE)?

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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -251,6 +251,16 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
 } else /*-mno-lasx*/
   Features.push_back("-lasx");
   }
+
+  // Select frecipe feature determined by -m[no-]frecipe.
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_mfrecipe, options::OPT_mno_frecipe)) {
+// -mno-frecipe conflicts with -mfrecipe.
+if (A->getOption().matches(options::OPT_mfrecipe)) {
+  Features.push_back("+frecipe");
+} else /*-mnofrecipe*/

SixWeining wrote:

Unnecessary comment.

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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -19,12 +19,15 @@ def SDT_LoongArchMOVGR2FR_W_LA64
 def SDT_LoongArchMOVFR2GR_S_LA64
 : SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, f32>]>;
 def SDT_LoongArchFTINT : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisFP<1>]>;
+def SDT_LoongArchFRECIPE : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisFP<1>]>;
 
 def loongarch_movgr2fr_w_la64
 : SDNode<"LoongArchISD::MOVGR2FR_W_LA64", SDT_LoongArchMOVGR2FR_W_LA64>;
 def loongarch_movfr2gr_s_la64
 : SDNode<"LoongArchISD::MOVFR2GR_S_LA64", SDT_LoongArchMOVFR2GR_S_LA64>;
 def loongarch_ftint : SDNode<"LoongArchISD::FTINT", SDT_LoongArchFTINT>;
+def loongarch_frecipe_s : SDNode<"LoongArchISD::FRECIPE_S", 
SDT_LoongArchFRECIPE>;
+def loongarch_frsqrte_s : SDNode<"LoongArchISD::FRSQRTE_S", 
SDT_LoongArchFRECIPE>;

SixWeining wrote:

Use a different type.

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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -5902,6 +5914,92 @@ Register 
LoongArchTargetLowering::getExceptionSelectorRegister(
   return LoongArch::R5;
 }
 
+//===--===//
+// Target Optimization Hooks
+//===--===//
+
+static int getEstimateRefinementSteps(EVT VT,
+  const LoongArchSubtarget &Subtarget) {
+  // Feature FRECIPE instrucions relative accuracy is 2^-14.
+  // IEEE float has 23 digits and double has 52 digits.
+  int RefinementSteps = VT.getScalarType() == MVT::f64 ? 2 : 1;
+  return RefinementSteps;
+}
+
+SDValue LoongArchTargetLowering::getSqrtEstimate(SDValue Operand,
+ SelectionDAG &DAG, int 
Enabled,
+ int &RefinementSteps,
+ bool &UseOneConstNR,
+ bool Reciprocal) const {
+  if (Subtarget.hasFrecipe()) {
+SDLoc DL(Operand);
+EVT VT = Operand.getValueType();
+unsigned Opcode;
+
+if (VT == MVT::f32) {

SixWeining wrote:

Useless `{}`.

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


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-10 Thread Lu Weining via cfe-commits


@@ -0,0 +1,396 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch32 --mattr=+f,-d,-frecipe < %s | FileCheck %s 
--check-prefix=LA32F
+; RUN: llc --mtriple=loongarch32 --mattr=+f,-d,+frecipe < %s | FileCheck %s 
--check-prefix=LA32F-FRECIPE
+; RUN: llc --mtriple=loongarch64 --mattr=+d,-frecipe < %s | FileCheck %s 
--check-prefix=LA64D
+; RUN: llc --mtriple=loongarch64 --mattr=+d,+frecipe < %s | FileCheck %s 
--check-prefix=LA64D-FRECIPE
+
+
+declare float @llvm.sqrt.f32(float)
+declare double @llvm.sqrt.f64(double)
+
+define float @frsqrt_f32(float %a) nounwind {
+; LA32F-LABEL: frsqrt_f32:
+; LA32F:   # %bb.0:
+; LA32F-NEXT:frsqrt.s $fa0, $fa0
+; LA32F-NEXT:ret
+;
+; LA32F-FRECIPE-LABEL: frsqrt_f32:
+; LA32F-FRECIPE:   # %bb.0:
+; LA32F-FRECIPE-NEXT:frsqrte.s $fa1, $fa0
+; LA32F-FRECIPE-NEXT:pcalau12i $a0, %pc_hi20(.LCPI0_0)
+; LA32F-FRECIPE-NEXT:fld.s $fa2, $a0, %pc_lo12(.LCPI0_0)
+; LA32F-FRECIPE-NEXT:pcalau12i $a0, %pc_hi20(.LCPI0_1)
+; LA32F-FRECIPE-NEXT:fld.s $fa3, $a0, %pc_lo12(.LCPI0_1)
+; LA32F-FRECIPE-NEXT:fmul.s$fa1, $fa0, $fa1
+; LA32F-FRECIPE-NEXT:fmul.s$fa0, $fa0, $fa1
+; LA32F-FRECIPE-NEXT:fmadd.s   $fa0, $fa0, $fa1, $fa2
+; LA32F-FRECIPE-NEXT:fmul.s$fa1, $fa1, $fa3
+; LA32F-FRECIPE-NEXT:fmul.s$fa0, $fa1, $fa0
+; LA32F-FRECIPE-NEXT:ret
+;
+; LA64D-LABEL: frsqrt_f32:
+; LA64D:   # %bb.0:
+; LA64D-NEXT:frsqrt.s $fa0, $fa0
+; LA64D-NEXT:ret
+;
+; LA64D-FRECIPE-LABEL: frsqrt_f32:
+; LA64D-FRECIPE:   # %bb.0:
+; LA64D-FRECIPE-NEXT:frsqrte.s $fa1, $fa0
+; LA64D-FRECIPE-NEXT:pcalau12i $a0, %pc_hi20(.LCPI0_0)
+; LA64D-FRECIPE-NEXT:fld.s $fa2, $a0, %pc_lo12(.LCPI0_0)
+; LA64D-FRECIPE-NEXT:pcalau12i $a0, %pc_hi20(.LCPI0_1)
+; LA64D-FRECIPE-NEXT:fld.s $fa3, $a0, %pc_lo12(.LCPI0_1)
+; LA64D-FRECIPE-NEXT:fmul.s$fa1, $fa0, $fa1
+; LA64D-FRECIPE-NEXT:fmul.s$fa0, $fa0, $fa1
+; LA64D-FRECIPE-NEXT:fmadd.s   $fa0, $fa0, $fa1, $fa2
+; LA64D-FRECIPE-NEXT:fmul.s$fa1, $fa1, $fa3
+; LA64D-FRECIPE-NEXT:fmul.s$fa0, $fa1, $fa0
+; LA64D-FRECIPE-NEXT:ret
+
+  %1 = call fast float @llvm.sqrt.f32(float %a)
+  %2 = fdiv fast float 1.0, %1
+  ret float %2
+}
+
+define double @frsqrt_f64(double %a) nounwind {
+; LA32F-LABEL: frsqrt_f64:
+; LA32F:   # %bb.0:
+; LA32F-NEXT:addi.w$sp, $sp, -16
+; LA32F-NEXT:st.w  $ra, $sp, 12 
+; LA32F-NEXT:bl%plt(sqrt)
+; LA32F-NEXT:move  $a2, $a0
+; LA32F-NEXT:move  $a3, $a1
+; LA32F-NEXT:lu12i.w   $a1, 261888
+; LA32F-NEXT:move  $a0, $zero
+; LA32F-NEXT:bl%plt(__divdf3)
+; LA32F-NEXT:ld.w  $ra, $sp, 12  
+; LA32F-NEXT:addi.w$sp, $sp, 16
+; LA32F-NEXT:ret
+;
+; LA32F-FRECIPE-LABEL: frsqrt_f64:
+; LA32F-FRECIPE:   # %bb.0:
+; LA32F-FRECIPE-NEXT:addi.w$sp, $sp, -16
+; LA32F-FRECIPE-NEXT:st.w  $ra, $sp, 12# 4-byte Folded 
Spill
+; LA32F-FRECIPE-NEXT:bl%plt(sqrt)
+; LA32F-FRECIPE-NEXT:move  $a2, $a0
+; LA32F-FRECIPE-NEXT:move  $a3, $a1
+; LA32F-FRECIPE-NEXT:lu12i.w   $a1, 261888
+; LA32F-FRECIPE-NEXT:move  $a0, $zero
+; LA32F-FRECIPE-NEXT:bl%plt(__divdf3)
+; LA32F-FRECIPE-NEXT:ld.w  $ra, $sp, 12# 4-byte Folded 
Reload
+; LA32F-FRECIPE-NEXT:addi.w$sp, $sp, 16
+; LA32F-FRECIPE-NEXT:ret
+;
+; LA64D-LABEL: frsqrt_f64:
+; LA64D:   # %bb.0:
+; LA64D-NEXT:frsqrt.d $fa0, $fa0
+; LA64D-NEXT:ret
+;
+; LA64D-FRECIPE-LABEL: frsqrt_f64:
+; LA64D-FRECIPE:   # %bb.0:
+; LA64D-FRECIPE-NEXT:frsqrte.d $fa1, $fa0
+; LA64D-FRECIPE-NEXT:pcalau12i $a0, %pc_hi20(.LCPI1_0)
+; LA64D-FRECIPE-NEXT:fld.d $fa2, $a0, %pc_lo12(.LCPI1_0)
+; LA64D-FRECIPE-NEXT:pcalau12i $a0, %pc_hi20(.LCPI1_1)
+; LA64D-FRECIPE-NEXT:fld.d $fa3, $a0, %pc_lo12(.LCPI1_1)
+; LA64D-FRECIPE-NEXT:fmul.d$fa1, $fa0, $fa1
+; LA64D-FRECIPE-NEXT:fmul.d$fa4, $fa0, $fa1
+; LA64D-FRECIPE-NEXT:fmadd.d   $fa4, $fa4, $fa1, $fa2
+; LA64D-FRECIPE-NEXT:fmul.d$fa1, $fa1, $fa3
+; LA64D-FRECIPE-NEXT:fmul.d$fa1, $fa1, $fa4
+; LA64D-FRECIPE-NEXT:fmul.d$fa0, $fa0, $fa1
+; LA64D-FRECIPE-NEXT:fmadd.d   $fa0, $fa0, $fa1, $fa2
+; LA64D-FRECIPE-NEXT:fmul.d$fa1, $fa1, $fa3
+; LA64D-FRECIPE-NEXT:fmul.d$fa0, $fa1, $fa0
+; LA64D-FRECIPE-NEXT:ret
+  %1 = call fast double @llvm.sqrt.f64(double %a)
+  %2 = fdiv fast double 1.0, %1
+  ret double %2
+}
+
+define double @sqrt_simplify_before_recip_3_uses_f64(double %x, ptr %p1, ptr 
%p2) nounwind {
+; LA64D-LABEL: sqrt_simplify_before_recip_3_uses_f64:
+; LA64D:   # %bb.0:
+; LA64D-NEXT:pcalau12i $a2, %pc_hi20(.LCPI2_0)
+; LA64D-NEXT:fld.d $fa2, $a2, %pc_lo12(.LCPI2_0)
+; LA64D-NEXT:fsqrt.d

[clang] Reland: [clang] Finish implementation of P0522 (PR #111711)

2024-10-10 Thread James Y Knight via cfe-commits

jyknight wrote:

Here's another test-case which is broken by this commit (both at this commit, 
and after the follow-up PRs). It seems to no longer allow non-type template 
packs of multiple types. I'm surprised we have no test-cases for this in the 
clang test-suite!

```
template  class Arg>
struct TmplTmpl {};

template 
struct Tmpl;

using Test = TmplTmpl;
```

```
test.cc:1:28: error: deduced non-type template argument does not have the same 
type as the corresponding template parameter ('int' vs 'short')
1 | template  class Arg>
  |^
test.cc:7:23: note: template template argument has different template 
parameters than its corresponding template template parameter
7 | using Test = TmplTmpl;
  |   ^
test.cc:1:36: note: previous template template parameter is here
1 | template  class Arg>
  |   ~~   ^
test.cc:4:24: note: template parameter is declared here
4 | template 
  |^
1 error generated.
```

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


[clang] 36b0707 - [clang][bytecode] Return an lvalue path for dummy pointers (#111862)

2024-10-10 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-10-11T05:58:25+02:00
New Revision: 36b07077673b6c639804160c6b31ce57718e13db

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

LOG: [clang][bytecode] Return an lvalue path for dummy pointers (#111862)

Not doing this is wrong in general and we need to reject expressions
where it would matter differently.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Pointer.cpp
clang/test/AST/ByteCode/cxx1z.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index ba4c5600d613b0..0a3b38b0dc6e57 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6006,6 +6006,9 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
 
   return this->emitGetPtrParam(It->second.Offset, E);
 }
+
+if (D->getType()->isReferenceType())
+  return false; // FIXME: Do we need to emit InvalidDeclRef?
   }
 
   // In case we need to re-visit a declaration.
@@ -6042,9 +6045,7 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
 const auto typeShouldBeVisited = [&](QualType T) -> bool {
   if (T.isConstant(Ctx.getASTContext()))
 return true;
-  if (const auto *RT = T->getAs())
-return RT->getPointeeType().isConstQualified();
-  return false;
+  return T->isReferenceType();
 };
 
 // DecompositionDecls are just proxies for us.
@@ -6060,9 +6061,12 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
 // other words, we're evaluating the initializer, just to know if we 
can
 // evaluate the initializer.
 if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
-VD->getInit() && !VD->getInit()->isValueDependent() &&
-VD->evaluateValue())
-  return revisit(VD);
+VD->getInit() && !VD->getInit()->isValueDependent()) {
+
+  if (VD->evaluateValue())
+return revisit(VD);
+  return this->emitInvalidDeclRef(cast(E), E);
+}
   }
 } else {
   if (const auto *VD = dyn_cast(D);

diff  --git a/clang/lib/AST/ByteCode/Pointer.cpp 
b/clang/lib/AST/ByteCode/Pointer.cpp
index a52f0e336ef298..75b00dcb2ab242 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -253,11 +253,6 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const 
{
 }
   }
 
-  // FIXME(perf): We compute the lvalue path above, but we can't supply it
-  // for dummy pointers (that causes crashes later in CheckConstantExpression).
-  if (isDummy())
-Path.clear();
-
   // We assemble the LValuePath starting from the innermost pointer to the
   // outermost one. SO in a.b.c, the first element in Path will refer to
   // the field 'c', while later code expects it to refer to 'a'.

diff  --git a/clang/test/AST/ByteCode/cxx1z.cpp 
b/clang/test/AST/ByteCode/cxx1z.cpp
index 2b5d215f016548..1a06597fa348fe 100644
--- a/clang/test/AST/ByteCode/cxx1z.cpp
+++ b/clang/test/AST/ByteCode/cxx1z.cpp
@@ -10,3 +10,6 @@ namespace Temp {
   A c; // both-error {{reference to subobject of temporary 
object}}
   A d; // both-error {{pointer to subobject of temporary 
object}}
 }
+
+char arr[3];
+A d; // both-error {{refers to subobject '&arr[1]'}}



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


[clang] [clang][bytecode] Return an lvalue path for dummy pointers (PR #111862)

2024-10-10 Thread Timm Baeder via cfe-commits

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


[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-10 Thread Justin Bogner via cfe-commits

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

Looks good once Chris's comments and the clang-format issue are resolved.

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


[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)

2024-10-10 Thread via cfe-commits


@@ -171,6 +171,9 @@ C++23 Feature Support
 ^
 - Removed the restriction to literal types in constexpr functions in C++23 
mode.
 
+- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now 
fully
+  supported `P2718R0 Lifetime extension in range-based for loops 
`_.

yronglin wrote:

Thanks, l'll fix it.

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


[clang] [llvm] [Clang] Put offloading globals in the `.llvm.rodata.offloading` section (PR #111890)

2024-10-10 Thread Shilei Tian via cfe-commits

https://github.com/shiltian commented:

It looks reasonable to me.

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


[libcxx] [libcxxabi] [libunwind] [runtimes] Always define cxx_shared, cxx_static & other targets (PR #80007)

2024-10-10 Thread Paul Kirth via cfe-commits


@@ -264,19 +263,18 @@ if (LIBCXX_ENABLE_SHARED)
 APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker 
/MANIFEST:NO")
 endif()
   endif()
-endif()
 
 set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
 
 # Build the static library.
-if (LIBCXX_ENABLE_STATIC)
-  add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
+  add_library(cxx_static STATIC ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
   target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
   target_link_libraries(cxx_static PUBLIC cxx-headers libcxx-libc-static
PRIVATE ${LIBCXX_LIBRARIES}
PRIVATE libcxx-abi-static)
   set_target_properties(cxx_static
 PROPERTIES
+  EXCLUDE_FROM_ALL "$,FALSE,TRUE>"

ilovepi wrote:

nvmd I see my mistake. Disregard.

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


[clang] [llvm] [Clang] Put offloading globals in the `.llvm.rodata.offloading` section (PR #111890)

2024-10-10 Thread Joseph Huber via cfe-commits

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

>From db58755323a6538c7a65bbdc323c5718dbc89dcb Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Thu, 10 Oct 2024 13:42:22 -0500
Subject: [PATCH] [Clang] Put offloading globals in the
 `.llvm.rodata.offloading` section

Summary:
For our offloading entries, we currently store all the string names of
kernels that the runtime will need to load from the target executable.
These are available via pointer in the `__tgt_offload_entry` struct,
however this makes it difficult to obtain from the object itself. This
patch simply puts the strings in a named section so they can be easily
queried.

The motivation behind this is that when the linker wrapper is doing
linking, it wants to know which kernels the host executable is calling.
We *could* get this already via the `.relaomp_offloading_entires`
section and trawling through the string table, but that's quite annoying
and not portable. The follow-up to this should be to make the linker
wrapper get a list of all used symbols the device link job should count
as "needed" so we can handle static linking more directly.
---
 clang/test/CodeGenCUDA/offloading-entries.cu | 65 ++--
 llvm/lib/Frontend/Offloading/Utility.cpp |  8 +++
 2 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index ec21f018607ff0..259e3324e8ac94 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -15,48 +15,48 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// HIP: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00", section ".llvm.rodata.offloading", align 1
 // HIP: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry 
{ ptr @_Z3foov, ptr @.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"hip_offloading_entries", align 1
-// HIP: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// HIP: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1
 // HIP: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z6kernelv, ptr @.offloading.entry_name.1, 
i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1
-// HIP: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// HIP: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00", section ".llvm.rodata.offloading", align 1
 // HIP: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, sec

[clang] [llvm] [Clang] Put offloading globals in the `.llvm.rodata.offloading` section (PR #111890)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)


Changes

Summary:
For our offloading entries, we currently store all the string names of
kernels that the runtime will need to load from the target executable.
These are available via pointer in the `__tgt_offload_entry` struct,
however this makes it difficult to obtain from the object itself. This
patch simply puts the strings in a named section so they can be easily
queried.

The motivation behind this is that when the linker wrapper is doing
linking, it wants to know which kernels the host executable is calling.
We *could* get this already via the `.relaomp_offloading_entires`
section and trawling through the string table, but that's quite annoying
and not portable. The follow-up to this should be to make the linker
wrapper get a list of all used symbols the device link job should count
as "needed" so we can handle static linking more directly.


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


2 Files Affected:

- (modified) clang/test/CodeGenCUDA/offloading-entries.cu (+45-20) 
- (modified) llvm/lib/Frontend/Offloading/Utility.cpp (+8) 


``diff
diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index ec21f018607ff0..259e3324e8ac94 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -15,48 +15,48 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// HIP: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00", section ".llvm.rodata.offloading", align 1
 // HIP: @.offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry 
{ ptr @_Z3foov, ptr @.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"hip_offloading_entries", align 1
-// HIP: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// HIP: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1
 // HIP: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z6kernelv, ptr @.offloading.entry_name.1, 
i64 0, i32 0, i32 0 }, section "hip_offloading_entries", align 1
-// HIP: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// HIP: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00", section ".llvm.rodata.offloading", align 1
 // HIP: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"hip_offloading_entries", align 1
-// HIP: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// HIP: @.offloading.entry_name.3 =

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> Failed Tests (2):
  Clang :: Driver/print-supported-extensions-riscv.c
  Clang :: Preprocessor/riscv-target-features.c

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


[clang] [llvm] Apply alignment / size in linker rather than IR (PR #111918)

2024-10-10 Thread Florian Mayer via cfe-commits

https://github.com/fmayer created 
https://github.com/llvm/llvm-project/pull/111918

This greatly simplifies the code, and makes sure no optimizations are
applied that assume the bigger alignment or size, which could be
incorrect if we link together with non-instrumented code.


>From 3a962270521aa7b48b64e5ac5fa0edb900990023 Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Thu, 10 Oct 2024 16:05:50 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/lib/CodeGen/SanitizerMetadata.cpp   |  45 -
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp|   7 +-
 llvm/lib/Target/AArch64/AArch64.h |   2 -
 .../Target/AArch64/AArch64GlobalsTagging.cpp  | 155 --
 .../Target/AArch64/AArch64TargetMachine.cpp   |   2 -
 llvm/lib/Target/AArch64/CMakeLists.txt|   1 -
 .../llvm/lib/Target/AArch64/BUILD.gn  |   1 -
 7 files changed, 46 insertions(+), 167 deletions(-)
 delete mode 100644 llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp

diff --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 5b212a163611dc..784d9061647f5c 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -34,6 +34,37 @@ static SanitizerMask 
expandKernelSanitizerMasks(SanitizerMask Mask) {
   return Mask;
 }
 
+static bool shouldTagGlobal(const llvm::GlobalVariable &G) {
+  // For now, don't instrument constant data, as it'll be in .rodata anyway. It
+  // may be worth instrumenting these in future to stop them from being used as
+  // gadgets.
+  if (G.getName().starts_with("llvm.") || G.isThreadLocal() || G.isConstant())
+return false;
+
+  // Globals can be placed implicitly or explicitly in sections. There's two
+  // different types of globals that meet this criteria that cause problems:
+  //  1. Function pointers that are going into various init arrays (either
+  // explicitly through `__attribute__((section()))` or implicitly
+  // through `__attribute__((constructor)))`, such as ".(pre)init(_array)",
+  // ".fini(_array)", ".ctors", and ".dtors". These function pointers end 
up
+  // overaligned and overpadded, making iterating over them problematic, 
and
+  // each function pointer is individually tagged (so the iteration over
+  // them causes SIGSEGV/MTE[AS]ERR).
+  //  2. Global variables put into an explicit section, where the section's 
name
+  // is a valid C-style identifier. The linker emits a `__start_` and
+  // `__stop_` symbol for the section, so that you can iterate over
+  // globals within this section. Unfortunately, again, these globals would
+  // be tagged and so iteration causes SIGSEGV/MTE[AS]ERR.
+  //
+  // To mitigate both these cases, and because specifying a section is rare
+  // outside of these two cases, disable MTE protection for globals in any
+  // section.
+  if (G.hasSection())
+return false;
+
+  return true;
+}
+
 void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
  SourceLocation Loc, StringRef Name,
  QualType Ty,
@@ -60,11 +91,15 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable 
*GV,
   Meta.NoHWAddress |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::HWAddress, GV, Loc, Ty);
 
-  Meta.Memtag |=
-  static_cast(FsanitizeArgument.Mask & SanitizerKind::MemtagGlobals);
-  Meta.Memtag &= !NoSanitizeAttrSet.hasOneOf(SanitizerKind::MemTag);
-  Meta.Memtag &= !CGM.isInNoSanitizeList(
-  FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
+  if (shouldTagGlobal(*GV)) {
+Meta.Memtag |=
+static_cast(FsanitizeArgument.Mask & 
SanitizerKind::MemtagGlobals);
+Meta.Memtag &= !NoSanitizeAttrSet.hasOneOf(SanitizerKind::MemTag);
+Meta.Memtag &= !CGM.isInNoSanitizeList(
+FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
+  } else {
+Meta.Memtag = false;
+  }
 
   Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
FsanitizeArgument.has(SanitizerKind::Address) &&
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3a8cde7330efc0..6a2817f417d30d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -764,11 +764,16 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable 
*GV) {
 
   const DataLayout &DL = GV->getDataLayout();
   uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
+  if (GV->isTagged()) Size = alignTo(Size, 16);
 
   // If the alignment is specified, we *must* obey it.  Overaligning a global
   // with a specified alignment is a prompt way to break globals emitted to
   // sections and expected to be contiguous (e.g. ObjC metadata).

[clang] [llvm] [RISCV] Add Smdbltrp and Ssdbltrp extension (PR #111837)

2024-10-10 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> > > > Personally I don't like to add a privileged extension if it doesn't 
> > > > introduce new CSRs/instructions.
> > > 
> > > 
> > > I'd actually put that on the 
> > > [agenda](https://docs.google.com/document/d/1G3ocHm2zE6AYTS2N3_3w2UxFnSEyKkcF57siLWe-NVs/edit?tab=t.0)
> > >  for today's sync-up call already. We did add the ones that are in the 
> > > profiles. I could see an argument for supporting everything as people can 
> > > then have a `-march` string that fully describes the target and don't 
> > > need to go and sort through which options to drop as they don't affect 
> > > the compiler. But I also see a counter-argument. I'll summarise anything 
> > > relevant from the sync-up call discussion here.
> > 
> > 
> > The conclusion was that nobody present saw a real argument against, feeling 
> > "why not" and as I mentioned above, it means people can just match the 
> > `-march` string to their CPU data sheet. Did you have a particular reason 
> > against adding such extensions?
> 
> Our hardware build generates a configuration file with a full -march string 
> based on all extensions present in the RTL which we deliver to our customers. 
> So I would like all extensions to be supported otherwise I have to do it 
> downstream.

Make sense to me. No strong objection.


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


[clang] [llvm] Apply alignment / size in linker rather than IR (PR #111918)

2024-10-10 Thread Florian Mayer via cfe-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/111918

>From 3a962270521aa7b48b64e5ac5fa0edb900990023 Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Thu, 10 Oct 2024 16:05:50 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/lib/CodeGen/SanitizerMetadata.cpp   |  45 -
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp|   7 +-
 llvm/lib/Target/AArch64/AArch64.h |   2 -
 .../Target/AArch64/AArch64GlobalsTagging.cpp  | 155 --
 .../Target/AArch64/AArch64TargetMachine.cpp   |   2 -
 llvm/lib/Target/AArch64/CMakeLists.txt|   1 -
 .../llvm/lib/Target/AArch64/BUILD.gn  |   1 -
 7 files changed, 46 insertions(+), 167 deletions(-)
 delete mode 100644 llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp

diff --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 5b212a163611dc..784d9061647f5c 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -34,6 +34,37 @@ static SanitizerMask 
expandKernelSanitizerMasks(SanitizerMask Mask) {
   return Mask;
 }
 
+static bool shouldTagGlobal(const llvm::GlobalVariable &G) {
+  // For now, don't instrument constant data, as it'll be in .rodata anyway. It
+  // may be worth instrumenting these in future to stop them from being used as
+  // gadgets.
+  if (G.getName().starts_with("llvm.") || G.isThreadLocal() || G.isConstant())
+return false;
+
+  // Globals can be placed implicitly or explicitly in sections. There's two
+  // different types of globals that meet this criteria that cause problems:
+  //  1. Function pointers that are going into various init arrays (either
+  // explicitly through `__attribute__((section()))` or implicitly
+  // through `__attribute__((constructor)))`, such as ".(pre)init(_array)",
+  // ".fini(_array)", ".ctors", and ".dtors". These function pointers end 
up
+  // overaligned and overpadded, making iterating over them problematic, 
and
+  // each function pointer is individually tagged (so the iteration over
+  // them causes SIGSEGV/MTE[AS]ERR).
+  //  2. Global variables put into an explicit section, where the section's 
name
+  // is a valid C-style identifier. The linker emits a `__start_` and
+  // `__stop_` symbol for the section, so that you can iterate over
+  // globals within this section. Unfortunately, again, these globals would
+  // be tagged and so iteration causes SIGSEGV/MTE[AS]ERR.
+  //
+  // To mitigate both these cases, and because specifying a section is rare
+  // outside of these two cases, disable MTE protection for globals in any
+  // section.
+  if (G.hasSection())
+return false;
+
+  return true;
+}
+
 void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
  SourceLocation Loc, StringRef Name,
  QualType Ty,
@@ -60,11 +91,15 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable 
*GV,
   Meta.NoHWAddress |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::HWAddress, GV, Loc, Ty);
 
-  Meta.Memtag |=
-  static_cast(FsanitizeArgument.Mask & SanitizerKind::MemtagGlobals);
-  Meta.Memtag &= !NoSanitizeAttrSet.hasOneOf(SanitizerKind::MemTag);
-  Meta.Memtag &= !CGM.isInNoSanitizeList(
-  FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
+  if (shouldTagGlobal(*GV)) {
+Meta.Memtag |=
+static_cast(FsanitizeArgument.Mask & 
SanitizerKind::MemtagGlobals);
+Meta.Memtag &= !NoSanitizeAttrSet.hasOneOf(SanitizerKind::MemTag);
+Meta.Memtag &= !CGM.isInNoSanitizeList(
+FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
+  } else {
+Meta.Memtag = false;
+  }
 
   Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
FsanitizeArgument.has(SanitizerKind::Address) &&
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3a8cde7330efc0..6a2817f417d30d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -764,11 +764,16 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable 
*GV) {
 
   const DataLayout &DL = GV->getDataLayout();
   uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
+  if (GV->isTagged()) Size = alignTo(Size, 16);
 
   // If the alignment is specified, we *must* obey it.  Overaligning a global
   // with a specified alignment is a prompt way to break globals emitted to
   // sections and expected to be contiguous (e.g. ObjC metadata).
-  const Align Alignment = getGVAlignment(GV, DL);
+  Align Alignment = getGVAlignment(GV, DL);
+  if (GV->isTagged() && Alignment < 16) {
+assert(!GV->hasSection());
+Alignment = Al

[clang] [llvm] [MTE] Apply alignment / size in linker rather than IR (PR #111918)

2024-10-10 Thread Florian Mayer via cfe-commits

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


[clang] [llvm] [MTE] Apply alignment / size in AsmPrinter rather than IR (PR #111918)

2024-10-10 Thread Florian Mayer via cfe-commits

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


[clang] [NFC][clang] Fix typo in ReleaseNotes (PR #111930)

2024-10-10 Thread via cfe-commits

https://github.com/yronglin created 
https://github.com/llvm/llvm-project/pull/111930

Fix a typo in ReleaseNotes that introduced by 
https://github.com/llvm/llvm-project/pull/86960.

>From c874daa3829eefeaf8b329f58c3964e80c478f22 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Fri, 11 Oct 2024 08:13:35 +0800
Subject: [PATCH] [NFC][clang] Fix typo in ReleaseNotes

Signed-off-by: yronglin 
---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e48835d4738007..df165b91252505 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -172,7 +172,7 @@ C++23 Feature Support
 - Removed the restriction to literal types in constexpr functions in C++23 
mode.
 
 - Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now 
fully
-  supported `P2718R0 Lifetime extension in range-based for loops 
`_.
+  supports `P2718R0 Lifetime extension in range-based for loops 
`_.
 
 C++20 Feature Support
 ^

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


[clang] Enable matrices in HLSL (PR #111415)

2024-10-10 Thread Chris B via cfe-commits


@@ -17,12 +17,12 @@ void add(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
   // expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float 
__attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 
'float __attribute__((matrix_type(5, 10)))')}}
 
   a = b + &c;
-  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' 
(aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  
__attribute__((matrix_type(10, 5)))*'))}}
-  // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  
__attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' 
(aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float 
* __attribute__((matrix_type(10, 5)))'))}}

llvm-beanz wrote:

The new printing is illegal. You've changed it from a matrix of `float` to a 
matrix of `float*`. The type printer shouldn't be printing types in a way that 
changes their meaning.

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


[compiler-rt] [libunwind] [AArch64] Fix nofp regressions in compiler-rt and libunwind (PR #111235)

2024-10-10 Thread Keith Packard via cfe-commits


@@ -238,7 +236,8 @@ END_COMPILERRT_OUTLINE_FUNCTION(__arm_sc_memcpy)
 
 DEFINE_COMPILERRT_FUNCTION_ALIAS(__arm_sc_memmove, __arm_sc_memcpy)
 
-
+// This version uses FP registers. Use this only on targets with them
+#if defined(__aarch64__) && __ARM_FP != 0

keith-packard wrote:

I'm not sure; the previous version protected this with `#ifdef __aarch64__`, so 
I just kept that in place. Seemed odd to me as well.

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


[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)

2024-10-10 Thread via cfe-commits


@@ -171,6 +171,9 @@ C++23 Feature Support
 ^
 - Removed the restriction to literal types in constexpr functions in C++23 
mode.
 
+- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now 
fully
+  supported `P2718R0 Lifetime extension in range-based for loops 
`_.

h-vetinari wrote:

Typo: "Clang now fully supports ...", not "supported"

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


[clang] [clang][bytecode] Check number of addcarry/subborrow args (PR #111952)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Apparently this can fail as well.

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


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+1-1) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1765193f5bebbc..74e9e1cf629372 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1287,7 +1287,7 @@ static bool 
interp__builtin_ia32_addcarry_subborrow(InterpState &S,
 const InterpFrame *Frame,
 const Function *Func,
 const CallExpr *Call) {
-  if (!Call->getArg(0)->getType()->isIntegerType() ||
+  if (Call->getNumArgs() != 4 || !Call->getArg(0)->getType()->isIntegerType() 
||
   !Call->getArg(1)->getType()->isIntegerType() ||
   !Call->getArg(2)->getType()->isIntegerType())
 return false;

``




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


[clang] [clang][bytecode] Check number of addcarry/subborrow args (PR #111952)

2024-10-10 Thread Timm Baeder via cfe-commits

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

Apparently this can fail as well.

>From 129097176ae2673f8b6a5270edefbf6a787df55b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 11 Oct 2024 07:34:50 +0200
Subject: [PATCH] [clang][bytecode] Check number of addcarry/subborrow args

Apparently this can fail as well.
---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1765193f5bebbc..74e9e1cf629372 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1287,7 +1287,7 @@ static bool 
interp__builtin_ia32_addcarry_subborrow(InterpState &S,
 const InterpFrame *Frame,
 const Function *Func,
 const CallExpr *Call) {
-  if (!Call->getArg(0)->getType()->isIntegerType() ||
+  if (Call->getNumArgs() != 4 || !Call->getArg(0)->getType()->isIntegerType() 
||
   !Call->getArg(1)->getType()->isIntegerType() ||
   !Call->getArg(2)->getType()->isIntegerType())
 return false;

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


[clang] [clang][bytecode] Fix temporary lvalue base expression (PR #111808)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `clang` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/0/3 (2025 of 2034)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/2/3 (2026 of 2034)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (2027 of 2034)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (2028 of 2034)
PASS: lldb-unit :: Utility/./UtilityTests/7/8 (2029 of 2034)
PASS: lldb-unit :: Host/./HostTests/11/12 (2030 of 2034)
PASS: lldb-unit :: Target/./TargetTests/11/14 (2031 of 2034)
PASS: lldb-unit :: Host/./HostTests/3/12 (2032 of 2034)
PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/9 (2033 of 2034)
UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (2034 of 2034)
 TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/make --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-server
 -p TestLldbGdbServer.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
55d51dd9dca8220ffaf9260d56dae9f5c34b7120)
  clang revision 55d51dd9dca8220ffaf9260d56dae9f5c34b7120
  llvm revision 55d51dd9dca8220ffaf9260d56dae9f5c34b7120
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_writes_all_gpr_registers_debugserver 
(TestLldbGdbServer.LldbGdbServe

[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

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


@@ -212,6 +212,25 @@ typedef llvm::ImmutableMap
 REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingArrayDestruction,
  PendingArrayDestructionMap)
 
+// This trait is used to heuristically filter out results produced from
+// execution paths that took "weak" assumptions within a loop.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(SeenWeakLoopAssumption, bool)
+
+ProgramStateRef clang::ento::recordWeakLoopAssumption(ProgramStateRef State) {
+  return State->set(true);
+}
+
+bool clang::ento::seenWeakLoopAssumption(ProgramStateRef State) {
+  return State->get();
+}

NagyDonat wrote:

> Does it still worth to keep them once we finished processing the loop? The 
> loop condition only gives us information while we are inside the loop the 
> condition belongs to, right? Once the loop is exited, the trait could be 
> safely removed I think.

No, there is a common false positive pattern where an unfounded assumption 
within the loop is used _after the loop_ and produces an unwanted result at 
that point. See e.g. the testcase `loop_suppress_after_zero_iterations` where 
the assumption in the loop introduces `len == 0` as a separate branch, while 
there is no justified reason to handle this separately.

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


[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)

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

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

>From c52634882631a71fad956a70179b480abf13006a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 29 Sep 2024 22:01:38 +0300
Subject: [PATCH 1/3] [Clang] fix overload resolution for object parameters
 with top-level cv-qualifiers in member functions

---
 clang/docs/ReleaseNotes.rst| 1 +
 clang/lib/Sema/SemaOverload.cpp| 3 +++
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 11 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28c759538f7df6..1bec2838765dab 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -447,6 +447,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
+- Fixed overload handling for object parameters with top-level cv-qualifiers 
in explicit member functions (#GH100394)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 0c1e054f7c30a4..7c40bab70bbe9d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1511,6 +1511,9 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   auto NewObjectType = New->getFunctionObjectParameterReferenceType();
   auto OldObjectType = Old->getFunctionObjectParameterReferenceType();
 
+  if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified())
+return false;
+
   auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) {
 return F->getRefQualifier() == RQ_None &&
!F->isExplicitObjectMemberFunction();
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 63bf92e8d5edd3..5fd02502ce6df4 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1073,3 +1073,10 @@ int main() {
   return foo[]; // expected-error {{no viable overloaded operator[] for type 
'Foo'}}
 }
 }
+
+namespace GH100394 {
+struct C {
+  void f(this const C);
+  void f() const ;  // ok
+};
+}

>From d377c01f46acf28f1dc74103c6a26df6c0c2e376 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 6 Oct 2024 11:52:48 +0300
Subject: [PATCH 2/3] adjust overload resolution for volatile qualifiers

---
 clang/lib/Sema/SemaOverload.cpp|  7 +--
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 12 +---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 7c40bab70bbe9d..56705971517cc3 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1511,8 +1511,11 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   auto NewObjectType = New->getFunctionObjectParameterReferenceType();
   auto OldObjectType = Old->getFunctionObjectParameterReferenceType();
 
-  if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified())
-return false;
+  if (Old->isExplicitObjectMemberFunction() &&
+  OldObjectType.getQualifiers() != NewObjectType.getQualifiers())
+return OldObjectType.isConstQualified() &&
+   (NewObjectType.isConstQualified() ||
+NewObjectType.isVolatileQualified());
 
   auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) {
 return F->getRefQualifier() == RQ_None &&
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5fd02502ce6df4..7dcd63a587c708 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1075,8 +1075,14 @@ int main() {
 }
 
 namespace GH100394 {
-struct C {
-  void f(this const C);
-  void f() const ;  // ok
+struct C1 {
+  void f(this const C1);
+  void f() const;// ok
+};
+
+struct C2 {
+  void f(this const C2);// expected-note {{previous declaration is here}}
+  void f(this volatile C2); // expected-error {{class member cannot be 
redeclared}} \
+// expected-warning {{volatile-qualified parameter 
type 'volatile C2' is deprecated}}
 };
 }

>From d524f7c0556fa08bd93a48f1ac6edd754a12926a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 9 Oct 2024 02:46:48 +0300
Subject: [PATCH 3/3] adjust qualifier restrictions for overriding explicit
 object members

---
 clang/lib/Sema/SemaOverload.cpp| 31 ++
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 21 +++
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cp

[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

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



@@ -212,6 +212,25 @@ typedef llvm::ImmutableMap
 REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingArrayDestruction,
  PendingArrayDestructionMap)
 
+// This trait is used to heuristically filter out results produced from
+// execution paths that took "weak" assumptions within a loop.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(SeenWeakLoopAssumption, bool)
+
+ProgramStateRef clang::ento::recordWeakLoopAssumption(ProgramStateRef State) {
+  return State->set(true);
+}
+
+bool clang::ento::seenWeakLoopAssumption(ProgramStateRef State) {
+  return State->get();
+}

steakhal wrote:

There is nothing to be removed here as this trait is a `bool`.

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


[clang] [clang] Ignore inline namespace for `hasName` (PR #109147)

2024-10-10 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource updated 
https://github.com/llvm/llvm-project/pull/109147

From d369d26aad940299eb98ff0c322614043144c558 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Mon, 24 Jul 2023 13:56:29 +0200
Subject: [PATCH 1/4] [clang] Ignore inline namespace for hasName

Add a new flag AlwaysSuppressInlineNamespace to PrintingPolicy that is
explicit about *always* removing inline namespaces regardless of
ambiguity.

Specializing a template from an inline namespace should be transparent
to said namespace. For instance

```
namespace foo {
inline namespace v1 {
template
void function(A&);
}
}

namespace foo {
template<>
void function(int&);
}
```

`hasName` should match both declarations of `foo::function`.

Makes the behavior of `matchesNodeFullSlow` and `matchesNodeFullFast`
consistent.
---
 clang/include/clang/AST/PrettyPrinter.h   | 11 +--
 clang/lib/AST/Decl.cpp|  7 +++--
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  1 +
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  | 29 +++
 4 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 332ac3c6a004a9..a671211bf3ef93 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -61,9 +61,9 @@ struct PrintingPolicy {
 SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
 SuppressScope(false), SuppressUnwrittenScope(false),
 SuppressInlineNamespace(true), SuppressElaboration(false),
-SuppressInitializers(false), ConstantArraySizeAsWritten(false),
-AnonymousTagLocations(true), SuppressStrongLifetime(false),
-SuppressLifetimeQualifiers(false),
+AlwaysSuppressInlineNamespace(false), SuppressInitializers(false),
+ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
+SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
 SuppressTemplateArgsInCXXConstructors(false),
 SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
 Nullptr(LO.CPlusPlus11 || LO.C23), 
NullptrTypeInNamespace(LO.CPlusPlus),
@@ -151,6 +151,11 @@ struct PrintingPolicy {
   LLVM_PREFERRED_TYPE(bool)
   unsigned SuppressElaboration : 1;
 
+  /// Suppress printing parts of scope specifiers that correspond
+  /// to inline namespaces, even if the name is ambiguous with the specifier
+  /// removed.
+  unsigned AlwaysSuppressInlineNamespace : 1;
+
   /// Suppress printing of variable initializers.
   ///
   /// This flag is used when printing the loop variable in a for-range
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index a14b1b33d35efc..a3ac12d58ed044 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1737,8 +1737,11 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream &OS,
   continue;
 
 // Suppress inline namespace if it doesn't make the result ambiguous.
-if (P.SuppressInlineNamespace && Ctx->isInlineNamespace() && NameInScope &&
-cast(Ctx)->isRedundantInlineQualifierFor(NameInScope))
+if (Ctx->isInlineNamespace() && NameInScope &&
+(P.AlwaysSuppressInlineNamespace ||
+ (P.SuppressInlineNamespace &&
+  cast(Ctx)->isRedundantInlineQualifierFor(
+  NameInScope
   continue;
 
 // Skip non-named contexts such as linkage specifications and ExportDecls.
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 06309d327896b3..731fc97707eee7 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -656,6 +656,7 @@ bool HasNameMatcher::matchesNodeFullSlow(const NamedDecl 
&Node) const {
 PrintingPolicy Policy = Node.getASTContext().getPrintingPolicy();
 Policy.SuppressUnwrittenScope = SkipUnwritten;
 Policy.SuppressInlineNamespace = SkipUnwritten;
+Policy.AlwaysSuppressInlineNamespace = SkipUnwritten;
 Node.printQualifiedName(OS, Policy);
 
 const StringRef FullName = OS.str();
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 611e1f9ba5327c..d696375547acce 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2599,6 +2599,35 @@ TEST_P(ASTMatchersTest, 
HasName_MatchesInlinedNamespaces) {
   EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C";
 }
 
+TEST_P(ASTMatchersTest, HasName_MatchesSpecializedInlinedNamespace) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+
+  StringRef code = R"(
+namespace a {
+inline namespace v1 {
+template T foo(T);
+}
+}
+
+namespace a {
+enum Tag{T1, T2};
+
+template  T foo(T);
+}
+
+auto v1 = a::foo(1);
+auto v2 =

[clang] 8306114 - [clang][x86] Add constexpr support for _mm_cvtsi32_ss/_mm_cvt_si2ss/_mm_cvtsi64_ss SSE1 intrinsics

2024-10-10 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2024-10-10T12:49:56+01:00
New Revision: 8306114ed2313a7febdb0d0d0c31df357ed53fdd

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

LOG: [clang][x86] Add constexpr support for 
_mm_cvtsi32_ss/_mm_cvt_si2ss/_mm_cvtsi64_ss SSE1 intrinsics

Followup to #111001

Added: 


Modified: 
clang/lib/Headers/xmmintrin.h
clang/test/CodeGen/X86/sse-builtins.c

Removed: 




diff  --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 2aa688adefc25a..20e66d190113a3 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -1618,9 +1618,8 @@ _mm_cvtt_ps2pi(__m128 __a)
 /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
 ///converted value of the second operand. The upper 96 bits are copied from
 ///the upper 96 bits of the first operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_cvtsi32_ss(__m128 __a, int __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvtsi32_ss(__m128 
__a,
+ int __b) {
   __a[0] = __b;
   return __a;
 }
@@ -1641,9 +1640,8 @@ _mm_cvtsi32_ss(__m128 __a, int __b)
 /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
 ///converted value of the second operand. The upper 96 bits are copied from
 ///the upper 96 bits of the first operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_cvt_si2ss(__m128 __a, int __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvt_si2ss(__m128 __a,
+int __b) {
   return _mm_cvtsi32_ss(__a, __b);
 }
 
@@ -1665,9 +1663,8 @@ _mm_cvt_si2ss(__m128 __a, int __b)
 /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
 ///converted value of the second operand. The upper 96 bits are copied from
 ///the upper 96 bits of the first operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_cvtsi64_ss(__m128 __a, long long __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_cvtsi64_ss(__m128 __a, long long __b) {
   __a[0] = __b;
   return __a;
 }

diff  --git a/clang/test/CodeGen/X86/sse-builtins.c 
b/clang/test/CodeGen/X86/sse-builtins.c
index 932d6f36b09b66..391e049a6ae3ef 100644
--- a/clang/test/CodeGen/X86/sse-builtins.c
+++ b/clang/test/CodeGen/X86/sse-builtins.c
@@ -948,6 +948,15 @@ void test_constexpr() {
   constexpr __m128 v_mm_movelh_ps = _mm_movelh_ps(k1, k2);
   static_assert(v_mm_movelh_ps[0] == +1.0f && v_mm_movelh_ps[1] == +0.0f && 
v_mm_movelh_ps[2] == +8.0f && v_mm_movelh_ps[3] == +4.0f);
 
+  constexpr __m128 v_mm_cvtsi32_ss = _mm_cvtsi32_ss(k1, 42);
+  static_assert(v_mm_cvtsi32_ss[0] == 42.0f && v_mm_cvtsi32_ss[1] == +0.0f && 
v_mm_cvtsi32_ss[2] == +2.0f && v_mm_cvtsi32_ss[3] == +4.0f);
+
+  constexpr __m128 v_mm_cvt_si2ss = _mm_cvt_si2ss(k2, -99);
+  static_assert(v_mm_cvt_si2ss[0] == -99.0f && v_mm_cvt_si2ss[1] == +4.0f && 
v_mm_cvt_si2ss[2] == +2.0f && v_mm_cvt_si2ss[3] == +1.0f);
+
+  constexpr __m128 v_mm_cvtsi64_ss = _mm_cvtsi64_ss(k3, 555);
+  static_assert(v_mm_cvtsi64_ss[0] == 555.0f && v_mm_cvtsi64_ss[1] == -5.0f && 
v_mm_cvtsi64_ss[2] == +6.0f && v_mm_cvtsi64_ss[3] == +7.0f);
+
   static_assert(_mm_cvtss_f32(k2) == +8.0f);
 }
 



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


[libcxx] [libcxxabi] [libunwind] [runtimes] Always define cxx_shared, cxx_static & other targets (PR #80007)

2024-10-10 Thread Louis Dionne via cfe-commits

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


[clang] [Fuchsia][CMake] Set output name for libc++ shared library (PR #111791)

2024-10-10 Thread Louis Dionne via cfe-commits

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


[clang] b94c763 - [Fuchsia][CMake] Set output name for libc++ shared library (#111791)

2024-10-10 Thread via cfe-commits

Author: Petr Hosek
Date: 2024-10-10T07:59:34-04:00
New Revision: b94c763b7c123995ae31a6ce44223e89ef9f226a

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

LOG: [Fuchsia][CMake] Set output name for libc++ shared library (#111791)

This is a dependency of #80007.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 26ae30c71b4df3..5af98c7b3b3fba 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -345,6 +345,7 @@ foreach(target 
armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi)
   set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING 
"")
   set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
@@ -396,6 +397,7 @@ foreach(target riscv32-unknown-elf)
   set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING 
"")
   set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")



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


[clang] [Clang] [Sema] Don't crash on unexpanded pack in invalid block literal (PR #110762)

2024-10-10 Thread via cfe-commits

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


[clang] [Clang] [Sema] Don't crash on unexpanded pack in invalid block literal (PR #110762)

2024-10-10 Thread via cfe-commits

Sirraide wrote:

> I can instead look into refactoring blocks to work the same way as lambdas

Surprisingly, this turned out to be fairly straight-forward to implement. 

(I had to fix something in the template instantiator, but I’ve run into the 
exact same problem before with lambdas, so I knew what to do this time round ;Þ)

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -212,6 +212,25 @@ typedef llvm::ImmutableMap
 REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingArrayDestruction,
  PendingArrayDestructionMap)
 
+// This trait is used to heuristically filter out results produced from
+// execution paths that took "weak" assumptions within a loop.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(SeenWeakLoopAssumption, bool)
+
+ProgramStateRef clang::ento::recordWeakLoopAssumption(ProgramStateRef State) {
+  return State->set(true);
+}
+
+bool clang::ento::seenWeakLoopAssumption(ProgramStateRef State) {
+  return State->get();
+}
+
+// This trait points to the last expression (logical operator) where an eager
+// assumption introduced a state split (i.e. both cases were feasible). This is
+// used by the WeakLoopAssumption heuristic to find situations where the an
+// eager assumption introduces a state split within the evaluation of a loop
+// condition.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(LastEagerlyAssumeAssumptionAt, const Expr *)

isuckatcs wrote:

I suggested a renaming only because I'm not sure that `EagerlyAssumeAssumption` 
is a correct english phrase.

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -441,10 +441,32 @@ void CoreEngine::HandleCallEnter(const CallEnter &CE, 
ExplodedNode *Pred) {
 void CoreEngine::HandleBranch(const Stmt *Cond, const Stmt *Term,
 const CFGBlock * B, ExplodedNode *Pred) {
   assert(B->succ_size() == 2);
+
+  const LocationContext *LC = Pred->getLocationContext();
+  BlockCounter Counter = WList->getBlockCounter();
+  unsigned BlockCount =
+  Counter.getNumVisited(LC->getStackFrame(), B->getBlockID());
+  std::optional IterationsFinishedInLoop = std::nullopt;
+  if (isa(Term)) {
+// FIXME: This code approximates the number of finished iterations based on
+// the block count, i.e. the number of evaluations of the terminator block
+// on the current execution path (which includes the current evaluation, so
+// is always >= 1). This is probably acceptable for the checker-specific
+// false positive suppression that currently uses this value, but it would
+// be better to calcuate an accurate count of iterations.
+assert(BlockCount >= 1);
+IterationsFinishedInLoop = BlockCount - 1;
+  } else if (isa(Term)) {
+// FIXME: The fixme note in the previous branch also applies here.
+// In a do-while loop one iteration happens before the first evaluation of
+// the loop condition, so we don't subtract one from the block count.

isuckatcs wrote:

I think both of these `FIXME`s could be addressed by maintaining a state trait, 
where you track the current iteration count for the loop. That way you don't 
depend on the execution path, only on the current loop that you are visiting.

E.g.:
  entering loop -> set the trait
  finsihed iteration -> increment the trait
  exiting loop -> remove trait

This is probably a different patch anyway.

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -583,11 +603,11 @@ class ExprEngine {
 ExplodedNode *Pred,
 ExplodedNodeSet &Dst);
 
-  /// evalEagerlyAssumeBinOpBifurcation - Given the nodes in 'Src', eagerly 
assume symbolic
-  ///  expressions of the form 'x != 0' and generate new nodes (stored in Dst)
-  ///  with those assumptions.
-  void evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet 
&Src,
- const Expr *Ex);
+  /// evalEagerlyAssumeOpBifurcation - Given the nodes in 'Src', eagerly assume
+  /// symbolic expressions of the form 'x != 0' or '!x' and generate new nodes

isuckatcs wrote:

My point was that some other methods that this method calls also have the same 
misleading and incorrect name like `geteagerlyAssumeBinOpBifurcationTags()`. I 
think if we rename this method, every other similar method should also be 
renamed. 

This is why I suggested a separate patch, or if you want to do it in this patch 
just keep them in 2 different commits so they are separated when the PR is 
merged.

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -212,6 +212,24 @@ typedef llvm::ImmutableMap
 REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingArrayDestruction,
  PendingArrayDestructionMap)
 
+// This trait is used to heuristically filter out results produced from
+// execution paths that took "weak" assumptions within a loop.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(SeenWeakLoopAssumption, bool)
+
+ProgramStateRef clang::ento::recordWeakLoopAssumption(ProgramStateRef State) {
+  return State->set(true);
+}
+
+bool clang::ento::seenWeakLoopAssumption(ProgramStateRef State) {
+  return State->get();
+}

isuckatcs wrote:

Could you please move these definitions to the place, where the other similar 
definitions for other state traits are found, so that they stay grouped 
together?

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -121,6 +121,34 @@ struct EvalCallOptions {
   EvalCallOptions() {}
 };
 
+/// Simple control flow statements like `if` can only produce a single two-way
+/// state split, so when the analyzer cannot determine the value of the
+/// condition, it can assume either of the two options, because the fact that
+/// they are in the source code implies that the programmer thought that they
+/// are possible (at least under some conditions).
+/// (Note that this heuristic is not entirely correct when there are _several_
+/// `if` statements with unmarked logical connections between them, but it's
+/// still good enough and the analyzer heavily relies on it.)
+/// In contrast with this, a single loop statement can produce multiple state
+/// splits, and we cannot always single out safe assumptions where we can say
+/// that "the programmer included this loop in the source code, so they clearly
+/// thought that this execution path is possible".
+/// However, the analyzer wants to explore the code in and after the loop, so
+/// it makes assumptions about the loop condition (to get a concrete execution
+/// path) even when they are not justified.
+/// This function is called by the engine to mark the `State` when it makes an
+/// assumption which is "weak". Checkers may use this heuristical mark to
+/// discard the result and reduce the amount of false positives.
+/// TODO: Instead of just marking these branches for checker-specific handling,
+/// we could discard them completely. I suspect that this could eliminate some
+/// false positives without suppressing too many true positives, but I didn't
+/// have time to measure its effects.
+ProgramStateRef recordWeakLoopAssumption(ProgramStateRef State);
+
+/// Returns true if `recordWeakLoopAssumption()` was called on the execution
+/// path which produced `State`.
+bool seenWeakLoopAssumption(ProgramStateRef State);

isuckatcs wrote:

While browsing through the codebase, I've seen that these methods for the other 
traits are defined inside `class ExprEngine` as `static` methods with setters 
and deleters being `private` and getters being `public`. 

IIUC, they are in the global scope so that they can be accessed from 
`ArrayBoundCheckerV2`. Tbh, I would make `recordWeakLoopAssumption()` a 
`private` `static` method of the `ExprEngine` class, as only this class is able 
to assume anything about the condition, so it should be the only one, that can 
set any state traits related to those assumptions, while 
`seenWeakLoopAssumption()` could be a `public` `static` member function of 
`ExprEngine` to follow the pattern.


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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -212,6 +212,25 @@ typedef llvm::ImmutableMap
 REGISTER_TRAIT_WITH_PROGRAMSTATE(PendingArrayDestruction,
  PendingArrayDestructionMap)
 
+// This trait is used to heuristically filter out results produced from
+// execution paths that took "weak" assumptions within a loop.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(SeenWeakLoopAssumption, bool)
+
+ProgramStateRef clang::ento::recordWeakLoopAssumption(ProgramStateRef State) {
+  return State->set(true);
+}
+
+bool clang::ento::seenWeakLoopAssumption(ProgramStateRef State) {
+  return State->get();
+}

isuckatcs wrote:

Yes, but with this left turned on, the coverage drop is huge even in cases that 
are not affected by the assumption.

```c++
void foo(int x, int y) {
  for (unsigned i = 0; i < x; i++) ; // split the state and set 
SeenWeakLoopAssumption to 'true'
  if (x != 0) return;// drop the 'true' branch

  // no warnings are reported from this point on

  int buf[1] = {0};
  for (int i = 0; i < y; i++)
buf[i] = 1;  // SeenWeakLoopAssumption is 'true', so 
the warning is suppressed
}
```
This goes on through multiple function calls too.
```c++
void a() {}

void b() { a(); }

void c() { b(); }

void d() { c(); }

void main() {
  for (unsigned i = 0; i < x; i++)  ;
  if (x != 0) return;

  // no warnings are reported from this point on

  d();
}
```
If a warning is found inside any of `a()`, `b()`, `c()` or `d()`, it is 
suppressed because the trait is set on the top of the execution path. 

Since we generate a sink it is just 1 false negative though, while relying on 
an unfounded assumption might trigger a false positive in one of the nested 
functions, so I guess we can live with this.

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


[clang] [llvm] [mlir] [polly] [NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (PR #111752)

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

jurahul wrote:

Yes, and that’s the motivation for this (this is a prep PR for that change)

On Thu, Oct 10, 2024 at 12:41 AM Matt Arsenault ***@***.***>
wrote:

> ***@***. approved this pull request.
>
> There are definitely places that would benefit from a getDeclaration.
> There are several places that have to awkwardly construct the intrinsic
> name to check getFunction
>
> —
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


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


[clang] [llvm] [NFC] Replace more DenseMaps with SmallDenseMaps (PR #111836)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-debuginfo

Author: Jeremy Morse (jmorse)


Changes

These DenseMaps all appear as some of the most frequent sources of 
memory-allocations that could otherwise be accomodated with an initial stack 
allocation. For simplicity, I've typedef'd one map-type to be BlockColorMapT, 
used by various block colouring functions.

This also features one opportunistic replacement of std::vector with 
SmallVector, as it's in a path that obviously always allocates.

Compared to the other patches reducing DenseMap allocations the benefits from 
this one are quite small -- I've reached the point of diminishing returns: 
https://llvm-compile-time-tracker.com/compare.php?from=c7fbcae72557cbe14bca615038254649c1177401&to=0785a8d0fd31541d6a8af616111312780e268611&stat=instructions:u

---

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


32 Files Affected:

- (modified) clang/include/clang/AST/CXXInheritance.h (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+2-2) 
- (modified) llvm/include/llvm/ADT/SCCIterator.h (+1-1) 
- (modified) llvm/include/llvm/Analysis/ConstraintSystem.h (+4-4) 
- (modified) llvm/include/llvm/Analysis/DominanceFrontier.h (+2-2) 
- (modified) llvm/include/llvm/Analysis/DominanceFrontierImpl.h (+1-1) 
- (modified) llvm/include/llvm/Analysis/LoopIterator.h (+4-4) 
- (modified) llvm/include/llvm/Analysis/MemorySSA.h (+2-2) 
- (modified) llvm/include/llvm/Analysis/MustExecute.h (+2-2) 
- (modified) llvm/include/llvm/IR/EHPersonalities.h (+2-1) 
- (modified) llvm/include/llvm/IR/PredIteratorCache.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/Cloning.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h (+1-1) 
- (modified) llvm/lib/Analysis/InlineCost.cpp (+1-1) 
- (modified) llvm/lib/Analysis/LazyValueInfo.cpp (+1-1) 
- (modified) llvm/lib/Analysis/MustExecute.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/MachineSSAUpdater.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/WinEHPrepare.cpp (+2-2) 
- (modified) llvm/lib/IR/EHPersonalities.cpp (+2-2) 
- (modified) llvm/lib/IR/Verifier.cpp (+1-1) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+5-5) 
- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+2-2) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARC.cpp (+3-3) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARC.h (+2-2) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp (+5-5) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Scalar/ConstraintElimination.cpp (+3-3) 
- (modified) llvm/lib/Transforms/Scalar/Reassociate.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/SSAUpdater.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index bbef01843e0b0a..b9057e15a41988 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -268,7 +268,7 @@ struct UniqueVirtualMethod {
 /// subobject in which that virtual function occurs).
 class OverridingMethods {
   using ValuesT = SmallVector;
-  using MapType = llvm::MapVector;
+  using MapType = llvm::SmallMapVector;
 
   MapType Overrides;
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 777cdca1a0c0d7..0ec0855cf52440 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -392,8 +392,8 @@ class CXXNameMangler {
   AbiTagState *AbiTags = nullptr;
   AbiTagState AbiTagsRoot;
 
-  llvm::DenseMap Substitutions;
-  llvm::DenseMap ModuleSubstitutions;
+  llvm::SmallDenseMap Substitutions;
+  llvm::SmallDenseMap ModuleSubstitutions;
 
   ASTContext &getASTContext() const { return Context.getASTContext(); }
 
diff --git a/llvm/include/llvm/ADT/SCCIterator.h 
b/llvm/include/llvm/ADT/SCCIterator.h
index 3bd103c13f19f9..a35e0a3f8e8c95 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -73,7 +73,7 @@ class scc_iterator : public iterator_facade_base<
   ///
   /// nodeVisitNumbers are per-node visit numbers, also used as DFS flags.
   unsigned visitNum;
-  DenseMap nodeVisitNumbers;
+  SmallDenseMap nodeVisitNumbers;
 
   /// Stack holding nodes of the SCC.
   std::vector SCCNodeStack;
diff --git a/llvm/include/llvm/Analysis/ConstraintSystem.h 
b/llvm/include/llvm/Analysis/ConstraintSystem.h
index 449852343964ca..2ac0fc1ddc06c3 100644
--- a/llvm/include/llvm/Analysis/ConstraintSystem.h
+++ b/llvm/include/llvm/Analysis/ConstraintSystem.h
@@ -51,7 +51,7 @@ class ConstraintSystem {
 
   /// A map of variables (IR values) to their corresponding index in the
   /// constraint system.
-  DenseMap Value2Index;
+  

[clang] [llvm] [NFC] Replace more DenseMaps with SmallDenseMaps (PR #111836)

2024-10-10 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 774893dcd929c370bad714a70a7d670bb2d6f649 
d2b935e3a537e065b00f543a1792d1979ba413d9 --extensions h,cpp -- 
clang/include/clang/AST/CXXInheritance.h clang/lib/AST/ItaniumMangle.cpp 
llvm/include/llvm/ADT/SCCIterator.h 
llvm/include/llvm/Analysis/ConstraintSystem.h 
llvm/include/llvm/Analysis/DominanceFrontier.h 
llvm/include/llvm/Analysis/DominanceFrontierImpl.h 
llvm/include/llvm/Analysis/LoopIterator.h 
llvm/include/llvm/Analysis/MemorySSA.h llvm/include/llvm/Analysis/MustExecute.h 
llvm/include/llvm/IR/EHPersonalities.h llvm/include/llvm/IR/PredIteratorCache.h 
llvm/include/llvm/Transforms/Utils/Cloning.h 
llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h 
llvm/lib/Analysis/InlineCost.cpp llvm/lib/Analysis/LazyValueInfo.cpp 
llvm/lib/Analysis/MustExecute.cpp 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
llvm/lib/CodeGen/MachineSSAUpdater.cpp llvm/lib/CodeGen/WinEHPrepare.cpp 
llvm/lib/IR/EHPersonalities.cpp llvm/lib/IR/Verifier.cpp 
llvm/lib/Target/X86/X86WinEHState.cpp 
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp 
llvm/lib/Transforms/ObjCARC/ObjCARC.cpp llvm/lib/Transforms/ObjCARC/ObjCARC.h 
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp 
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
llvm/lib/Transforms/Scalar/Reassociate.cpp 
llvm/lib/Transforms/Utils/SSAUpdater.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/include/llvm/Analysis/LoopIterator.h 
b/llvm/include/llvm/Analysis/LoopIterator.h
index aaca0298d2..b641cd5231 100644
--- a/llvm/include/llvm/Analysis/LoopIterator.h
+++ b/llvm/include/llvm/Analysis/LoopIterator.h
@@ -97,8 +97,8 @@ struct LoopBodyTraits {
 class LoopBlocksDFS {
 public:
   /// Postorder list iterators.
-  typedef SmallVector::const_iterator POIterator;
-  typedef SmallVector::const_reverse_iterator RPOIterator;
+  typedef SmallVector::const_iterator POIterator;
+  typedef SmallVector::const_reverse_iterator RPOIterator;
 
   friend class LoopBlocksTraversal;
 
@@ -108,8 +108,8 @@ private:
   /// Map each block to its postorder number. A block is only mapped after it 
is
   /// preorder visited by DFS. It's postorder number is initially zero and set
   /// to nonzero after it is finished by postorder traversal.
-  SmallDenseMap PostNumbers;
-  SmallVector PostBlocks;
+  SmallDenseMap PostNumbers;
+  SmallVector PostBlocks;
 
 public:
   LoopBlocksDFS(Loop *Container) :
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp 
b/llvm/lib/Analysis/LazyValueInfo.cpp
index d7e663d60d..81899e9fe1 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -322,7 +322,7 @@ class LazyValueInfoImpl {
   SmallVector, 8> BlockValueStack;
 
   /// Keeps track of which block-value pairs are in BlockValueStack.
-  SmallDenseSet, 16> BlockValueSet;
+  SmallDenseSet, 16> BlockValueSet;
 
   /// Push BV onto BlockValueStack unless it's already in there.
   /// Returns true on success.
diff --git a/llvm/lib/Analysis/MustExecute.cpp 
b/llvm/lib/Analysis/MustExecute.cpp
index 52d631b56b..d08165633c 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -28,8 +28,7 @@ using namespace llvm;
 
 #define DEBUG_TYPE "must-execute"
 
-const BlockColorMapT &
-LoopSafetyInfo::getBlockColors() const {
+const BlockColorMapT &LoopSafetyInfo::getBlockColors() const {
   return BlockColors;
 }
 
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp 
b/llvm/lib/Target/X86/X86WinEHState.cpp
index 199f8438c6..2181d7a70d 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -70,10 +70,10 @@ private:
   bool isStateStoreNeeded(EHPersonality Personality, CallBase &Call);
   void rewriteSetJmpCall(IRBuilder<> &Builder, Function &F, CallBase &Call,
  Value *State);
-  int getBaseStateForBB(BlockColorMapT &BlockColors,
-WinEHFuncInfo &FuncInfo, BasicBlock *BB);
-  int getStateForCall(BlockColorMapT &BlockColors,
-  WinEHFuncInfo &FuncInfo, CallBase &Call);
+  int getBaseStateForBB(BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
+BasicBlock *BB);
+  int getStateForCall(BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
+  CallBase &Call);
 
   // Module-level type getters.
   Type *getEHLinkRegistrationType();
@@ -500,9 +500,8 @@ void WinEHStatePass::rewriteSetJmpCall(IRBuilder<> 
&Builder, Function &F,
 }
 
 // Figure out what state we should assign calls in this block.
-int WinEHStatePass::getBaseStateForBB(
-BlockColorMapT &BlockColors, WinEHFuncInfo &

[clang] [CLANG]Add Scalable vectors for mfloat8_t (PR #101644)

2024-10-10 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/101644

>From 7134302c7e1054021af36a207dbfd0c40c9e8c51 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Fri, 2 Aug 2024 08:47:18 +
Subject: [PATCH] [CLANG]Add Scalable vectors for mfloat8_t

This patch adds these new vector sizes for sve:
svmfloat8_t

According to the ARM ACLE PR#323[1].

[1] ARM-software/acle#323
---
 .../clang/Basic/AArch64SVEACLETypes.def   |  7 
 clang/include/clang/Basic/arm_sve_sme_incl.td |  1 +
 .../include/clang/Serialization/ASTBitCodes.h |  2 +-
 clang/lib/AST/ASTContext.cpp  | 14 ++--
 clang/test/CodeGen/arm-mfp8.c | 28 
 clang/test/Modules/no-external-type-id.cppm   |  2 +-
 clang/test/Sema/arm-mfp8.cpp  | 13 
 clang/utils/TableGen/SveEmitter.cpp   | 33 ---
 8 files changed, 91 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGen/arm-mfp8.c
 create mode 100644 clang/test/Sema/arm-mfp8.cpp

diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def 
b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 55ed9c36f6c5cd..b72327af61844a 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -69,6 +69,11 @@
 
 #ifndef SVE_VECTOR_TYPE_BFLOAT
 #define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
+  SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, true, false, true)
+#endif
+
+#ifndef SVE_VECTOR_TYPE_MFLOAT
+#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, 
ElBits, NF) \
   SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, 
NF, false, false, true)
 #endif
 
@@ -114,6 +119,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat32_t", "__SVFloat32_t", 
SveFloat32, SveFloat32Ty
 SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, 
SveFloat64Ty, 2, 64, 1)
 
 SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, 1)
+SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t",  SveMFloat8, 
SveMFloat8Ty, 16, 8, 1)
 
 //
 // x2
@@ -183,6 +189,7 @@ SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, 
SveCountTy)
 
 #undef SVE_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE_BFLOAT
+#undef SVE_VECTOR_TYPE_MFLOAT
 #undef SVE_VECTOR_TYPE_FLOAT
 #undef SVE_VECTOR_TYPE_INT
 #undef SVE_PREDICATE_TYPE
diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td 
b/clang/include/clang/Basic/arm_sve_sme_incl.td
index fdf4ba55fe9382..50911fb63e818e 100644
--- a/clang/include/clang/Basic/arm_sve_sme_incl.td
+++ b/clang/include/clang/Basic/arm_sve_sme_incl.td
@@ -162,6 +162,7 @@ def EltTyBool16  : EltType<10>;
 def EltTyBool32  : EltType<11>;
 def EltTyBool64  : EltType<12>;
 def EltTyBFloat16 : EltType<13>;
+def EltTyMFloat8  : EltType<14>;
 
 class MemEltType {
   int Value = val;
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 5be33ae0ed1b98..d468d49e1e632f 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1145,7 +1145,7 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 505;
+const unsigned NUM_PREDEF_TYPE_IDS = 506;
 
 // Ensure we do not overrun the predefined types we reserved
 // in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index fd8aa8de79b49f..7c11fec02a3f60 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4304,7 +4304,6 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType 
*Ty) const {
   switch (Ty->getKind()) {
   default:
 llvm_unreachable("Unsupported builtin vector type");
-
 #define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls,
\
 ElBits, NF, IsSigned)  
\
   case BuiltinType::Id:
\
@@ -4319,12 +4318,16 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType 
*Ty) const {
ElBits, NF) 
\
   case BuiltinType::Id:
\
 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
+#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, 
\
+   ElBits, NF) 
\
+  case BuiltinType::Id:
\
+return {getIntTypeForBitwidth(ElBits, false),  
\
+llvm::ElementCount::getScalable(NumEls), NF};
 #define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) 
\
   case Bu

[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)

2024-10-10 Thread Erich Keane via cfe-commits

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


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


[clang] [llvm] [NFC] Replace more DenseMaps with SmallDenseMaps (PR #111836)

2024-10-10 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Jeremy Morse (jmorse)


Changes

These DenseMaps all appear as some of the most frequent sources of 
memory-allocations that could otherwise be accomodated with an initial stack 
allocation. For simplicity, I've typedef'd one map-type to be BlockColorMapT, 
used by various block colouring functions.

This also features one opportunistic replacement of std::vector with 
SmallVector, as it's in a path that obviously always allocates.

Compared to the other patches reducing DenseMap allocations the benefits from 
this one are quite small -- I've reached the point of diminishing returns: 
https://llvm-compile-time-tracker.com/compare.php?from=c7fbcae72557cbe14bca615038254649c1177401&to=0785a8d0fd31541d6a8af616111312780e268611&stat=instructions:u

---

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


32 Files Affected:

- (modified) clang/include/clang/AST/CXXInheritance.h (+1-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+2-2) 
- (modified) llvm/include/llvm/ADT/SCCIterator.h (+1-1) 
- (modified) llvm/include/llvm/Analysis/ConstraintSystem.h (+4-4) 
- (modified) llvm/include/llvm/Analysis/DominanceFrontier.h (+2-2) 
- (modified) llvm/include/llvm/Analysis/DominanceFrontierImpl.h (+1-1) 
- (modified) llvm/include/llvm/Analysis/LoopIterator.h (+4-4) 
- (modified) llvm/include/llvm/Analysis/MemorySSA.h (+2-2) 
- (modified) llvm/include/llvm/Analysis/MustExecute.h (+2-2) 
- (modified) llvm/include/llvm/IR/EHPersonalities.h (+2-1) 
- (modified) llvm/include/llvm/IR/PredIteratorCache.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/Cloning.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h (+1-1) 
- (modified) llvm/lib/Analysis/InlineCost.cpp (+1-1) 
- (modified) llvm/lib/Analysis/LazyValueInfo.cpp (+1-1) 
- (modified) llvm/lib/Analysis/MustExecute.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/MachineSSAUpdater.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/WinEHPrepare.cpp (+2-2) 
- (modified) llvm/lib/IR/EHPersonalities.cpp (+2-2) 
- (modified) llvm/lib/IR/Verifier.cpp (+1-1) 
- (modified) llvm/lib/Target/X86/X86WinEHState.cpp (+5-5) 
- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+2-2) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARC.cpp (+3-3) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARC.h (+2-2) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp (+5-5) 
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Scalar/ConstraintElimination.cpp (+3-3) 
- (modified) llvm/lib/Transforms/Scalar/Reassociate.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/SSAUpdater.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index bbef01843e0b0a..b9057e15a41988 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -268,7 +268,7 @@ struct UniqueVirtualMethod {
 /// subobject in which that virtual function occurs).
 class OverridingMethods {
   using ValuesT = SmallVector;
-  using MapType = llvm::MapVector;
+  using MapType = llvm::SmallMapVector;
 
   MapType Overrides;
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 777cdca1a0c0d7..0ec0855cf52440 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -392,8 +392,8 @@ class CXXNameMangler {
   AbiTagState *AbiTags = nullptr;
   AbiTagState AbiTagsRoot;
 
-  llvm::DenseMap Substitutions;
-  llvm::DenseMap ModuleSubstitutions;
+  llvm::SmallDenseMap Substitutions;
+  llvm::SmallDenseMap ModuleSubstitutions;
 
   ASTContext &getASTContext() const { return Context.getASTContext(); }
 
diff --git a/llvm/include/llvm/ADT/SCCIterator.h 
b/llvm/include/llvm/ADT/SCCIterator.h
index 3bd103c13f19f9..a35e0a3f8e8c95 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -73,7 +73,7 @@ class scc_iterator : public iterator_facade_base<
   ///
   /// nodeVisitNumbers are per-node visit numbers, also used as DFS flags.
   unsigned visitNum;
-  DenseMap nodeVisitNumbers;
+  SmallDenseMap nodeVisitNumbers;
 
   /// Stack holding nodes of the SCC.
   std::vector SCCNodeStack;
diff --git a/llvm/include/llvm/Analysis/ConstraintSystem.h 
b/llvm/include/llvm/Analysis/ConstraintSystem.h
index 449852343964ca..2ac0fc1ddc06c3 100644
--- a/llvm/include/llvm/Analysis/ConstraintSystem.h
+++ b/llvm/include/llvm/Analysis/ConstraintSystem.h
@@ -51,7 +51,7 @@ class ConstraintSystem {
 
   /// A map of variables (IR values) to their corresponding index in the
   /// constraint system.

[clang] [llvm] [NFC] Replace more DenseMaps with SmallDenseMaps (PR #111836)

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

https://github.com/jmorse created 
https://github.com/llvm/llvm-project/pull/111836

These DenseMaps all appear as some of the most frequent sources of 
memory-allocations that could otherwise be accomodated with an initial stack 
allocation. For simplicity, I've typedef'd one map-type to be BlockColorMapT, 
used by various block colouring functions.

This also features one opportunistic replacement of std::vector with 
SmallVector, as it's in a path that obviously always allocates.

Compared to the other patches reducing DenseMap allocations the benefits from 
this one are quite small -- I've reached the point of diminishing returns: 
https://llvm-compile-time-tracker.com/compare.php?from=c7fbcae72557cbe14bca615038254649c1177401&to=0785a8d0fd31541d6a8af616111312780e268611&stat=instructions:u

>From d2b935e3a537e065b00f543a1792d1979ba413d9 Mon Sep 17 00:00:00 2001
From: Jeremy Morse 
Date: Thu, 10 Oct 2024 14:17:34 +0100
Subject: [PATCH] [NFC] Replace more DenseMaps with SmallDenseMaps

These DenseMaps all appear as some of the most frequent sources of
memory-allocations that could otherwise be accomodated with an initial
stack allocation. For simplicity, I've typedef'd one map-type to be
BlockColorMapT, used by various block colouring functions.

This also features one opportunistic replacement of std::vector with
SmallVector, as it's in a path that obviously always allocates.
---
 clang/include/clang/AST/CXXInheritance.h   |  2 +-
 clang/lib/AST/ItaniumMangle.cpp|  4 ++--
 llvm/include/llvm/ADT/SCCIterator.h|  2 +-
 llvm/include/llvm/Analysis/ConstraintSystem.h  |  8 
 llvm/include/llvm/Analysis/DominanceFrontier.h |  4 ++--
 llvm/include/llvm/Analysis/DominanceFrontierImpl.h |  2 +-
 llvm/include/llvm/Analysis/LoopIterator.h  |  8 
 llvm/include/llvm/Analysis/MemorySSA.h |  4 ++--
 llvm/include/llvm/Analysis/MustExecute.h   |  4 ++--
 llvm/include/llvm/IR/EHPersonalities.h |  3 ++-
 llvm/include/llvm/IR/PredIteratorCache.h   |  2 +-
 llvm/include/llvm/Transforms/Utils/Cloning.h   |  2 +-
 llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h|  2 +-
 llvm/lib/Analysis/InlineCost.cpp   |  2 +-
 llvm/lib/Analysis/LazyValueInfo.cpp|  2 +-
 llvm/lib/Analysis/MustExecute.cpp  |  2 +-
 llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp |  2 +-
 llvm/lib/CodeGen/MachineSSAUpdater.cpp |  2 +-
 llvm/lib/CodeGen/WinEHPrepare.cpp  |  4 ++--
 llvm/lib/IR/EHPersonalities.cpp|  4 ++--
 llvm/lib/IR/Verifier.cpp   |  2 +-
 llvm/lib/Target/X86/X86WinEHState.cpp  | 10 +-
 .../Transforms/InstCombine/InstructionCombining.cpp|  2 +-
 .../Transforms/Instrumentation/AddressSanitizer.cpp|  2 +-
 .../Transforms/Instrumentation/PGOInstrumentation.cpp  |  4 ++--
 llvm/lib/Transforms/ObjCARC/ObjCARC.cpp|  6 +++---
 llvm/lib/Transforms/ObjCARC/ObjCARC.h  |  4 ++--
 llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp| 10 +-
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp|  2 +-
 llvm/lib/Transforms/Scalar/ConstraintElimination.cpp   |  6 +++---
 llvm/lib/Transforms/Scalar/Reassociate.cpp |  2 +-
 llvm/lib/Transforms/Utils/SSAUpdater.cpp   |  2 +-
 32 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index bbef01843e0b0a..b9057e15a41988 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -268,7 +268,7 @@ struct UniqueVirtualMethod {
 /// subobject in which that virtual function occurs).
 class OverridingMethods {
   using ValuesT = SmallVector;
-  using MapType = llvm::MapVector;
+  using MapType = llvm::SmallMapVector;
 
   MapType Overrides;
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 777cdca1a0c0d7..0ec0855cf52440 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -392,8 +392,8 @@ class CXXNameMangler {
   AbiTagState *AbiTags = nullptr;
   AbiTagState AbiTagsRoot;
 
-  llvm::DenseMap Substitutions;
-  llvm::DenseMap ModuleSubstitutions;
+  llvm::SmallDenseMap Substitutions;
+  llvm::SmallDenseMap ModuleSubstitutions;
 
   ASTContext &getASTContext() const { return Context.getASTContext(); }
 
diff --git a/llvm/include/llvm/ADT/SCCIterator.h 
b/llvm/include/llvm/ADT/SCCIterator.h
index 3bd103c13f19f9..a35e0a3f8e8c95 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -73,7 +73,7 @@ class scc_iterator : public iterator_facade_base<
   ///
   /// nodeVisitNumbers are per-node visit numbers, also used as DFS flags.
   unsigned visitNum;
-  DenseM

[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-10-10 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -441,10 +441,32 @@ void CoreEngine::HandleCallEnter(const CallEnter &CE, 
ExplodedNode *Pred) {
 void CoreEngine::HandleBranch(const Stmt *Cond, const Stmt *Term,
 const CFGBlock * B, ExplodedNode *Pred) {
   assert(B->succ_size() == 2);
+
+  const LocationContext *LC = Pred->getLocationContext();
+  BlockCounter Counter = WList->getBlockCounter();
+  unsigned BlockCount =
+  Counter.getNumVisited(LC->getStackFrame(), B->getBlockID());
+  std::optional IterationsFinishedInLoop = std::nullopt;
+  if (isa(Term)) {
+// FIXME: This code approximates the number of finished iterations based on
+// the block count, i.e. the number of evaluations of the terminator block
+// on the current execution path (which includes the current evaluation, so
+// is always >= 1). This is probably acceptable for the checker-specific
+// false positive suppression that currently uses this value, but it would
+// be better to calcuate an accurate count of iterations.
+assert(BlockCount >= 1);
+IterationsFinishedInLoop = BlockCount - 1;
+  } else if (isa(Term)) {
+// FIXME: The fixme note in the previous branch also applies here.
+// In a do-while loop one iteration happens before the first evaluation of
+// the loop condition, so we don't subtract one from the block count.

isuckatcs wrote:

I just realised, we already talked about this in a previous comment.

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


[clang] [llvm] [NFC] Replace more DenseMaps with SmallDenseMaps (PR #111836)

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

https://github.com/jmorse updated 
https://github.com/llvm/llvm-project/pull/111836

>From d2b935e3a537e065b00f543a1792d1979ba413d9 Mon Sep 17 00:00:00 2001
From: Jeremy Morse 
Date: Thu, 10 Oct 2024 14:17:34 +0100
Subject: [PATCH 1/2] [NFC] Replace more DenseMaps with SmallDenseMaps

These DenseMaps all appear as some of the most frequent sources of
memory-allocations that could otherwise be accomodated with an initial
stack allocation. For simplicity, I've typedef'd one map-type to be
BlockColorMapT, used by various block colouring functions.

This also features one opportunistic replacement of std::vector with
SmallVector, as it's in a path that obviously always allocates.
---
 clang/include/clang/AST/CXXInheritance.h   |  2 +-
 clang/lib/AST/ItaniumMangle.cpp|  4 ++--
 llvm/include/llvm/ADT/SCCIterator.h|  2 +-
 llvm/include/llvm/Analysis/ConstraintSystem.h  |  8 
 llvm/include/llvm/Analysis/DominanceFrontier.h |  4 ++--
 llvm/include/llvm/Analysis/DominanceFrontierImpl.h |  2 +-
 llvm/include/llvm/Analysis/LoopIterator.h  |  8 
 llvm/include/llvm/Analysis/MemorySSA.h |  4 ++--
 llvm/include/llvm/Analysis/MustExecute.h   |  4 ++--
 llvm/include/llvm/IR/EHPersonalities.h |  3 ++-
 llvm/include/llvm/IR/PredIteratorCache.h   |  2 +-
 llvm/include/llvm/Transforms/Utils/Cloning.h   |  2 +-
 llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h|  2 +-
 llvm/lib/Analysis/InlineCost.cpp   |  2 +-
 llvm/lib/Analysis/LazyValueInfo.cpp|  2 +-
 llvm/lib/Analysis/MustExecute.cpp  |  2 +-
 llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp |  2 +-
 llvm/lib/CodeGen/MachineSSAUpdater.cpp |  2 +-
 llvm/lib/CodeGen/WinEHPrepare.cpp  |  4 ++--
 llvm/lib/IR/EHPersonalities.cpp|  4 ++--
 llvm/lib/IR/Verifier.cpp   |  2 +-
 llvm/lib/Target/X86/X86WinEHState.cpp  | 10 +-
 .../Transforms/InstCombine/InstructionCombining.cpp|  2 +-
 .../Transforms/Instrumentation/AddressSanitizer.cpp|  2 +-
 .../Transforms/Instrumentation/PGOInstrumentation.cpp  |  4 ++--
 llvm/lib/Transforms/ObjCARC/ObjCARC.cpp|  6 +++---
 llvm/lib/Transforms/ObjCARC/ObjCARC.h  |  4 ++--
 llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp| 10 +-
 llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp|  2 +-
 llvm/lib/Transforms/Scalar/ConstraintElimination.cpp   |  6 +++---
 llvm/lib/Transforms/Scalar/Reassociate.cpp |  2 +-
 llvm/lib/Transforms/Utils/SSAUpdater.cpp   |  2 +-
 32 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index bbef01843e0b0a..b9057e15a41988 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -268,7 +268,7 @@ struct UniqueVirtualMethod {
 /// subobject in which that virtual function occurs).
 class OverridingMethods {
   using ValuesT = SmallVector;
-  using MapType = llvm::MapVector;
+  using MapType = llvm::SmallMapVector;
 
   MapType Overrides;
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 777cdca1a0c0d7..0ec0855cf52440 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -392,8 +392,8 @@ class CXXNameMangler {
   AbiTagState *AbiTags = nullptr;
   AbiTagState AbiTagsRoot;
 
-  llvm::DenseMap Substitutions;
-  llvm::DenseMap ModuleSubstitutions;
+  llvm::SmallDenseMap Substitutions;
+  llvm::SmallDenseMap ModuleSubstitutions;
 
   ASTContext &getASTContext() const { return Context.getASTContext(); }
 
diff --git a/llvm/include/llvm/ADT/SCCIterator.h 
b/llvm/include/llvm/ADT/SCCIterator.h
index 3bd103c13f19f9..a35e0a3f8e8c95 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -73,7 +73,7 @@ class scc_iterator : public iterator_facade_base<
   ///
   /// nodeVisitNumbers are per-node visit numbers, also used as DFS flags.
   unsigned visitNum;
-  DenseMap nodeVisitNumbers;
+  SmallDenseMap nodeVisitNumbers;
 
   /// Stack holding nodes of the SCC.
   std::vector SCCNodeStack;
diff --git a/llvm/include/llvm/Analysis/ConstraintSystem.h 
b/llvm/include/llvm/Analysis/ConstraintSystem.h
index 449852343964ca..2ac0fc1ddc06c3 100644
--- a/llvm/include/llvm/Analysis/ConstraintSystem.h
+++ b/llvm/include/llvm/Analysis/ConstraintSystem.h
@@ -51,7 +51,7 @@ class ConstraintSystem {
 
   /// A map of variables (IR values) to their corresponding index in the
   /// constraint system.
-  DenseMap Value2Index;
+  SmallDenseMap Value2Index;
 
   // Eliminate constraints from the system using Fourier–Motzkin elimination.
   bool eliminateUsingFM();
@@ -70,7 +70,7 @@ class C

[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-10 Thread Erich Keane via cfe-commits

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


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


[clang] [Fuchsia][CMake] Set output name for libc++ shared library (PR #111791)

2024-10-10 Thread Louis Dionne via cfe-commits

ldionne wrote:

Thanks!

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


[clang] [Fuchsia][CMake] Set output name for libc++ shared library (PR #111791)

2024-10-10 Thread Louis Dionne via cfe-commits

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


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


[libcxx] [libcxxabi] [libunwind] [runtimes][NFC] Reindent CMake files (PR #111821)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)


Changes

This is a purely mechanical commit for fixing the indentation of the runtimes' 
CMakeLists files after #80007. That PR didn't update the indentation in 
order to make the diff easier to review and for merge conflicts to be easier to 
resolve (for downstream changes).

This doesn't change any code, it only reindents it.

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


3 Files Affected:

- (modified) libcxx/src/CMakeLists.txt (+97-97) 
- (modified) libcxxabi/src/CMakeLists.txt (+70-70) 
- (modified) libunwind/src/CMakeLists.txt (+20-20) 


``diff
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 9f31822065be9d..4af04f202db1f7 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,76 +173,76 @@ split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
 # Build the shared library.
-  add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
-  target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-  target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
-   PRIVATE ${LIBCXX_LIBRARIES})
-  set_target_properties(cxx_shared
-PROPERTIES
-  EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
-  COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-  LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
-  OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
-  VERSION   "${LIBCXX_LIBRARY_VERSION}"
-  SOVERSION "${LIBCXX_ABI_VERSION}"
-  DEFINE_SYMBOL ""
+add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
+target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
+  PRIVATE ${LIBCXX_LIBRARIES})
+set_target_properties(cxx_shared
+  PROPERTIES
+EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
+COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
+OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
+VERSION   "${LIBCXX_LIBRARY_VERSION}"
+SOVERSION "${LIBCXX_ABI_VERSION}"
+DEFINE_SYMBOL ""
+)
+cxx_add_common_build_flags(cxx_shared)
+
+if(ZOS)
+  add_custom_command(TARGET cxx_shared POST_BUILD
+COMMAND
+  ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
+  $ $ 
"${LIBCXX_DLL_NAME}"
+COMMENT "Rename dll name inside the side deck file"
+WORKING_DIRECTORY $
   )
-  cxx_add_common_build_flags(cxx_shared)
-
-  if(ZOS)
-add_custom_command(TARGET cxx_shared POST_BUILD
-  COMMAND
-${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
-$ $ 
"${LIBCXX_DLL_NAME}"
-  COMMENT "Rename dll name inside the side deck file"
-  WORKING_DIRECTORY $
-)
-  endif()
+endif()
 
-  # Link against libc++abi
-  if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
-  else()
-target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
-  endif()
+# Link against libc++abi
+if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
+else()
+  target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
+endif()
 
-  # Maybe force some symbols to be weak, not weak or not exported.
-  # TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
-  if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
-AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE
-  
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
-  
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
-  endif()
+# Maybe force some symbols to be weak, not weak or not exported.
+# TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
+if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
+  AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE
+
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
+"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
+endif()
 
-  # Generate a linker script in place of a libc++.so symlink.
-  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-set(link_libraries)
-
-set(imported_libname 
"$")
-set(output_name "$")
-string(APPEND link_libraries 
"${CMAKE_LINK_LIBRARY_FLAG}$,${imported_libname},${output_name}>")
-
-# TODO: Move to the same approach as above for the unwind library
-if (LIBCXXABI_USE_LLVM_UNWINDER)
-  if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
-# libunwind is already included in libc++abi
-  elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
-string(APPEND link_libraries " 
${CMAKE_LINK_LIBRARY_FLAG}$")
-  else

[libcxx] [libcxxabi] [libunwind] [runtimes][NFC] Reindent CMake files (PR #111821)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libunwind

Author: Louis Dionne (ldionne)


Changes

This is a purely mechanical commit for fixing the indentation of the runtimes' 
CMakeLists files after #80007. That PR didn't update the indentation in 
order to make the diff easier to review and for merge conflicts to be easier to 
resolve (for downstream changes).

This doesn't change any code, it only reindents it.

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


3 Files Affected:

- (modified) libcxx/src/CMakeLists.txt (+97-97) 
- (modified) libcxxabi/src/CMakeLists.txt (+70-70) 
- (modified) libunwind/src/CMakeLists.txt (+20-20) 


``diff
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 9f31822065be9d..4af04f202db1f7 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,76 +173,76 @@ split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
 # Build the shared library.
-  add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
-  target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-  target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
-   PRIVATE ${LIBCXX_LIBRARIES})
-  set_target_properties(cxx_shared
-PROPERTIES
-  EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
-  COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-  LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
-  OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
-  VERSION   "${LIBCXX_LIBRARY_VERSION}"
-  SOVERSION "${LIBCXX_ABI_VERSION}"
-  DEFINE_SYMBOL ""
+add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
+target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
+  PRIVATE ${LIBCXX_LIBRARIES})
+set_target_properties(cxx_shared
+  PROPERTIES
+EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
+COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
+OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
+VERSION   "${LIBCXX_LIBRARY_VERSION}"
+SOVERSION "${LIBCXX_ABI_VERSION}"
+DEFINE_SYMBOL ""
+)
+cxx_add_common_build_flags(cxx_shared)
+
+if(ZOS)
+  add_custom_command(TARGET cxx_shared POST_BUILD
+COMMAND
+  ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
+  $ $ 
"${LIBCXX_DLL_NAME}"
+COMMENT "Rename dll name inside the side deck file"
+WORKING_DIRECTORY $
   )
-  cxx_add_common_build_flags(cxx_shared)
-
-  if(ZOS)
-add_custom_command(TARGET cxx_shared POST_BUILD
-  COMMAND
-${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
-$ $ 
"${LIBCXX_DLL_NAME}"
-  COMMENT "Rename dll name inside the side deck file"
-  WORKING_DIRECTORY $
-)
-  endif()
+endif()
 
-  # Link against libc++abi
-  if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
-  else()
-target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
-  endif()
+# Link against libc++abi
+if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
+else()
+  target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
+endif()
 
-  # Maybe force some symbols to be weak, not weak or not exported.
-  # TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
-  if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
-AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE
-  
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
-  
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
-  endif()
+# Maybe force some symbols to be weak, not weak or not exported.
+# TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
+if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
+  AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE
+
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
+"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
+endif()
 
-  # Generate a linker script in place of a libc++.so symlink.
-  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-set(link_libraries)
-
-set(imported_libname 
"$")
-set(output_name "$")
-string(APPEND link_libraries 
"${CMAKE_LINK_LIBRARY_FLAG}$,${imported_libname},${output_name}>")
-
-# TODO: Move to the same approach as above for the unwind library
-if (LIBCXXABI_USE_LLVM_UNWINDER)
-  if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
-# libunwind is already included in libc++abi
-  elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
-string(APPEND link_libraries " 
${CMAKE_LINK_LIBRARY_FLAG}$")
-  e

[libcxx] [libcxxabi] [libunwind] [runtimes][NFC] Reindent CMake files (PR #111821)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxxabi

Author: Louis Dionne (ldionne)


Changes

This is a purely mechanical commit for fixing the indentation of the runtimes' 
CMakeLists files after #80007. That PR didn't update the indentation in 
order to make the diff easier to review and for merge conflicts to be easier to 
resolve (for downstream changes).

This doesn't change any code, it only reindents it.

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


3 Files Affected:

- (modified) libcxx/src/CMakeLists.txt (+97-97) 
- (modified) libcxxabi/src/CMakeLists.txt (+70-70) 
- (modified) libunwind/src/CMakeLists.txt (+20-20) 


``diff
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 9f31822065be9d..4af04f202db1f7 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,76 +173,76 @@ split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
 # Build the shared library.
-  add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
-  target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-  target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
-   PRIVATE ${LIBCXX_LIBRARIES})
-  set_target_properties(cxx_shared
-PROPERTIES
-  EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
-  COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-  LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
-  OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
-  VERSION   "${LIBCXX_LIBRARY_VERSION}"
-  SOVERSION "${LIBCXX_ABI_VERSION}"
-  DEFINE_SYMBOL ""
+add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
+target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
+  PRIVATE ${LIBCXX_LIBRARIES})
+set_target_properties(cxx_shared
+  PROPERTIES
+EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
+COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
+OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
+VERSION   "${LIBCXX_LIBRARY_VERSION}"
+SOVERSION "${LIBCXX_ABI_VERSION}"
+DEFINE_SYMBOL ""
+)
+cxx_add_common_build_flags(cxx_shared)
+
+if(ZOS)
+  add_custom_command(TARGET cxx_shared POST_BUILD
+COMMAND
+  ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
+  $ $ 
"${LIBCXX_DLL_NAME}"
+COMMENT "Rename dll name inside the side deck file"
+WORKING_DIRECTORY $
   )
-  cxx_add_common_build_flags(cxx_shared)
-
-  if(ZOS)
-add_custom_command(TARGET cxx_shared POST_BUILD
-  COMMAND
-${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
-$ $ 
"${LIBCXX_DLL_NAME}"
-  COMMENT "Rename dll name inside the side deck file"
-  WORKING_DIRECTORY $
-)
-  endif()
+endif()
 
-  # Link against libc++abi
-  if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
-  else()
-target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
-  endif()
+# Link against libc++abi
+if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
+else()
+  target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
+endif()
 
-  # Maybe force some symbols to be weak, not weak or not exported.
-  # TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
-  if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
-AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE
-  
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
-  
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
-  endif()
+# Maybe force some symbols to be weak, not weak or not exported.
+# TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
+if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
+  AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE
+
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
+"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
+endif()
 
-  # Generate a linker script in place of a libc++.so symlink.
-  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-set(link_libraries)
-
-set(imported_libname 
"$")
-set(output_name "$")
-string(APPEND link_libraries 
"${CMAKE_LINK_LIBRARY_FLAG}$,${imported_libname},${output_name}>")
-
-# TODO: Move to the same approach as above for the unwind library
-if (LIBCXXABI_USE_LLVM_UNWINDER)
-  if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
-# libunwind is already included in libc++abi
-  elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
-string(APPEND link_libraries " 
${CMAKE_LINK_LIBRARY_FLAG}$")
-  e

[libcxx] [libcxxabi] [libunwind] [runtimes][NFC] Reindent CMake files (PR #111821)

2024-10-10 Thread Louis Dionne via cfe-commits

https://github.com/ldionne created 
https://github.com/llvm/llvm-project/pull/111821

This is a purely mechanical commit for fixing the indentation of the runtimes' 
CMakeLists files after #80007. That PR didn't update the indentation in order 
to make the diff easier to review and for merge conflicts to be easier to 
resolve (for downstream changes).

This doesn't change any code, it only reindents it.

>From cada9088fee6b71b9e8c7b2c91e6400e73d7418a Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Thu, 10 Oct 2024 08:03:00 -0400
Subject: [PATCH] [runtimes][NFC] Reindent CMake files

This is a purely mechanical commit for fixing the indentation of the
runtimes' CMakeLists files after #80007. That PR didn't update the
indentation in order to make the diff easier to review and for merge
conflicts to be easier to resolve (for downstream changes).

This doesn't change any code, it only reindents it.
---
 libcxx/src/CMakeLists.txt| 194 +--
 libcxxabi/src/CMakeLists.txt | 140 -
 libunwind/src/CMakeLists.txt |  40 
 3 files changed, 187 insertions(+), 187 deletions(-)

diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 9f31822065be9d..4af04f202db1f7 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,76 +173,76 @@ split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
 # Build the shared library.
-  add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
-  target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-  target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
-   PRIVATE ${LIBCXX_LIBRARIES})
-  set_target_properties(cxx_shared
-PROPERTIES
-  EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
-  COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-  LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
-  OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
-  VERSION   "${LIBCXX_LIBRARY_VERSION}"
-  SOVERSION "${LIBCXX_ABI_VERSION}"
-  DEFINE_SYMBOL ""
+add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
+target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
+  PRIVATE ${LIBCXX_LIBRARIES})
+set_target_properties(cxx_shared
+  PROPERTIES
+EXCLUDE_FROM_ALL "$,FALSE,TRUE>"
+COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
+OUTPUT_NAME   "${LIBCXX_SHARED_OUTPUT_NAME}"
+VERSION   "${LIBCXX_LIBRARY_VERSION}"
+SOVERSION "${LIBCXX_ABI_VERSION}"
+DEFINE_SYMBOL ""
+)
+cxx_add_common_build_flags(cxx_shared)
+
+if(ZOS)
+  add_custom_command(TARGET cxx_shared POST_BUILD
+COMMAND
+  ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
+  $ $ 
"${LIBCXX_DLL_NAME}"
+COMMENT "Rename dll name inside the side deck file"
+WORKING_DIRECTORY $
   )
-  cxx_add_common_build_flags(cxx_shared)
-
-  if(ZOS)
-add_custom_command(TARGET cxx_shared POST_BUILD
-  COMMAND
-${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
-$ $ 
"${LIBCXX_DLL_NAME}"
-  COMMENT "Rename dll name inside the side deck file"
-  WORKING_DIRECTORY $
-)
-  endif()
+endif()
 
-  # Link against libc++abi
-  if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
-  else()
-target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
-  endif()
+# Link against libc++abi
+if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
+else()
+  target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
+endif()
 
-  # Maybe force some symbols to be weak, not weak or not exported.
-  # TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
-  if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
-AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
-target_link_libraries(cxx_shared PRIVATE
-  
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
-  
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
-  endif()
+# Maybe force some symbols to be weak, not weak or not exported.
+# TODO: This shouldn't depend on the platform, and ideally it should be done 
in the sources.
+if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
+  AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
+  target_link_libraries(cxx_shared PRIVATE
+
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
+"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
+endif()
 
-  # Generate a linker script in place of a libc++.so symlink.
-  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-set(link_libraries)
-
-set(imported_libname 
"$")
-set(output_na

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-10 Thread via cfe-commits

luxufan wrote:

Thanks for your detailed explanation! I have updated the PR.

> > But, I have a question: now that it has ensured the uniqueness of 
> > typeinfo's address, why does the implementation still compare the type 
> > equality by the address of type name string?
> 
> The uniqueness of the address of the `type_info` object itself is not 
> guaranteed. The reason is that we sometimes [generate `type_info` objects for 
> pointers to incomplete 
> types](https://itanium-cxx-abi.github.io/cxx-abi/abi.html#:~:text=When%20it%20is,the%20type_info%20addresses.)
>  as part of exception handling, so we can end up with multiple `type_info` 
> objects for the same type.
> 
> > For symbols with internal linkage or hidden visibility, I don't think there 
> > would be problems if they were allowed to be merged. For example, 
> > considering there are 2 translation units 0.cpp and 1.cpp, and we defined 
> > internal `class A {}` in these 2 translation units, since they are all 
> > internal symbols, I think comparing `0.cpp::A` with `1.cpp::A` is undefined 
> > behavior. Because there at least one symbol was referenced outside of the 
> > current visibility scope.
> 
> Such comparisons can happen in valid C++ code. For example:
> 
> ```c++
> // a.cc
> namespace { class A {}; }
> void throwA() { throw A(); }
> ```
> 
> ```c++
> // b.cc
> namespace { class A {}; }
> void throwA();
> int main() {
>   try { throwA(); }
>   catch (A) { return 1; }
>   catch (...) { return 2; }
> }
> ```
> 
> This program is valid and `main` is required to return 2 -- the `A` in `a.cc` 
> and the `A` in `b.cc` are two different types. During exception handling, we 
> will compare them by comparing their `type_info`, which means we will compare 
> the addresses of the name strings, so we need two different addresses.
> 
> > For dynamic loading, if there are two same symbols in different DSOs, the 
> > symbol would be interposed.
> 
> Not in the cases I mentioned. (I think we can _probably_ get away with 
> marking type name strings as `unnamed_addr` if the type has external linkage, 
> because we don't expect `unnamed_addr` to have any effect after static 
> linking. But it's not clear to me that that's actually guaranteed by the LLVM 
> semantics, or whether it would be permissible to make use of `unnamed_addr` 
> in some cross-DSO LTO situation.)
> 
> You _can_ still apply `unnamed_addr` in the cases where the the target ABI 
> rule is that `type_info` comparisons will always use or fall back to a string 
> comparison. Per the libc++ implementation, that's that case on Apple arm64 
> targets. You can detect this using `classifyRTTIUniqueness`.
> 
> I think it's also correct and safe to apply `local_unnamed_addr` to these 
> type name strings in all cases. Merging with another string literal from the 
> same compilation should always be OK.

I think it is also safe to apply `local_unnamed_addr` to type info global 
variable. What do you think?

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


[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)

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

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

>From c52634882631a71fad956a70179b480abf13006a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 29 Sep 2024 22:01:38 +0300
Subject: [PATCH 1/3] [Clang] fix overload resolution for object parameters
 with top-level cv-qualifiers in member functions

---
 clang/docs/ReleaseNotes.rst| 1 +
 clang/lib/Sema/SemaOverload.cpp| 3 +++
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 11 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28c759538f7df6..1bec2838765dab 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -447,6 +447,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
+- Fixed overload handling for object parameters with top-level cv-qualifiers 
in explicit member functions (#GH100394)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 0c1e054f7c30a4..7c40bab70bbe9d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1511,6 +1511,9 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   auto NewObjectType = New->getFunctionObjectParameterReferenceType();
   auto OldObjectType = Old->getFunctionObjectParameterReferenceType();
 
+  if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified())
+return false;
+
   auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) {
 return F->getRefQualifier() == RQ_None &&
!F->isExplicitObjectMemberFunction();
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 63bf92e8d5edd3..5fd02502ce6df4 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1073,3 +1073,10 @@ int main() {
   return foo[]; // expected-error {{no viable overloaded operator[] for type 
'Foo'}}
 }
 }
+
+namespace GH100394 {
+struct C {
+  void f(this const C);
+  void f() const ;  // ok
+};
+}

>From d377c01f46acf28f1dc74103c6a26df6c0c2e376 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 6 Oct 2024 11:52:48 +0300
Subject: [PATCH 2/3] adjust overload resolution for volatile qualifiers

---
 clang/lib/Sema/SemaOverload.cpp|  7 +--
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 12 +---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 7c40bab70bbe9d..56705971517cc3 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1511,8 +1511,11 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   auto NewObjectType = New->getFunctionObjectParameterReferenceType();
   auto OldObjectType = Old->getFunctionObjectParameterReferenceType();
 
-  if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified())
-return false;
+  if (Old->isExplicitObjectMemberFunction() &&
+  OldObjectType.getQualifiers() != NewObjectType.getQualifiers())
+return OldObjectType.isConstQualified() &&
+   (NewObjectType.isConstQualified() ||
+NewObjectType.isVolatileQualified());
 
   auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) {
 return F->getRefQualifier() == RQ_None &&
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5fd02502ce6df4..7dcd63a587c708 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1075,8 +1075,14 @@ int main() {
 }
 
 namespace GH100394 {
-struct C {
-  void f(this const C);
-  void f() const ;  // ok
+struct C1 {
+  void f(this const C1);
+  void f() const;// ok
+};
+
+struct C2 {
+  void f(this const C2);// expected-note {{previous declaration is here}}
+  void f(this volatile C2); // expected-error {{class member cannot be 
redeclared}} \
+// expected-warning {{volatile-qualified parameter 
type 'volatile C2' is deprecated}}
 };
 }

>From d524f7c0556fa08bd93a48f1ac6edd754a12926a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 9 Oct 2024 02:46:48 +0300
Subject: [PATCH 3/3] adjust qualifier restrictions for overriding explicit
 object members

---
 clang/lib/Sema/SemaOverload.cpp| 31 ++
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 21 +++
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cp

[clang] [clang-format] Make some binary operations imply requires clause (PR #110942)

2024-10-10 Thread Emilia Kond via cfe-commits

https://github.com/rymiel updated 
https://github.com/llvm/llvm-project/pull/110942

>From ef604d0bd621cfef32a8dd4b5410bd530ed2fe80 Mon Sep 17 00:00:00 2001
From: Emilia Kond 
Date: Thu, 3 Oct 2024 03:06:10 +0300
Subject: [PATCH 1/2] [clang-format] Make some binary operations imply requires
 clause

This patch adjusts the requires clause/expression lookahead heuristic to
assume that some binary operation mean that the requires keyword refers
to a clause.

This partially reverts the removed case clauses from
9b68c095d6b52d6ec0390c653528f65c42e5f570, with an additional check that
we're not in a type parameter.

This is quite a band-aid fix, it may be worth it to rewrite that whole
heuristic to track more state in the future, instead of just blindly
marching forward across multiple unrelated definitions, since right now,
the definition following the one with the requires clause can influence
whether the heuristic chooses clause or expression.

Fixes https://github.com/llvm/llvm-project/issues/110485
---
 clang/lib/Format/UnwrappedLineParser.cpp  | 11 +++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 15 +++
 2 files changed, 26 insertions(+)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 40f77266fabdca..98078fb50dcfaa 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -3528,6 +3528,17 @@ bool UnwrappedLineParser::parseRequires() {
 return false;
   }
   break;
+case tok::equalequal:
+case tok::greaterequal:
+case tok::lessequal:
+case tok::r_paren:
+case tok::pipepipe:
+  if (OpenAngles == 0) {
+FormatTok = Tokens->setPosition(StoredPosition);
+parseRequiresClause(RequiresToken);
+return true;
+  }
+  break;
 case tok::eof:
   // Break out of the loop.
   Lookahead = 50;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1884d41a5f23f5..6f1b1df0bda655 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1296,6 +1296,21 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   Tokens = annotate("bool x = t && requires(Foo x) { x.foo(); };");
   ASSERT_EQ(Tokens.size(), 25u) << Tokens;
   EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresExpression);
+
+  // Second function definition is required due to lookahead
+  Tokens = annotate("void f() & requires(n == 1) {}\nvoid g();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
+  Tokens = annotate("void f() & requires(n || h) {}\nvoid g();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
+  Tokens = annotate("bool x = t && requires(F x) { x.foo(); };");
+  ASSERT_EQ(Tokens.size(), 25u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresExpression);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsRequiresExpressions) {

>From 64b9240349f07729de3700eb4a9c43fc135e38ed Mon Sep 17 00:00:00 2001
From: Emilia Kond 
Date: Thu, 10 Oct 2024 16:09:43 +0300
Subject: [PATCH 2/2] Reduce scope of PR

---
 clang/lib/Format/UnwrappedLineParser.cpp | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 98078fb50dcfaa..b051994c800494 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -3470,10 +3470,10 @@ bool UnwrappedLineParser::parseRequires() {
   case tok::r_paren:
   case tok::kw_noexcept:
   case tok::kw_const:
+  case tok::amp:
 // This is a requires clause.
 parseRequiresClause(RequiresToken);
 return true;
-  case tok::amp:
   case tok::ampamp: {
 // This can be either:
 // if (... && requires (T t) ...)
@@ -3528,17 +3528,6 @@ bool UnwrappedLineParser::parseRequires() {
 return false;
   }
   break;
-case tok::equalequal:
-case tok::greaterequal:
-case tok::lessequal:
-case tok::r_paren:
-case tok::pipepipe:
-  if (OpenAngles == 0) {
-FormatTok = Tokens->setPosition(StoredPosition);
-parseRequiresClause(RequiresToken);
-return true;
-  }
-  break;
 case tok::eof:
   // Break out of the loop.
   Lookahead = 50;

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


[clang] [clang-format] Make bitwise and imply requires clause (PR #110942)

2024-10-10 Thread Emilia Kond via cfe-commits

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


[clang] [clang-format] Make bitwise and imply requires clause (PR #110942)

2024-10-10 Thread Emilia Kond via cfe-commits

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


[clang] [Clang] prevent recovery call expression from proceeding with explicit attributes and undeclared templates (PR #107786)

2024-10-10 Thread via cfe-commits

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

LGTM. do you need me to merge it for you?

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


[clang] [Clang][perf-training] Do build of libLLVMSupport for perf training (PR #111625)

2024-10-10 Thread Aiden Grossman via cfe-commits


@@ -0,0 +1,2 @@
+RUN: %cmake -G %cmake_generator -B %t -S %llvm_src_dir 
-DCMAKE_C_COMPILER=%clang -DCMAKE_CXX_COMPILER=%clang 
-DCMAKE_CXX_FLAGS="--driver-mode=g++" -DCMAKE_BUILD_TYPE=Release

boomanaiden154 wrote:

Ah, makes sense. Seems reasonable enough to me!

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


[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-10 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

TypedefNameDecl referenced by a synthesized CTAD guide for type aliases was not 
transformed previously, resulting in a substitution failure in 
`BuildDeductionGuideForTypeAlias()` when substituting into the right-hand-side 
deduction guide.

This patch fixes it in the way we have been doing since 
https://reviews.llvm.org/D80743. We transform all the function parameters, 
parenting referenced TypedefNameDecls with the CXXDeductionGuideDecl. Then we 
instantiate these declarations in FindInstantiatedDecl() as we build up the 
eventual deduction guide, using the mechanism introduced in D80743

Fixes #111508 

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+18-3) 
- (modified) clang/test/SemaCXX/cxx20-ctad-type-alias.cpp (+13) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index ca93c840f03215..871c705ab65421 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -70,8 +70,8 @@ class ExtractTypeForDeductionGuide
   ExtractTypeForDeductionGuide(
   Sema &SemaRef,
   llvm::SmallVectorImpl &MaterializedTypedefs,
-  ClassTemplateDecl *NestedPattern,
-  const MultiLevelTemplateArgumentList *OuterInstantiationArgs)
+  ClassTemplateDecl *NestedPattern = nullptr,
+  const MultiLevelTemplateArgumentList *OuterInstantiationArgs = nullptr)
   : Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs),
 NestedPattern(NestedPattern),
 OuterInstantiationArgs(OuterInstantiationArgs) {
@@ -1215,10 +1215,25 @@ FunctionTemplateDecl 
*DeclareAggregateDeductionGuideForTypeAlias(
   getRHSTemplateDeclAndArgs(SemaRef, AliasTemplate).first;
   if (!RHSTemplate)
 return nullptr;
+
+  llvm::SmallVector TypedefDecls;
+  llvm::SmallVector NewParamTypes;
+  ExtractTypeForDeductionGuide TypeAliasTransformer(SemaRef, TypedefDecls);
+  for (QualType P : ParamTypes) {
+QualType Type = TypeAliasTransformer.TransformType(P);
+if (Type.isNull())
+  return nullptr;
+NewParamTypes.push_back(Type);
+  }
+
   auto *RHSDeductionGuide = SemaRef.DeclareAggregateDeductionGuideFromInitList(
-  RHSTemplate, ParamTypes, Loc);
+  RHSTemplate, NewParamTypes, Loc);
   if (!RHSDeductionGuide)
 return nullptr;
+
+  for (TypedefNameDecl *TD : TypedefDecls)
+TD->setDeclContext(RHSDeductionGuide->getTemplatedDecl());
+
   return BuildDeductionGuideForTypeAlias(SemaRef, AliasTemplate,
  RHSDeductionGuide, Loc);
 }
diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp 
b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
index 5392573fcdb9d5..675c32a81f1ae8 100644
--- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
+++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
@@ -481,3 +481,16 @@ struct Out {
 Out::B out(100); // deduced to Out::A;
 static_assert(__is_same(decltype(out), Out::A));
 }
+
+namespace GH111508 {
+
+template  struct S {
+  using T = V;
+  T Data;
+};
+
+template  using Alias = S;
+
+Alias A(42);
+
+} // namespace GH111508

``




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


[clang] 99608f1 - [clang][HLSL] Add sign intrinsic part 4 (#108396)

2024-10-10 Thread via cfe-commits

Author: Tim Gymnich
Date: 2024-10-10T05:18:15-04:00
New Revision: 99608f114f36efe30572d2bbf281cae56df78a9a

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

LOG: [clang][HLSL] Add sign intrinsic part 4 (#108396)

- Add handling for unsigned integers to hlsl_elementwise_sign
- Use `select` instead of adding dx and spirv intrinsics for unsigned
integers as [discussed previously
](https://github.com/llvm/llvm-project/pull/101988#discussion_r1736779424)

fixes #70078

### Related PRs
- https://github.com/llvm/llvm-project/pull/101987
- https://github.com/llvm/llvm-project/pull/101988
- https://github.com/llvm/llvm-project/pull/101989

cc @farzonl @pow2clk @bob80905 @bogner @llvm-beanz

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/hlsl/hlsl_intrinsics.h
clang/lib/Sema/SemaHLSL.cpp
clang/test/CodeGenHLSL/builtins/sign.hlsl

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 57705f2d2d0423..2449b90a0e7902 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18876,18 +18876,25 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
 return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID));
   }
   case Builtin::BI__builtin_hlsl_elementwise_sign: {
-Value *Op0 = EmitScalarExpr(E->getArg(0));
+auto *Arg0 = E->getArg(0);
+Value *Op0 = EmitScalarExpr(Arg0);
 llvm::Type *Xty = Op0->getType();
 llvm::Type *retType = llvm::Type::getInt32Ty(this->getLLVMContext());
 if (Xty->isVectorTy()) {
-  auto *XVecTy = E->getArg(0)->getType()->getAs();
+  auto *XVecTy = Arg0->getType()->getAs();
   retType = llvm::VectorType::get(
   retType, ElementCount::getFixed(XVecTy->getNumElements()));
 }
-assert((E->getArg(0)->getType()->hasFloatingRepresentation() ||
-E->getArg(0)->getType()->hasSignedIntegerRepresentation()) &&
+assert((Arg0->getType()->hasFloatingRepresentation() ||
+Arg0->getType()->hasIntegerRepresentation()) &&
"sign operand must have a float or int representation");
 
+if (Arg0->getType()->hasUnsignedIntegerRepresentation()) {
+  Value *Cmp = Builder.CreateICmpEQ(Op0, ConstantInt::get(Xty, 0));
+  return Builder.CreateSelect(Cmp, ConstantInt::get(retType, 0),
+  ConstantInt::get(retType, 1), "hlsl.sign");
+}
+
 return Builder.CreateIntrinsic(
 retType, CGM.getHLSLRuntime().getSignIntrinsic(),
 ArrayRef{Op0}, nullptr, "hlsl.sign");

diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index f39a68ba847e98..813f8a317bf6bf 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -2088,6 +2088,19 @@ int3 sign(int16_t3);
 _HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int4 sign(int16_t4);
+
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int sign(uint16_t);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int2 sign(uint16_t2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int3 sign(uint16_t3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int4 sign(uint16_t4);
 #endif
 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
@@ -2112,6 +2125,15 @@ int3 sign(int3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int4 sign(int4);
 
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int sign(uint);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int2 sign(uint2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int3 sign(uint3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int4 sign(uint4);
+
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int sign(float);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
@@ -2130,6 +2152,15 @@ int3 sign(int64_t3);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int4 sign(int64_t4);
 
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int sign(uint64_t);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int2 sign(uint64_t2);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int3 sign(uint64_t3);
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
+int4 sign(uint64_t4);
+
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
 int sign(double);
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)

diff  --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index d2d2df829e7b11..05e6e7800112df 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1708,9 +1708,9 @@ st

[clang] [clang][HLSL] Add sign intrinsic part 4 (PR #108396)

2024-10-10 Thread Farzon Lotfi via cfe-commits

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


[clang] [clang][HLSL] Add sign intrinsic part 4 (PR #108396)

2024-10-10 Thread Farzon Lotfi via cfe-commits

farzonl wrote:

Build failure was on `Driver/hip-partial-link.hip` Not related to this change. 
Will proceed with merging.

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


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

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-fuzzer` running on `sanitizer-buildbot11` while 
building `.github,clang,flang,llvm,offload,openmp` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure) (timed out)
...
#6 0xacedca160438 in 
fuzzer::Fuzzer::Loop(std::__Fuzzer::vector>&) 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:910:5
#7 0xacedca14f828 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned 
char const*, unsigned long)) 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:915:6
#8 0xacedca178ec4 in main 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
#9 0xe71967a684c0  (/lib/aarch64-linux-gnu/libc.so.6+0x284c0) (BuildId: 
32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)
#10 0xe71967a68594 in __libc_start_main 
(/lib/aarch64-linux-gnu/libc.so.6+0x28594) (BuildId: 
32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)
#11 0xacedca143cac in _start 
(/home/b/sanitizer-aarch64-linux-fuzzer/build/RUNDIR-c-ares-CVE-2016-5180/c-ares-CVE-2016-5180-fsanitize_fuzzer+0xb3cac)

SUMMARY: AddressSanitizer: heap-buffer-overflow ares_create_query.c in 
ares_create_query
@@@BUILD_STEP test openssl-1.0.1f fuzzer@@@
Cloning into 'SRC'...
command timed out: 1200 seconds without output running [b'python', 
b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'],
 attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2985.777262
Step 13 (test openssl-1.0.1f fuzzer) failure: test openssl-1.0.1f fuzzer 
(failure)
@@@BUILD_STEP test openssl-1.0.1f fuzzer@@@
Cloning into 'SRC'...

command timed out: 1200 seconds without output running [b'python', 
b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'],
 attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2985.777262

```



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


[clang-tools-extra] [clang-include-cleaner] Fix incorrect directory issue for writing files (PR #111375)

2024-10-10 Thread Byoungchan Lee via cfe-commits

https://github.com/bc-lee updated 
https://github.com/llvm/llvm-project/pull/111375

>From 23b90bba12c010e5882e09e9f6b765a7281324aa Mon Sep 17 00:00:00 2001
From: Byoungchan Lee 
Date: Mon, 7 Oct 2024 22:19:38 +0900
Subject: [PATCH 1/6] [clang-include-cleaner] Fix incorrect directory issue for
 writing files

If the current working directory of `clang-include-cleaner` differs from
the directory of the input files specified in the compilation database,
it doesn't adjust the input file paths properly. As a result,
`clang-include-cleaner` either writes files to the wrong directory or
fails to write files altogether.

This pull request fixes the issue by checking whether the input file
path is absolute. If it isn't, the path is concatenated with
the directory of the input file specified in the compilation database.

Fixes #110843.
---
 .../include-cleaner/tool/IncludeCleaner.cpp   | 24 +--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 080099adc9a07a..1cb8b9c4ae99b7 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -173,11 +173,22 @@ class Action : public clang::ASTFrontendAction {
 if (!HTMLReportPath.empty())
   writeHTML();
 
+// Source File's path relative to compilation database.
 llvm::StringRef Path =
 SM.getFileEntryRefForID(SM.getMainFileID())->getName();
 assert(!Path.empty() && "Main file path not known?");
 llvm::StringRef Code = SM.getBufferData(SM.getMainFileID());
 
+auto Cwd = getCompilerInstance()
+   .getFileManager()
+   .getVirtualFileSystem()
+   .getCurrentWorkingDirectory();
+if (Cwd.getError()) {
+  llvm::errs() << "Failed to get current working directory: "
+   << Cwd.getError().message() << "\n";
+  return;
+}
+
 auto Results =
 analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI,
 getCompilerInstance().getPreprocessor(), HeaderFilter);
@@ -201,8 +212,17 @@ class Action : public clang::ASTFrontendAction {
   }
 }
 
-if (!Results.Missing.empty() || !Results.Unused.empty())
-  EditedFiles.try_emplace(Path, Final);
+if (!Results.Missing.empty() || !Results.Unused.empty()) {
+  auto Sept = llvm::sys::path::get_separator();
+  // Adjust the path to be absolute if it is not.
+  std::string FullPath;
+  if (llvm::sys::path::is_absolute(Path))
+FullPath = Path.str();
+  else
+FullPath = Cwd.get() + Sept.str() + Path.str();
+
+  EditedFiles.try_emplace(FullPath, Final);
+}
   }
 
   void writeHTML() {

>From eef397cf22e062cf024ffcd84fef7bdf98833351 Mon Sep 17 00:00:00 2001
From: Byoungchan Lee 
Date: Wed, 9 Oct 2024 19:43:02 +0900
Subject: [PATCH 2/6] Fix path issue identified by @kadircet

Some Bazel systems might have a read-only file system in the build
directory. In such cases, the output file should be written to
the original source file. Adjusted the logic to find the correct
output directory based on the compilation database and
the current working directory.
---
 .../include-cleaner/tool/IncludeCleaner.cpp   | 95 ++-
 1 file changed, 73 insertions(+), 22 deletions(-)

diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 1cb8b9c4ae99b7..4481601140e3fe 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -179,16 +179,6 @@ class Action : public clang::ASTFrontendAction {
 assert(!Path.empty() && "Main file path not known?");
 llvm::StringRef Code = SM.getBufferData(SM.getMainFileID());
 
-auto Cwd = getCompilerInstance()
-   .getFileManager()
-   .getVirtualFileSystem()
-   .getCurrentWorkingDirectory();
-if (Cwd.getError()) {
-  llvm::errs() << "Failed to get current working directory: "
-   << Cwd.getError().message() << "\n";
-  return;
-}
-
 auto Results =
 analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI,
 getCompilerInstance().getPreprocessor(), HeaderFilter);
@@ -212,17 +202,8 @@ class Action : public clang::ASTFrontendAction {
   }
 }
 
-if (!Results.Missing.empty() || !Results.Unused.empty()) {
-  auto Sept = llvm::sys::path::get_separator();
-  // Adjust the path to be absolute if it is not.
-  std::string FullPath;
-  if (llvm::sys::path::is_absolute(Path))
-FullPath = Path.str();
-  else
-FullPath = Cwd.get() + Sept.str() + Path.str();
-
-  EditedFiles.try_emplace(FullPath, Final);
-}
+if (!Results.Missing.empty() || !Results.Unused.empty())
+  EditedFiles.

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

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` 
running on `sanitizer-buildbot2` while building 
`.github,clang,flang,llvm,offload,openmp` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[385/391] Generating FuzzerUtils-x86_64-Test
[386/391] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o
[387/391] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[388/391] Generating Msan-x86_64-with-call-Test
[389/391] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[390/391] Generating Msan-x86_64-Test
[390/391] Running compiler_rt regression tests
llvm-lit: 
/home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 4686 of 10415 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: libFuzzer-x86_64-static-libcxx-Linux :: reduce_inputs.test (4580 of 4686)
 TEST 'libFuzzer-x86_64-static-libcxx-Linux :: 
reduce_inputs.test' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: rm -rf 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
+ rm -rf 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
RUN: at line 4: mkdir -p 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
+ mkdir -p 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
RUN: at line 5: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  
  -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m64 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowSimpleTest.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m64 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowSimpleTest.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest
RUN: at line 6: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  
  -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m64 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowTest.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowTest
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m64 
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowTest.cpp
 -o 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowTest
RUN: at line 7: 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest
  -exit_on_item=0eb8e4ed029b774d80f2b66408203801cb982a60   -runs=100 
/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/X86_64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
 2>&1 | FileCheck 
/hom

[clang] [Cuda] Handle -fcuda-short-ptr even with -nocudalib (PR #111682)

2024-10-10 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> > > I'm not sure why we would ever want the current default if this is an 
> > > option. I'm trying to see it, but I can't work out a case where a 64bit 
> > > pointer would make sense, since the even tens-of-thousands of money 
> > > supercomputer cards have less than 256KiB of addressable shared memory.
> > > It might be a bit of an intrusive change (albeit a relatively mechanical 
> > > one), but until we see a GPU come to market that has >4GiB addressable 
> > > shared memory, I think we should use the "short pointer" datalayout as 
> > > default
> > 
> > 
> > It also applies to constant and private / local address spaces. I don't 
> > think those hit 4 GiB yet but it's more feasible than shared. Making 
> > address space 3 32-bit by default would make sense to me.
> 
> I was also considering separating out address space 3 into its own option, 
> yep. At that point I suppose you might as well split out the remaining two, 
> and have `-fcuda-short-ptr` alias the three of them.

@jhuber6 do you have any thoughts on how we'd best split up `-fcuda-short-ptr`? 
I was initially thinking of `-f[no-]cuda-short-ptr={shared,local,const}` and 
have the old `-f[no-]cuda-short-ptr` alias "all". However, it seems like this 
sort of (bitfield toggling on//off) option isn't supported by clang's automated 
marshalling, and the documented advice is to reconsider the option, rather than 
do custom marshalling.

It seems as though a comma-joined operation is best marshalled as a list of 
strings, but having the corresponding "no-" case is pretty rare, and would 
undoubtedly add extra code and complicate things when trying to tie it in with 
the old option format.

Maybe we don't need `-fno-cuda-short-ptr=...`, which I think would simplify 
things here. Of course, I might be thinking about this all wrong, and the 
frontend and cc1 options could be split up somehow.

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


  1   2   3   4   5   >