[clang] baf0b12 - [NFC] skip the test modules-vtable.cppm on windows

2023-06-14 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-06-14T15:05:31+08:00
New Revision: baf0b12ca6c624b2a59aa6f2fd0310c72d35ac56

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

LOG: [NFC] skip the test modules-vtable.cppm on windows

The new added test has problems on windows since the patch is about ABI
and MSVC ABI is not covered. Skip the test on windows to make the CI
green.

Added: 


Modified: 
clang/test/CodeGenCXX/modules-vtable.cppm

Removed: 




diff  --git a/clang/test/CodeGenCXX/modules-vtable.cppm 
b/clang/test/CodeGenCXX/modules-vtable.cppm
index 3af626d575416..5662f40515cd6 100644
--- a/clang/test/CodeGenCXX/modules-vtable.cppm
+++ b/clang/test/CodeGenCXX/modules-vtable.cppm
@@ -1,3 +1,5 @@
+// REQUIRES: !system-windows
+
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 // RUN: cd %t



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


[clang] 91b90e0 - [7/11][Clang][RISCV] Expand all variants for strided segment store

2023-06-14 Thread via cfe-commits

Author: eopXD
Date: 2023-06-14T00:06:58-07:00
New Revision: 91b90e0ea0ec096bfc7e7293d6dd2f6bb4c5d5b0

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

LOG: [7/11][Clang][RISCV] Expand all variants for strided segment store

This is the 7th patch of the patch-set. For the cover letter, please
checkout D152069.

Depends on D152074.

This patch expands all variants for strided segment store. The store
intrinsics does not have any policy variants. This patch also fixes the
trailing suffix in the intrinsics' function name that representing the
return type, adding `x{NF}`.

For the same reason mentioned in [3/11], only full test case for
vssseg2e32 is added for now.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152075

Added: 

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c

Modified: 
clang/include/clang/Basic/riscv_vector.td

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 50ca7af351163..cd5d85004bc1d 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -1752,9 +1752,15 @@ multiclass RVVStridedSegLoadTuple {
 }
 
 multiclass RVVStridedSegStoreTuple {
-  foreach type = ["i"] in {
-defvar eew = !cond(!eq(type, "i") : "32");
-  foreach nf = [2] in {
+  foreach type = TypeList in {
+defvar eew = !cond(!eq(type, "c") : "8",
+   !eq(type, "s") : "16",
+   !eq(type, "i") : "32",
+   !eq(type, "l") : "64",
+   !eq(type, "x") : "16",
+   !eq(type, "f") : "32",
+   !eq(type, "d") : "64");
+  foreach nf = NFList in {
 let Name = op # nf # "e" # eew # "_v_tuple",
 OverloadedName = op # nf # "e" # eew # "_tuple",
 IRName = op # nf,
@@ -1789,8 +1795,11 @@ multiclass RVVStridedSegStoreTuple {
   return Builder.CreateCall(F, Operands, "");
 }
 }] in {
-  defvar T = "(Tuple:" # nf # ")";
-  def : RVVBuiltin<"v", "0Pet" # T # "v", type>;
+defvar T = "(Tuple:" # nf # ")";
+def : RVVBuiltin;
+if !not(IsFloat.val) then {
+  def : RVVBuiltin;
+}
   }
 }
   }

diff  --git 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
index 548e1104b9b7d..8d1de9b619fe6 100644
--- 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
+++ 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
@@ -7,8 +7,78 @@
 
 #include 
 
-// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_tuple_i32m1
-// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]], 
 [[V_TUPLE_COERCE0:%.*]],  
[[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]], 
 [[V_TUPLE_COERCE0:%.*]],  
[[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , 
 } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv1f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], 
i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32mf2x2(float *base, ptr
diff _t bstride, vfloat32mf2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_v_tuple_f32mf2x2(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m1x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]], 
 [[V_TUPLE_COERCE0:%.*]],  
[[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , 
 } [[TMP1]], 1
+// CHECK-RV64-NEXT:call voi

[PATCH] D152075: [7/11][Clang][RISCV] Expand all variants for strided segment store

2023-06-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91b90e0ea0ec: [7/11][Clang][RISCV] Expand all variants for 
strided segment store (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152075/new/

https://reviews.llvm.org/D152075

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
@@ -0,0 +1,345 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv1f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32mf2x2(float *base, ptrdiff_t bstride, vfloat32mf2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m1x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv2f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m1x2(float *base, ptrdiff_t bstride, vfloat32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv4f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m2x2(float *base, ptrdiff_t bstride, vfloat32m2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m4x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv8f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m4x2(float *base, ptrdiff_t bstride, vfloat32m4x2_t v_tuple, siz

[PATCH] D152076: [8/11][Clang][RISCV] Expand all variants for indexed strided segment load

2023-06-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9588b18969a2: [8/11][Clang][RISCV] Expand all variants for 
indexed strided segment load (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152076/new/

https://reviews.llvm.org/D152076

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vluxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vluxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vluxseg2ei32_tuple.c

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


[PATCH] D152078: [10/11][Clang][RISCV] Expand all variants for vget on tuple types

2023-06-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1b6b893ed57: [10/11][Clang][RISCV] Expand all variants for 
vget on tuple types (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152078/new/

https://reviews.llvm.org/D152078

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vget.c

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


[PATCH] D152079: [11/11][Clang][RISCV] Expand all variants for vset on tuple types

2023-06-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG804306b38215: [11/11][Clang][RISCV] Expand all variants for 
vset on tuple types (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152079/new/

https://reviews.llvm.org/D152079

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vset.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c

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


[clang] 01b6f06 - Fix test Driver/mips-mti-linux.c

2023-06-14 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-06-14T08:30:03+01:00
New Revision: 01b6f06263dd0a3db61c1bf0e6a3464c7cbd7ea2

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

LOG: Fix test Driver/mips-mti-linux.c

Added: 


Modified: 
clang/lib/Driver/ToolChains/MipsLinux.cpp
clang/lib/Driver/ToolChains/MipsLinux.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MipsLinux.cpp 
b/clang/lib/Driver/ToolChains/MipsLinux.cpp
index 6157970233ae5..eacdcbf730b62 100644
--- a/clang/lib/Driver/ToolChains/MipsLinux.cpp
+++ b/clang/lib/Driver/ToolChains/MipsLinux.cpp
@@ -56,7 +56,7 @@ void MipsLLVMToolChain::AddClangSystemIncludeArgs(
 
   const auto &Callback = Multilibs.includeDirsCallback();
   if (Callback) {
-for (const auto &Path : Callback(SelectedMultilib))
+for (const auto &Path : Callback(SelectedMultilibs.back()))
   addExternCSystemIncludeIfExists(DriverArgs, CC1Args,
   D.getInstalledDir() + Path);
   }
@@ -68,11 +68,11 @@ Tool *MipsLLVMToolChain::buildLinker() const {
 
 std::string MipsLLVMToolChain::computeSysRoot() const {
   if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot + SelectedMultilib.osSuffix();
+return getDriver().SysRoot + SelectedMultilibs.back().osSuffix();
 
   const std::string InstalledDir(getDriver().getInstalledDir());
   std::string SysRootPath =
-  InstalledDir + "/../sysroot" + SelectedMultilib.osSuffix();
+  InstalledDir + "/../sysroot" + SelectedMultilibs.back().osSuffix();
   if (llvm::sys::fs::exists(SysRootPath))
 return SysRootPath;
 
@@ -96,7 +96,7 @@ void MipsLLVMToolChain::addLibCxxIncludePaths(
 const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const {
   if (const auto &Callback = Multilibs.includeDirsCallback()) {
-for (std::string Path : Callback(SelectedMultilib)) {
+for (std::string Path : Callback(SelectedMultilibs.back())) {
   Path = getDriver().getInstalledDir() + Path + "/c++/v1";
   if (llvm::sys::fs::exists(Path)) {
 addSystemInclude(DriverArgs, CC1Args, Path);
@@ -122,7 +122,7 @@ std::string MipsLLVMToolChain::getCompilerRT(const ArgList 
&Args,
  StringRef Component,
  FileType Type) const {
   SmallString<128> Path(getDriver().ResourceDir);
-  llvm::sys::path::append(Path, SelectedMultilib.osSuffix(), "lib" + LibSuffix,
+  llvm::sys::path::append(Path, SelectedMultilibs.back().osSuffix(), "lib" + 
LibSuffix,
   getOS());
   const char *Suffix;
   switch (Type) {

diff  --git a/clang/lib/Driver/ToolChains/MipsLinux.h 
b/clang/lib/Driver/ToolChains/MipsLinux.h
index 31b547c0063ca..a968804f2a6ec 100644
--- a/clang/lib/Driver/ToolChains/MipsLinux.h
+++ b/clang/lib/Driver/ToolChains/MipsLinux.h
@@ -53,7 +53,6 @@ class LLVM_LIBRARY_VISIBILITY MipsLLVMToolChain : public 
Linux {
   }
 
 private:
-  Multilib SelectedMultilib;
   std::string LibSuffix;
 };
 



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


[PATCH] D152804: [clang-format] Propose a new solution to - Fix overlapping replacements before PPDirectives

2023-06-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

So whilst this solves the unit tests (and the golden.h issue) that were added 
it DOESN'T solve the overlapping replacements that was the original bug.

  struct foo {
void test() {
  #if 1
  #else
  #endif
}
  #if 1
  private:
  
  
  #endif
  };

This issue is caused by the `private:\n\n\n` and doesn't happen when there its 
only `private:\n\n` @owenpan , any thoughts, I'm abit stuck?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152804/new/

https://reviews.llvm.org/D152804

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-14 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 531219.
HaohaiWen added a comment.

Fix sections binding check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152785/new/

https://reviews.llvm.org/D152785

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_id

[clang] 0211a75 - [Clang] Rename getElementBitCast() -> withElementType() (NFC)

2023-06-14 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-14T09:58:52+02:00
New Revision: 0211a75ed8b80848af7c87d2f925467448ae4f34

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

LOG: [Clang] Rename getElementBitCast() -> withElementType() (NFC)

This no longer creates a bitcast, just changes the element type
of the ConstantAddress.

Added: 


Modified: 
clang/lib/CodeGen/Address.h
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index e020d95344ade..899aceac88672 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -127,10 +127,8 @@ class ConstantAddress : public Address {
 return llvm::cast(Address::getPointer());
   }
 
-  ConstantAddress getElementBitCast(llvm::Type *ElemTy) const {
-llvm::Constant *BitCast = llvm::ConstantExpr::getBitCast(
-getPointer(), ElemTy->getPointerTo(getAddressSpace()));
-return ConstantAddress(BitCast, ElemTy, getAlignment());
+  ConstantAddress withElementType(llvm::Type *ElemTy) const {
+return ConstantAddress(getPointer(), ElemTy, getAlignment());
   }
 
   static bool isaImpl(Address addr) {

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index bf5013e521097..9c63e154ebebd 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -137,7 +137,7 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const 
VarDecl &D,
 }
   // Otherwise, the standard logic requires a helper function.
   } else {
-Addr = Addr.getElementBitCast(CGF.ConvertTypeForMem(Type));
+Addr = Addr.withElementType(CGF.ConvertTypeForMem(Type));
 Func = CodeGenFunction(CGM)
.generateDestroyHelper(Addr, Type, CGF.getDestroyer(DtorKind),
   CGF.needsEHCleanup(DtorKind), &D);

diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index b0dd598715840..5bd42d9337506 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1987,7 +1987,7 @@ static ConstantLValue emitConstantObjCStringLiteral(const 
StringLiteral *S,
 QualType T,
 CodeGenModule &CGM) {
   auto C = CGM.getObjCRuntime().GenerateConstantString(S);
-  return C.getElementBitCast(CGM.getTypes().ConvertTypeForMem(T));
+  return C.withElementType(CGM.getTypes().ConvertTypeForMem(T));
 }
 
 ConstantLValue



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


[PATCH] D152867: OpenMP: Add a new test for constantexpr evaluation of math headers

2023-06-14 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152867/new/

https://reviews.llvm.org/D152867

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


[PATCH] D152279: [Driver] Default -msmall-data-limit= to 0

2023-06-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D152279#4415974 , @MaskRay wrote:

> However, RISC-V `-msmall-data-limit=` is probably a case warranting a 
> difference.
> The global pointer relaxation has a very limited value (benchmarked by 
> multiple parties, including a party which implemented this feature in the GNU 
> toolchain: even they can only say the optimization only applies to very 
> specific projects).
> The default value is confusing: as explained by the summary.
>
> I suspect that `-msmall-data-limit=8` is too conservative, maybe 16 would be 
> better, I don't know. I think global pointer relaxation users should toggle 
> this by themselves, not relying on `0` or `8` default decided by a bunch of 
> strange conditions.

I don't disagree that the small data limit being 8 rather than something else 
doesn't seem to be particularly well motivated, but I understand that the case 
where the option does make a difference is on embedded targets (I think the 
data that was shared before was for SPEC, but could be wrong?). I think we can 
generally expect more willingness for people targeting embedded systems to 
explore different compiler flags, but just matching gcc does feel like a better 
default. What do you think about keeping the default for bare metal targets?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152279/new/

https://reviews.llvm.org/D152279

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/AST/DeclBase.h:1686
 
-/// [C++17] Only used by CXXDeductionGuideDecl. Indicates that
-/// the Deduction Guide is the implicitly generated 'copy
-/// deduction candidate' (is used during overload resolution).
-uint64_t IsCopyDeductionCandidate : 1;
+/// Only used by CXXDeductionGuideDecl. Indicates the kind
+/// of the Deduction Guide that is the implicitly generated

shafik wrote:
> Why remove `[C++17]` ?
I don't think this adds any information, I'm happy to see it removed. And 
arguably in c++17 there was only one kind of DG.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139837/new/

https://reviews.llvm.org/D139837

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


[PATCH] D152804: [clang-format] Propose a new solution to - Fix overlapping replacements before PPDirectives

2023-06-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

I got something that looks promising:

  diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
  index dd23bd35411d..bba030238338 100644
  --- a/clang/lib/Format/FormatToken.h
  +++ b/clang/lib/Format/FormatToken.h
  @@ -418,6 +418,12 @@ public:
 /// and thereby e.g. leave an empty line between two function definitions.
 unsigned NewlinesBefore = 0;
  
  +  /// The number of newlines immediately before the \c Token after 
formatting.
  +  ///
  +  /// This is used to avoid overlapping whitespace replacements when \c 
Newlines
  +  /// is recomputed for a finalized preprocessor branching directive.
  +  int Newlines = -1;
  +
 /// The offset just past the last '\n' in this token's leading
 /// whitespace (relative to \c WhiteSpaceStart). 0 if there is no '\n'.
 unsigned LastNewlineOffset = 0;
  diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
  index 5172deb494b2..72293945122b 100644
  --- a/clang/lib/Format/UnwrappedLineFormatter.cpp
  +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
  @@ -1418,22 +1418,13 @@ unsigned UnwrappedLineFormatter::format(
 return Penalty;
   }
  
  -void UnwrappedLineFormatter::formatFirstToken(
  -const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
  -const AnnotatedLine *PrevPrevLine,
  -const SmallVectorImpl &Lines, unsigned Indent,
  -unsigned NewlineIndent) {
  -  FormatToken &RootToken = *Line.First;
  -  if (RootToken.is(tok::eof)) {
  -unsigned Newlines =
  -std::min(RootToken.NewlinesBefore,
  - Style.KeepEmptyLinesAtEOF ? Style.MaxEmptyLinesToKeep + 1 : 
1);
  -unsigned TokenIndent = Newlines ? NewlineIndent : 0;
  -Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
  -   TokenIndent);
  -return;
  -  }
  -  unsigned Newlines =
  +static auto computeNewlines(const AnnotatedLine &Line,
  +const AnnotatedLine *PreviousLine,
  +const AnnotatedLine *PrevPrevLine,
  +const SmallVectorImpl &Lines,
  +const FormatStyle &Style) {
  +  const auto &RootToken = *Line.First;
  +  auto Newlines =
 std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
 // Remove empty lines before "}" where applicable.
 if (RootToken.is(tok::r_brace) &&
  @@ -1512,7 +1503,32 @@ void UnwrappedLineFormatter::formatFirstToken(
   }
 }
  
  -  if (Newlines)
  +  return Newlines;
  +}
  +
  +void UnwrappedLineFormatter::formatFirstToken(
  +const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
  +const AnnotatedLine *PrevPrevLine,
  +const SmallVectorImpl &Lines, unsigned Indent,
  +unsigned NewlineIndent) {
  +  FormatToken &RootToken = *Line.First;
  +  if (RootToken.is(tok::eof)) {
  +unsigned Newlines =
  +std::min(RootToken.NewlinesBefore,
  + Style.KeepEmptyLinesAtEOF ? Style.MaxEmptyLinesToKeep + 1 : 
1);
  +unsigned TokenIndent = Newlines ? NewlineIndent : 0;
  +Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
  +   TokenIndent);
  +return;
  +  }
  +
  +  if (RootToken.Newlines < 0) {
  +RootToken.Newlines = computeNewlines(Line, PreviousLine, PrevPrevLine,
  + Lines, Style);
  +  }
  +
  +  assert(RootToken.Newlines >= 0);
  +  if (RootToken.Newlines > 0)
   Indent = NewlineIndent;
  
 // Preprocessor directives get indented before the hash only if specified. 
In
  @@ -1524,7 +1540,7 @@ void UnwrappedLineFormatter::formatFirstToken(
   Indent = 0;
 }
  
  -  Whitespaces->replaceWhitespace(RootToken, Newlines, Indent, Indent,
  +  Whitespaces->replaceWhitespace(RootToken, RootToken.Newlines, Indent, 
Indent,
/*IsAligned=*/false,
Line.InPPDirective &&
!RootToken.HasUnescapedNewline);

I'll submit a patch based on the above in a day or two.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152804/new/

https://reviews.llvm.org/D152804

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-14 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n updated this revision to Diff 531233.
goldstein.w.n added a comment.

Remove unused check count. Use memory effects directly instead of
function/callbase attribute API


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152226/new/

https://reviews.llvm.org/D152226

Files:
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  clang/test/CodeGen/LoongArch/inline-asm-operand-modifiers.c
  clang/test/CodeGen/LoongArch/intrinsic-la32.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  clang/test/CodeGen/PowerPC/builtins-ppc-build-pair-mma.c
  clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
  
clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReseve-StoreCond-64bit-only.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  clang/test/CodeGen/PowerPC/ppc64-inline-asm.c
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c
  clang/test/CodeGen/X86/fma-builtins-constrained.c
  clang/test/CodeGen/X86/ms-x86-intrinsics.c
  clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c
  clang/test/CodeGen/aarch64-ls64-inline-asm.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sh.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1ub.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1uh.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1uw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1b.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1h.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1w.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilege.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_dup_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_get_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_set_neonq.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-riscv-rvv-vector-bits-call.c
  clang/test/CodeGen/attr-riscv-rvv-vector-bits-cast.c
  clang/test/CodeGen/msp430-builtins.c
  clang/test/CodeGen/nofpclass.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/Transforms/Utils/InferCallsiteAttrs.h
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp
  llvm/test/Other/cgscc-devirt-iteration.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/FunctionAttrs/readattrs.ll
  llvm/test/Transforms/FunctionAttrs/willreturn-callsites.ll
  llvm/test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll
  llvm/test/Transforms/PhaseOrdering/X86/loop-idiom-vs-indvars.ll
  llvm/test/Transforms/PhaseOrdering/memset-tail.ll

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-14 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added inline comments.



Comment at: llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp:597
+  // callsite violating the constraint.
+  if (checkCallerDoesNotAccessMemory() && !CB->doesNotAccessMemory()) {
+// Wait until we know we actually need it to do potentially expensive

nikic wrote:
> For these you generally want to query `getMemoryEffects()` on the 
> caller/callee once and then work on that representation, instead of doing 
> separate queries for everything. This may allow more precise handling and 
> likely reduces the compile-time impact, as doing these attribute lookups is 
> quite expensive.
Re-running compile time checks, will post revised numbers tomorrow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152226/new/

https://reviews.llvm.org/D152226

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


[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Christian Ulmann via Phabricator via cfe-commits
Dinistro added a comment.

I'm getting a linking error by some of the files changed in this revision.

  ld.lld: error: undefined symbol: vtable for 
clang::tidy::performance::NoexceptDestructorCheck
  >>> referenced by NoexceptDestructorCheck.h:26 
(/home/christianu/repos/llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines/../performance/NoexceptDestructorCheck.h:26)
  >>>   
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/CppCoreGuidelinesTidyModule.cpp.o:(std::enable_if>, void 
clang::tidy::ClangTidyCheckFactories::registerCheck(ll
  vm::StringRef)::'lambda'(llvm::StringRef, clang::tidy::ClangTidyContext*)&, 
llvm::StringRef, clang::tidy::ClangTidyContext*>, 
std::unique_ptr>>::type 
std::__invoke_r>, void 
clang::tidy::ClangTidyCheckFactories::registerCheck
  
(llvm::StringRef)::'lambda'(llvm::StringRef,
 clang::tidy::ClangTidyContext*)&, llvm::StringRef, 
clang::tidy::ClangTidyContext*>(void clang::tidy::C
  
langTidyCheckFactories::registerCheck(llvm::StringRef)::'lambda'(llvm::StringRef,
 clang::tidy::ClangTidyContext*)&, llvm::StringRef&&, clang::tidy:
  :ClangTidyContext*&&))
  >>> the vtable symbol may be undefined because the class is missing its key 
function (see https://lld.llvm.org/missingkeyfunction)
  
  ld.lld: error: undefined symbol: vtable for 
clang::tidy::performance::NoexceptMoveConstructorCheck
  >>> referenced by NoexceptMoveConstructorCheck.h:30 
(/home/christianu/repos/llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines/../performance/NoexceptMoveConstructorCheck.h:30)
  >>>   
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/CppCoreGuidelinesTidyModule.cpp.o:(std::enable_if>, void 
clang::tidy::ClangTidyCheckFactories::registerCheck(llvm::StringRef)::'lambda'(llvm::StringRef, 
clang::tidy::ClangTidyContext*)&, llvm::StringRef, 
clang::tidy::ClangTidyContext*>, std::unique_ptr>>::type 
std::__invoke_r>, void 
clang::tidy::ClangTidyCheckFactories::register
  
Check(llvm::StringRef)::'lambda'(llvm::StringRef,
 clang::tidy::ClangTidyContext*)&, llvm::StringRef, 
clang::tidy::ClangTidyContext*>(void clan
  
g::tidy::ClangTidyCheckFactories::registerCheck(llvm::StringRef)::'lambda'(llvm::StringRef,
 clang::tidy::ClangTidyContext*)&, llvm::StringRef&
  &, clang::tidy::ClangTidyContext*&&))
  >>> the vtable symbol may be undefined because the class is missing its key 
function (see https://lld.llvm.org/missingkeyfunction)
  
  ld.lld: error: undefined symbol: vtable for 
clang::tidy::performance::NoexceptSwapCheck
  >>> referenced by NoexceptSwapCheck.h:26 
(/home/christianu/repos/llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines/../performance/NoexceptSwapCheck.h:26)
  >>>   
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/CppCoreGuidelinesTidyModule.cpp.o:(std::enable_if>, void 
clang::tidy::ClangTidyCheckFactories::registerCheck(llvm::St
  ringRef)::'lambda'(llvm::StringRef, clang::tidy::ClangTidyContext*)&, 
llvm::StringRef, clang::tidy::ClangTidyContext*>, 
std::unique_ptr>>::type 
std::__invoke_r>, void 
clang::tidy::ClangTidyCheckFactories::registerCheck(llvm::StringRef)::'lambda'(llvm::StringRef,
 clang::tidy::ClangTidyContext*)&, llvm::StringRef, 
clang::tidy::ClangTidyContext*>(void clang::tidy::ClangTidyChec
  
kFactories::registerCheck(llvm::StringRef)::'lambda'(llvm::StringRef,
 clang::tidy::ClangTidyContext*)&, llvm::StringRef&&, 
clang::tidy::ClangTidyContext*
  &&))
  >>> the vtable symbol may be undefined because the class is missing its key 
function (see https://lld.llvm.org/missingkeyfunction)
  clang-16: error: linker command failed with exit code 1 (use -v to see 
invocation)

I'm building with shared libraries on.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-14 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added inline comments.



Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:1764
+  if (ICA.processFunction(F))
+Changed.insert(F);
+  }

Do we actually need to add the function to the changed list here? We aren't 
modifying the functions attributes, only callsites within the function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152226/new/

https://reviews.llvm.org/D152226

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


[PATCH] D152852: [clang-tidy] Fix wrong code generation for `modernize-loop-convert` with structured bindings.

2023-06-14 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

Overall looks fine.




Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:545-547
+if (isa(AliasDecl->getSingleDecl())) {
+  const auto *AliasDecompositionDecl =
+  cast(AliasDecl->getSingleDecl());

this could be merged, try dyn_cast


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152852/new/

https://reviews.llvm.org/D152852

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


[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-14 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

Pre-merge check failures are in a test for the unchecked-optional-access check 
clang-tidy. The test that's failing is the following from 
unchecked-optional-access.cpp:

  c++
  void multiple_unchecked_accesses(absl::optional opt1,
   absl::optional opt2) {
for (int i = 0; i < 10; i++) {
  opt1.value();
  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: unchecked access to optional
}
opt2.value();
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional 
value
  }

Both of the expected diagnostics are not output.

It looks to me as if the values we're now newly producing for integer literals 
are causing non-convergence of the analysis on the for-loop.

This looks like a pretty serious issue. We would certainly want analysis of a 
simple loop like this to converge, especially with a small bounded trip count, 
but even with an unbounded trip count. It looks as if, currently, the analysis 
is converging merely because we don't generate values for integer literals.

Next step will be to repro this issue with a test in TransferTest.cpp so that I 
can take a closer look at why we're failing to converge.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152813/new/

https://reviews.llvm.org/D152813

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


[PATCH] D151855: [clang] Use `{File,Directory}EntryRef` in modular header search (part 2/2)

2023-06-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D151855#4403934 , @jansvoboda11 
wrote:

> In D151855#4403879 , @benlangmuir 
> wrote:
>
>>> I think it should be fine to allow dropping the 
>>> A.framework/Frameworks/B.framework directory from the reproducer VFS
>>
>> I think technically this is wrong, since if you're missing the symlink, then 
>> A might not build -- e.g. it could be doing a relative include that needs 
>> the symlink.  But am I understanding correctly that the reproducer was 
>> already broken in this case? If so I'm fine with this.
>
> You're right, this would break relative includes, which I believe the current 
> test case would handle correctly. (It only fails to canonicalize the paths to 
> `B.framework` and make it into a top-level framework.) I'll try to verify 
> this, just to be sure.

I tried changing the `#include ` to relative `#include 
"../Frameworks/B.framework/Headers/B.h"` in `A.h`. The original Clang 
invocation compiles both of these fine with and without this patch, promoting 
`B` to a top-level framework.

The relative include fails to compile with the reproducer VFS, both with and 
without this patch. This boils down to Clang calling 
`FileSystem::getRealPath("/Frameworks/A.framework/Frameworks/B.framework")`
 when deciding whether to promote `B` to top-level framework. Here the 
`RedirectingFileSystem` ends up just canonicalizing the path (making it 
absolute, removing `.`, etc.) and forwarding 

 to the underlying (real) FS. This doesn't have the symlink, so it returns 
non-zero error-code, and `FileManager::getCanonicalName()` ends up returning 
the virtual path 

 under `A.framework`, preventing promotion of `B` to a top-level framework. 
This ends up registering `B` as a sub-framework of `A` in one place, but then 
Clang sees `/Frameworks/B.framework` and attempts to create `B` again 
with the same `DirectoryEntry` umbrella directory, resulting in the error below:

  
/tools/clang/test/Modules/Output/crash-vfs-umbrella-frameworks.m.tmp/i/Frameworks/A.framework/Frameworks/B.framework/Modules/module.modulemap:2:19:
 error: umbrella for module 'A.B' already covers this directory
  2 |   umbrella header "B.h"
|   ^
  
/tools/clang/test/Modules/Output/crash-vfs-umbrella-frameworks.m.tmp/i/Frameworks/A.framework/Frameworks/B.framework/Modules/module.modulemap:4:10:
 error: inferred submodules require a module with an umbrella
  4 |   module * { export * }
|  ^
  While building module 'I' imported from 
/clang/test/Modules/crash-vfs-umbrella-frameworks.m:42:
  In file included from :1:
  
/tools/clang/test/Modules/Output/crash-vfs-umbrella-frameworks.m.tmp/i/Frameworks/I.framework/Headers/I.h:2:9:
 fatal error: could not build module 'A'
  2 | #import 
|  ~~~^
  /clang/test/Modules/crash-vfs-umbrella-frameworks.m:42:9: fatal 
error: could not build module 'I'
 42 | @import I;
|  ~~~^
  4 errors generated.

(Note that the `A.framework/Frameworks/B.framework/Headers/B.h` and 
`A.framework/Frameworks/B.framework/Modules/module.modulemap` files do make it 
into the reproducer VFS with this patch, since they both get touched by the 
original Clang invocation. For some reason, we end up with duplicate entries 
for these in the overlay file without this patch.)

That said, this patch doesn't regress the relative include reproducer, since 
it's already broken. I'm not exactly sure what the fix for that particular 
issue is, since the interactions are pretty subtle. I don't think it's worth 
blocking this patch on it, though. What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151855/new/

https://reviews.llvm.org/D151855

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


[PATCH] D152747: [include-cleaner] Traverse implicit template instantations if the templates are inside the main file.

2023-06-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Though I'm not a reviewer, I was looking through the emails and found this 
change interesting. This is not intended to block the review in any way, just 
trying to get a picture of the direction include-cleaner is taking.

Is this a digression from the initial idea of include-what-you-spell?
I thought that the whole point was in trying to make the analysis more "local" 
and avoid relying on implicit instantiations.

What is our strategy on balancing the number of false-positive removals we 
produce with the number of false-negatives where we don't remove something 
that's actually unused?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152747/new/

https://reviews.llvm.org/D152747

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-06-14 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 531243.
Krishna-13-cyber removed a reviewer: Quuxplusone.
Krishna-13-cyber added a comment.

- Update with the given suggestion
- Add release notes

Thanks a lot @aaron.ballman for the instant assistance.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149000/new/

https://reviews.llvm.org/D149000

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conditional-expr.c
  clang/test/Sema/warn-tautological-compare.c


Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,9 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void)
+{
+int *a = (void *) 0;
+int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 
'a' equal to a null pointer is always false}}
+}
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,8 @@
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); /* expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+   
  expected-warning {{comparison of address of 
'x' not equal to a null pointer is always true}} */
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14844,7 +14844,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (auto *UO = dyn_cast(E->IgnoreParens())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -340,6 +340,8 @@
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
 - Clang no longer emits ``-Wunused-variable`` warnings for variables declared
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
+- Clang now issues expected warnings for situations of comparing with NULL 
pointers.
+  (`#42992: `_)
 
 Bug Fixes in This Version
 -


Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,9 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void)
+{
+int *a = (void *) 0;
+int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 'a' equal to a null pointer is always false}}
+}
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,8 @@
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); /* expected-warning {{C99 forbids conditional expressions with only one void side}}
+ expected-warning {{comparison of address of 'x' not equal to a null pointer is always true}} */
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14844,7 +14844,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (auto *UO = dyn_cast(E->IgnoreParens())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -340,6 +340,8 @@
   can be contro

[PATCH] D149248: [RISCV][MC] MC layer support for the experimental zacas extension

2023-06-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 531244.
asb added a comment.

Rebase and ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149248/new/

https://reviews.llvm.org/D149248

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoA.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zacas-invalid.s
  llvm/test/MC/RISCV/rv32zacas-valid.s
  llvm/test/MC/RISCV/rv64zacas-invalid.s
  llvm/test/MC/RISCV/rv64zacas-valid.s

Index: llvm/test/MC/RISCV/rv64zacas-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zacas-valid.s
@@ -0,0 +1,51 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zacas -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zacas < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zacas -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: not llvm-mc -triple=riscv64 -mattr=+a -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+# Odd register numbers for rd and rs2 are allowed for amocas.d on RV64.
+
+# CHECK-ASM-AND-OBJ: amocas.d a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d a1, a3, (a5)
+# CHECK-ASM-AND-OBJ: amocas.d.aq a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2c]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d.aq a1, a3, (a5)
+# CHECK-ASM-AND-OBJ: amocas.d.rl a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2a]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d.rl a1, a3, (a5)
+# CHECK-ASM-AND-OBJ: amocas.d.aqrl a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2e]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d.aqrl a1, a3, (a5)
+
+# CHECK-ASM-AND-OBJ: amocas.q a0, a2, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc5,0xc5,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q a0, a2, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q a0, a2, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc5,0xc5,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q a0, a2, 0(a1)
+# CHECK-ASM-AND-OBJ: amocas.q zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q zero, zero, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q.aq zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2c]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q.aq zero, zero, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q.rl zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2a]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q.rl zero, zero, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q.aqrl zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2e]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q.aqrl zero, zero, (a1)
Index: llvm/test/MC/RISCV/rv64zacas-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zacas-invalid.s
@@ -0,0 +1,16 @@
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zacas < %s 2>&1 | FileCheck %s
+
+# Non-zero offsets not supported for the third operand (rs1).
+amocas.w a1, a3, 1(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0
+amocas.d a1, a3, 2(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0
+amocas.q a1, a3, 3(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0
+
+# First and second operands (rd and rs2) of amocas.q must be even.
+amocas.q a1, a2, (a1) # CHECK: :[[@LINE]]:10: error: The destination register must be even.
+amocas.q a0, a1, (a1) # CHECK: :[[@LINE]]:14: error: The source register must be even.
+amocas.q.aq a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even.
+amocas.q.aq a0, a1, (a1) # CHECK: :[[@LINE]]:17: error: The source register must be even.
+amocas.q.rl a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even.
+amocas.q.rl a0, a1, (a1) # CHECK: :[[@LINE]]:17: error: The source register must be even.
+amocas.q.aqrl a1, a2, (a1) # CH

[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-14 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

In D152813#4420399 , @mboehme wrote:

> It looks to me as if the values we're now newly producing for integer 
> literals are causing non-convergence of the analysis on the for-loop.

For integer literals specifically, we should be returning the same value for 
the same literal over multiple loop iterations. And also, ideally, for multiple 
equal literals, too, so that an integer literal "42", no matter how many times 
spelled in the program, creates the same symbolic value.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152813/new/

https://reviews.llvm.org/D152813

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


[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-14 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D152813#4420445 , @gribozavr2 
wrote:

> In D152813#4420399 , @mboehme wrote:
>
>> It looks to me as if the values we're now newly producing for integer 
>> literals are causing non-convergence of the analysis on the for-loop.
>
> For integer literals specifically, we should be returning the same value for 
> the same literal over multiple loop iterations. And also, ideally, for 
> multiple equal literals, too, so that an integer literal "42", no matter how 
> many times spelled in the program, creates the same symbolic value.

That's true, and I'll modify the patch so that we do this. (I should probably 
also include a test that checks that `42 == 42` is equivalent to `true`.)

But even without this, wouldn't we expect the analysis to converge? The way I'm 
treating integer literals right now, the analysis is in effect "seeing" the 
example I quoted above like this:

  int return_some_random_int();
  void multiple_unchecked_accesses(absl::optional opt1,
   absl::optional opt2) {
for (int i = return_some_random_int(); i < return_some_random_int(); i++) {
  opt1.value();
  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: unchecked access to optional
}
opt2.value();
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional 
value
  }

We would expect analysis of this code to converge too -- right? So I think the 
problem we're seeing here is independent of how we treat integer literals 
specifically (though I agree the same integer literal should always be 
represented by the same `Value`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152813/new/

https://reviews.llvm.org/D152813

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


[PATCH] D151938: [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

2023-06-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 531245.
jansvoboda11 marked 3 inline comments as done.
jansvoboda11 added a comment.

Remove accidental diff with `--crash` in test, add file header, continue being 
defensive in `CXLoadedDiagnostic.cpp`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151938/new/

https://reviews.llvm.org/D151938

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Frontend/ASTUnit.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CIndexHigh.cpp
  clang/tools/libclang/CIndexInclusionStack.cpp
  clang/tools/libclang/CLog.h
  clang/tools/libclang/CXFile.h
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/tools/libclang/CXIndexDataConsumer.h
  clang/tools/libclang/CXLoadedDiagnostic.cpp
  clang/tools/libclang/CXSourceLocation.cpp
  clang/tools/libclang/Indexing.cpp

Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -255,7 +255,8 @@
 
 if (Loc == MainFileLoc && Reason == PPCallbacks::EnterFile) {
   IsMainFileEntered = true;
-  DataConsumer.enteredMainFile(SM.getFileEntryForID(SM.getMainFileID()));
+  DataConsumer.enteredMainFile(
+  *SM.getFileEntryRefForID(SM.getMainFileID()));
 }
   }
 
@@ -350,8 +351,8 @@
 PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
 
 if (!PPOpts.ImplicitPCHInclude.empty()) {
-  auto File = CI.getFileManager().getFile(PPOpts.ImplicitPCHInclude);
-  if (File)
+  if (auto File =
+  CI.getFileManager().getOptionalFileRef(PPOpts.ImplicitPCHInclude))
 DataConsumer->importedPCH(*File);
 }
 
@@ -694,17 +695,18 @@
 
   ASTUnit::ConcurrencyCheck Check(*Unit);
 
-  if (const FileEntry *PCHFile = Unit->getPCHFile())
-DataConsumer.importedPCH(PCHFile);
+  if (OptionalFileEntryRef PCHFile = Unit->getPCHFile())
+DataConsumer.importedPCH(*PCHFile);
 
   FileManager &FileMgr = Unit->getFileManager();
 
   if (Unit->getOriginalSourceFileName().empty())
-DataConsumer.enteredMainFile(nullptr);
-  else if (auto MainFile = FileMgr.getFile(Unit->getOriginalSourceFileName()))
+DataConsumer.enteredMainFile(std::nullopt);
+  else if (auto MainFile =
+   FileMgr.getFileRef(Unit->getOriginalSourceFileName()))
 DataConsumer.enteredMainFile(*MainFile);
   else
-DataConsumer.enteredMainFile(nullptr);
+DataConsumer.enteredMainFile(std::nullopt);
 
   DataConsumer.setASTContext(Unit->getASTContext());
   DataConsumer.startedTranslationUnit();
Index: clang/tools/libclang/CXSourceLocation.cpp
===
--- clang/tools/libclang/CXSourceLocation.cpp
+++ clang/tools/libclang/CXSourceLocation.cpp
@@ -13,6 +13,7 @@
 #include "CXSourceLocation.h"
 #include "CIndexer.h"
 #include "CLog.h"
+#include "CXFile.h"
 #include "CXLoadedDiagnostic.h"
 #include "CXString.h"
 #include "CXTranslationUnit.h"
@@ -128,19 +129,19 @@
   LogRef Log = Logger::make(__func__);
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   ASTUnit::ConcurrencyCheck Check(*CXXUnit);
-  const FileEntry *File = static_cast(file);
+  FileEntryRef File = *cxfile::getFileEntryRef(file);
   SourceLocation SLoc = CXXUnit->getLocation(File, line, column);
   if (SLoc.isInvalid()) {
 if (Log)
   *Log << llvm::format("(\"%s\", %d, %d) = invalid",
-   File->getName().str().c_str(), line, column);
+   File.getName().str().c_str(), line, column);
 return clang_getNullLocation();
   }
   
   CXSourceLocation CXLoc =
   cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
   if (Log)
-*Log << llvm::format("(\"%s\", %d, %d) = ", File->getName().str().c_str(),
+*Log << llvm::format("(\"%s\", %d, %d) = ", File.getName().str().c_str(),
  line, column)
  << CXLoc;
 
@@ -160,7 +161,7 @@
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
 
   SourceLocation SLoc 
-= CXXUnit->getLocation(static_cast(file), offset);
+= CXXUnit->getLocation(*cxfile::getFileEntryRef(file), offset);
 
   if (SLoc.isInvalid())
 return clang_getNullLocation();
@@ -251,7 +252,7 @@
   }
   
   if (file)
-*file = const_cast(SM.getFileEntryForSLocEntry(sloc));
+*file = cxfile::makeCXFile(SM.getFileEntryRefForID(fileID));
   if (line)
 *line = SM.getExpansionLineNumber(ExpansionLoc);
   if (column)
@@ -328,7 +329,7 @@
 return createNullLocation(file, line, column, offset);
   
   if (file)
-*file = const_cast(SM.getFileEntryForID(FID));
+*file = cxfile::makeCXFile(SM.getFileEntryRefForID(FID));
   if (line)
 *line = SM.getLineNumber(FID, FileOffset);
   if (column)
@@ -364,7 +365,7 @@
 return createNullLocation(fil

[PATCH] D151938: [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

2023-06-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/Modules/crash-vfs-umbrella-frameworks.m:13
 // RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
-// RUN: not %clang -nostdinc -fsyntax-only %s \
+// RUN: not --crash %clang -nostdinc -fsyntax-only %s \
 // RUN: -F %/t/i/Frameworks -fmodules \

benlangmuir wrote:
> This looks suspicious; what's going on here?
Bad cherry-pick, removed.



Comment at: clang/tools/libclang/CXLoadedDiagnostic.cpp:279
   else {
-LoadedLoc.file = const_cast(TopDiags->Files[FileID]);
+LoadedLoc.file = cxfile::makeCXFile(TopDiags->Files.find(FileID)->second);
 if (!LoadedLoc.file)

benlangmuir wrote:
> Does this preserve behaviour in call cases? operator[] will construct nullptr 
> if the key is missing, but the new code will crash dereferencing an invalid 
> iterator.  
You're right, let's continue being defensive here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151938/new/

https://reviews.llvm.org/D151938

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


[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-14 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

In D152813#4420448 , @mboehme wrote:

> We would expect analysis of this code to converge too -- right?

Yes - but we might need universal top values for that? maybe?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152813/new/

https://reviews.llvm.org/D152813

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-14 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn added a comment.

@nikic Ping :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148216/new/

https://reviews.llvm.org/D148216

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


[clang] bf449be - [docs] Add missing empty line before lists

2023-06-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-06-14T11:42:09+01:00
New Revision: bf449be9677bf9fd8c591512cfba152250170432

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

LOG: [docs] Add missing empty line before lists

Added: 


Modified: 
clang/docs/Multilib.rst

Removed: 




diff  --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index 78a300a60f8bc..e50bd367cd401 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -59,6 +59,7 @@ Multilib processing
 
 Clang goes through the following steps to use multilib from a configuration
 file:
+
 #. Normalize command line options. Clang can accept the same
information via 
diff erent options - for example,
``--target=arm-none-eabi -march=armv7-m`` and
@@ -91,6 +92,7 @@ matches.
 
 It is up to the ToolChain subclass to decide what to do in this case.
 There are two options permitted:
+
 #. Use only the *last* matching multilib variant. This option exists primarily
for compatibility with the previous multilib design.
 #. Use all matching variants, thereby layering them.



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


[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-14 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D152813#4420471 , @gribozavr2 
wrote:

> In D152813#4420448 , @mboehme wrote:
>
>> We would expect analysis of this code to converge too -- right?
>
> Yes - but we might need universal top values for that? maybe?

Ah, I see what you mean.

Anyway, I'll look at producing "reproducible" `Value`s for the same integer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152813/new/

https://reviews.llvm.org/D152813

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


[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

2023-06-14 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1386
+if (const auto *VTSD = dyn_cast(DiagD))
+  DiagRange.setEnd(VTSD->getTemplateArgsInfo()->RAngleLoc);
 if (DiagD->isReferenced()) {

It looks like `VarTemplateSpecializationDecl::getTemplateArgsInfo()` could be 
null, so I'll add another check for that to avoid regression.

(This seems weird to me because IIRC there's no template type deduction for 
variable templates and thus every specialization for variable templates has 
explicit template arguments provided)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152707/new/

https://reviews.llvm.org/D152707

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! There's still a formatting issue in warn-tautological-compare.c but I can 
fix that up when landing, assuming you still need me to land this on your 
behalf. (If you can land it on your own, then feel free to fix the formatting 
issue when you land it.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149000/new/

https://reviews.llvm.org/D149000

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


[clang-tools-extra] ffd7a20 - [clang-tidy] Fix build bot break after 474a2b9367ad

2023-06-14 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2023-06-14T06:47:34-05:00
New Revision: ffd7a200fdfbd01ef296101647d2f2da91ddfd41

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

LOG: [clang-tidy] Fix build bot break after 474a2b9367ad

The commmit added clang-tidy checks without adding
the required library to the link step.
Caused failures with shared library builds.

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index b63f28fa3ddcd..3b6fd642ae88d 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -39,6 +39,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
   clangTidy
   clangTidyMiscModule
   clangTidyModernizeModule
+  clangTidyPerformanceModule
   clangTidyReadabilityModule
   clangTidyUtils
 



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


[clang] 00b1dd8 - [docs] Add missing empty line at start of code-block

2023-06-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-06-14T12:49:07+01:00
New Revision: 00b1dd82d72f4000c26c28e1471128569255dadc

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

LOG: [docs] Add missing empty line at start of code-block

Added: 


Modified: 
clang/docs/Multilib.rst

Removed: 




diff  --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index e50bd367cd401..a04eae4b1e216 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -151,6 +151,7 @@ For a more comprehensive example see
 ``clang/test/Driver/baremetal-multilib.yaml`` in the ``llvm-project`` sources.
 
 .. code-block:: yaml
+
   # multilib.yaml
 
   # This format is experimental and is likely to change!



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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-06-14 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber added a comment.

In D149000#4420607 , @aaron.ballman 
wrote:

> LGTM! There's still a formatting issue in warn-tautological-compare.c but I 
> can fix that up when landing, assuming you still need me to land this on your 
> behalf. (If you can land it on your own, then feel free to fix the formatting 
> issue when you land it.)

Yes, I don't have the commit access to the repository, It would be great if you 
could land it on my behalf. Apologies for missing out on the formatting issues.
Thanks a lot!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149000/new/

https://reviews.llvm.org/D149000

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


[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

2023-06-14 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 531266.
hazohelet added a comment.

Added an additional null check that I mentioned earlier


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152707/new/

https://reviews.llvm.org/D152707

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/Inputs/diag-unused-source-ranges.h
  clang/test/Misc/diag-unused-source-ranges.cpp

Index: clang/test/Misc/diag-unused-source-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-unused-source-ranges.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -Wunused -Wunused-template -Wunused-exception-parameter -Wunused-member-function -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+#include "Inputs/diag-unused-source-ranges.h"
+
+#define CAT(a, b) a ## b
+
+// CHECK:  :{55:15-55:20}: warning: unused exception parameter 'param'
+// CHECK-NEXT:   catch (int ¶m) {}
+// CHECK-NEXT:   ^{{$}}
+
+// CHECK:  :{53:7-53:12}: warning: unused variable 'local'
+// CHECK-NEXT:   int local = 0;
+// CHECK-NEXT:   ^{{$}}
+
+// CHECK:  In file included from
+// CHECK-NEXT: :{1:13-1:18}: warning: 'static' function 'thing' declared in header file should be declared 'static inline'
+// CHECK-NEXT:   static void thing(void) {}
+// CHECK-NEXT:   ^{{$}}
+
+namespace {
+class A {
+  // CHECK:  :{[[@LINE+3]]:10-[[@LINE+3]]:14}: warning: member function 'func' is not needed
+  // CHECK-NEXT:   void func() {}
+  // CHECK-NEXT:^~~~{{$}}
+void func() {}
+  // CHECK:  :{[[@LINE+3]]:32-[[@LINE+3]]:37}: warning: unused function template
+  // CHECK-NEXT:   void templ(T) {}
+  // CHECK-NEXT:^{{$}}
+template  void templ(T) {}
+  // CHECK:  :{[[@LINE+3]]:22-[[@LINE+3]]:32}: warning: member function 'templ' is not needed
+  // CHECK-NEXT:   void templ(int) {}
+  // CHECK-NEXT:^~{{$}}
+template <> void templ(int) {}
+  // CHECK:  :{[[@LINE+3]]:22-[[@LINE+3]]:27}: warning: member function 'templ' is not needed
+  // CHECK-NEXT:   void templ(float) {}
+  // CHECK-NEXT:^{{$}}
+template <> void templ(float) {}
+
+  // CHECK:  :{[[@LINE+4]]:10-[[@LINE+4]]:13}: warning: unused function template
+  // CHECK-NEXT:   void foo() {
+  // CHECK-NEXT:^~~{{$}}
+template 
+void foo() {
+  func();
+  templ(0);
+  templ(0.0f);
+  templ(0.0);
+}
+};
+// CHECK:  :{[[@LINE+3]]:12-[[@LINE+3]]:23}: warning: unused function 'unused_func'
+// CHECK-NEXT:   static int unused_func(int aaa, char bbb) {
+// CHECK-NEXT:  ^~~{{$}}
+static int unused_func(int aaa, char bbb) {
+  int local = 0;
+  try{}
+  catch (int ¶m) {}
+  return 0;
+}
+
+// CHECK:  :{[[@LINE+4]]:6-[[@LINE+4]]:16}: warning: unused function template
+// CHECK-NEXT:   auto arrow_decl(T a, T b) ->
+// CHECK-NEXT:^~{{$}}
+template 
+auto arrow_decl(T a, T b) -> decltype(a + b) { thing(); return a + b; }
+
+// CHECK:  :{[[@LINE+4]]:6-[[@LINE+4]]:21}: warning: unused function 'arrow_decl'
+// CHECK-NEXT:   auto arrow_decl(int a, int b) ->
+// CHECK-NEXT:^~~{{$}}
+template <>
+auto arrow_decl(int a, int b) -> int { return a + b; }
+
+
+// CHECK:  :{[[@LINE+4]]:10-[[@LINE+4]]:20}: warning: unused function template
+// CHECK-NEXT:   static T func_templ(int bbb, T ccc) {
+// CHECK-NEXT:^~{{$}}
+template 
+static T func_templ(int bbb, T ccc) {
+  return ccc;
+}
+
+// CHECK:  :{[[@LINE+3]]:17-[[@LINE+3]]:32}: warning: function 'func_templ' is not needed
+// CHECK-NEXT:   int func_templ(int bbb, int ccc) {
+// CHECK-NEXT:   ^~~{{$}}
+template <> int func_templ(int bbb, int ccc) {
+  return bbb;
+}
+
+// CHECK:  :{[[@LINE+3]]:35-[[@LINE+3]]:47}: warning: unused function template
+// CHECK-NEXT:   static void never_called() {
+// CHECK-NEXT:   ^~~~{{$}}
+template  static void never_called() {
+  func_templ(0, 0);
+}
+
+// CHECK:  :{[[@LINE+3]]:22-[[@LINE+3]]:31}: warning: unused variable template
+// CHECK-NEXT:   int var_templ =
+// CHECK-NEXT:   ^{{$}}
+template  int var_templ = n * var_templ;
+// CHECK:  :{[[@LINE+3]]:17-[[@LINE+3]]:29}: warning: variable 'var_templ<0>' is not needed
+// CHECK-NEXT:   int var_templ<0> =
+// CHECK-NEXT:   ^~~~{{$}}
+template <> int var_templ<0> = 1;
+struct {
+// CHECK:  :{[[@LINE+3]]:8-[[@LINE+3]]:11}: warning: unused member function 'fun'
+// CHECK-NEXT:   void fun() {}
+// CHECK-NEXT:^~~{{$}}
+  void fun() {}
+// CHECK:  :{[[@LINE+3]]:3-[[@LINE+3]]:8}: warning: unused variable 'var_x'
+// CHECK-NEXT:   } var_x;
+// CHECK-NEXT: ^{{$}}
+} var_x;
+
+// CHECK:  :{[[@LINE+5]]:12-[[@LINE+6]]:12}: warning: unused variable 'new_line'
+// CHECK-NEXT:   static int CAT(new_,
+// CHECK-NEXT:  ^~~

[clang] 7e20e13 - [docs] Add missing label

2023-06-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-06-14T13:08:07+01:00
New Revision: 7e20e13dd88bb9f2d7665186d97632846e566304

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

LOG: [docs] Add missing label

Added: 


Modified: 
clang/docs/Multilib.rst

Removed: 




diff  --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index a04eae4b1e216..ab737e43b97d2 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -79,11 +79,13 @@ file:
a match.
If more than one variant matches then a toolchain may opt to either use only
the *last* matching multilib variant, or may use all matching variants,
-   thereby :ref:`layering` them.
+   thereby :ref:`layering` them.
 #. Generate ``-isystem`` and ``-L`` options. Iterate in reverse order over
the matching multilib variants, and generate ``-isystem`` and ``-L``
options based on the multilib variant's directory.
 
+.. _multilib-layering:
+
 Multilib layering
 =
 



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


[PATCH] D152852: [clang-tidy] Fix wrong code generation for `modernize-loop-convert` with structured bindings.

2023-06-14 Thread André Schackier via Phabricator via cfe-commits
AMS21 updated this revision to Diff 531274.
AMS21 added a comment.

Use dyn_cast


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152852/new/

https://reviews.llvm.org/D152852

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-structured-binding.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-structured-binding.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-structured-binding.cpp
@@ -0,0 +1,49 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-loop-convert %t
+
+struct S {
+  int a{0};
+  int b{1};
+};
+
+template 
+struct array {
+
+  T *begin() { return data; }
+  const T* cbegin() const { return data; }
+  T *end() { return data + Size; }
+  const T *cend() const { return data + Size; }
+
+  T data[Size];
+};
+
+const int N = 6;
+S Arr[N];
+
+void f() {
+  int Sum = 0;
+
+  for (int I = 0; I < N; ++I) {
+auto [a, b] = Arr[I];
+Sum += a + b;
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead [modernize-loop-convert]
+  // CHECK-FIXES: for (auto [a, b] : Arr) {
+  // CHECK-FIXES-NEXT: Sum += a + b;
+
+  array arr;
+  for (auto* It = arr.begin(); It != arr.end(); ++It) {
+auto [a, b] = *It;
+Sum = a + b;
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead [modernize-loop-convert]
+  // CHECK-FIXES: for (auto [a, b] : arr) {
+  // CHECK-FIXES-NEXT: Sum = a + b;
+
+  for (auto* It = arr.cbegin(); It != arr.cend(); ++It) {
+auto [a, b] = *It;
+Sum = a + b;
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead [modernize-loop-convert]
+  // CHECK-FIXES: for (auto [a, b] : arr) {
+  // CHECK-FIXES-NEXT: Sum = a + b;
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -320,6 +320,10 @@
   using macro between namespace declarations, to fix false positive when using namespace
   with attributes and to support nested inline namespace introduced in c++20.
 
+- Fixed an issue in `modernize-loop-convert
+  ` generating wrong code
+  when using structured bindings.
+
 - In :doc:`modernize-use-default-member-init
   ` count template
   constructors toward hand written constructors so that they are skipped if more
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -533,32 +533,48 @@
 const ValueDecl *MaybeContainer, const UsageResult &Usages,
 const DeclStmt *AliasDecl, bool AliasUseRequired, bool AliasFromForInit,
 const ForStmt *Loop, RangeDescriptor Descriptor) {
-  std::string VarName;
+  std::string VarNameOrStructuredBinding;
   bool VarNameFromAlias = (Usages.size() == 1) && AliasDecl;
   bool AliasVarIsRef = false;
   bool CanCopy = true;
   std::vector FixIts;
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
-VarName = AliasVar->getName().str();
-
-// Use the type of the alias if it's not the same
-QualType AliasVarType = AliasVar->getType();
-assert(!AliasVarType.isNull() && "Type in VarDecl is null");
-if (AliasVarType->isReferenceType()) {
-  AliasVarType = AliasVarType.getNonReferenceType();
-  AliasVarIsRef = true;
+
+// Handle structured bindings
+if (const auto *AliasDecompositionDecl =
+dyn_cast(AliasDecl->getSingleDecl())) {
+  VarNameOrStructuredBinding = "[";
+
+  assert(!AliasDecompositionDecl->bindings().empty() && "No bindings");
+  for (const BindingDecl *Binding : AliasDecompositionDecl->bindings()) {
+VarNameOrStructuredBinding += Binding->getName().str() + ", ";
+  }
+
+  VarNameOrStructuredBinding.erase(VarNameOrStructuredBinding.size() - 2,
+   2);
+  VarNameOrStructuredBinding += "]";
+} else {
+  VarNameOrStructuredBinding = AliasVar->getName().str();
+
+  // Use the type of the alias if it's not the same
+  QualType AliasVarType = AliasVar->getType();
+  assert(!AliasVarType.isNull() && "Type in VarDecl is null");
+  if (AliasVarType->isReferenceType()) {
+AliasVarType = AliasVarType.getNonReferenceType();
+AliasVarIsRef = true;
+  }
+  if (Descriptor.ElemType.isNull() ||
+  !Context->hasSameUnqualifiedType(AliasVarType, Descriptor.ElemType))
+Descriptor.ElemType = AliasVarType;
 }
-if (Descriptor.ElemType.isNull() ||
-!Context->hasSameUnqua

[PATCH] D152852: [clang-tidy] Fix wrong code generation for `modernize-loop-convert` with structured bindings.

2023-06-14 Thread André Schackier via Phabricator via cfe-commits
AMS21 marked an inline comment as done.
AMS21 added a comment.

If there are no more problems, I would kindly ask for someone to push this on 
my behalf :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152852/new/

https://reviews.llvm.org/D152852

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20e81a80e9cb: Update with warning message for comparison to 
NULL pointer (authored by Krishna-13-cyber, committed by aaron.ballman).

Changed prior to commit:
  https://reviews.llvm.org/D149000?vs=531243&id=531279#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149000/new/

https://reviews.llvm.org/D149000

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conditional-expr.c
  clang/test/Sema/warn-tautological-compare.c


Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,8 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void) {
+  int *a = (void *) 0;
+  int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 
'a' equal to a null pointer is always false}}
+}
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,8 @@
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); /* expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+   
  expected-warning {{comparison of address of 
'x' not equal to a null pointer is always true}} */
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14844,7 +14844,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (auto *UO = dyn_cast(E->IgnoreParens())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -340,6 +340,8 @@
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
 - Clang no longer emits ``-Wunused-variable`` warnings for variables declared
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
+- Clang now issues expected warnings for situations of comparing with NULL 
pointers.
+  (`#42992: `_)
 
 Bug Fixes in This Version
 -


Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,8 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void) {
+  int *a = (void *) 0;
+  int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 'a' equal to a null pointer is always false}}
+}
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,8 @@
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); /* expected-warning {{C99 forbids conditional expressions with only one void side}}
+ expected-warning {{comparison of address of 'x' not equal to a null pointer is always true}} */
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14844,7 +14844,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (auto *UO = dyn_cast(E->IgnoreParens())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++

[clang] 20e81a8 - Update with warning message for comparison to NULL pointer

2023-06-14 Thread Aaron Ballman via cfe-commits

Author: Krishna Narayanan
Date: 2023-06-14T08:28:35-04:00
New Revision: 20e81a80e9cb6403f850ab981438f3d9d88b5a4b

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

LOG: Update with warning message for comparison to NULL pointer

The tautological comparison warning was not properly looking through
parenthesized expressions, which is now fixed.

Fixes https://github.com/llvm/llvm-project/issues/42992
Differential Revision: https://reviews.llvm.org/D149000

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/conditional-expr.c
clang/test/Sema/warn-tautological-compare.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6bfd77cc91028..2960183eb8c5f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -340,6 +340,8 @@ Improvements to Clang's diagnostics
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
 - Clang no longer emits ``-Wunused-variable`` warnings for variables declared
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
+- Clang now issues expected warnings for situations of comparing with NULL 
pointers.
+  (`#42992: `_)
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 96f8d49b80f2c..55220138f94f5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14844,7 +14844,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (auto *UO = dyn_cast(E->IgnoreParens())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;

diff  --git a/clang/test/Sema/conditional-expr.c 
b/clang/test/Sema/conditional-expr.c
index 81997459c1f20..b54b689ec4f05 100644
--- a/clang/test/Sema/conditional-expr.c
+++ b/clang/test/Sema/conditional-expr.c
@@ -86,7 +86,8 @@ void foo(void) {
 
 int Postgresql(void) {
   char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); /* expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+   
  expected-warning {{comparison of address of 
'x' not equal to a null pointer is always true}} */
 }
 
 #define nil ((void*) 0)

diff  --git a/clang/test/Sema/warn-tautological-compare.c 
b/clang/test/Sema/warn-tautological-compare.c
index 88e0f98b48ea4..dd41f04036391 100644
--- a/clang/test/Sema/warn-tautological-compare.c
+++ b/clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,8 @@ void test_conditional_operator(void) {
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void) {
+  int *a = (void *) 0;
+  int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 
'a' equal to a null pointer is always false}}
+}



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


[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: AMDGPU, foad, rampitec, yaxunl, Pierre-vh, cdevadas.
Herald added subscribers: StephenFan, kerbowa, hiraditya, tpr, dstuttard, 
jvesely, kzhuravl.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

Provide direct access to v_exp_f32 and v_exp_f16, so we can start
correctly lowering the generic exp intrinsics.

  

Unfortunately have to break from the usual naming convention of
matching the instruction name and stripping the v_ prefix. exp is
already taken by the export intrinsic. On the clang builtin side, we
have a choice of maintaining the convention to the instruction name,
or following the intrinsic name.


https://reviews.llvm.org/D152901

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,SDAG %s
+; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,GISEL %s
+
+define float @v_exp2_f32(float %src)  {
+; GCN-LABEL: v_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %src)
+  ret float %exp2
+}
+
+define float @v_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %fabs.src)
+  ret float %exp2
+}
+
+define float @v_fneg_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %neg.fabs.src = fneg float %fabs.src
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %neg.fabs.src)
+  ret float %exp2
+}
+
+define half @v_exp2_f16(half %src)  {
+; GCN-LABEL: v_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %src)
+  ret half %exp2
+}
+
+define half @v_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %fabs.src)
+  ret half %exp2
+}
+
+define half @v_fneg_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %neg.fabs.src = fneg half %fabs.src
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %neg.fabs.src)
+  ret half %exp2
+}
+
+declare half @llvm.amdgcn.exp2.f16(half) #0
+declare float @llvm.amdgcn.exp2.f32(float) #0
+declare float @llvm.fabs.f32(float) #0
+declare half @llvm.fabs.f16(half) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GISEL: {{.*}}
+; SDAG: {{.*}}
Index: llvm/lib/Target/AMDGPU/VOP1Instructions.td
===
--- llvm/lib/Target/AMDGPU/VOP1Instructions.td
+++ llvm/lib/Target/AMDGPU/VOP1Instructions.td
@@ -321,7 +321,7 @@
 defm V_FLOOR_F32 : VOP1Inst <"v_floor_f32", VOP_F32_F32, ffloor>;
 
 let TRANS = 1, SchedRW = [WriteTrans32] in {
-defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, fexp2>;
+defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, AMDGPUexp>;
 defm V_LOG_F32 : VOP1Inst <"v_log_f32", VOP_F32_F32, AMDGPUlog>;
 defm V_RCP_F32 : VOP1Inst <"v_rcp_f32", VOP_F32_F32, AMDGPUrcp>;
 defm V_RCP_IFLAG_F32 : VOP1Inst <"v_rcp_iflag

[PATCH] D152856: [Driver] Allow warning for unclaimed TargetSpecific options

2023-06-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

Looks great to me, thanks! (Didn't test it myself yet though.) Just one small 
nit.




Comment at: llvm/include/llvm/Option/Arg.h:53
+  /// This is used for generating an "argument unused" warning (without
+  /// clang::driver::options::TargetSpecific) or "unsupported option" error
+  /// (with TargetSpecific).

Technically, as this is a llvm level API, talking about clang specific 
behaviours here is a bit at the wrong level.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152856/new/

https://reviews.llvm.org/D152856

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


[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo updated this revision to Diff 531275.
VitaNuo added a comment.
VitaNuo updated this revision to Diff 531278.
VitaNuo added a reviewer: kadircet.
VitaNuo published this revision for review.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Remove redundant variables.


VitaNuo added a comment.

Remove redundancy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152900

Files:
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "TestFS.h"
 #include "TestTU.h"
+#include "URI.h"
 #include "index/SymbolCollector.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -226,23 +227,18 @@
 
 class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  SymbolIndexActionFactory(SymbolCollector::Options COpts,
-   CommentHandler *PragmaHandler)
-  : COpts(std::move(COpts)), PragmaHandler(PragmaHandler) {}
+  SymbolIndexActionFactory(SymbolCollector::Options COpts)
+  : COpts(std::move(COpts)) {}
 
   std::unique_ptr create() override {
 class IndexAction : public ASTFrontendAction {
 public:
   IndexAction(std::shared_ptr DataConsumer,
-  const index::IndexingOptions &Opts,
-  CommentHandler *PragmaHandler)
-  : DataConsumer(std::move(DataConsumer)), Opts(Opts),
-PragmaHandler(PragmaHandler) {}
+  const index::IndexingOptions &Opts)
+  : DataConsumer(std::move(DataConsumer)), Opts(Opts) {}
 
   std::unique_ptr
   CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) override {
-if (PragmaHandler)
-  CI.getPreprocessor().addCommentHandler(PragmaHandler);
 return createIndexingASTConsumer(DataConsumer, Opts,
  CI.getPreprocessorPtr());
   }
@@ -256,20 +252,17 @@
 private:
   std::shared_ptr DataConsumer;
   index::IndexingOptions Opts;
-  CommentHandler *PragmaHandler;
 };
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
 IndexOpts.IndexFunctionLocals = true;
 Collector = std::make_shared(COpts);
-return std::make_unique(Collector, std::move(IndexOpts),
- PragmaHandler);
+return std::make_unique(Collector, std::move(IndexOpts));
   }
 
   std::shared_ptr Collector;
   SymbolCollector::Options COpts;
-  CommentHandler *PragmaHandler;
 };
 
 class SymbolCollectorTest : public ::testing::Test {
@@ -289,8 +282,7 @@
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
-auto Factory = std::make_unique(
-CollectorOpts, PragmaHandler.get());
+auto Factory = std::make_unique(CollectorOpts);
 
 std::vector Args = {"symbol_collector", "-fsyntax-only",
  "-xc++", "-include", TestHeaderName};
@@ -324,7 +316,6 @@
   RefSlab Refs;
   RelationSlab Relations;
   SymbolCollector::Options CollectorOpts;
-  std::unique_ptr PragmaHandler;
 };
 
 TEST_F(SymbolCollectorTest, CollectSymbols) {
@@ -1573,9 +1564,6 @@
 
 TEST_F(SymbolCollectorTest, IWYUPragma) {
   CollectorOpts.CollectIncludePath = true;
-  CanonicalIncludes Includes;
-  PragmaHandler = collectIWYUHeaderMaps(&Includes);
-  CollectorOpts.Includes = &Includes;
   const std::string Header = R"(
 // IWYU pragma: private, include the/good/header.h
 class Foo {};
@@ -1588,9 +1576,6 @@
 
 TEST_F(SymbolCollectorTest, IWYUPragmaWithDoubleQuotes) {
   CollectorOpts.CollectIncludePath = true;
-  CanonicalIncludes Includes;
-  PragmaHandler = collectIWYUHeaderMaps(&Includes);
-  CollectorOpts.Includes = &Includes;
   const std::string Header = R"(
 // IWYU pragma: private, include "the/good/header.h"
 class Foo {};
@@ -1601,6 +1586,27 @@
  includeHeader("\"the/good/header.h\"";
 }
 
+TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
+  CollectorOpts.CollectIncludePath = true;
+  const std::string Header = R"cpp(#pragma once
+#include "exporter.h"
+  )cpp";
+  auto ExporterFile = testPath("exporter.h");
+  InMemoryFileSystem->addFile(
+  ExporterFile, 0, llvm::MemoryBuffer::getMemBuffer(R"cpp(#pragma once
+#include "private.h" // IWYU pragma: export

[PATCH] D152570: [clang] Apply -fmacro-prefix-map to anonymous tags in template arguments

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from the issue with the release note.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152570/new/

https://reviews.llvm.org/D152570

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


[clang] b8c08f7 - [clang][Sema] Fix diagnostic message for unused constant variable templates

2023-06-14 Thread Takuya Shimizu via cfe-commits

Author: Takuya Shimizu
Date: 2023-06-14T21:43:03+09:00
New Revision: b8c08f7ae86da4723f9e125d5defa5404518d87d

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

LOG: [clang][Sema] Fix diagnostic message for unused constant variable templates

BEFORE this patch, unused const-qualified variable templates such as `template 
 const double var_t = 0;` were diagnosed as `unused variable 
'var_t'`
This patch fixes this message to `unused variable template 'var_t'`

Differential Revision: https://reviews.llvm.org/D152796

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/Sema.cpp
clang/test/SemaCXX/warn-unused-filescoped.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2960183eb8c5f..32cc7c94a3252 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,8 @@ Improvements to Clang's diagnostics
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
 - Clang now issues expected warnings for situations of comparing with NULL 
pointers.
   (`#42992: `_)
+- Clang now diagnoses unused const-qualified variable template as
+  "unused variable template" rather than "unused variable".
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index e6507d8808011..09084176cbf41 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1380,6 +1380,9 @@ void Sema::ActOnEndOfTranslationUnit() {
 if (DiagD->isReferenced()) {
   Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
   << /*variable*/ 1 << DiagD;
+} else if (DiagD->getDescribedVarTemplate()) {
+  Diag(DiagD->getLocation(), diag::warn_unused_template)
+  << /*variable*/ 1 << DiagD;
 } else if (DiagD->getType().isConstQualified()) {
   const SourceManager &SM = SourceMgr;
   if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
@@ -1387,11 +1390,7 @@ void Sema::ActOnEndOfTranslationUnit() {
 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
 << DiagD;
 } else {
-  if (DiagD->getDescribedVarTemplate())
-Diag(DiagD->getLocation(), diag::warn_unused_template)
-<< /*variable*/ 1 << DiagD;
-  else
-Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
+  Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
 }
   }
 }

diff  --git a/clang/test/SemaCXX/warn-unused-filescoped.cpp 
b/clang/test/SemaCXX/warn-unused-filescoped.cpp
index d53608003b16d..be8d350855c07 100644
--- a/clang/test/SemaCXX/warn-unused-filescoped.cpp
+++ b/clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -155,8 +155,7 @@ namespace test5 {
   int y = sizeof(d);
 
   namespace {
-  // FIXME: Should be "unused variable template 'var_t'" instead.
-  template  const double var_t = 0; // expected-warning {{unused 
variable 'var_t'}}
+  template  const double var_t = 0; // expected-warning {{unused 
variable template 'var_t'}}
   template <> const double var_t = 0;  // expected-warning {{variable 
'var_t' is not needed and will not be emitted}}
   int z = sizeof(var_t);   // expected-warning {{unused 
variable 'z'}}
   } // namespace



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


[PATCH] D152796: [clang][Sema] Fix diagnostic message for unused constant varialbe templates

2023-06-14 Thread Takuya Shimizu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb8c08f7ae86d: [clang][Sema] Fix diagnostic message for 
unused constant variable templates (authored by hazohelet).

Changed prior to commit:
  https://reviews.llvm.org/D152796?vs=530844&id=531293#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152796/new/

https://reviews.llvm.org/D152796

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unused-filescoped.cpp


Index: clang/test/SemaCXX/warn-unused-filescoped.cpp
===
--- clang/test/SemaCXX/warn-unused-filescoped.cpp
+++ clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -155,8 +155,7 @@
   int y = sizeof(d);
 
   namespace {
-  // FIXME: Should be "unused variable template 'var_t'" instead.
-  template  const double var_t = 0; // expected-warning {{unused 
variable 'var_t'}}
+  template  const double var_t = 0; // expected-warning {{unused 
variable template 'var_t'}}
   template <> const double var_t = 0;  // expected-warning {{variable 
'var_t' is not needed and will not be emitted}}
   int z = sizeof(var_t);   // expected-warning {{unused 
variable 'z'}}
   } // namespace
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1380,6 +1380,9 @@
 if (DiagD->isReferenced()) {
   Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
   << /*variable*/ 1 << DiagD;
+} else if (DiagD->getDescribedVarTemplate()) {
+  Diag(DiagD->getLocation(), diag::warn_unused_template)
+  << /*variable*/ 1 << DiagD;
 } else if (DiagD->getType().isConstQualified()) {
   const SourceManager &SM = SourceMgr;
   if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
@@ -1387,11 +1390,7 @@
 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
 << DiagD;
 } else {
-  if (DiagD->getDescribedVarTemplate())
-Diag(DiagD->getLocation(), diag::warn_unused_template)
-<< /*variable*/ 1 << DiagD;
-  else
-Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
+  Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
 }
   }
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -342,6 +342,8 @@
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
 - Clang now issues expected warnings for situations of comparing with NULL 
pointers.
   (`#42992: `_)
+- Clang now diagnoses unused const-qualified variable template as
+  "unused variable template" rather than "unused variable".
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/warn-unused-filescoped.cpp
===
--- clang/test/SemaCXX/warn-unused-filescoped.cpp
+++ clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -155,8 +155,7 @@
   int y = sizeof(d);
 
   namespace {
-  // FIXME: Should be "unused variable template 'var_t'" instead.
-  template  const double var_t = 0; // expected-warning {{unused variable 'var_t'}}
+  template  const double var_t = 0; // expected-warning {{unused variable template 'var_t'}}
   template <> const double var_t = 0;  // expected-warning {{variable 'var_t' is not needed and will not be emitted}}
   int z = sizeof(var_t);   // expected-warning {{unused variable 'z'}}
   } // namespace
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1380,6 +1380,9 @@
 if (DiagD->isReferenced()) {
   Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
   << /*variable*/ 1 << DiagD;
+} else if (DiagD->getDescribedVarTemplate()) {
+  Diag(DiagD->getLocation(), diag::warn_unused_template)
+  << /*variable*/ 1 << DiagD;
 } else if (DiagD->getType().isConstQualified()) {
   const SourceManager &SM = SourceMgr;
   if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
@@ -1387,11 +1390,7 @@
 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
 << DiagD;
 } else {
-  if (DiagD->getDescribedVarTemplate())
-Diag(DiagD->getLocation(), diag::warn_unused_template)
-<< /*variable*/ 1 << DiagD;
-  else
-Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;

[PATCH] D152274: [clang] Don't create import decls without -fmodules

2023-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

The internal state when modules are off but layering check is on is really 
counterintuitive, and clearly not all configurations have been tested :-(
I'm pretty sure this is the right behavior, though.

Just readability nits.




Comment at: clang/lib/Sema/SemaModule.cpp:639
 
-  bool ShouldAddImport = !IsInModuleIncludes;
+  bool ShouldAddImport = !IsInModuleIncludes && getLangOpts().Modules;
 

It's been a couple of weeks since we looked at this together, and I already had 
trouble following the logic here.

I think it would be slightly clearer by:
 - flipping the order (LangOpts.Modules is "more fundanmental"/a prerequisite)
 - moving this var *after* the comment that explains it
 - adding a brief comment for the extra clause.

Something like

```
// If we are really importing a module (not just checking layering)
// due to an #include in the main file, synthesize an ImportDecl.
bool ShouldAddImport = getLangOpts().Modules && !IsInModuleIncludes;
if (ShouldAddImport) {
```

I'd also consider inlining+dropping the `ShouldAddImport` variable, since the 
comment explains pretty well what the condition represents

all up to you though


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152274/new/

https://reviews.llvm.org/D152274

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


[PATCH] D152880: [clang][NFC] Add a notice to desugarForDiagnostic

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the extra documentation, that is a surprising behavior


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152880/new/

https://reviews.llvm.org/D152880

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


[PATCH] D148700: [clang] Add support for “regular” keyword attributes

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D148700#4418767 , @rsandifo-arm 
wrote:

> Hi @jyknight , @rsmith
>
> Do you have any more thoughts on the above?  Quick version is:
>
> 1. Is it OK to have `[[…]]` attributes in the `arm` namespace that affect 
> semantics?

Yes, any attribute in a vendor namespace can do anything it wants, including 
impacting semantics.

> 1. Is it OK to raise an error for unrecognised attributes in the `arm` 
> namespace (for a measure of future-proofing)?

Yes, part of "anything it wants" includes diagnostic behavior.

> Given the differing views, I'm unsure whether to revert the series and do (1) 
> (and possibly (2)), or whether to leave things as they are.

The reason why we suggested keywords isn't because of concerns with how *Clang* 
implements the attribute, it's about portability of the code between Clang and 
other compilers that don't implement the attribute. Compilers do not issue an 
error diagnostic on unrecognized attributes in a vendor namespace (per spec 
they're defined to be ignored: 
https://eel.is/c++draft/dcl.attr#grammar-6.sentence-1 so if you're lucky, 
you'll get a warning about the attribute being unknown, but there's no 
guarantee: https://godbolt.org/z/8qaqPzYYG). So when the attribute impacts 
semantics in such a way that silently ignoring the attribute would lead to Very 
Bad Outcomes (think: crashes, ABI mismatches, security concerns, etc), using a 
keyword for the attribute is a better user experience because unknown keywords 
are not ignored by implementations (they get diagnosed as a syntax error).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148700/new/

https://reviews.llvm.org/D148700

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


[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 531300.
arsenm added a comment.

Fix patch split


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152901/new/

https://reviews.llvm.org/D152901

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,SDAG %s
+; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,GISEL %s
+
+define float @v_exp2_f32(float %src)  {
+; GCN-LABEL: v_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %src)
+  ret float %exp2
+}
+
+define float @v_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %fabs.src)
+  ret float %exp2
+}
+
+define float @v_fneg_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %neg.fabs.src = fneg float %fabs.src
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %neg.fabs.src)
+  ret float %exp2
+}
+
+define half @v_exp2_f16(half %src)  {
+; GCN-LABEL: v_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %src)
+  ret half %exp2
+}
+
+define half @v_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %fabs.src)
+  ret half %exp2
+}
+
+define half @v_fneg_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %neg.fabs.src = fneg half %fabs.src
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %neg.fabs.src)
+  ret half %exp2
+}
+
+declare half @llvm.amdgcn.exp2.f16(half) #0
+declare float @llvm.amdgcn.exp2.f32(float) #0
+declare float @llvm.fabs.f32(float) #0
+declare half @llvm.fabs.f16(half) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GISEL: {{.*}}
+; SDAG: {{.*}}
Index: llvm/lib/Target/AMDGPU/VOP1Instructions.td
===
--- llvm/lib/Target/AMDGPU/VOP1Instructions.td
+++ llvm/lib/Target/AMDGPU/VOP1Instructions.td
@@ -321,7 +321,7 @@
 defm V_FLOOR_F32 : VOP1Inst <"v_floor_f32", VOP_F32_F32, ffloor>;
 
 let TRANS = 1, SchedRW = [WriteTrans32] in {
-defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, fexp2>;
+defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, AMDGPUexp>;
 defm V_LOG_F32 : VOP1Inst <"v_log_f32", VOP_F32_F32, AMDGPUlog>;
 defm V_RCP_F32 : VOP1Inst <"v_rcp_f32", VOP_F32_F32, AMDGPUrcp>;
 defm V_RCP_IFLAG_F32 : VOP1Inst <"v_rcp_iflag_f32", VOP_F32_F32, AMDGPUrcp_iflag>;
@@ -488,7 +488,7 @@
 defm V_SQRT_F16 : VOP1Inst_t16 <"v_sqrt_f16", VOP_F16_F16, any_amdgcn_sqrt>;
 defm V_RSQ_F16 : VOP1Inst_t16 <"v_rsq_f16", VOP_F16_F16, AMDGPUrsq>;
 defm V_LOG_F16 : VOP1Inst_t16 <"v_log_f16", VOP_F16_F16, AMDGPUlogf16>;
-defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, fexp2>;
+defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, AMDGPUexpf16>;
 defm V_SIN_F16 : VOP1Inst_t16 <"v_sin_f16", VOP_F16_F16, AMDGPUsin>;
 defm V_COS_F16 : VOP1Inst_t16 <"v_cos_f16", VOP_F16_F16, AMDGPUcos>;
 } // End TRANS = 1, SchedRW = [WriteTrans32]
In

[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2023-06-14 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam accepted this revision.
saiislam added a comment.

Thank you @animeshk-amd!
LGTM!

As discussed in the multi-company OpenMP LLVM meeting, this is the right time 
to upgrade the default OpenMP spec version to 5.1.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129635/new/

https://reviews.llvm.org/D129635

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


[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 531301.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152901/new/

https://reviews.llvm.org/D152901

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,SDAG %s
+; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,GISEL %s
+
+define float @v_exp2_f32(float %src)  {
+; GCN-LABEL: v_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %src)
+  ret float %exp2
+}
+
+define float @v_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %fabs.src)
+  ret float %exp2
+}
+
+define float @v_fneg_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %neg.fabs.src = fneg float %fabs.src
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %neg.fabs.src)
+  ret float %exp2
+}
+
+define half @v_exp2_f16(half %src)  {
+; GCN-LABEL: v_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %src)
+  ret half %exp2
+}
+
+define half @v_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %fabs.src)
+  ret half %exp2
+}
+
+define half @v_fneg_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %neg.fabs.src = fneg half %fabs.src
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %neg.fabs.src)
+  ret half %exp2
+}
+
+declare half @llvm.amdgcn.exp2.f16(half) #0
+declare float @llvm.amdgcn.exp2.f32(float) #0
+declare float @llvm.fabs.f32(float) #0
+declare half @llvm.fabs.f16(half) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GISEL: {{.*}}
+; SDAG: {{.*}}
Index: llvm/lib/Target/AMDGPU/VOP1Instructions.td
===
--- llvm/lib/Target/AMDGPU/VOP1Instructions.td
+++ llvm/lib/Target/AMDGPU/VOP1Instructions.td
@@ -321,7 +321,7 @@
 defm V_FLOOR_F32 : VOP1Inst <"v_floor_f32", VOP_F32_F32, ffloor>;
 
 let TRANS = 1, SchedRW = [WriteTrans32] in {
-defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, fexp2>;
+defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, AMDGPUexp>;
 defm V_LOG_F32 : VOP1Inst <"v_log_f32", VOP_F32_F32, AMDGPUlog>;
 defm V_RCP_F32 : VOP1Inst <"v_rcp_f32", VOP_F32_F32, AMDGPUrcp>;
 defm V_RCP_IFLAG_F32 : VOP1Inst <"v_rcp_iflag_f32", VOP_F32_F32, AMDGPUrcp_iflag>;
@@ -488,7 +488,7 @@
 defm V_SQRT_F16 : VOP1Inst_t16 <"v_sqrt_f16", VOP_F16_F16, any_amdgcn_sqrt>;
 defm V_RSQ_F16 : VOP1Inst_t16 <"v_rsq_f16", VOP_F16_F16, AMDGPUrsq>;
 defm V_LOG_F16 : VOP1Inst_t16 <"v_log_f16", VOP_F16_F16, AMDGPUlogf16>;
-defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, fexp2>;
+defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, AMDGPUexpf16>;
 defm V_SIN_F16 : VOP1Inst_t16 <"v_sin_f16", VOP_F16_F16, AMDGPUsin>;
 defm V_COS_F16 : VOP1Inst_t16 <"v_cos_f16", VOP_F16_F16, AMDGPUcos>;
 } // End TRANS = 1, SchedRW = [WriteTrans32]
Index: llvm/lib/Target/AMDGPU/AMDGPURegister

[PATCH] D152913: [clangd] Use include_cleaner spelling strategies in clangd.

2023-06-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152913

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -75,11 +75,6 @@
 convertIncludes(const SourceManager &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -182,8 +182,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -412,22 +413,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManager())) {
-  std::string SpelledHeader =
-  llvm::cantFail(URI::includeSpelling(URI::create(*CanonicalPath)));
-  if (!SpelledHeader.empty())
-return SpelledHeader;
-}
-  }
-  return include_cleaner::spellHeader(
-  {Provider, AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
-}
-
 IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
   // Interaction is only polished for C/CPP.
   if (AST.getLangOpts().ObjC)
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -18,6 +18,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "clang-include-cleaner/Analysis.h"
+#include "clang-include-cleaner/IncludeSpeller.h"
 #include "clang-include-cleaner/Types.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
@@ -1223,7 +1224,9 @@
 // on local variables, etc.
 return;
 
-  HI.Provider = spellHeader(AST, SM.getFileEntryForID(SM.getMainFileID()), H);
+  HI.Provider = include_cleaner::spellHeader(
+  {H, AST.getPreprocessor().getHeaderSearchInfo(),
+   SM.getFileEntryForID(SM.getMainFileID())});
 }
 
 // FIXME: similar functions are present in FindHeaders.cpp (symbolName)


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -75,11 +75,6 @@
 convertIncludes(const SourceManager &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -182,8 +182,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -412,22 +413,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto Ca

[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-14 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam marked an inline comment as done.
zahiraam added inline comments.



Comment at: clang/lib/Basic/Builtins.cpp:33
 static constexpr Builtin::Info BuiltinInfo[] = {
-{"not a builtin function", nullptr, nullptr, nullptr, 
HeaderDesc::NO_HEADER,
+#define INTERESTING_IDENTIFIER(ID) 
\
+  {#ID, nullptr, nullptr, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},

From your comment in Builtin.h: "You shouldn't muddle this into Builtin::ID."
This means this shouldn't happen here. It should be done in 
IdentiferTable::AddKeywords as I had done previously?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146148/new/

https://reviews.llvm.org/D146148

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


[PATCH] D152914: [Draft] Make __builtin_cpu builtins target-independent

2023-06-14 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: PowerPC, RKSimon, pengfei, arsenm, t.p.northover.
Herald added subscribers: steven.zhang, kbarton, hiraditya.
Herald added a project: All.
nemanjai requested review of this revision.
Herald added subscribers: jdoerfert, wdng.
Herald added projects: clang, LLVM.

This is just a proposal patch for a possible direction we can extend these 
builtins to other targets as well as an implementation for PowerPC.

This adds a new instruction similar to `LOAD_STACK_GUARD` that is meant to load 
things from fixed addresses. The new instruction has semantics that are a 
superset of what `LOAD_STACK_GUARD` does so the two can be folded into one.

My hope with this patch is to collect feedback from the community about the 
direction, so please provide any feedback you may have.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152914

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-cpu-supports.c
  clang/test/Sema/builtin-cpu-supports.c
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/include/llvm/TargetParser/PPCTargetParser.def
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/lib/Target/PowerPC/PPCTargetMachine.h
  llvm/test/CodeGen/PowerPC/cpu-supports.ll

Index: llvm/test/CodeGen/PowerPC/cpu-supports.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/cpu-supports.ll
@@ -0,0 +1,111 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -mcpu=pwr9 -ppc-asm-full-reg-names \
+; RUN:   -mtriple=powerpc64-linux-gnu < %s | FileCheck  %s \
+; RUN:   -check-prefix=BE64
+; RUN: llc -mcpu=pwr9 -ppc-asm-full-reg-names \
+; RUN:   -mtriple=powerpc-linux-gnu < %s | FileCheck  %s \
+; RUN:   -check-prefix=BE32
+; RUN: llc -mcpu=pwr9 -ppc-asm-full-reg-names \
+; RUN:   -mtriple=powerpc64le-linux-gnu < %s | FileCheck  %s \
+; RUN:   -check-prefix=LE
+define dso_local signext i32 @test(i32 noundef signext %a) local_unnamed_addr #0 {
+; BE64-LABEL: test:
+; BE64:   # %bb.0: # %entry
+; BE64-NEXT:lwz r4, -28772(r13)
+; BE64-NEXT:andis. r4, r4, 128
+; BE64-NEXT:bne cr0, .LBB0_3
+; BE64-NEXT:  # %bb.1: # %if.else
+; BE64-NEXT:lwz r4, -28776(r13)
+; BE64-NEXT:andis. r4, r4, 1024
+; BE64-NEXT:bne cr0, .LBB0_4
+; BE64-NEXT:  # %bb.2: # %if.else3
+; BE64-NEXT:lwz r4, -28764(r13)
+; BE64-NEXT:cmplwi r4, 39
+; BE64-NEXT:addi r4, r3, 5
+; BE64-NEXT:slwi r3, r3, 1
+; BE64-NEXT:iseleq r3, r3, r4
+; BE64-NEXT:  .LBB0_3: # %return
+; BE64-NEXT:extsw r3, r3
+; BE64-NEXT:blr
+; BE64-NEXT:  .LBB0_4: # %if.then2
+; BE64-NEXT:addi r3, r3, -5
+; BE64-NEXT:extsw r3, r3
+; BE64-NEXT:blr
+;
+; BE32-LABEL: test:
+; BE32:   # %bb.0: # %entry
+; BE32-NEXT:lwz r4, -28732(r2)
+; BE32-NEXT:andis. r4, r4, 128
+; BE32-NEXT:bnelr cr0
+; BE32-NEXT:  # %bb.1: # %if.else
+; BE32-NEXT:lwz r4, -28736(r2)
+; BE32-NEXT:andis. r4, r4, 1024
+; BE32-NEXT:bne cr0, .LBB0_3
+; BE32-NEXT:  # %bb.2: # %if.else3
+; BE32-NEXT:lwz r4, -28724(r2)
+; BE32-NEXT:cmplwi r4, 39
+; BE32-NEXT:addi r4, r3, 5
+; BE32-NEXT:slwi r3, r3, 1
+; BE32-NEXT:iseleq r3, r3, r4
+; BE32-NEXT:blr
+; BE32-NEXT:  .LBB0_3: # %if.then2
+; BE32-NEXT:addi r3, r3, -5
+; BE32-NEXT:blr
+;
+; LE-LABEL: test:
+; LE:   # %bb.0: # %entry
+; LE-NEXT:lwz r4, -28776(r13)
+; LE-NEXT:andis. r4, r4, 128
+; LE-NEXT:bne cr0, .LBB0_3
+; LE-NEXT:  # %bb.1: # %if.else
+; LE-NEXT:lwz r4, -28772(r13)
+; LE-NEXT:andis. r4, r4, 1024
+; LE-NEXT:bne cr0, .LBB0_4
+; LE-NEXT:  # %bb.2: # %if.else3
+; LE-NEXT:lwz r4, -28764(r13)
+; LE-NEXT:cmplwi r4, 39
+; LE-NEXT:addi r4, r3, 5
+; LE-NEXT:slwi r3, r3, 1
+; LE-NEXT:iseleq r3, r3, r4
+; LE-NEXT:  .LBB0_3: # %return
+; LE-NEXT:extsw r3, r3
+; LE-NEXT:blr
+; LE-NEXT:  .LBB0_4: # %if.then2
+; LE-NEXT:addi r3, r3, -5
+; LE-NEXT:extsw r3, r3
+; LE-NEXT:blr
+entry:
+  %cpu_supports = tail call i32 @llvm.fixed.addr.ld(i32 1)
+  %0 = and i32 %cpu_supports, 8388608
+  %.not = icmp eq i32 %0, 0
+  br i1 %.not, label %if.else, label %return
+
+if.else:  ; preds = %entry
+  %cpu_supports1 = tail call i32

[PATCH] D152914: [Draft] Make __builtin_cpu builtins target-independent

2023-06-14 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1785
 
+  if (static_cast(TM).hasGlibcHWCAPAccess())
+OutStreamer->emitSymbolValue(

This probably deserves a comment along the lines of:
```
// Emit a reference to a symbol exported by versions of GLIBC
// that provide the HWCAP access. If a program built with this
// is run on a system with an old GLIBC, it should cause a
// load-time error rather than loading garbage.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152914/new/

https://reviews.llvm.org/D152914

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


[PATCH] D152070: [2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types

2023-06-14 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

FYI after this change:

  Building CXX object 
tools/lldb/sou...luginTypeSystemClang.dir/TypeSystemClang.cpp.o
  
/home/david.spickett/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4843:13:
 warning: 225 enumeration values not handled in switch: 'RvvInt8mf8x2', 
'RvvInt8mf8x3', 'RvvInt8mf8x4'... [-Wswitch]
  switch (llvm::cast(qual_type)->getKind()) {
  ^~~~

lldb doesn't do anything with RVV yet, so you can likely just add all the names 
to the existing block of RVV stuff that just `break`s at the end.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152070/new/

https://reviews.llvm.org/D152070

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


[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-14 Thread Jay Foad via Phabricator via cfe-commits
foad added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h:463
+  // exp2, no denormal handling for f32.
+  EXP,
+

Is this used anywhere?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152901/new/

https://reviews.llvm.org/D152901

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


[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152707/new/

https://reviews.llvm.org/D152707

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


[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.

2023-06-14 Thread Nicole Rabjohn via Phabricator via cfe-commits
nicolerabjohn added a comment.

I've opened an issue (https://github.com/llvm/llvm-project/issues/63063) where 
we hit the same assertion. There's a smaller test case, and we've done enough 
investigation that we understand the problem. I'd be happy to discuss over on 
the issue as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152818/new/

https://reviews.llvm.org/D152818

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


[PATCH] D152741: [WPD] implement -fskip-vtable-filepaths

2023-06-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D152741#4419366 , @modimo wrote:

> In D152741#4419324 , @tejohnson 
> wrote:
>
>> In D152741#4419265 , @modimo wrote:
>>
>>> In D152741#4418831 , @tejohnson 
>>> wrote:
>>>
 I think I understand the motivation, but not sure I agree this is the 
 right approach - can you simply not pass -flto-unit and 
 -fwhole-program-vtables for these files?
>>>
>>> For our third-party libraries, they're pre-built into native files by GCC 
>>> so that's unfortunately not an option.
>>
>> I'm confused - how would you pass this new option then? I was assuming you 
>> were passing this option to some LLVM built files at the interface of those 
>> libraries. In which case not passing -flto-unit and 
>> -fwhole-program-visibility should have a similar effect (suppress the type 
>> metadata).
>
> Oh I see, I misunderstood. Yes this is being passed to LLVM built files. We 
> want to avoid manual allowlists/blocklists because code changes make it less 
> flexible and scalable than an automatic option.

It seems like you need allowlists or blocklists in either case - either it is 
passed as a regex via the option proposed here, or the build system modifies 
the options for that set of files.

> This can also be pretty tricky to do correctly since we can get type metadata 
> from multiple TUs and all of them would need to be opted out for WPD to not 
> kick in.

But clang is presumably compiling a single TU at a time, so your regex needs to 
cover them all anyway? I'm not sure I understand the distinction between doing 
something like -fskip-vtable-filepaths=third-party/.* vs something like 
applying -funknown-vtable-visibility to each third-party/*.cc compile.

I really think the logic for which files to apply this option to belongs in the 
build system, not in the clang driver - just like any other clang option. It 
isn't clear to me why this particular option should be applied based on a file 
regex.

I like the approach of communicating this via vcall visibility, but just think 
that it should be applied to the current TU whenever a TBD new option is 
provided.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152741/new/

https://reviews.llvm.org/D152741

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


[PATCH] D137524: clang/AMDGPU: Emit atomicrmw for atomic_inc/dec builtins

2023-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision as: yaxunl.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137524/new/

https://reviews.llvm.org/D137524

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


[clang-tools-extra] 6a6c7ed - [clangd] Use include_cleaner spelling strategies in clangd.

2023-06-14 Thread Viktoriia Bakalova via cfe-commits

Author: Viktoriia Bakalova
Date: 2023-06-14T14:06:35Z
New Revision: 6a6c7ed5cd8d1a7e0991128e46abfd2b7d95f8e8

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

LOG: [clangd] Use include_cleaner spelling strategies in clangd.

Differential Revision: https://reviews.llvm.org/D152913

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/IncludeCleaner.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 0ae70dd121ebf..d7a249c6bc21f 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -18,6 +18,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "clang-include-cleaner/Analysis.h"
+#include "clang-include-cleaner/IncludeSpeller.h"
 #include "clang-include-cleaner/Types.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
@@ -1223,7 +1224,9 @@ void maybeAddSymbolProviders(ParsedAST &AST, HoverInfo 
&HI,
 // on local variables, etc.
 return;
 
-  HI.Provider = spellHeader(AST, SM.getFileEntryForID(SM.getMainFileID()), H);
+  HI.Provider = include_cleaner::spellHeader(
+  {H, AST.getPreprocessor().getHeaderSearchInfo(),
+   SM.getFileEntryForID(SM.getMainFileID())});
 }
 
 // FIXME: similar functions are present in FindHeaders.cpp (symbolName)

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 95585a61c023d..95f6064b769a7 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -182,8 +182,9 @@ std::vector generateMissingIncludeDiagnostics(
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -412,22 +413,6 @@ convertIncludes(const SourceManager &SM,
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManager())) {
-  std::string SpelledHeader =
-  llvm::cantFail(URI::includeSpelling(URI::create(*CanonicalPath)));
-  if (!SpelledHeader.empty())
-return SpelledHeader;
-}
-  }
-  return include_cleaner::spellHeader(
-  {Provider, AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
-}
-
 IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
   // Interaction is only polished for C/CPP.
   if (AST.getLangOpts().ObjC)

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.h 
b/clang-tools-extra/clangd/IncludeCleaner.h
index 58849846e0df7..edd89777faf3d 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.h
+++ b/clang-tools-extra/clangd/IncludeCleaner.h
@@ -75,11 +75,6 @@ include_cleaner::Includes
 convertIncludes(const SourceManager &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 



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


[PATCH] D152913: [clangd] Use include_cleaner spelling strategies in clangd.

2023-06-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a6c7ed5cd8d: [clangd] Use include_cleaner spelling 
strategies in clangd. (authored by VitaNuo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152913/new/

https://reviews.llvm.org/D152913

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -75,11 +75,6 @@
 convertIncludes(const SourceManager &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -182,8 +182,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -412,22 +413,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManager())) {
-  std::string SpelledHeader =
-  llvm::cantFail(URI::includeSpelling(URI::create(*CanonicalPath)));
-  if (!SpelledHeader.empty())
-return SpelledHeader;
-}
-  }
-  return include_cleaner::spellHeader(
-  {Provider, AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
-}
-
 IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
   // Interaction is only polished for C/CPP.
   if (AST.getLangOpts().ObjC)
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -18,6 +18,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "clang-include-cleaner/Analysis.h"
+#include "clang-include-cleaner/IncludeSpeller.h"
 #include "clang-include-cleaner/Types.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
@@ -1223,7 +1224,9 @@
 // on local variables, etc.
 return;
 
-  HI.Provider = spellHeader(AST, SM.getFileEntryForID(SM.getMainFileID()), H);
+  HI.Provider = include_cleaner::spellHeader(
+  {H, AST.getPreprocessor().getHeaderSearchInfo(),
+   SM.getFileEntryForID(SM.getMainFileID())});
 }
 
 // FIXME: similar functions are present in FindHeaders.cpp (symbolName)


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -75,11 +75,6 @@
 convertIncludes(const SourceManager &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -182,8 +182,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -412,22 +413,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provi

[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h:463
+  // exp2, no denormal handling for f32.
+  EXP,
+

foad wrote:
> Is this used anywhere?
Will be in the next patch


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152901/new/

https://reviews.llvm.org/D152901

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


[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 531315.
arsenm added a comment.

Release notes


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152901/new/

https://reviews.llvm.org/D152901

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/R600Instructions.td
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,SDAG %s
+; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,GISEL %s
+
+define float @v_exp2_f32(float %src)  {
+; GCN-LABEL: v_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %src)
+  ret float %exp2
+}
+
+define float @v_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %fabs.src)
+  ret float %exp2
+}
+
+define float @v_fneg_fabs_exp2_f32(float %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f32_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %neg.fabs.src = fneg float %fabs.src
+  %exp2 = call float @llvm.amdgcn.exp2.f32(float %neg.fabs.src)
+  ret float %exp2
+}
+
+define half @v_exp2_f16(half %src)  {
+; GCN-LABEL: v_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %src)
+  ret half %exp2
+}
+
+define half @v_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %fabs.src)
+  ret half %exp2
+}
+
+define half @v_fneg_fabs_exp2_f16(half %src)  {
+; GCN-LABEL: v_fneg_fabs_exp2_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_exp_f16_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %neg.fabs.src = fneg half %fabs.src
+  %exp2 = call half @llvm.amdgcn.exp2.f16(half %neg.fabs.src)
+  ret half %exp2
+}
+
+declare half @llvm.amdgcn.exp2.f16(half) #0
+declare float @llvm.amdgcn.exp2.f32(float) #0
+declare float @llvm.fabs.f32(float) #0
+declare half @llvm.fabs.f16(half) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GISEL: {{.*}}
+; SDAG: {{.*}}
Index: llvm/lib/Target/AMDGPU/VOP1Instructions.td
===
--- llvm/lib/Target/AMDGPU/VOP1Instructions.td
+++ llvm/lib/Target/AMDGPU/VOP1Instructions.td
@@ -321,7 +321,7 @@
 defm V_FLOOR_F32 : VOP1Inst <"v_floor_f32", VOP_F32_F32, ffloor>;
 
 let TRANS = 1, SchedRW = [WriteTrans32] in {
-defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, fexp2>;
+defm V_EXP_F32 : VOP1Inst <"v_exp_f32", VOP_F32_F32, AMDGPUexp>;
 defm V_LOG_F32 : VOP1Inst <"v_log_f32", VOP_F32_F32, AMDGPUlog>;
 defm V_RCP_F32 : VOP1Inst <"v_rcp_f32", VOP_F32_F32, AMDGPUrcp>;
 defm V_RCP_IFLAG_F32 : VOP1Inst <"v_rcp_iflag_f32", VOP_F32_F32, AMDGPUrcp_iflag>;
@@ -488,7 +488,7 @@
 defm V_SQRT_F16 : VOP1Inst_t16 <"v_sqrt_f16", VOP_F16_F16, any_amdgcn_sqrt>;
 defm V_RSQ_F16 : VOP1Inst_t16 <"v_rsq_f16", VOP_F16_F16, AMDGPUrsq>;
 defm V_LOG_F16 : VOP1Inst_t16 <"v_log_f16", VOP_F16_F16, AMDGPUlogf16>;
-defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, fexp2>;
+defm V_EXP_F16 : VOP1Inst_t16 <"v_exp_f16", VOP_F16_F16, AMDGPUexpf16>;
 defm V_SIN_F16 : VOP1Inst_t16 <"v_sin_f16", VOP_F16_F16, AMDGPUsin>;
 defm V_COS_F16 : VOP1Inst_t16 <"v_cos_f16", V

[PATCH] D152882: [LinkerWrapper] Support device binaries in multiple link jobs

2023-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

The design of target ID put constraints on target ID's that can be embedded 
into one executable 
https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id . For 
example, gfx90a and gfx90a:xnack+ cannot be embedded into one executable since 
this will cause difficulty for runtime to choose device binary to run, 
especially when there are multiple target ID features. clang does not allow 
--offload-arch=gfx90a and --offload-arch=gfx90a:xnack+ to be used together to 
compile HIP programs. It would be preferred for offloack-packager to enforce 
this constraint too.

However, bitcode of  target ID gfx90a:xnack+ is allowed to link in bitcode of 
target ID gfx90a as long as they are from different containers. So there are 
two rules about target ID: 1. compatibility rules for objects/bitcode in the 
same container 2. compatibility rules for linking bitcode of different target 
ID's.

we need tests for both rules.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152882/new/

https://reviews.llvm.org/D152882

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


[PATCH] D134677: [Clang][AArch64][SME] Add ZA zeroing intrinsics

2023-06-14 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 531330.
bryanpkc added a comment.

Addressed @sdesmalen's comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134677/new/

https://reviews.llvm.org/D134677

Files:
  clang/include/clang/Basic/arm_sme.td
  clang/include/clang/Basic/arm_sve_sme_incl.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
  clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp

Index: clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp
===
--- clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp
+++ clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp
@@ -14,8 +14,10 @@
 
 #ifdef DISABLE_SME_ATTRIBUTES
 #define ARM_STREAMING_ATTR
+#define ARM_SHARED_ZA_ATTR
 #else
 #define ARM_STREAMING_ATTR __attribute__((arm_streaming))
+#define ARM_SHARED_ZA_ATTR __attribute__((arm_shared_za))
 #endif
 
 ARM_STREAMING_ATTR
@@ -203,6 +205,14 @@
   SVE_ACLE_FUNC(svwrite_ver_za8, _s8, _m,)(0, -1, 16, pg, svundef_s8());
 }
 
+ARM_SHARED_ZA_ATTR
+void test_range_0_255(svbool_t pg, void *ptr) {
+  // expected-error@+1 {{argument value 256 is outside the valid range [0, 255]}}
+  SVE_ACLE_FUNC(svzero_mask_za,,,)(256);
+  // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 255]}}
+  SVE_ACLE_FUNC(svzero_mask_za,,,)(-1);
+}
+
 ARM_STREAMING_ATTR
 void test_constant(uint64_t u64, svbool_t pg, void *ptr) {
   SVE_ACLE_FUNC(svld1_hor_za8,,,)(u64, u64, 0, pg, ptr);  // expected-error {{argument to 'svld1_hor_za8' must be a constant integer}}
Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
@@ -0,0 +1,52 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+#ifdef DISABLE_SME_ATTRIBUTES
+#define ARM_SHARED_ZA_ATTR
+#else
+#define ARM_SHARED_ZA_ATTR __attribute__((arm_shared_za))
+#endif
+
+// CHECK-C-LABEL: @test_svzero_mask_za(
+// CHECK-CXX-LABEL: @_Z19test_svzero_mask_zav(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 0)
+// CHECK-NEXT:ret void
+//
+ARM_SHARED_ZA_ATTR void test_svzero_mask_za() {
+  svzero_mask_za(0);
+}
+
+// CHECK-C-LABEL: @test_svzero_mask_za_1(
+// CHECK-CXX-LABEL: @_Z21test_svzero_mask_za_1v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 176)
+// CHECK-NEXT:ret void
+//
+ARM_SHARED_ZA_ATTR void test_svzero_mask_za_1() {
+  svzero_mask_za(176);
+}
+
+// CHECK-C-LABEL: @test_svzero_mask_za_2(
+// CHECK-CXX-LABEL: @_Z21test_svzero_mask_za_2v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 255)
+// CHECK-NEXT:ret void
+//
+ARM_SHARED_ZA_ATTR void test_svzero_mask_za_2() {
+  svzero_mask_za(255);
+}
+
+// CHECK-C-LABEL: @test_svzero_za(
+// CHECK-CXX-LABEL: @_Z14test_svzero_zav(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 255)
+// CHECK-NEXT:ret void
+//
+ARM_SHARED_ZA_ATTR void test_svzero_za() {
+  svzero_za();
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2995,6 +2995,10 @@
   if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 15))
 HasError = true;
   break;
+case SVETypeFlags::ImmCheck0_255:
+  if (SemaBuiltinConstantArgRange(TheCall, ArgNum, 0, 255))
+HasError = true;
+  break;
 }
   }
 
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4266,6 +4266,9 @@
   llvm::Value *EmitSMEReadWrite(SVETypeFlags TypeFlags,
 llvm::SmallVectorImpl &Ops,
 unsigned IntID);
+  llvm::Value *EmitSMEZero(SVETypeFlags TypeFlags,
+   llvm::SmallVectorImpl &Ops,
+   unsigned IntID);
   llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
 
   llvm::Value *EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExp

[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as`

2023-06-14 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: w2yehia, MaskRay, shchenz, Esme.
qiongsiwu1 added a project: clang.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits.
Herald added a project: LLVM.

`libLTO` currently ignores the `-f[no-]integrated-as` flags. This patch teaches 
`libLTO` to respect them.

The implementation consists of two parts:

1. Migrate `llc`'s `-no-integrated-as` option to a codegen option so that the 
option is available to `libLTO`/`lld`/`gold`.
2. Teach `clang` to pass `-no-integrated-as` accordingly to `libLTO` depending 
on the `-f[no-]integrated-as` flags.

`libLTO` cannot use system assemblers on platforms other than AIX. As part of 
the option processing, a warning is implemented if `-fno-integrated-as` is used 
for LTO on platforms other than AIX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152924

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto-aix.c
  clang/test/Driver/lto.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/tools/llvm-lto/aix-sys-as.ll
  llvm/test/tools/llvm-lto/aix.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -106,10 +106,6 @@
  "'none' means that all ELF features can be used, "
  "regardless of binutils support"));
 
-static cl::opt
-NoIntegratedAssembler("no-integrated-as", cl::Hidden,
-  cl::desc("Disable integrated assembler"));
-
 static cl::opt
 PreserveComments("preserve-as-comments", cl::Hidden,
  cl::desc("Preserve Comments in outputted assembly"),
@@ -517,7 +513,6 @@
 
 Options.BinutilsVersion =
 TargetMachine::parseBinutilsVersion(BinutilsVersion);
-Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.AsmVerbose = AsmVerbose;
 Options.MCOptions.PreserveAsmComments = PreserveComments;
Index: llvm/test/tools/llvm-lto/aix.ll
===
--- llvm/test/tools/llvm-lto/aix.ll
+++ llvm/test/tools/llvm-lto/aix.ll
@@ -1,4 +1,4 @@
-; REQUIRES: system-aix
+; REQUIRES: powerpc-registered-target
 ; RUN: llvm-as < %s > %t1
 ; RUN: llvm-lto %t1 | FileCheck %s
 
Index: llvm/test/tools/llvm-lto/aix-sys-as.ll
===
--- /dev/null
+++ llvm/test/tools/llvm-lto/aix-sys-as.ll
@@ -0,0 +1,12 @@
+; REQUIRES: system-aix
+; RUN: llvm-as < %s > %t1
+; RUN: llvm-lto -no-integrated-as=1 %t1 | FileCheck %s
+
+target triple = "powerpc-ibm-aix"
+
+define i32 @main() {
+entry:
+  ret i32 42
+}
+; CHECK: Wrote native object file
+
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -244,7 +244,7 @@
 
 bool LTOCodeGenerator::useAIXSystemAssembler() {
   const auto &Triple = TargetMach->getTargetTriple();
-  return Triple.isOSAIX();
+  return Triple.isOSAIX() && Config.Options.DisableIntegratedAS;
 }
 
 bool LTOCodeGenerator::runAIXSystemAssembler(SmallString<128> &AssemblyFile) {
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -81,6 +81,7 @@
 CGOPT(bool, StackRealign)
 CGOPT(std::string, TrapFuncName)
 CGOPT(bool, UseCtors)
+CGOPT(bool, DisableIntegratedAS)
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
@@ -487,6 +488,11 @@
   cl::init(false));
   CGBINDOPT(XCOFFReadOnlyPointers);
 
+  static cl::opt DisableIntegratedAS(
+  "no-integrated-as", cl::desc("Disable integrated assembler"),
+  cl::init(false));
+  CGBINDOPT(DisableIntegratedAS);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ -540,6 +546,7 @@
   Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
   Options.StackSymbolOrdering = getStackSymbolOrdering();
   Options.UseInitArray = !getUseCtors();
+  Options.DisableIntegratedAS = getDisableIntegratedAS();
   Options.RelaxELFRelocations = getRelaxELFRelocations();
   Options.DataSections =
   getExplicitDataSections().value_or(TheTriple.hasDefaultDataSections());
Index: llvm/include/llvm/CodeGen/CommandFlags.h
===
--- llvm/include/llvm/CodeGen/CommandFlags.h
+++ llvm/include/llvm/CodeGen/CommandFlags.h
@@ -94,6 +94,8 @@
 
 bool getUseCtors();
 
+bool getDisableInte

[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

In D148697#4420359 , @Dinistro wrote:

> I'm getting a linking error by some of the files changed in this revision.

You shouldn't because this library got dependency on clangTidyPerformanceModule.
Is this a blocker for you, or you can live with this for 1 day ? Until I verify 
this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Christian Ulmann via Phabricator via cfe-commits
Dinistro added a comment.

In D148697#4421268 , @PiotrZSL wrote:

> In D148697#4420359 , @Dinistro 
> wrote:
>
>> I'm getting a linking error by some of the files changed in this revision.
>
> You shouldn't because this library got dependency on 
> clangTidyPerformanceModule.
> Is this a blocker for you, or you can live with this for 1 day ? Until I 
> verify this.

I don't necessarily need to build clang-tidy, so it's fine for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D150023: [ABI] [C++20] [Modules] Don't generate vtable if the class is defined in other module unit

2023-06-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks check-clang on Mac: 
http://45.33.8.238/macm1/62779/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150023/new/

https://reviews.llvm.org/D150023

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


[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

In D148697#4421339 , @Dinistro wrote:

> In D148697#4421268 , @PiotrZSL 
> wrote:
>
>> In D148697#4420359 , @Dinistro 
>> wrote:
>>
>>> I'm getting a linking error by some of the files changed in this revision.
>>
>> You shouldn't because this library got dependency on 
>> clangTidyPerformanceModule.
>> Is this a blocker for you, or you can live with this for 1 day ? Until I 
>> verify this.
>
> I don't necessarily need to build clang-tidy, so it's fine for now.

I did a clean build with shared libraries enabled, everything is working.
I do not get those issues. Try a clean-build. I will try to check build with 
clang-16.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D152932: [ARM] Adding precommit tests for D146242.

2023-06-14 Thread Jirui Wu via Phabricator via cfe-commits
JiruiWu created this revision.
JiruiWu added reviewers: olista01, simon_tatham, rjmccall, tmatheson, pratlucas.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
JiruiWu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adding precommit tests to better demonstrate the effects of D146242 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152932

Files:
  clang/test/CodeGen/aarch64-ABI-align-packed.c

Index: clang/test/CodeGen/aarch64-ABI-align-packed.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-ABI-align-packed.c
@@ -0,0 +1,240 @@
+// RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-eabi \
+// RUN:   -target-feature +neon \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+#include 
+#include 
+
+// natural alignment 16, adjusted alignment 16
+// expected alignment of copy on callee stack: 16
+struct non_packed_struct {
+  uint16x8_t M0; // member alignment 16
+};
+
+// natural alignment 1, adjusted alignment 1
+// expected alignment of copy on callee stack: 8
+struct __attribute((packed)) packed_struct {
+  uint16x8_t M0; // member alignment 1, because the field is packed when the struct is packed
+};
+
+// natural alignment 1, adjusted alignment 1
+// expected alignment of copy on callee stack: 8
+struct packed_member {
+  uint16x8_t M0 __attribute((packed)); // member alignment 1
+};
+
+// natural alignment 16, adjusted alignment 16 since __attribute((aligned (n))) sets the minimum alignment
+// expected alignment of copy on callee stack: 16
+struct __attribute((aligned (8))) aligned_struct_8 {
+  uint16x8_t M0; // member alignment 16
+};
+
+// natural alignment 16, adjusted alignment 16
+// expected alignment of copy on callee stack: 16
+struct aligned_member_8 {
+  uint16x8_t M0 __attribute((aligned (8))); // member alignment 16 since __attribute((aligned (n))) sets the minimum alignment
+};
+
+// natural alignment 8, adjusted alignment 8
+// expected alignment of copy on callee stack: 8
+#pragma pack(8)
+struct pragma_packed_struct_8 {
+  uint16x8_t M0; // member alignment 8 because the struct is subject to packed(8)
+};
+
+// natural alignment 4, adjusted alignment 4
+// expected alignment of copy on callee stack: 8
+#pragma pack(4)
+struct pragma_packed_struct_4 {
+  uint16x8_t M0; // member alignment 4 because the struct is subject to packed(4)
+};
+
+// Struct passed as a named argument
+// CHECK-LABEL: define dso_local void @named_arg_non_packed_struct
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+void named_arg_non_packed_struct(struct non_packed_struct arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_packed_struct
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_packed_struct(struct packed_struct arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_packed_member
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_packed_member(struct packed_member arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_aligned_struct_8
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_aligned_struct_8(struct aligned_struct_8 arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_aligned_member_8
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_aligned_member_8(struct aligned_member_8 arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_pragma_packed_struct_8
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_pragma_packed_struct_8(struct pragma_packed_struct_8 arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_pragma_packed_struct_4
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_pragma_packed_struct_4(struct pragma_packed_struct_4 arg) {}
+
+// Struct passed as a variadic argument
+// CHECK-LABEL: define dso_local void @variadic_non_packed_struct
+// CHECK:   vaarg.end:
+// CHECK:   call void @llvm.memcpy.p0.p0.i64(ptr align 16 [[ON_CALLEE_STACK:.*]], ptr align 16 [[VAARGS_ADDR:.*]], i64 16, i1 false)
+// CHECK-NEXT:ret void
+void variadic_non_packed_struct(int named_arg, ...) {
+  va_list vl;
+  va_start(vl, named_arg);
+  struct non_packed_struct on_callee_stack;
+  on_callee_stack = va_arg(vl, struct non_packed_struct);
+}
+
+// CHECK-LABEL: define dso_local void @variadic_packed_struct
+// CHECK:   vaarg.end:
+// CHECK:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[ON_CALLEE_STACK:.*]], ptr align 8 [[VAARGS_ADDR:.*]], i64 16, i1 false)
+// CHECK-NEXT:ret void
+void variadic_packed_struct(int named_arg, ...) {
+  va_list vl;
+  va_start(vl, named_arg);
+  struct packed_struct on_callee_stack;
+  on_callee_stack = va_arg(vl, struct packed_struct);
+}
+
+// CHECK-LABEL: define dso_local void @variadic_packed_member
+// CHECK:   

[PATCH] D152932: [ARM] Adding precommit tests for D146242

2023-06-14 Thread Jirui Wu via Phabricator via cfe-commits
JiruiWu updated this revision to Diff 531373.
JiruiWu retitled this revision from "[ARM] Adding precommit tests for D146242." 
to "[ARM] Adding precommit tests for D146242".
JiruiWu added a comment.

Updating the commit message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152932/new/

https://reviews.llvm.org/D152932

Files:
  clang/test/CodeGen/aarch64-ABI-align-packed.c

Index: clang/test/CodeGen/aarch64-ABI-align-packed.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-ABI-align-packed.c
@@ -0,0 +1,240 @@
+// RUN: %clang_cc1 -fsyntax-only -triple aarch64-none-eabi \
+// RUN:   -target-feature +neon \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+#include 
+#include 
+
+// natural alignment 16, adjusted alignment 16
+// expected alignment of copy on callee stack: 16
+struct non_packed_struct {
+  uint16x8_t M0; // member alignment 16
+};
+
+// natural alignment 1, adjusted alignment 1
+// expected alignment of copy on callee stack: 8
+struct __attribute((packed)) packed_struct {
+  uint16x8_t M0; // member alignment 1, because the field is packed when the struct is packed
+};
+
+// natural alignment 1, adjusted alignment 1
+// expected alignment of copy on callee stack: 8
+struct packed_member {
+  uint16x8_t M0 __attribute((packed)); // member alignment 1
+};
+
+// natural alignment 16, adjusted alignment 16 since __attribute((aligned (n))) sets the minimum alignment
+// expected alignment of copy on callee stack: 16
+struct __attribute((aligned (8))) aligned_struct_8 {
+  uint16x8_t M0; // member alignment 16
+};
+
+// natural alignment 16, adjusted alignment 16
+// expected alignment of copy on callee stack: 16
+struct aligned_member_8 {
+  uint16x8_t M0 __attribute((aligned (8))); // member alignment 16 since __attribute((aligned (n))) sets the minimum alignment
+};
+
+// natural alignment 8, adjusted alignment 8
+// expected alignment of copy on callee stack: 8
+#pragma pack(8)
+struct pragma_packed_struct_8 {
+  uint16x8_t M0; // member alignment 8 because the struct is subject to packed(8)
+};
+
+// natural alignment 4, adjusted alignment 4
+// expected alignment of copy on callee stack: 8
+#pragma pack(4)
+struct pragma_packed_struct_4 {
+  uint16x8_t M0; // member alignment 4 because the struct is subject to packed(4)
+};
+
+// Struct passed as a named argument
+// CHECK-LABEL: define dso_local void @named_arg_non_packed_struct
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+void named_arg_non_packed_struct(struct non_packed_struct arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_packed_struct
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_packed_struct(struct packed_struct arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_packed_member
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_packed_member(struct packed_member arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_aligned_struct_8
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_aligned_struct_8(struct aligned_struct_8 arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_aligned_member_8
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_aligned_member_8(struct aligned_member_8 arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_pragma_packed_struct_8
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_pragma_packed_struct_8(struct pragma_packed_struct_8 arg) {}
+
+// CHECK-LABEL: define dso_local void @named_arg_pragma_packed_struct_4
+// CHECK-SAME: ([1 x <8 x i16>] [[ARG_COERCE:%.*]]) #[[ATTR0]] {
+void named_arg_pragma_packed_struct_4(struct pragma_packed_struct_4 arg) {}
+
+// Struct passed as a variadic argument
+// CHECK-LABEL: define dso_local void @variadic_non_packed_struct
+// CHECK:   vaarg.end:
+// CHECK:   call void @llvm.memcpy.p0.p0.i64(ptr align 16 [[ON_CALLEE_STACK:.*]], ptr align 16 [[VAARGS_ADDR:.*]], i64 16, i1 false)
+// CHECK-NEXT:ret void
+void variadic_non_packed_struct(int named_arg, ...) {
+  va_list vl;
+  va_start(vl, named_arg);
+  struct non_packed_struct on_callee_stack;
+  on_callee_stack = va_arg(vl, struct non_packed_struct);
+}
+
+// CHECK-LABEL: define dso_local void @variadic_packed_struct
+// CHECK:   vaarg.end:
+// CHECK:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[ON_CALLEE_STACK:.*]], ptr align 8 [[VAARGS_ADDR:.*]], i64 16, i1 false)
+// CHECK-NEXT:ret void
+void variadic_packed_struct(int named_arg, ...) {
+  va_list vl;
+  va_start(vl, named_arg);
+  struct packed_struct on_callee_stack;
+  on_callee_stack = va_arg(vl, struct packed_struct);
+}
+
+// CHECK-LABEL: define dso_local void @variadic_packed_member
+// CHECK:   vaarg.end:
+// CHECK:   call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[ON_CALLEE_STACK:.*]], ptr al

[PATCH] D151855: [clang] Use `{File,Directory}EntryRef` in modular header search (part 2/2)

2023-06-14 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

> I don't think it's worth blocking this patch on it, though. What do you think?

Agreed, I don't think this is making it worse.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151855/new/

https://reviews.llvm.org/D151855

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


[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

2023-06-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

thanks for the patch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152433/new/

https://reviews.llvm.org/D152433

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


[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as`

2023-06-14 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

`lld` does not use LTOCodeGenerator.

I am also not sure how disable integrated assembler suppose to work? Do you 
have an end to end design for how to invoke assembler during linking? For 
current libLTO API, this is probably going to produce assembler file buffer to 
linker, which is not usable by linker.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152924/new/

https://reviews.llvm.org/D152924

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


[PATCH] D152762: [clang][docs] Update SanitizerSpecialCaseList docs

2023-06-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This is unrelated to this change but related to the issue this change is 
addressing. The use of regular expressions for special case list with the 
special handling of `*` is error-prone, I've seen many people having issues it. 
Furthermore, regular expression for matching file names requires excessive 
escaping (see for example 
https://fuchsia-review.git.corp.google.com/c/fuchsia/+/763162) and most 
patterns used for function names only utilize `*`, not requiring the full 
strength of regular expression. I think we should consider replacing regular 
expressions with glob patterns. These are already implemented in 
https://github.com/llvm/llvm-project/blob/3391bdc255f1a75c59d71c7305959e84d8d5f468/llvm/include/llvm/Support/GlobPattern.h
 so the implementation should be straightforward, but it's going to be a 
breaking change. I don't know how widespread the use of special case lists is 
and whether that's going to be an issue?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152762/new/

https://reviews.llvm.org/D152762

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


[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

@Dinistro It compiles & links with clang 16 also (shared libs). So I'm unable 
to reproduce.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Christian Ulmann via Phabricator via cfe-commits
Dinistro added a comment.

In D148697#4421420 , @PiotrZSL wrote:

> In D148697#4421339 , @Dinistro 
> wrote:
>
>> In D148697#4421268 , @PiotrZSL 
>> wrote:
>>
>>> In D148697#4420359 , @Dinistro 
>>> wrote:
>>>
 I'm getting a linking error by some of the files changed in this revision.
>>>
>>> You shouldn't because this library got dependency on 
>>> clangTidyPerformanceModule.
>>> Is this a blocker for you, or you can live with this for 1 day ? Until I 
>>> verify this.
>>
>> I don't necessarily need to build clang-tidy, so it's fine for now.
>
> I did a clean build with shared libraries enabled, everything is working.
> I do not get those issues. Try a clean-build. I will try to check build with 
> clang-16.

I tried with a clean build, and I get the exact same issues. Might be caused by 
the lld and clang-16 combination, not sure.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D152788: [Clang] Show type in enum out of range diagnostic

2023-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2479-2486
+template struct Bitfield {
+  static constexpr T max = static_cast((1 << size) - 1);
+};
+
+void testValueInRangeOfEnumerationValuesViaTemplate() {
+  Bitfield good;
+  Bitfield bad;

Equivalent but a bit easier to tell where the diagnostic is expected to happen 
at.

Perhaps a good follow-up would be to find out why we're not printing an 
"instantiated from here" note for this case (CC @shafik), but no need to do 
that for this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152788/new/

https://reviews.llvm.org/D152788

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


[PATCH] D152762: [clang][docs] Update SanitizerSpecialCaseList docs

2023-06-14 Thread Ellis Hoag via Phabricator via cfe-commits
ellis planned changes to this revision.
ellis added a comment.

In D152762#4421630 , @phosek wrote:

> This is unrelated to this change but related to the issue this change is 
> addressing. The use of regular expressions for special case list with the 
> special handling of `*` is error-prone, I've seen many people having issues 
> it. Furthermore, regular expression for matching file names requires 
> excessive escaping (see for example 
> https://fuchsia-review.git.corp.google.com/c/fuchsia/+/763162) and most 
> patterns used for function names only utilize `*`, not requiring the full 
> strength of regular expression. I think we should consider replacing regular 
> expressions with glob patterns. These are already implemented in 
> https://github.com/llvm/llvm-project/blob/3391bdc255f1a75c59d71c7305959e84d8d5f468/llvm/include/llvm/Support/GlobPattern.h
>  so the implementation should be straightforward, but it's going to be a 
> breaking change. I don't know how widespread the use of special case lists is 
> and whether that's going to be an issue?

Oh neat, I wasn't aware of `GlobPattern.h`. Personally, I would be happy with 
this change, but it would require changing some blocklists on my end (which is 
fine). I'm not sure what the processes is for a breaking change like this, but 
since clang 16 has just been released, it seems like a good time to change 
this. Thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152762/new/

https://reviews.llvm.org/D152762

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


[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-06-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I think this is now style wise pretty good, I still found some potential 
problems below.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:1487
+  // possible, or else at the end of the function.
+  void emitBlock(BasicBlock *BB, Function *CurFn, bool IsFinished = false);
+

jdoerfert wrote:
> This does not mention the deletion stuff, etc.
This talks about creating a new block, but reading the function it seems it 
will just place `\p BB`. Which one is it?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4122
+  Builder.CreateCall(getOrCreateRuntimeFunctionPtr(*MapperFunc),
+ OffloadingArgs);
+} else {

Can we at least assert MapperFunc is non null if standalone is true. It seems 
like an invariant almost worth documenting, at least with an assertion + 
message.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4761
+if (CondConstant)
+  ThenGen(Builder.saveIP(), Builder.saveIP());
+else

In the call above you pass the AllocaIP here, now it is both times the saveIP. 
I doubt this is correct. Allocas will end up in the wrong spot, won't they? Do 
we have a test for that?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4741
+  if (IsFinished && BB->use_empty()) {
+delete BB;
+return;

TIFitis wrote:
> jdoerfert wrote:
> > you should not just delete BB. eraseFromParent is a better way. That said, 
> > it is also weird you would delete something in an "emit" function.
> I've changed it.
> 
> The `emitBlock`, `emitBranch` and `emitIfClause` functions are ported from 
> Clang btw.
> //clang/lib/CodeGen/CGStmt.cpp//
That might be so, but given the name and initial documentation, nobody would 
have expected this function to delete the block, or at least I would not have.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146557/new/

https://reviews.llvm.org/D146557

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


[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-14 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl marked 4 inline comments as done.
brendandahl added inline comments.



Comment at: lld/test/wasm/custom-undefine.s:17
+.type   bar,@function
+bar:
+.functype   bar () -> ()

dschuff wrote:
> I don't fully understand how this test is different from custom-attr.s. Bar 
> is still defined, so the only thing I can see that's different is that it's 
> not called. Is it relying on the linker GCing bar so that it's not defined? 
> is the result different when bar is really undefined?
Undefined is a bad name. I'll change to unreferenced or something. This tests 
when the function isn't referenced a tombstone will be placed in the custom 
section (e.g. the payload below has a ).



Comment at: lld/test/wasm/merge-custom-attr-section.ll:47
+}
+
+attributes #0 = { "wasm-custom"="custom0" }

sbc100 wrote:
> Is there some reason we can't use assembly for this test?
Nope, I rewrote the other two, but missed this one. I'll fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150803/new/

https://reviews.llvm.org/D150803

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


[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-14 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl updated this revision to Diff 531390.
brendandahl marked an inline comment as done.
brendandahl added a comment.

Review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150803/new/

https://reviews.llvm.org/D150803

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/WebAssembly/wasm-custom-attr.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-wasm-custom.c
  clang/test/Sema/wasm-custom-support.c
  lld/test/wasm/custom-attr-tombstone.s
  lld/test/wasm/custom-attr.s
  lld/test/wasm/merge-custom-attr-section.s
  lld/wasm/InputChunks.cpp
  lld/wasm/InputFiles.cpp
  llvm/include/llvm/BinaryFormat/WasmRelocs.def
  llvm/include/llvm/MC/MCExpr.h
  llvm/lib/MC/MCExpr.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
  llvm/test/CodeGen/WebAssembly/custom-attr.ll
  llvm/test/MC/WebAssembly/custom-attr.s

Index: llvm/test/MC/WebAssembly/custom-attr.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/custom-attr.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
+# Check that it also comiled to object for format.
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
+
+foo:
+.globl foo
+.functype foo () -> ()
+end_function
+
+.section.custom_section.func_attr.custom0,"",@
+.int32  foo@FUNCINDEX
+
+# CHECK:   .section .custom_section.func_attr.custom0,"",@
+# CHECK-NEXT: .int32  foo@FUNCINDEX
+
+# CHECK-OBJ:- Type:CUSTOM
+# CHECK-OBJ-NEXT: Relocations:
+# CHECK-OBJ-NEXT:- Type:R_WASM_FUNCTION_INDEX_I32
+# CHECK-OBJ-NEXT:  Index:   0
+# CHECK-OBJ-NEXT:  Offset:  0x0
+# CHECK-OBJ-NEXT: Name:func_attr.custom0
Index: llvm/test/CodeGen/WebAssembly/custom-attr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/custom-attr.ll
@@ -0,0 +1,24 @@
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+define void @test0() #0 {
+  ret void
+}
+
+define void @test1() #0 {
+  ret void
+}
+
+define void @test3() #1 {
+  ret void
+}
+
+attributes #0 = { "wasm-custom"="custom0" }
+attributes #1 = { "wasm-custom"="custom1" }
+
+; CHECK:  .section.custom_section.func_attr.custom0,"",@
+; CHECK-NEXT: .int32  test0@FUNCINDEX
+; CHECK-NEXT: .int32  test1@FUNCINDEX
+; CHECK:  .section.custom_section.func_attr.custom1,"",@
+; CHECK-NEXT: .int32  test3@FUNCINDEX
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
@@ -66,6 +66,7 @@
   void emitEndOfAsmFile(Module &M) override;
   void EmitProducerInfo(Module &M);
   void EmitTargetFeatures(Module &M);
+  void EmitCustomFunctionAttributes(Module &M);
   void emitSymbolType(const MCSymbolWasm *Sym);
   void emitGlobalVariable(const GlobalVariable *GV) override;
   void emitJumpTableInfo() override;
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -25,6 +25,7 @@
 #include "WebAssemblyRegisterInfo.h"
 #include "WebAssemblyRuntimeLibcallSignatures.h"
 #include "WebAssemblyTargetMachine.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/BinaryFormat/Wasm.h"
@@ -438,6 +439,7 @@
 
   EmitProducerInfo(M);
   EmitTargetFeatures(M);
+  EmitCustomFunctionAttributes(M);
 }
 
 void WebAssemblyAsmPrinter::EmitProducerInfo(Module &M) {
@@ -556,6 +558,34 @@
   OutStreamer->popSection();
 }
 
+void WebAssemblyAsmPrinter::EmitCustomFunctionAttributes(Module &M) {
+  DenseMap> CustomSections;
+  // Group all the custom attributes by name.
+  for (const auto &F : M) {
+auto *Sym = cast(getSymbol(&F));
+if (F.hasFnAttribute("wasm-custom")) {
+  StringRef Name = F.getFnAttribute("wasm-custom").getValueAsString();
+  CustomSections[Name].push_back(Sym);
+}
+  }
+
+  // Emit a custom section for each unique attribute.
+  for (auto [Name, Symbols] : CustomSections) {
+MCSectionWasm *CustomSection = OutContext.getWasmSection(
+".custom_section.fu

[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-14 Thread Christian Ulmann via Phabricator via cfe-commits
Dinistro added a comment.

In D148697#4421643 , @PiotrZSL wrote:

> @Dinistro It compiles & links with clang 16 also (shared libs). So I'm unable 
> to reproduce.

I used the following command to build:

  cmake -S/home/christianu/repos/llvm-project/llvm 
-B/home/christianu/repos/llvm-project/build-clang-tidy -GNinja 
-DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" 
-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_ASSERTIONS=ON -DBUILD_SHARED_LIBS=ON 
-DLLVM_INCLUDE_UTILS=ON -DLLVM_INSTALL_UTILS=ON -DLLVM_BUILD_EXAMPLES=OFF 
-DLLVM_CCACHE_BUILD=ON -DLLVM_OPTIMIZED_TABLEGEN=ON -DCMAKE_BUILD_TYPE=Debug 
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ 
-DLLVM_ENABLE_RUNTIMES=openmp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148697/new/

https://reviews.llvm.org/D148697

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


[PATCH] D152554: [OpenMP] Migrate deviice code privatization from Clang CodeGen to OMPIRBuilder

2023-06-14 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 531395.
TIFitis added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152554/new/

https://reviews.llvm.org/D152554

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4085,7 +4085,7 @@
 omp::RuntimeFunction *MapperFunc,
 function_ref
 BodyGenCB,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
@@ -4127,6 +4127,14 @@
 
   Builder.CreateCall(BeginMapperFunc, OffloadingArgs);
 
+  for (auto DeviceMap : Info.DevicePtrInfoMap) {
+if (isa(DeviceMap.second.second)) {
+  auto *LI =
+  Builder.CreateLoad(Builder.getPtrTy(), DeviceMap.second.first);
+  Builder.CreateStore(LI, DeviceMap.second.second);
+}
+  }
+
   // If device pointer privatization is required, emit the body of the
   // region here. It will have to be duplicated: with and without
   // privatization.
@@ -4538,7 +4546,7 @@
 void OpenMPIRBuilder::emitOffloadingArrays(
 InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
 TargetDataInfo &Info, bool IsNonContiguous,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
 
   // Reset the array information.
@@ -4673,9 +4681,21 @@
 BPVal, BP, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
 
 if (Info.requiresDevicePointerInfo()) {
-  assert(DeviceAddrCB &&
- "DeviceAddrCB missing for DevicePtr code generation");
-  DeviceAddrCB(I, BP, BPVal);
+  if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Pointer) {
+CodeGenIP = Builder.saveIP();
+Builder.restoreIP(AllocaIP);
+Info.DevicePtrInfoMap[BPVal] = {
+BP, Builder.CreateAlloca(Builder.getPtrTy(), nullptr, "xyz")};
+Builder.restoreIP(CodeGenIP);
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, Info.DevicePtrInfoMap[BPVal].second);
+  } else if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Address) {
+Info.DevicePtrInfoMap[BPVal] = {BP, BP};
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, BP);
+  }
 }
 
 Value *PVal = CombinedInfo.Pointers[I];
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1568,6 +1568,9 @@
   public:
 TargetDataRTArgs RTArgs;
 
+SmallMapVector, 4>
+DevicePtrInfoMap;
+
 /// Indicate whether any user-defined mapper exists.
 bool HasMapper = false;
 /// The total number of pointers passed to the runtime library.
@@ -1594,7 +1597,9 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  enum class DeviceInfoTy { None, Pointer, Address };
   using MapValuesArrayTy = SmallVector;
+  using MapDeviceInfoArrayTy = SmallVector;
   using MapFlagsArrayTy = SmallVector;
   using MapNamesArrayTy = SmallVector;
   using MapDimArrayTy = SmallVector;
@@ -1613,6 +1618,7 @@
 };
 MapValuesArrayTy BasePointers;
 MapValuesArrayTy Pointers;
+MapDeviceInfoArrayTy DevicePointers;
 MapValuesArrayTy Sizes;
 MapFlagsArrayTy Types;
 MapNamesArrayTy Names;
@@ -1623,6 +1629,8 @@
   BasePointers.append(CurInfo.BasePointers.begin(),
   CurInfo.BasePointers.end());
   Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  DevicePointers.append(CurInfo.DevicePointers.begin(),
+CurInfo.DevicePointers.end());
   Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
   Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
   Names.append(CurInfo.Names.begin(), CurInfo.Names.end());
@@ -1659,7 +1667,7 @@
   void emitOffloadingArrays(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
   TargetDataInfo &Info, bool IsNonContiguous = false,
-  function_ref DeviceAddrCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
   function_ref CustomMapperCB = nullptr);
 
   /// Creates offloading entry for the provided entry ID \a ID, address \a
@@ -2046,7 +2054,7 @@
  

[PATCH] D152554: [OpenMP] Migrate deviice code privatization from Clang CodeGen to OMPIRBuilder

2023-06-14 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 531401.
TIFitis added a comment.

Fixed typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152554/new/

https://reviews.llvm.org/D152554

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4085,7 +4085,7 @@
 omp::RuntimeFunction *MapperFunc,
 function_ref
 BodyGenCB,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
@@ -4127,6 +4127,14 @@
 
   Builder.CreateCall(BeginMapperFunc, OffloadingArgs);
 
+  for (auto DeviceMap : Info.DevicePtrInfoMap) {
+if (isa(DeviceMap.second.second)) {
+  auto *LI =
+  Builder.CreateLoad(Builder.getPtrTy(), DeviceMap.second.first);
+  Builder.CreateStore(LI, DeviceMap.second.second);
+}
+  }
+
   // If device pointer privatization is required, emit the body of the
   // region here. It will have to be duplicated: with and without
   // privatization.
@@ -4538,7 +4546,7 @@
 void OpenMPIRBuilder::emitOffloadingArrays(
 InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
 TargetDataInfo &Info, bool IsNonContiguous,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
 
   // Reset the array information.
@@ -4673,9 +4681,21 @@
 BPVal, BP, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
 
 if (Info.requiresDevicePointerInfo()) {
-  assert(DeviceAddrCB &&
- "DeviceAddrCB missing for DevicePtr code generation");
-  DeviceAddrCB(I, BP, BPVal);
+  if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Pointer) {
+CodeGenIP = Builder.saveIP();
+Builder.restoreIP(AllocaIP);
+Info.DevicePtrInfoMap[BPVal] = {
+BP, Builder.CreateAlloca(Builder.getPtrTy())};
+Builder.restoreIP(CodeGenIP);
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, Info.DevicePtrInfoMap[BPVal].second);
+  } else if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Address) {
+Info.DevicePtrInfoMap[BPVal] = {BP, BP};
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, BP);
+  }
 }
 
 Value *PVal = CombinedInfo.Pointers[I];
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1568,6 +1568,9 @@
   public:
 TargetDataRTArgs RTArgs;
 
+SmallMapVector, 4>
+DevicePtrInfoMap;
+
 /// Indicate whether any user-defined mapper exists.
 bool HasMapper = false;
 /// The total number of pointers passed to the runtime library.
@@ -1594,7 +1597,9 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  enum class DeviceInfoTy { None, Pointer, Address };
   using MapValuesArrayTy = SmallVector;
+  using MapDeviceInfoArrayTy = SmallVector;
   using MapFlagsArrayTy = SmallVector;
   using MapNamesArrayTy = SmallVector;
   using MapDimArrayTy = SmallVector;
@@ -1613,6 +1618,7 @@
 };
 MapValuesArrayTy BasePointers;
 MapValuesArrayTy Pointers;
+MapDeviceInfoArrayTy DevicePointers;
 MapValuesArrayTy Sizes;
 MapFlagsArrayTy Types;
 MapNamesArrayTy Names;
@@ -1623,6 +1629,8 @@
   BasePointers.append(CurInfo.BasePointers.begin(),
   CurInfo.BasePointers.end());
   Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  DevicePointers.append(CurInfo.DevicePointers.begin(),
+CurInfo.DevicePointers.end());
   Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
   Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
   Names.append(CurInfo.Names.begin(), CurInfo.Names.end());
@@ -1659,7 +1667,7 @@
   void emitOffloadingArrays(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
   TargetDataInfo &Info, bool IsNonContiguous = false,
-  function_ref DeviceAddrCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
   function_ref CustomMapperCB = nullptr);
 
   /// Creates offloading entry for the provided entry ID \a ID, address \a
@@ -2046,7 +2054,7 @@
   function

[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Basic/Builtins.cpp:33
 static constexpr Builtin::Info BuiltinInfo[] = {
-{"not a builtin function", nullptr, nullptr, nullptr, 
HeaderDesc::NO_HEADER,
+#define INTERESTING_IDENTIFIER(ID) 
\
+  {#ID, nullptr, nullptr, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},

zahiraam wrote:
> From your comment in Builtin.h: "You shouldn't muddle this into Builtin::ID."
> This means this shouldn't happen here. It should be done in 
> IdentiferTable::AddKeywords as I had done previously?
You shouldn't be adding entries for the interesting keywords to the builtins 
table, no.  This table is indexed by Builtin::ID.

I agree that `AddKeywords` seems like the right place to set up the interesting 
identifiers rather than `initializeBuiltins`.



Comment at: clang/lib/Basic/Builtins.cpp:138
+  // Step #2: mark all target-independent builtins with their ID's.
+  for (unsigned i = FirstBuiltinID; i != Builtin::FirstTSBuiltin; ++i)
 if (builtinIsSupported(BuiltinInfo[i], LangOpts)) {

You shouldn't use FirstBuiltinID and FirstInterestingIdentifierID as the 
starting points here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146148/new/

https://reviews.llvm.org/D146148

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


[PATCH] D150023: [ABI] [C++20] [Modules] Don't generate vtable if the class is defined in other module unit

2023-06-14 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao added a comment.

> Looks like this breaks check-clang on Mac: 
> http://45.33.8.238/macm1/62779/step_7.txt

Same here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150023/new/

https://reviews.llvm.org/D150023

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


[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as` on AIX

2023-06-14 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

In D152924#4421624 , @steven_wu wrote:

> `lld` does not use LTOCodeGenerator.
>
> I am also not sure how disable integrated assembler suppose to work? Do you 
> have an end to end design for how to invoke assembler during linking? For 
> current libLTO API, this is probably going to produce assembler file buffer 
> to linker, which is not usable by linker.

Thanks for chiming in @steven_wu! This patch is enabling 
`-f[no-]-integrated-as` on //AIX only//. There is already code to invoke the 
assembler during linking 
https://github.com/llvm/llvm-project/blob/807adcf4b9cca5586fd1fb669811768528d9dd1d/llvm/lib/LTO/LTOCodeGenerator.cpp#L343.
 `clang` will emit a warning on other platforms. The patch title is revised to 
reflect that this feature is AIX only at the moment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152924/new/

https://reviews.llvm.org/D152924

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


[PATCH] D152472: [Clang][MS] Remove assertion on BaseOffset can't be smaller than Size.

2023-06-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:3727
+SmallVector Bases;
+for (auto Base: Info.CXXInfo->BaseOffsets) {
+  Bases.push_back(Base.second.getQuantity());

Rather than iterating the map and sorting afterwards, IMO it's better to 
iterate `RD->bases()` and look each base up in the map and use that offset. It 
guarantees they'll be in the right order, even if the offsets aren't in 
ascending order (although due to the ABI, they usually are).



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:3739
+SmallVector VBases;
+for (auto VBase: Info.CXXInfo->VBaseOffsets) {
+  VBases.push_back(VBase.second.VBaseOffset.getQuantity());

Ditto here, better to iterate over vbases().



Comment at: clang/lib/Frontend/LayoutOverrideSource.cpp:38
+  unsigned long long Offset = 0;
+  (void)S.substr(0, Idx).getAsInteger(10, Offset);
+  S = S.substr(Idx);

Can you pass in ULL directly here, rather than making a local and copying it 
out?



Comment at: clang/lib/Frontend/LayoutOverrideSource.cpp:230
+unsigned NumVB = 0;
+for (const auto &I : RD->bases()) {
+  const CXXRecordDecl *Base = I.getType()->getAsCXXRecordDecl();

I think it's better to iterate `vbases()` directly, and then iterate bases() 
and skip bases that are virtual.



Comment at: clang/test/CodeGenCXX/override-layout-ms.cpp:1
+// RUN: %clang_cc1 -w -triple=x86_64-pc-win32 -fms-compatibility 
-fdump-record-layouts 
-foverride-record-layout=%S/Inputs/override-layout-ms.layout %s | FileCheck  %s
+

Go ahead and add a second RUN line without the "override-record-layout" flag to 
confirm the layout is correct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152472/new/

https://reviews.llvm.org/D152472

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


[clang-tools-extra] 19c9af8 - [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-14 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-06-14T13:51:00-04:00
New Revision: 19c9af81b1c5dd7b3d11d235a77b7181b9368a28

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

LOG: [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl()

Fixes https://github.com/clangd/clangd/issues/1663

Differential Revision: https://reviews.llvm.org/D152500

Added: 


Modified: 
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/HeuristicResolver.cpp 
b/clang-tools-extra/clangd/HeuristicResolver.cpp
index 460b9be592baa..e91bd0e87a8b7 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.cpp
+++ b/clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -35,6 +35,9 @@ const auto TemplateFilter = [](const NamedDecl *D) {
 CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
   assert(T);
 
+  // Unwrap type sugar such as type aliases.
+  T = T->getCanonicalTypeInternal().getTypePtr();
+
   if (const auto *RT = T->getAs())
 return dyn_cast(RT->getDecl());
 

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index fe87e4be3940e..d54539b53badd 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -863,6 +863,20 @@ TEST_F(TargetDeclTest, DependentExprs) {
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr",
"template  T convert() const");
+
+  Code = R"cpp(
+template 
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+void foo(Wally w) {
+  w.[[find]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {



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


[PATCH] D152500: [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-14 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19c9af81b1c5: [clangd] Unwrap type sugar in 
HeuristicResolver::resolveTypeToRecordDecl() (authored by nridge).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152500/new/

https://reviews.llvm.org/D152500

Files:
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -863,6 +863,20 @@
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr",
"template  T convert() const");
+
+  Code = R"cpp(
+template 
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+void foo(Wally w) {
+  w.[[find]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -35,6 +35,9 @@
 CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
   assert(T);
 
+  // Unwrap type sugar such as type aliases.
+  T = T->getCanonicalTypeInternal().getTypePtr();
+
   if (const auto *RT = T->getAs())
 return dyn_cast(RT->getDecl());
 


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -863,6 +863,20 @@
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr",
"template  T convert() const");
+
+  Code = R"cpp(
+template 
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+void foo(Wally w) {
+  w.[[find]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -35,6 +35,9 @@
 CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
   assert(T);
 
+  // Unwrap type sugar such as type aliases.
+  T = T->getCanonicalTypeInternal().getTypePtr();
+
   if (const auto *RT = T->getAs())
 return dyn_cast(RT->getDecl());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152788: [Clang] Show type in enum out of range diagnostic

2023-06-14 Thread Dimitry Andric via Phabricator via cfe-commits
dim added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2479-2486
+template struct Bitfield {
+  static constexpr T max = static_cast((1 << size) - 1);
+};
+
+void testValueInRangeOfEnumerationValuesViaTemplate() {
+  Bitfield good;
+  Bitfield bad;

aaron.ballman wrote:
> Equivalent but a bit easier to tell where the diagnostic is expected to 
> happen at.
> 
> Perhaps a good follow-up would be to find out why we're not printing an 
> "instantiated from here" note for this case (CC @shafik), but no need to do 
> that for this patch.
Ah, I didn't know that syntax. At first I had the `cxx11-error@` just below the 
`static_cast` in the `Bitfield` class, but it seemed clearer to do it the way I 
did.

That said, you are right that it would probably be handy to show where the 
instantiation is coming from (if there is a template involved), because 
currently it does not point you to the exact source line where the problem is: 
in this case the `bad` declaration.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152788/new/

https://reviews.llvm.org/D152788

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


[PATCH] D93829: [clangd] Support outgoing calls in call hierarchy

2023-06-14 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thank you Sam for the suggested performance improvements, and outlining a way 
forward.

@qchateau, are you interested in updating the patch to implement some of the 
described optimizations / address other comments?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93829/new/

https://reviews.llvm.org/D93829

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


  1   2   3   >