[clang] 724d689 - [Driver][test] Add --cuda-path= and ignore %clang exit code for -mcpu=native

2023-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-28T22:14:36-07:00
New Revision: 724d68967018deb86e56a5e269500833b54945f8

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

LOG: [Driver][test] Add --cuda-path= and ignore %clang exit code for 
-mcpu=native

Their exit code is otherwise dependent on whether /usr/local/cuda exists or the 
default target triple.

Added: 


Modified: 
clang/test/Driver/aarch64-mcpu.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/cuda-bad-arch.cu
clang/test/Driver/cuda-flush-denormals-to-zero.cu
clang/test/Driver/cuda-openmp-driver.cu
clang/test/Driver/cuda-options.cu
clang/test/Driver/cuda-output-asm.cu
clang/test/Driver/fbasic-block-sections.c
clang/test/Driver/lto.cu
clang/test/Driver/opt-record.c
clang/test/Driver/riscv-cpus.c

Removed: 




diff  --git a/clang/test/Driver/aarch64-mcpu.c 
b/clang/test/Driver/aarch64-mcpu.c
index 6b2c5786256eb6..321d3a739b3535 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -19,7 +19,8 @@
 
 // We cannot check much for -mcpu=native, but it should be replaced by either 
generic or a valid
 // Arm cpu string, depending on the host.
-// RUN: %clang --target=arm64 -mcpu=native -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-NATIVE %s
+// RUN: %clang --target=arm64 -mcpu=native -### -c %s 2> %t.err || true
+// RUN: FileCheck --input-file=%t.err -check-prefix=ARM64-NATIVE %s
 // ARM64-NATIVE-NOT: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"native"
 
 // RUN: %clang --target=arm64-apple-ios -arch arm64 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-IOS %s

diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 8a27140cd16e5f..d0691211bd6d98 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -60,7 +60,7 @@
 
 //
 // RUN: %clang -### -x cuda -nocudainc -nocudalib \
-// RUN:-c -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 \
+// RUN:-c -fprofile-sample-use=%S/Inputs/file.prof 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:  | FileCheck -check-prefix=CHECK-CUDA-SAMPLE-PROFILE %s
 // -fprofile-sample-use should not be passed to the GPU compilation
 // CHECK-CUDA-SAMPLE-PROFILE: "-cc1"

diff  --git a/clang/test/Driver/cuda-bad-arch.cu 
b/clang/test/Driver/cuda-bad-arch.cu
index 14da44cdedf94a..47bfb2daa80c98 100644
--- a/clang/test/Driver/cuda-bad-arch.cu
+++ b/clang/test/Driver/cuda-bad-arch.cu
@@ -3,7 +3,7 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 
2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s

diff  --git a/clang/test/Driver/cuda-flush-denormals-to-zero.cu 
b/clang/test/Driver/cuda-flush-denormals-to-zero.cu
index 15525f9c1b814b..ea808f2302fbb7 100644
--- a/clang/test/Driver/cuda-flush-denormals-to-zero.cu
+++ b/clang/test/Driver/cuda-flush-denormals-to-zero.cu
@@ -2,14 +2,14 @@
 // -fgpu-flush-denormals-to-zero. This should be translated to
 // -fdenormal-fp-math-f32=preserve-sign
 
-// RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_20 -fgpu-flush-denormals-to-zero -nocudainc -nocudalib %s 
2>&1 | FileCheck -check-prefix=FTZ %s
-// RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_20 -fno-gpu-flush-denormals-to-zero -nocudainc -nocudalib %s 
2>&1 | FileCheck -check-prefix=NOFTZ %s
+// RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_20 -fgpu-flush-denormals-to-zero -nocudainc -nocudalib 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 | FileCheck -check-prefix=FTZ 
%s
+// RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_20 -fno-gpu-flush-denormals-to-zero -nocudainc -nocudalib 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 | FileCheck 
-check-prefix=NOFTZ %s
 // RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_70 -fgpu-flush-denormals-to-zero -nocudainc -nocudalib %s 
2>&1 | FileCheck -check-prefix=FTZ %s
 // RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_70 -fno-gpu-flush-denormals-to-zero -nocudainc -nocudalib %s 
2>&1 | FileCheck -check-prefix=NOFTZ %s
 
 // Test alias options -f[no-]cuda-flush-denormals-to-zero
-// RUN: %clang -### --target=x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_20 -fcuda-flush-denormals-to-zero -nocudainc -nocudalib %s 
2>&1 | FileCheck 

[clang] f7f65b6 - [test] Set target triple for Driver/miamcu-opt.c

2023-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-28T22:06:11-07:00
New Revision: f7f65b68b0e774feee59d4860033ddccc67c134d

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

LOG: [test] Set target triple for Driver/miamcu-opt.c

Otherwise %clang may fail if the default target triple isn't x86.

Added: 


Modified: 
clang/test/Driver/miamcu-opt.c

Removed: 




diff  --git a/clang/test/Driver/miamcu-opt.c b/clang/test/Driver/miamcu-opt.c
index e668b6ad828fec..fd3ab7152f8459 100644
--- a/clang/test/Driver/miamcu-opt.c
+++ b/clang/test/Driver/miamcu-opt.c
@@ -1,13 +1,11 @@
-// REQUIRES: x86-registered-target
-//
-// RUN: %clang -miamcu -rtlib=platform -### %s 2>&1 | FileCheck %s
-// RUN: %clang -miamcu -rtlib=platform -m32 -### %s 2>&1 | FileCheck %s
-// RUN: %clang -miamcu -rtlib=platform --target=x86_64-unknown-linux-gnu -### 
%s 2>&1 | FileCheck %s
-// RUN: %clang -mno-iamcu -miamcu -rtlib=platform -### %s 2>&1 | FileCheck %s
-// RUN: %clang -miamcu -rtlib=platform -m64 -### %s 2>&1 | FileCheck %s 
-check-prefix=M64
-// RUN: %clang -miamcu -rtlib=platform -dynamic -### %s 2>&1 | FileCheck %s 
-check-prefix=DYNAMIC
-// RUN: %clang -miamcu -rtlib=platform  --target=armv8-eabi -### %s 2>&1 | 
FileCheck %s -check-prefix=NOT-X86
-// RUN: %clang -miamcu -mno-iamcu --target=x86_64-unknown-linux-gnu -### %s 
2>&1 | FileCheck %s -check-prefix=MNOIAMCU
+// RUN: %clang -### --target=x86_64 -miamcu -rtlib=platform %s 2>&1 | 
FileCheck %s
+// RUN: %clang -### --target=x86_64 -miamcu -rtlib=platform -m32 %s 2>&1 | 
FileCheck %s
+// RUN: %clang -### --target=x86_64 -miamcu -rtlib=platform 
--target=x86_64-unknown-linux-gnu %s 2>&1 | FileCheck %s
+// RUN: %clang -### --target=x86_64 -mno-iamcu -miamcu -rtlib=platform %s 2>&1 
| FileCheck %s
+// RUN: %clang -### --target=x86_64 -miamcu -rtlib=platform -m64 %s 2>&1 | 
FileCheck %s -check-prefix=M64
+// RUN: %clang -### --target=x86_64 -miamcu -rtlib=platform -dynamic %s 2>&1 | 
FileCheck %s -check-prefix=DYNAMIC
+// RUN: %clang -### --target=x86_64 -miamcu -rtlib=platform  
--target=armv8-eabi %s 2>&1 | FileCheck %s -check-prefix=NOT-X86
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -miamcu -mno-iamcu %s 
2>&1 | FileCheck %s -check-prefix=MNOIAMCU
 
 // M64: error: invalid argument '-miamcu' not allowed with '-m64'
 



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


[PATCH] D141892: Implement modernize-use-constraints

2023-07-28 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 545332.
ccotter added a comment.

- Fix ReleaseNotes again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141892

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.h
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints-first-greatergreater.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
@@ -0,0 +1,726 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-constraints %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template  struct enable_if { };
+
+template  struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+} // namespace std
+// NOLINTEND
+
+template 
+struct ConsumeVariadic;
+
+struct Obj {
+};
+
+namespace enable_if_in_return_type {
+
+
+// Section 1: enable_if in return type of function
+
+
+
+// General tests
+
+
+template 
+typename std::enable_if::type basic() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t basic_t() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic_t() requires T::some_value {{{$}}
+
+template 
+auto basic_trailing() -> typename std::enable_if::type {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:26: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}auto basic_trailing() -> Obj requires T::some_value {{{$}}
+
+template 
+typename std::enable_if::type existing_constraint() requires (T::another_value) {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}typename std::enable_if::type existing_constraint() requires (T::another_value) {{{$}}
+
+template 
+typename std::enable_if::type decl_without_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def() {
+  return Obj{};
+}
+// FIXME - Support definitions with separate decls
+
+template 
+std::enable_if_t no_dependent_type(U) {
+  return Obj{};
+}
+// FIXME - Support non-dependent enable_ifs. Low priority though...
+
+template 
+typename std::enable_if::type* pointer_of_enable_if() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t* pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+const std::enable_if_t* const_pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}const int* const_pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t const * const_pointer_of_enable_if_t2() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int const * const_pointer_of_enable_if_t2() requires T::some_value {{{$}}
+
+
+template 
+std::enable_if_t& reference_of_enable_if_t() {
+  static int x; return x;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if 

[PATCH] D141892: Implement modernize-use-constraints

2023-07-28 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 545331.
ccotter added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141892

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.h
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints-first-greatergreater.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
@@ -0,0 +1,726 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-constraints %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template  struct enable_if { };
+
+template  struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+} // namespace std
+// NOLINTEND
+
+template 
+struct ConsumeVariadic;
+
+struct Obj {
+};
+
+namespace enable_if_in_return_type {
+
+
+// Section 1: enable_if in return type of function
+
+
+
+// General tests
+
+
+template 
+typename std::enable_if::type basic() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t basic_t() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic_t() requires T::some_value {{{$}}
+
+template 
+auto basic_trailing() -> typename std::enable_if::type {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:26: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}auto basic_trailing() -> Obj requires T::some_value {{{$}}
+
+template 
+typename std::enable_if::type existing_constraint() requires (T::another_value) {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}typename std::enable_if::type existing_constraint() requires (T::another_value) {{{$}}
+
+template 
+typename std::enable_if::type decl_without_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def() {
+  return Obj{};
+}
+// FIXME - Support definitions with separate decls
+
+template 
+std::enable_if_t no_dependent_type(U) {
+  return Obj{};
+}
+// FIXME - Support non-dependent enable_ifs. Low priority though...
+
+template 
+typename std::enable_if::type* pointer_of_enable_if() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t* pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+const std::enable_if_t* const_pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}const int* const_pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t const * const_pointer_of_enable_if_t2() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int const * const_pointer_of_enable_if_t2() requires T::some_value {{{$}}
+
+
+template 
+std::enable_if_t& reference_of_enable_if_t() {
+  static int x; return x;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// 

[clang] 80765ed - [Driver][test] Ignore %clang exit code for -mcpu=native tests

2023-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-28T21:31:44-07:00
New Revision: 80765ede5bbcca1364c2d4ae06127011eaba6389

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

LOG: [Driver][test] Ignore %clang exit code for -mcpu=native tests

They may be either 0 or 1, depending whether `--target=` specifies a
native target.

Added: 


Modified: 
clang/test/Driver/aarch64-mcpu.c
clang/test/Driver/ppc-cpus.c
clang/test/Driver/riscv-cpus.c

Removed: 




diff  --git a/clang/test/Driver/aarch64-mcpu.c 
b/clang/test/Driver/aarch64-mcpu.c
index abcdf98e1f9652..321d3a739b3535 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -19,7 +19,8 @@
 
 // We cannot check much for -mcpu=native, but it should be replaced by either 
generic or a valid
 // Arm cpu string, depending on the host.
-// RUN: not %clang --target=arm64 -mcpu=native -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-NATIVE %s
+// RUN: %clang --target=arm64 -mcpu=native -### -c %s 2> %t.err || true
+// RUN: FileCheck --input-file=%t.err -check-prefix=ARM64-NATIVE %s
 // ARM64-NATIVE-NOT: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"native"
 
 // RUN: %clang --target=arm64-apple-ios -arch arm64 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-IOS %s

diff  --git a/clang/test/Driver/ppc-cpus.c b/clang/test/Driver/ppc-cpus.c
index 51ff2492eb8fab..b0fd539b198a2c 100644
--- a/clang/test/Driver/ppc-cpus.c
+++ b/clang/test/Driver/ppc-cpus.c
@@ -2,7 +2,8 @@
 // MCPU_PPC64: "-target-cpu" "ppc64"
 
 /// We cannot check much for -mcpu=native, but it should be replaced by a CPU 
name.
-// RUN: %clang -### -c --target=powerpc64 %s -mcpu=native 2>&1 | FileCheck 
--check-prefix=MCPU_NATIVE %s
+// RUN: %clang -### -c --target=powerpc64 %s -mcpu=native 2> %t.err || true
+// RUN: FileCheck --input-file=%t.err -check-prefix=MCPU_NATIVE %s
 // MCPU_NATIVE-NOT: "-target-cpu" "native"
 
 /// Check that we are passing unknown mcpu options to the backend so an error

diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index a7d4c3635410f3..bd8488d81c0b15 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -21,7 +21,8 @@
 // MCPU-SYNTACORE-SCR1-MAX: "-target-abi" "ilp32"
 
 // We cannot check much for -mcpu=native, but it should be replaced by a valid 
CPU string.
-// RUN: not %clang --target=riscv64 -### -c %s 2>&1 -mcpu=native | FileCheck 
-check-prefix=MCPU-NATIVE %s
+// RUN: %clang --target=riscv64 -### -c %s -mcpu=native 2> %t.err || true
+// RUN: FileCheck --input-file=%t.err -check-prefix=MCPU-NATIVE %s
 // MCPU-NATIVE-NOT: "-target-cpu" "native"
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=rocket-rv32 | FileCheck 
-check-prefix=MTUNE-ROCKET32 %s



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


[clang] 9155e51 - [Driver][test] Add --cuda-path= to some tests

2023-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-28T21:21:42-07:00
New Revision: 9155e517e6e1cda474d0d0fa82f71696c325bc10

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

LOG: [Driver][test] Add --cuda-path= to some tests

Their exit code is otherwise dependent on whether /usr/local/cuda exists.

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c
clang/test/Driver/cuda-arch-translation.cu
clang/test/Driver/cuda-bad-arch.cu
clang/test/Driver/cuda-bindings.cu
clang/test/Driver/cuda-flush-denormals-to-zero.cu
clang/test/Driver/cuda-openmp-driver.cu
clang/test/Driver/cuda-options.cu
clang/test/Driver/cuda-output-asm.cu
clang/test/Driver/fbasic-block-sections.c
clang/test/Driver/lto.cu
clang/test/Driver/nvptx-cuda-system-arch.c
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/opt-record.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 09fca3658456bc..f47f226b4386bd 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -59,8 +59,8 @@
 // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
 //
-// RUN: not %clang -### -x cuda -nocudainc -nocudalib \
-// RUN:-c -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 \
+// RUN: %clang -### -x cuda -nocudainc -nocudalib \
+// RUN:-c -fprofile-sample-use=%S/Inputs/file.prof 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:  | FileCheck -check-prefix=CHECK-CUDA-SAMPLE-PROFILE %s
 // -fprofile-sample-use should not be passed to the GPU compilation
 // CHECK-CUDA-SAMPLE-PROFILE: "-cc1"

diff  --git a/clang/test/Driver/cuda-arch-translation.cu 
b/clang/test/Driver/cuda-arch-translation.cu
index 4511d5cf1f5a02..f37964d87c66a1 100644
--- a/clang/test/Driver/cuda-arch-translation.cu
+++ b/clang/test/Driver/cuda-arch-translation.cu
@@ -28,7 +28,7 @@
 // RUN: | FileCheck -check-prefixes=CUDA,SM61 %s
 // RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_62 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM62 %s
-// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_70 %s 2>&1 
\
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_70 
--cuda-path=%S/Inputs/CUDA_111/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM70 %s
 // RUN: %clang -x hip -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=gfx600 
-nogpuinc -nogpulib %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=HIP,GFX600 %s

diff  --git a/clang/test/Driver/cuda-bad-arch.cu 
b/clang/test/Driver/cuda-bad-arch.cu
index 6c5f74a552933a..732f264e310a4f 100644
--- a/clang/test/Driver/cuda-bad-arch.cu
+++ b/clang/test/Driver/cuda-bad-arch.cu
@@ -3,7 +3,7 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN: not %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c 
%s 2>&1 \
+// RUN: not %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
 // RUN: not %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 
2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
@@ -22,7 +22,7 @@
 
 // RUN: not %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 
2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 // RUN: not %clang -### -x hip -target x86_64-linux-gnu --cuda-gpu-arch=gfx908 
-c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s

diff  --git a/clang/test/Driver/cuda-bindings.cu 
b/clang/test/Driver/cuda-bindings.cu
index 73109eef744810..79c9f6f0874c5f 100644
--- a/clang/test/Driver/cuda-bindings.cu
+++ b/clang/test/Driver/cuda-bindings.cu
@@ -190,10 +190,10 @@
 // Ensure we output the user's specified name in device-only mode.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -### \
-// RUN:--cuda-gpu-arch=sm_52 --cuda-device-only -c -o foo.o %s 2>&1 \
+// RUN:--cuda-gpu-arch=sm_52 --cuda-device-only -c -o foo.o 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefix=D_ONLY %s
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -### --offload-new-driver \
-// RUN:--cuda-gpu-arch=sm_52 --cuda-device-only -c -o foo.o %s 2>&1 \
+// RUN:--cuda-gpu-arch=sm_52 --cuda-device-only -c -o foo.o 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefix=D_ONLY %s
 // D_ONLY: "foo.o"
 
@@ -219,7 +219,7 @@
 // driver.
 // 
 // 

[clang] 2ca82f3 - [Driver][test] Add --cuda-path= to some tests

2023-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-28T20:27:40-07:00
New Revision: 2ca82f36813d984df9730794bcf6ba558daf0161

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

LOG: [Driver][test] Add --cuda-path= to some tests

An upcoming change D156363 will change -### to exit with code 1 if
hasErrorOccurred. Some AMDGPU tests would exit with code 1 due to not
found CUDA installation.

Added: 


Modified: 
clang/test/Driver/cuda-arch-translation.cu
clang/test/Driver/cuda-constructor-alias.cu
clang/test/Driver/cuda-cross-compiling.c
clang/test/Driver/cuda-dwarf-2.cu

Removed: 




diff  --git a/clang/test/Driver/cuda-arch-translation.cu 
b/clang/test/Driver/cuda-arch-translation.cu
index 97efcf4e7fbca0..4511d5cf1f5a02 100644
--- a/clang/test/Driver/cuda-arch-translation.cu
+++ b/clang/test/Driver/cuda-arch-translation.cu
@@ -4,63 +4,63 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM20 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_21 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_21 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM21 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_30 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM30 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_32 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_32 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM32 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_35 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM35 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_37 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_37 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM37 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_50 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_50 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM50 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_52 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_52 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM52 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_53 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_53 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM53 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_60 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_60 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM60 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_61 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_61 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM61 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_62 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_62 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=CUDA,SM62 %s
-// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_70 %s 2>&1 \
+// RUN: %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_70 %s 2>&1 
\
 // RUN: | FileCheck -check-prefixes=CUDA,SM70 %s
-// RUN: %clang -x hip -### -target x86_64-linux-gnu -c --cuda-gpu-arch=gfx600 
%s 2>&1 \
+// RUN: %clang -x hip -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=gfx600 
-nogpuinc -nogpulib %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=HIP,GFX600 %s
-// RUN: %clang -x hip -### -target x86_64-linux-gnu -c --cuda-gpu-arch=gfx601 
%s 2>&1 \
+// RUN: %clang -x hip -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=gfx601 
-nogpuinc -nogpulib %s 2>&1 \
 // RUN: | FileCheck -check-prefixes=HIP,GFX601 %s
-// RUN: %clang 

[clang] 2f79bb1 - [Driver][test] Add -nogpulib to some AMDGPU tests

2023-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-28T19:57:25-07:00
New Revision: 2f79bb10461d114783a1548201928549ace09755

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

LOG: [Driver][test] Add -nogpulib to some AMDGPU tests

An upcoming change D156363 will change -### to exit with code 1 if
hasErrorOccurred. Some AMDGPU tests would exit with code 0 due to not
found GPU installation.

Added: 


Modified: 
clang/test/Driver/amdgcn-gz-options.cl
clang/test/Driver/amdgcn-toolchain-pic.cl
clang/test/Driver/amdgpu-features.c
clang/test/Driver/amdgpu-openmp-toolchain.c
clang/test/Driver/amdgpu-toolchain-opencl.cl
clang/test/Driver/amdgpu-toolchain.c
clang/test/Driver/amdgpu-visibility.cl

Removed: 




diff  --git a/clang/test/Driver/amdgcn-gz-options.cl 
b/clang/test/Driver/amdgcn-gz-options.cl
index 0d09a714b0326b..8ffd58af509dbe 100644
--- a/clang/test/Driver/amdgcn-gz-options.cl
+++ b/clang/test/Driver/amdgcn-gz-options.cl
@@ -1,11 +1,11 @@
 // REQUIRES: zlib, amdgpu-registered-target
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -gz=none -x assembler %s 2>&1 | 
FileCheck -check-prefix CHECK-OPT_GZ_EQ_NONE %s
-// RUN: %clang -### -target amdgcn-amd-amdhsa -gz=none %s 2>&1 | FileCheck 
-check-prefix CHECK-OPT_GZ_EQ_NONE %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -gz=none -nogpulib %s 2>&1 | 
FileCheck -check-prefix CHECK-OPT_GZ_EQ_NONE %s
 // CHECK-OPT_GZ_EQ_NONE: {{.* "-cc1(as)?".* "--compress-debug-sections=none"}}
 // CHECK-OPT_GZ_EQ_NONE: "--compress-debug-sections=none"
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -gz=zlib -x assembler %s 2>&1 | 
FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
-// RUN: %clang -### -target amdgcn-amd-amdhsa -gz=zlib %s 2>&1 | FileCheck 
-check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa -gz=zlib -nogpulib %s 2>&1 | 
FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
 // CHECK-OPT_GZ_EQ_ZLIB: {{.* "-cc1(as)?".* "--compress-debug-sections=zlib"}}
 // CHECK-OPT_GZ_EQ_ZLIB: "--compress-debug-sections=zlib"

diff  --git a/clang/test/Driver/amdgcn-toolchain-pic.cl 
b/clang/test/Driver/amdgcn-toolchain-pic.cl
index acd5fe413ff71a..4d955a888fa2ce 100644
--- a/clang/test/Driver/amdgcn-toolchain-pic.cl
+++ b/clang/test/Driver/amdgcn-toolchain-pic.cl
@@ -1,4 +1,4 @@
-// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | 
FileCheck %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx803 -nogpulib %s 2>&1 
| FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | 
FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | 
FileCheck %s
 

diff  --git a/clang/test/Driver/amdgpu-features.c 
b/clang/test/Driver/amdgpu-features.c
index e4ff422d8ebadc..a516bc6b7ff200 100644
--- a/clang/test/Driver/amdgpu-features.c
+++ b/clang/test/Driver/amdgpu-features.c
@@ -1,4 +1,4 @@
-// RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx900:xnack+ %s 2>&1 | 
FileCheck --check-prefix=XNACK %s
+// RUN: %clang -### --target=amdgcn-amdhsa -mcpu=gfx900:xnack+ -nogpulib %s 
2>&1 | FileCheck --check-prefix=XNACK %s
 // XNACK: "-target-feature" "+xnack"
 
 // RUN: %clang -### -target amdgcn-amdpal -mcpu=gfx900:xnack- %s 2>&1 | 
FileCheck --check-prefix=NO-XNACK %s
@@ -7,7 +7,7 @@
 // RUN: %clang -### -target amdgcn-mesa3d -mcpu=gfx908:sramecc+ %s 2>&1 | 
FileCheck --check-prefix=SRAM-ECC %s
 // SRAM-ECC: "-target-feature" "+sramecc"
 
-// RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx908:sramecc- %s 2>&1 | 
FileCheck --check-prefix=NO-SRAM-ECC %s
+// RUN: %clang -### --target=amdgcn-amdhsa -mcpu=gfx908:sramecc- -nogpulib %s 
2>&1 | FileCheck --check-prefix=NO-SRAM-ECC %s
 // NO-SRAM-ECC: "-target-feature" "-sramecc"
 
 // RUN: %clang -### -target amdgcn -mcpu=gfx90A -mtgsplit %s 2>&1 | FileCheck 
--check-prefix=TGSPLIT %s

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 9a14f4594cfb5d..acb175b8663607 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,10 +1,10 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa \
-// RUN:  -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 
--libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib %s 2>&1 \
+// RUN:  -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 
--libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib -nogpulib %s 2>&1 \
 // RUN:   | FileCheck %s
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa \
-// RUN:  --offload-arch=gfx906 
--libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib %s 

[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-07-28 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D155145#4543326 , @anna wrote:

> We see a crash bisected to this patch about using an illegal instruction. 
> Here's the CPUInfo for the machine:
>
>   CPU info:
>   current cpu id: 22
>   total 32(physical cores 16) (assigned logical cores 32) (assigned physical 
> cores 16) (assigned_sockets:2 of 2) (8 cores per cpu, 2 threads per core) 
> family 6 model 45 stepping 7 microcode 0x71a, cmov, cx8, fxsr, mmx, sse, 
> sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, vzeroupper, avx, aes, clmul, ht, 
> tsc, tscinvbit, tscinv, clflush
>   AvgLoads: 0.30, 0.10, 0.18
>   CPU Model and flags from /proc/cpuinfo:
>   model name  : Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
>   flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
> cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx 
> pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology 
> nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est 
> tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt 
> tsc_deadline_timer aes xsave avx lahf_lm epb pti ssbd ibrs ibpb stibp 
> tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts 
> md_clear flush_l1d
>   Online cpus: 0-31
>   Offline cpus:
>   BIOS frequency limitation: 
>   Frequency switch latency (ns): 2
>   Available cpu frequencies: 
>   Current governor: schedutil
>   Core performance/turbo boost: 
>
> I don't see `avxvnniint16` in the flags list nor avx2. So, this (relatively 
> new) instruction shouldn't be generated for this machine. Any ideas on why 
> this might be happening?

As far as I can see from the patch, the only way to generate avxvnniint16 
instructions is to call its specific intrinsics explicitly. And we will check 
compiling options in FE before allowing to call the instructions. We do have an 
optimization to generate vnni instructions without intrinsics, but we haven't 
extend it to avxvnniint16 so far.
So I don't know what's wrong in your case, could you provide a reproducer for 
your problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D150124: [index][clangd] Consider labels when indexing function bodies

2023-07-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D150124#4542032 , @kadircet wrote:

> btw, thanks a lot Nathan for taking good care of clangd, I don't think I say 
> that enough

I'm happy to help!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150124

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


[PATCH] D150124: [index][clangd] Consider labels when indexing function bodies

2023-07-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang/lib/Index/IndexBody.cpp:150
+ParentDC,
+unsigned(SymbolRole::NameReference));
+  }

ckandeler wrote:
> kadircet wrote:
> > nridge wrote:
> > > `NameReference` was introduced in 
> > > https://github.com/llvm/llvm-project/commit/e7eb27a9a0edd859de49bcc9af7ca27dbb435886
> > >  to handle the somewhat unique situation with constructors and 
> > > destructors where the constructor/destructor references the class by name 
> > > but semantically denotes a separate entity.
> > > 
> > > Why is that applicable here?
> > > 
> > > Note that `handleReference()` will automatically add 
> > > `SymbolRole::Reference` 
> > > [here](https://searchfox.org/llvm/rev/cea72fe34194d58ac1ba9485ee9c9a63cf98a4e6/clang/lib/Index/IndexingContext.cpp#404).
> > +1 we shouldn't be setting namereference here.
> So set nothing at all here?
Yes, I think we should pass a default constructed `SymbolRoleSet()` here, and 
`handleReference()` will add `SymbolRole::Reference` into it automatically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150124

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


[PATCH] D156513: [clang] [libIndex] Remove unused 'RefD' parameter of IndexingContext::handleReference()

2023-07-28 Thread Nathan Ridge 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 rG5ddc37189032: [clang] [libIndex] Remove unused 
RefD parameter of IndexingContext… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156513

Files:
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/IndexingContext.h


Index: clang/lib/Index/IndexingContext.h
===
--- clang/lib/Index/IndexingContext.h
+++ clang/lib/Index/IndexingContext.h
@@ -79,7 +79,7 @@
const NamedDecl *Parent, const DeclContext *DC,
SymbolRoleSet Roles = SymbolRoleSet(),
ArrayRef Relations = std::nullopt,
-   const Expr *RefE = nullptr, const Decl *RefD = nullptr);
+   const Expr *RefE = nullptr);
 
   void handleMacroDefined(const IdentifierInfo , SourceLocation Loc,
   const MacroInfo );
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -76,8 +76,7 @@
   const DeclContext *DC,
   SymbolRoleSet Roles,
   ArrayRef Relations,
-  const Expr *RefE,
-  const Decl *RefD) {
+  const Expr *RefE) {
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return true;
 
@@ -87,7 +86,7 @@
 return true;
   }
   return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
-  RefE, RefD, DC);
+  RefE, nullptr, DC);
 }
 
 static void reportModuleReferences(const Module *Mod,


Index: clang/lib/Index/IndexingContext.h
===
--- clang/lib/Index/IndexingContext.h
+++ clang/lib/Index/IndexingContext.h
@@ -79,7 +79,7 @@
const NamedDecl *Parent, const DeclContext *DC,
SymbolRoleSet Roles = SymbolRoleSet(),
ArrayRef Relations = std::nullopt,
-   const Expr *RefE = nullptr, const Decl *RefD = nullptr);
+   const Expr *RefE = nullptr);
 
   void handleMacroDefined(const IdentifierInfo , SourceLocation Loc,
   const MacroInfo );
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -76,8 +76,7 @@
   const DeclContext *DC,
   SymbolRoleSet Roles,
   ArrayRef Relations,
-  const Expr *RefE,
-  const Decl *RefD) {
+  const Expr *RefE) {
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return true;
 
@@ -87,7 +86,7 @@
 return true;
   }
   return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
-  RefE, RefD, DC);
+  RefE, nullptr, DC);
 }
 
 static void reportModuleReferences(const Module *Mod,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5ddc371 - [clang] [libIndex] Remove unused 'RefD' parameter of IndexingContext::handleReference()

2023-07-28 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-07-28T21:36:27-04:00
New Revision: 5ddc371890324ba8aa5c54b42faeb0ed8a552fdb

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

LOG: [clang] [libIndex] Remove unused 'RefD' parameter of 
IndexingContext::handleReference()

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

Added: 


Modified: 
clang/lib/Index/IndexingContext.cpp
clang/lib/Index/IndexingContext.h

Removed: 




diff  --git a/clang/lib/Index/IndexingContext.cpp 
b/clang/lib/Index/IndexingContext.cpp
index ca8b144a431c0b..2dd68dfcc5a708 100644
--- a/clang/lib/Index/IndexingContext.cpp
+++ b/clang/lib/Index/IndexingContext.cpp
@@ -76,8 +76,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, 
SourceLocation Loc,
   const DeclContext *DC,
   SymbolRoleSet Roles,
   ArrayRef Relations,
-  const Expr *RefE,
-  const Decl *RefD) {
+  const Expr *RefE) {
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return true;
 
@@ -87,7 +86,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, 
SourceLocation Loc,
 return true;
   }
   return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
-  RefE, RefD, DC);
+  RefE, nullptr, DC);
 }
 
 static void reportModuleReferences(const Module *Mod,

diff  --git a/clang/lib/Index/IndexingContext.h 
b/clang/lib/Index/IndexingContext.h
index da6ec74b6e7441..89363b529fe99a 100644
--- a/clang/lib/Index/IndexingContext.h
+++ b/clang/lib/Index/IndexingContext.h
@@ -79,7 +79,7 @@ class IndexingContext {
const NamedDecl *Parent, const DeclContext *DC,
SymbolRoleSet Roles = SymbolRoleSet(),
ArrayRef Relations = std::nullopt,
-   const Expr *RefE = nullptr, const Decl *RefD = nullptr);
+   const Expr *RefE = nullptr);
 
   void handleMacroDefined(const IdentifierInfo , SourceLocation Loc,
   const MacroInfo );



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


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 545318.
tejohnson marked an inline comment as done.
tejohnson added a comment.

Address test comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

Files:
  clang/test/CodeGen/pgo-sample-preparation.c
  llvm/lib/Passes/PassBuilderPipelines.cpp
  
llvm/test/Transforms/PhaseOrdering/Inputs/simplifycfg-speculate-blocks.proftext
  
llvm/test/Transforms/PhaseOrdering/Inputs/simplifycfg-speculate-blocks.sampleprof
  llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll

Index: llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll
===
--- /dev/null
+++ llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll
@@ -0,0 +1,92 @@
+;; Check that SimplifyCFG does not attempt speculation until after PGO is
+;; annotated in the IR, and then does not perform it when unprofitable.
+
+;; No PGO: SimplifyCFG should speculate.
+; RUN: opt < %s -passes='default' -S | FileCheck %s --check-prefix=YES
+; RUN: opt < %s -passes='thinlto-pre-link' -S | FileCheck %s --check-prefix=YES
+; RUN: opt < %s -passes='lto-pre-link' -S | FileCheck %s --check-prefix=YES
+
+;; Instrumentation PGO: SimplifyCFG should only attempt speculation after PGO
+;; annotation, and in the below cases should not speculate given the branch
+;; biases.
+; RUN: llvm-profdata merge %S/Inputs/simplifycfg-speculate-blocks.proftext -o %t.profdata
+; RUN: opt < %s -passes='default' -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefixes=NO,INSTR
+; RUN: opt < %s -passes='thinlto-pre-link' -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefixes=NO,INSTR
+; RUN: opt < %s -passes='lto-pre-link' -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefixes=NO,INSTR --implicit-check-not=select
+
+;; Sample PGO: SimplifyCFG should only attempt speculation after PGO
+;; annotation, and in the below cases should not speculate given the branch
+;; biases.
+; RUN: opt < %s -passes='default' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/simplifycfg-speculate-blocks.sampleprof -S | FileCheck %s --check-prefixes=NO,SAMPLE
+; RUN: opt < %s -passes='thinlto-pre-link' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/simplifycfg-speculate-blocks.sampleprof -S | FileCheck %s --check-prefixes=NO,SAMPLE
+; RUN: opt < %s -passes='lto-pre-link' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/simplifycfg-speculate-blocks.sampleprof -S | FileCheck %s --check-prefixes=NO,SAMPLE
+
+%structx = type { [23 x i8], [0 x i8], i8 }
+define ptr @fold_two_entry_phi(ptr noundef nonnull align 8 dereferenceable(24) %v0) #0 !dbg !12 {
+; YES-LABEL: define ptr @fold_two_entry_phi
+; NO-LABEL: define ptr @fold_two_entry_phi
+  %1 = getelementptr inbounds %structx, ptr %v0, i64 0, i32 2
+  %2 = load i8, ptr %1, align 1
+  %3 = icmp slt i8 %2, 0
+  br i1 %3, label %truelabel, label %falselabel, !dbg !15
+; YES:select
+; INSTR: br i1 {{.*}} !prof ![[PROF:[0-9]+]]
+; SAMPLE: br i1 {{.*}} !prof ![[PROF1:[0-9]+]]
+truelabel:
+  %4 = load ptr, ptr %v0, align 8, !dbg !16
+  br label %retlabel, !dbg !16
+falselabel:
+  br label %retlabel, !dbg !17
+retlabel:
+  %5 = phi ptr [ %4, %truelabel ], [ %v0, %falselabel ], !dbg !18
+  ret ptr %5, !dbg !18
+}
+
+define void @fold_branch_to_common_dest(i8 %v0, i8 %v1) #0 !dbg !19 {
+; YES-LABEL: define void @fold_branch_to_common_dest
+; NO-LABEL: define void @fold_branch_to_common_dest
+pred:
+  %c0 = icmp eq i8 %v0, 0
+  br i1 %c0, label %dispatch, label %final_right, !dbg !20
+; YES:select
+; INSTR: br i1 %c0, label %dispatch, label %final_right, !dbg {{.*}}, !prof ![[PROF]]
+; SAMPLE: br i1 %c0, label %dispatch, label %final_right, !dbg {{.*}}, !prof ![[PROF2:[0-9]+]]
+dispatch:
+  %c1 = icmp eq i8 %v1, 0, !dbg !21
+  br i1 %c1, label %final_left, label %final_right, !dbg !21
+final_left:
+  call void @sideeffect0(), !dbg !22
+  ret void, !dbg !22
+final_right:
+  call void @sideeffect1(), !dbg !23
+  ret void, !dbg !23
+}
+
+declare void @sideeffect0()
+declare void @sideeffect1()
+
+; INSTR: ![[PROF]] = !{!"branch_weights", i32 0, i32 5000}
+; SAMPLE: ![[PROF1]] = !{!"branch_weights", i32 1, i32 5002}
+; SAMPLE: ![[PROF2]] = !{!"branch_weights", i32 1, i32 5001}
+
+attributes #0 = { "use-sample-profile" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0 (g...@github.com:llvm/llvm-project.git 180a8148f95d2d5ed96c670fc322292fa0df876c)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "simplifycfg-speculate-blocks.cc", directory: ".", checksumkind: CSK_MD5, checksum: 

[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked 2 inline comments as done.
tejohnson added inline comments.



Comment at: 
llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll:83
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}

aeubanks wrote:
> the debug info is necessary for sample profile to work I presume?
> 
> I think some of this can still be simplified, like `PIC Level`, etc
Right, that's need for SamplePGO. Removed the other stuff that wasn't necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D156576: Remove rdar links in clang/lib. NFC

2023-07-28 Thread Akira Hatanaka 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 rGb08d358e8ac8: Remove private rdar links. NFC (authored by 
ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156576

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaObjCProperty.cpp


Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't supported.
+  // a linker bug (see https://openradar.appspot.com/7198997), and CUDA device
+  // code, where aliases aren't supported.
   if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5983,7 +5983,7 @@
   }
 
   // Note: -fwritable-strings doesn't make the backing store strings of
-  // CFStrings writable. (See )
+  // CFStrings writable.
   auto *GV =
   new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, C, ".str");
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -3329,7 +3329,7 @@
   struct _objc_method_list *instance_methods;
   struct _objc_method_list *class_methods;
   struct _objc_protocol_list *protocols;
-  uint32_t size; // 
+  uint32_t size; // sizeof(struct _objc_category)
   struct _objc_property_list *instance_properties;
   struct _objc_property_list *class_properties;
   };
@@ -4486,14 +4486,10 @@
   want to implement correct ObjC/C++ exception interactions for the
   fragile ABI.
 
-  Note that for this use of setjmp/longjmp to be correct, we may need
-  to mark some local variables volatile: if a non-volatile local
-  variable is modified between the setjmp and the longjmp, it has
-  indeterminate value.  For the purposes of LLVM IR, it may be
-  sufficient to make loads and stores within the @try (to variables
-  declared outside the @try) volatile.  This is necessary for
-  optimized correctness, but is not currently being done; this is
-  being tracked as rdar://problem/8160285
+  Note that for this use of setjmp/longjmp to be correct in the presence of
+  optimization, we use inline assembly on the set of local variables to force
+  flushing locals to memory immediately before any protected calls and to
+  inhibit optimizing locals across the setjmp->catch edge.
 
   The basic framework for a @try-catch-finally is as follows:
   {
@@ -5092,7 +5088,8 @@
   eImageInfo_OptimizedByDyld = (1 << 3), // This flag is set by the dyld 
shared cache.
 
   // A flag indicating that the module has no instances of a @synthesize of a
-  // superclass variable. 
+  // superclass variable. This flag used to be consumed by the runtime to work
+  // around miscompile by gcc.
   eImageInfo_CorrectedSynthesize = (1 << 4), // This flag is no longer set by 
clang.
   eImageInfo_ImageIsSimulated= (1 << 5),
   eImageInfo_ClassProperties = (1 << 6)


Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't 

[clang] b08d358 - Remove private rdar links. NFC

2023-07-28 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2023-07-28T16:42:31-07:00
New Revision: b08d358e8ac83cf31c007a58c814bf2dca03d591

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

LOG: Remove private rdar links. NFC

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

Added: 


Modified: 
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaObjCProperty.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 32f4f411347a85..51c87f985fdf05 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -3329,7 +3329,7 @@ CGObjCCommonMac::EmitProtocolMethodTypes(Twine Name,
   struct _objc_method_list *instance_methods;
   struct _objc_method_list *class_methods;
   struct _objc_protocol_list *protocols;
-  uint32_t size; // 
+  uint32_t size; // sizeof(struct _objc_category)
   struct _objc_property_list *instance_properties;
   struct _objc_property_list *class_properties;
   };
@@ -4486,14 +4486,10 @@ llvm::FunctionType *FragileHazards::GetAsmFnType() {
   want to implement correct ObjC/C++ exception interactions for the
   fragile ABI.
 
-  Note that for this use of setjmp/longjmp to be correct, we may need
-  to mark some local variables volatile: if a non-volatile local
-  variable is modified between the setjmp and the longjmp, it has
-  indeterminate value.  For the purposes of LLVM IR, it may be
-  sufficient to make loads and stores within the @try (to variables
-  declared outside the @try) volatile.  This is necessary for
-  optimized correctness, but is not currently being done; this is
-  being tracked as rdar://problem/8160285
+  Note that for this use of setjmp/longjmp to be correct in the presence of
+  optimization, we use inline assembly on the set of local variables to force
+  flushing locals to memory immediately before any protected calls and to
+  inhibit optimizing locals across the setjmp->catch edge.
 
   The basic framework for a @try-catch-finally is as follows:
   {
@@ -5092,7 +5088,8 @@ enum ImageInfoFlags {
   eImageInfo_OptimizedByDyld = (1 << 3), // This flag is set by the dyld 
shared cache.
 
   // A flag indicating that the module has no instances of a @synthesize of a
-  // superclass variable. 
+  // superclass variable. This flag used to be consumed by the runtime to work
+  // around miscompile by gcc.
   eImageInfo_CorrectedSynthesize = (1 << 4), // This flag is no longer set by 
clang.
   eImageInfo_ImageIsSimulated= (1 << 5),
   eImageInfo_ClassProperties = (1 << 6)

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 332a879349cfc2..80c7ecedc28755 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5983,7 +5983,7 @@ CodeGenModule::GetAddrOfConstantCFString(const 
StringLiteral *Literal) {
   }
 
   // Note: -fwritable-strings doesn't make the backing store strings of
-  // CFStrings writable. (See )
+  // CFStrings writable.
   auto *GV =
   new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, C, ".str");

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ff4c9485619fb9..0fc476fba53f34 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't supported.
+  // a linker bug (see https://openradar.appspot.com/7198997), and CUDA device
+  // code, where aliases aren't supported.
   if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 

diff  --git a/clang/lib/Sema/SemaObjCProperty.cpp 
b/clang/lib/Sema/SemaObjCProperty.cpp
index 7e5dc3a71cbbad..0381607f32bfe9 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl,
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&



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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-07-28 Thread Fridtjof Mund via Phabricator via cfe-commits
fridtjof added a comment.

In D151373#4538604 , @aaron.ballman 
wrote:

> I think we should drop the `annotate_type` functionality from the patch 
> entirely rather than add it without any test coverage knowing it doesn't seem 
> to work as expected.

Agreed - I removed the superfluous code and also cleaned up the summary 
accordingly.


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

https://reviews.llvm.org/D151373

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-07-28 Thread Fridtjof Mund via Phabricator via cfe-commits
fridtjof updated this revision to Diff 545305.
fridtjof retitled this revision from "[libclang] Expose arguments of 
clang::annotate{_type}" to "[libclang] Expose arguments of clang::annotate".
fridtjof edited the summary of this revision.

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

https://reviews.llvm.org/D151373

Files:
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CursorVisitor.h
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1246,6 +1246,50 @@
   EXPECT_EQ(fromCXString(clang_getCursorSpelling(*staticAssertCsr)), "");
 }
 
+TEST_F(LibclangParseTest, ExposesAnnotateArgs) {
+  const char testSource[] = R"cpp(
+[[clang::annotate("category", 42)]]
+void func() {}
+)cpp";
+  std::string fileName = "main.cpp";
+  WriteFile(fileName, testSource);
+
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args, 1,
+   nullptr, 0, TUFlags);
+
+  int attrCount = 0;
+
+  Traverse(
+  [](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_AnnotateAttr) {
+  int childCount = 0;
+  clang_visitChildren(
+  cursor,
+  [](CXCursor child, CXCursor,
+ CXClientData data) -> CXChildVisitResult {
+int *pcount = static_cast(data);
+
+// we only expect one argument here, so bail otherwise
+EXPECT_EQ(*pcount, 0);
+
+auto *result = clang_Cursor_Evaluate(child);
+EXPECT_NE(result, nullptr);
+EXPECT_EQ(clang_EvalResult_getAsInt(result), 42);
+++*pcount;
+
+return CXChildVisit_Recurse;
+  },
+  );
+  attrCount++;
+  return CXChildVisit_Continue;
+}
+return CXChildVisit_Recurse;
+  });
+
+  EXPECT_EQ(attrCount, 1);
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -276,7 +276,9 @@
   bool IsInRegionOfInterest(CXCursor C);
   bool RunVisitorWorkList(VisitorWorkList );
   void EnqueueWorkList(VisitorWorkList , const Stmt *S);
+  void EnqueueWorkList(VisitorWorkList , const Attr *A);
   LLVM_ATTRIBUTE_NOINLINE bool Visit(const Stmt *S);
+  LLVM_ATTRIBUTE_NOINLINE bool Visit(const Attr *A);
 
 private:
   std::optional handleDeclForVisitation(const Decl *D);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -23,6 +23,7 @@
 #include "CursorVisitor.h"
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/AttrVisitor.h"
 #include "clang/AST/DeclObjCCommon.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -575,6 +576,13 @@
   A->getInterfaceLoc()->getTypeLoc().getBeginLoc(), TU));
   }
 
+  if (clang_isAttribute(Cursor.kind)) {
+if (const Attr *A = getCursorAttr(Cursor))
+  return Visit(A);
+
+return false;
+  }
+
   // If pointing inside a macro definition, check if the token is an identifier
   // that was ever defined as a macro. In such a case, create a "pseudo" macro
   // expansion cursor for that token.
@@ -2089,7 +2097,8 @@
 (SourceLocation::UIntTy)(uintptr_t)data[1]);
   }
 };
-class EnqueueVisitor : public ConstStmtVisitor {
+class EnqueueVisitor : public ConstStmtVisitor,
+   public ConstAttrVisitor {
   friend class OMPClauseEnqueue;
   VisitorWorkList 
   CXCursor Parent;
@@ -2231,6 +2240,9 @@
   void VisitOMPTargetTeamsDistributeSimdDirective(
   const OMPTargetTeamsDistributeSimdDirective *D);
 
+  // Attributes
+  void VisitAnnotateAttr(const AnnotateAttr *A);
+
 private:
   void AddDeclarationNameInfo(const Stmt *S);
   void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier);
@@ -2242,6 +2254,10 @@
   void AddTypeLoc(TypeSourceInfo *TI);
   void EnqueueChildren(const Stmt *S);
   void EnqueueChildren(const OMPClause *S);
+  template ::value,
+ bool> = true>
+  void EnqueueChildren(const AnnAttr *A);
 };
 } // namespace
 
@@ -2736,6 +2752,23 @@
   VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
   std::reverse(I, E);
 }
+
+template ::value,
+   bool>>
+void EnqueueVisitor::EnqueueChildren(const AnnAttr *A) {
+  unsigned size = WL.size();
+  for (const Expr *Arg : A->args()) {
+VisitStmt(Arg);
+  }
+  if (size == WL.size())
+return;
+ 

[PATCH] D156580: [FunctionImport] Reduce string duplication (NFC)

2023-07-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: mtrofin.
Herald added subscribers: hoy, ormris, steven_wu, hiraditya.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

The import/export maps, and the ModuleToDefinedGVSummaries map, are all
indexed by module paths, which are StringRef obtained from the module
summary index, which already has a data structure than owns these
strings (the ModulePathStringTable). Because these other maps are also
StringMap, which makes a copy of the string key, we were keeping
multiple extra copies of the module paths, leading to memory overhead.

Change these to DenseMap keyed by StringRef, and document that the
strings are owned by the index.

The only exception is the llvm-link tool which synthesizes an import list
from command line options, and I have added a string cache to maintain
ownership there.

I measured around 5% memory reduction in the thin link of a large
binary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156580

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Transforms/IPO/FunctionImport.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/tools/llvm-link/llvm-link.cpp

Index: llvm/tools/llvm-link/llvm-link.cpp
===
--- llvm/tools/llvm-link/llvm-link.cpp
+++ llvm/tools/llvm-link/llvm-link.cpp
@@ -323,6 +323,11 @@
   };
 
   ModuleLazyLoaderCache ModuleLoaderCache(ModuleLoader);
+  // Owns the filename strings used to key into the ImportList. Normally this is
+  // constructed from the index and the strings are owned by the index, however,
+  // since we are synthesizing this data structure from options we need a cache
+  // to own those strings.
+  StringSet<> FileNameStringCache;
   for (const auto  : Imports) {
 // Identify the requested function and its bitcode source file.
 size_t Idx = Import.find(':');
@@ -360,7 +365,8 @@
 if (Verbose)
   errs() << "Importing " << FunctionName << " from " << FileName << "\n";
 
-auto  = ImportList[FileName];
+auto  =
+ImportList[FileNameStringCache.insert(FileName).first->getKey()];
 Entry.insert(F->getGUID());
   }
   auto CachedModuleLoader = [&](StringRef Identifier) {
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -272,7 +272,7 @@
   function_ref
   IsPrevailing;
   FunctionImporter::ImportMapTy 
-  StringMap *const ExportLists;
+  DenseMap *const ExportLists;
 
   bool shouldImportGlobal(const ValueInfo ) {
 const auto  = DefinedGVSummaries.find(VI.getGUID());
@@ -357,7 +357,7 @@
   function_ref
   IsPrevailing,
   FunctionImporter::ImportMapTy ,
-  StringMap *ExportLists)
+  DenseMap *ExportLists)
   : Index(Index), DefinedGVSummaries(DefinedGVSummaries),
 IsPrevailing(IsPrevailing), ImportList(ImportList),
 ExportLists(ExportLists) {}
@@ -403,7 +403,7 @@
 isPrevailing,
 SmallVectorImpl , GlobalsImporter ,
 FunctionImporter::ImportMapTy ,
-StringMap *ExportLists,
+DenseMap *ExportLists,
 FunctionImporter::ImportThresholdsTy ) {
   GVImporter.onImportingSummary(Summary);
   static int ImportCount = 0;
@@ -576,7 +576,7 @@
 isPrevailing,
 const ModuleSummaryIndex , StringRef ModName,
 FunctionImporter::ImportMapTy ,
-StringMap *ExportLists = nullptr) {
+DenseMap *ExportLists = nullptr) {
   // Worklist contains the list of function imported in this module, for which
   // we will analyse the callees and may import further down the callgraph.
   SmallVector Worklist;
@@ -671,10 +671,10 @@
 #endif
 
 #ifndef NDEBUG
-static bool
-checkVariableImport(const ModuleSummaryIndex ,
-StringMap ,
-StringMap ) {
+static bool checkVariableImport(
+const ModuleSummaryIndex ,
+DenseMap ,
+DenseMap ) {
 
   DenseSet FlattenedImports;
 
@@ -702,7 +702,7 @@
   for (auto  : ExportLists)
 for (auto  : ExportPerModule.second)
   if (!FlattenedImports.count(VI.getGUID()) &&
-  IsReadOrWriteOnlyVarNeedingImporting(ExportPerModule.first(), VI))
+  IsReadOrWriteOnlyVarNeedingImporting(ExportPerModule.first, VI))
 return false;
 
   return true;
@@ -712,19 +712,18 @@
 /// Compute all the import and export for every module using the Index.
 void llvm::ComputeCrossModuleImport(
 const ModuleSummaryIndex ,
-const StringMap ,
+const DenseMap ,
 function_ref
 isPrevailing,
-StringMap ,
-StringMap ) {
+DenseMap ,
+DenseMap ) {
   // For each module that has function defined, compute the import/export lists.
   for (const 

[PATCH] D156576: Remove rdar links in clang/lib. NFC

2023-07-28 Thread Ravi via Phabricator via cfe-commits
ravikandhadai accepted this revision.
ravikandhadai added a comment.
This revision is now accepted and ready to land.

Thanks Akira.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156576

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


[PATCH] D156576: Remove rdar links in clang/lib. NFC

2023-07-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 545300.
ahatanak added a comment.

Remove git commit hash in comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156576

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaObjCProperty.cpp


Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't supported.
+  // a linker bug (see https://openradar.appspot.com/7198997), and CUDA device
+  // code, where aliases aren't supported.
   if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5983,7 +5983,7 @@
   }
 
   // Note: -fwritable-strings doesn't make the backing store strings of
-  // CFStrings writable. (See )
+  // CFStrings writable.
   auto *GV =
   new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, C, ".str");
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -3329,7 +3329,7 @@
   struct _objc_method_list *instance_methods;
   struct _objc_method_list *class_methods;
   struct _objc_protocol_list *protocols;
-  uint32_t size; // 
+  uint32_t size; // sizeof(struct _objc_category)
   struct _objc_property_list *instance_properties;
   struct _objc_property_list *class_properties;
   };
@@ -4486,14 +4486,10 @@
   want to implement correct ObjC/C++ exception interactions for the
   fragile ABI.
 
-  Note that for this use of setjmp/longjmp to be correct, we may need
-  to mark some local variables volatile: if a non-volatile local
-  variable is modified between the setjmp and the longjmp, it has
-  indeterminate value.  For the purposes of LLVM IR, it may be
-  sufficient to make loads and stores within the @try (to variables
-  declared outside the @try) volatile.  This is necessary for
-  optimized correctness, but is not currently being done; this is
-  being tracked as rdar://problem/8160285
+  Note that for this use of setjmp/longjmp to be correct in the presence of
+  optimization, we use inline assembly on the set of local variables to force
+  flushing locals to memory immediately before any protected calls and to
+  inhibit optimizing locals across the setjmp->catch edge.
 
   The basic framework for a @try-catch-finally is as follows:
   {
@@ -5092,7 +5088,8 @@
   eImageInfo_OptimizedByDyld = (1 << 3), // This flag is set by the dyld 
shared cache.
 
   // A flag indicating that the module has no instances of a @synthesize of a
-  // superclass variable. 
+  // superclass variable. This flag used to be consumed by the runtime to work
+  // around miscompile by gcc.
   eImageInfo_CorrectedSynthesize = (1 << 4), // This flag is no longer set by 
clang.
   eImageInfo_ImageIsSimulated= (1 << 5),
   eImageInfo_ClassProperties = (1 << 6)


Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't supported.
+  // a linker bug (see https://openradar.appspot.com/7198997), and CUDA device
+  // code, where 

[PATCH] D156237: Complete the implementation of P2361 Unevaluated string literals

2023-07-28 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:2349
+  if (isVariadicStringLiteralArgument(Args[N])) {
+for (; N < sizeof(uint32_t); N++)
+  Bits |= (1 << N);

maskTrailingZeros might also be useful


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156237

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


[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-28 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao added inline comments.



Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:8-12
+template struct S2 {
+T t[2];
+Ts... ts;
+};
+

dblaikie wrote:
> Did this test case come out of any particular bug discovered during 
> implementation?
No. I just wanted to test the case when the packed parameter is not the only 
parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

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


[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-28 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao added a comment.

In D156546#4543697 , @dblaikie wrote:

> (just a side note about the title of this patch: I got "packed data members" 
> confused and thought this was referring to struct packing 
> `__attribute__((packed))` - so perhaps something more like "data member 
> packs" would be a more clear term here?)

I changed the name to "data member packs" in description and in the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

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


[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-28 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao updated this revision to Diff 545297.
SlaterLatiao added a comment.

Address comments.

- Added test case of duplicate types in template arguments.
- Added ending new line to test case file.
- Renamed "packed data members" -> "data member packs"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenCXX/data_member_packs.cpp

Index: clang/test/CodeGenCXX/data_member_packs.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/data_member_packs.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 --std=c++20 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s --check-prefixes=CHECK
+
+// Tests declaration data member packs.
+template struct S1 {
+Ts... ts;
+};
+
+template struct S2 {
+T t[2];
+Ts... ts;
+};
+
+// CHECK: %struct.S1 = type { i32 }
+S1 s1;
+// CHECK-NEXT: %struct.S1.0 = type { i32, float, double }
+S1 s2;
+// Test template args as the last arg.
+// CHECK-NEXT: %struct.S2 = type { [2 x i32], float, double }
+S2 s3;
+// Test nested template args.
+// CHECK-NEXT: %struct.S1.1 = type { i32, float, %struct.S1.2 }
+// CHECK-NEXT: %struct.S1.2 = type { double, double }
+S1> s4;
+// Test empty template arg.
+// CHECK-NEXT: %struct.S1.3 = type { i8 }
+S1<> s5;
+// Test duplicate types in template args.
+// CHECK-NEXT: %struct.S1.4 = type { i32, i32 }
+S1 s6;
+
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5927,6 +5927,8 @@
  /*ExpectPackInType=*/false);
   }
   break;
+case DeclaratorContext::Member:
+  // Expand for packed data members.
 case DeclaratorContext::TemplateParam:
   // C++0x [temp.param]p15:
   //   If a template-parameter is a [...] is a parameter-declaration that
@@ -5954,7 +5956,6 @@
 case DeclaratorContext::CXXNew:
 case DeclaratorContext::AliasDecl:
 case DeclaratorContext::AliasTemplate:
-case DeclaratorContext::Member:
 case DeclaratorContext::Block:
 case DeclaratorContext::ForInit:
 case DeclaratorContext::SelectionInit:
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3267,42 +3267,74 @@
   continue;
 }
 
-Decl *NewMember = Instantiator.Visit(Member);
-if (NewMember) {
-  if (FieldDecl *Field = dyn_cast(NewMember)) {
-Fields.push_back(Field);
-  } else if (EnumDecl *Enum = dyn_cast(NewMember)) {
-// C++11 [temp.inst]p1: The implicit instantiation of a class template
-// specialization causes the implicit instantiation of the definitions
-// of unscoped member enumerations.
-// Record a point of instantiation for this implicit instantiation.
-if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
-Enum->isCompleteDefinition()) {
-  MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
-  assert(MSInfo && "no spec info for member enum specialization");
-  MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation);
-  MSInfo->setPointOfInstantiation(PointOfInstantiation);
-}
-  } else if (StaticAssertDecl *SA = dyn_cast(NewMember)) {
-if (SA->isFailed()) {
-  // A static_assert failed. Bail out; instantiating this
-  // class is probably not meaningful.
-  Instantiation->setInvalidDecl();
-  break;
+// Instantiate packed data members.
+if (FieldDecl *Field = dyn_cast(Member);
+Field && isa(Field->getType().getTypePtr())) {
+  QualType PatternType = Field->getType()
+ ->castAs()
+ ->getPattern();
+  std::optional NumArgumentsInExpansion =
+  getNumArgumentsInExpansion(Field->getType(), TemplateArgs);
+  assert(NumArgumentsInExpansion && "should not see unknown template argument here");
+  for (unsigned Arg = 0; Arg < NumArgumentsInExpansion; ++Arg) {
+// Generate a new field from PackExpansion field.
+if (Decl *NewMember = Instantiator.Visit(Member)) {
+  FieldDecl *PackedField = cast(NewMember);
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, Arg);
+  QualType T =
+  SubstType(PatternType, TemplateArgs, PackedField->getLocation(),
+PackedField->getDeclName());
+  PackedField->setType(T);
+  Fields.push_back(PackedField);
+  if (NewMember->isInvalidDecl())
+Instantiation->setInvalidDecl();
+} else {
+  // 

[PATCH] D155773: [llvm][MemoryBuiltins] Add alloca support to getInitialValueOfAllocation

2023-07-28 Thread John McIver via Phabricator via cfe-commits
jmciver updated this revision to Diff 545294.
jmciver edited the summary of this revision.
jmciver added a comment.
Herald added subscribers: foad, kerbowa, jvesely, arsenm.

Refactor AMDGPUPromoteAlloca to use getInitialValueOfAllocation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155773

Files:
  llvm/include/llvm/Analysis/MemoryBuiltins.h
  llvm/lib/Analysis/MemoryBuiltins.cpp
  llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp
  llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -24,6 +24,7 @@
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/IteratedDominanceFrontier.h"
+#include "llvm/Analysis/MemoryBuiltins.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
@@ -600,7 +601,7 @@
 if (I == StoresByIndex.begin()) {
   if (StoresByIndex.empty())
 // If there are no stores, the load takes the undef value.
-ReplVal = UndefValue::get(LI->getType());
+ReplVal = getInitialValueOfAllocation(AI, nullptr, LI->getType());
   else
 // There is no store before this load, bail out (load may be affected
 // by the following stores - see main comment).
Index: llvm/lib/Transforms/Scalar/NewGVN.cpp
===
--- llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1496,21 +1496,18 @@
   if (LoadPtr != lookupOperandLeader(DepInst) &&
   !AA->isMustAlias(LoadPtr, DepInst))
 return nullptr;
-  // If this load really doesn't depend on anything, then we must be loading an
-  // undef value.  This can happen when loading for a fresh allocation with no
-  // intervening stores, for example.  Note that this is only true in the case
-  // that the result of the allocation is pointer equal to the load ptr.
-  if (isa(DepInst)) {
-return createConstantExpression(UndefValue::get(LoadType));
-  }
   // If this load occurs either right after a lifetime begin,
   // then the loaded value is undefined.
-  else if (auto *II = dyn_cast(DepInst)) {
+  if (auto *II = dyn_cast(DepInst)) {
 if (II->getIntrinsicID() == Intrinsic::lifetime_start)
   return createConstantExpression(UndefValue::get(LoadType));
-  } else if (auto *InitVal =
- getInitialValueOfAllocation(DepInst, TLI, LoadType))
-  return createConstantExpression(InitVal);
+  }
+  // If this load really doesn't depend on anything, then we must be loading an
+  // undef value.  This can happen when loading for a fresh allocation with no
+  // intervening stores, for example.  Note that this is only true in the case
+  // that the result of the allocation is pointer equal to the load ptr.
+  else if (auto *InitVal = getInitialValueOfAllocation(DepInst, TLI, LoadType))
+return createConstantExpression(InitVal);
 
   return nullptr;
 }
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1239,11 +1239,12 @@
   }
   assert(DepInfo.isDef() && "follows from above");
 
-  // Loading the alloca -> undef.
   // Loading immediately after lifetime begin -> undef.
-  if (isa(DepInst) || isLifetimeStart(DepInst))
+  if (isLifetimeStart(DepInst))
 return AvailableValue::get(UndefValue::get(Load->getType()));
 
+  // In addition to allocator function calls this includes loading the alloca ->
+  // undef.
   if (Constant *InitVal =
   getInitialValueOfAllocation(DepInst, TLI, Load->getType()))
 return AvailableValue::get(InitVal);
Index: llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -32,6 +32,7 @@
 #include "llvm/Analysis/CaptureTracking.h"
 #include "llvm/Analysis/InstSimplifyFolder.h"
 #include "llvm/Analysis/InstructionSimplify.h"
+#include "llvm/Analysis/MemoryBuiltins.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/IR/IRBuilder.h"
@@ -805,7 +806,9 @@
   // undef.
   SSAUpdater Updater;
   Updater.Initialize(VectorTy, "promotealloca");
-  Updater.AddAvailableValue(Alloca.getParent(), UndefValue::get(VectorTy));
+  Updater.AddAvailableValue(
+  Alloca.getParent(),
+  getInitialValueOfAllocation(, nullptr, VectorTy));
 
   // First handle the initial worklist.
   SmallVector DeferredLoads;
Index: 

[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-07-28 Thread Shafik Yaghmour 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 rGcc1b6668c571: [Clang] Fix member lookup so that we 
dont ignore ambiguous lookups in some… (authored by shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155387

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Lookup.h
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
  clang/test/CXX/class.derived/class.member.lookup/p11.cpp
  clang/test/SemaCXX/arrow-operator.cpp

Index: clang/test/SemaCXX/arrow-operator.cpp
===
--- clang/test/SemaCXX/arrow-operator.cpp
+++ clang/test/SemaCXX/arrow-operator.cpp
@@ -4,11 +4,13 @@
 };
 
 struct A {
-  T* operator->(); // expected-note{{candidate function}}
+  T* operator->();
+   // expected-note@-1 {{member found by ambiguous name lookup}}
 };
 
 struct B {
-  T* operator->(); // expected-note{{candidate function}}
+  T* operator->();
+   // expected-note@-1 {{member found by ambiguous name lookup}}
 };
 
 struct C : A, B {
@@ -19,7 +21,8 @@
 struct E; // expected-note {{forward declaration of 'E'}}
 
 void f(C , D& d, E& e) {
-  c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}}
+  c->f();
+  // expected-error@-1 {{member 'operator->' found in multiple base classes of different types}}
   d->f();
   e->f(); // expected-error{{incomplete definition of type}}
 }
Index: clang/test/CXX/class.derived/class.member.lookup/p11.cpp
===
--- /dev/null
+++ clang/test/CXX/class.derived/class.member.lookup/p11.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct B1 {
+  void f();
+  static void f(int);
+  int i; // expected-note 2{{member found by ambiguous name lookup}}
+};
+struct B2 {
+  void f(double);
+};
+struct I1: B1 { };
+struct I2: B1 { };
+
+struct D: I1, I2, B2 {
+  using B1::f;
+  using B2::f;
+  void g() {
+f(); // expected-error {{ambiguous conversion from derived class 'D' to base class 'B1'}}
+f(0); // ok
+f(0.0); // ok
+// FIXME next line should be well-formed
+int B1::* mpB1 = ::i; // expected-error {{non-static member 'i' found in multiple base-class subobjects of type 'B1'}}
+int D::* mpD = ::i; // expected-error {{non-static member 'i' found in multiple base-class subobjects of type 'B1'}}
+  }
+};
Index: clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
===
--- /dev/null
+++ clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+  void operator()(int); // expected-note {{member found by ambiguous name lookup}}
+  void f(int); // expected-note {{member found by ambiguous name lookup}}
+};
+struct B {
+  void operator()(); // expected-note {{member found by ambiguous name lookup}}
+  void f() {} // expected-note {{member found by ambiguous name lookup}}
+};
+
+struct C : A, B {};
+
+int f() {
+C c;
+c(); // expected-error {{member 'operator()' found in multiple base classes of different types}}
+c.f(10); //expected-error {{member 'f' found in multiple base classes of different types}}
+return 0;
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -593,7 +593,7 @@
   // postfix-expression and does not name a class template, the name
   // found in the class of the object expression is used, otherwise
   FoundOuter.clear();
-} else if (!Found.isSuppressingDiagnostics()) {
+} else if (!Found.isSuppressingAmbiguousDiagnostics()) {
   //   - if the name found is a class template, it must refer to the same
   // entity as the one found in the class of the object expression,
   // otherwise the program is ill-formed.
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -950,7 +950,7 @@
 LookupResult Members(S, NotEqOp, OpLoc,
  Sema::LookupNameKind::LookupMemberName);
 S.LookupQualifiedName(Members, RHSRec->getDecl());
-Members.suppressDiagnostics();
+Members.suppressAccessDiagnostics();
 for (NamedDecl *Op : Members)
   if (FunctionsCorrespond(S.Context, EqFD, Op->getAsFunction()))
 return false;
@@ -961,7 +961,7 @@
   Sema::LookupNameKind::LookupOperatorName);
   S.LookupName(NonMembers,

[clang] cc1b666 - [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-07-28 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2023-07-28T15:21:57-07:00
New Revision: cc1b6668c57170cd440d321037ced89d6a61a9cb

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

LOG: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in 
some cases

There are some cases during member lookup we are aggressively suppressing
diagnostics when we should just be suppressing access control diagnostic.

In this PR I add the ability to simply suppress access diagnostics while not
suppressing ambiguous lookup diagnostics.

Fixes: https://github.com/llvm/llvm-project/issues/22413
https://github.com/llvm/llvm-project/issues/29942
https://github.com/llvm/llvm-project/issues/35574
https://github.com/llvm/llvm-project/issues/27224

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

Added: 
clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
clang/test/CXX/class.derived/class.member.lookup/p11.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Lookup.h
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCXX/arrow-operator.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index de93b15bc1b3c5..4b8a323093ccd5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -121,6 +121,12 @@ Bug Fixes to C++ Support
   a Unicode character whose name contains a ``-``.
   (`Fixes #64161 _`)
 
+- Fix cases where we ignore ambiguous name lookup when looking up memebers.
+  (`#22413 _`),
+  (`#29942 _`),
+  (`#35574 _`) and
+  (`#27224 _`).
+
 Bug Fixes to AST Handling
 ^
 

diff  --git a/clang/include/clang/Sema/Lookup.h 
b/clang/include/clang/Sema/Lookup.h
index 351fa0c6ca0cb9..cbc9b733940a3d 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -148,20 +148,22 @@ class LookupResult {
   : SemaPtr(), NameInfo(NameInfo), LookupKind(LookupKind),
 Redecl(Redecl != Sema::NotForRedeclaration),
 ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
-Diagnose(Redecl == Sema::NotForRedeclaration) {
+DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
+DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
 configure();
   }
 
   // TODO: consider whether this constructor should be restricted to take
   // as input a const IdentifierInfo* (instead of Name),
   // forcing other cases towards the constructor taking a DNInfo.
-  LookupResult(Sema , DeclarationName Name,
-   SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
+  LookupResult(Sema , DeclarationName Name, SourceLocation NameLoc,
+   Sema::LookupNameKind LookupKind,
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
   : SemaPtr(), NameInfo(Name, NameLoc), LookupKind(LookupKind),
 Redecl(Redecl != Sema::NotForRedeclaration),
 ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
-Diagnose(Redecl == Sema::NotForRedeclaration) {
+DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
+DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
 configure();
   }
 
@@ -192,12 +194,14 @@ class LookupResult {
 Redecl(std::move(Other.Redecl)),
 ExternalRedecl(std::move(Other.ExternalRedecl)),
 HideTags(std::move(Other.HideTags)),
-Diagnose(std::move(Other.Diagnose)),
+DiagnoseAccess(std::move(Other.DiagnoseAccess)),
+DiagnoseAmbiguous(std::move(Other.DiagnoseAmbiguous)),
 AllowHidden(std::move(Other.AllowHidden)),
 Shadowed(std::move(Other.Shadowed)),
 TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
 Other.Paths = nullptr;
-Other.Diagnose = false;
+Other.DiagnoseAccess = false;
+Other.DiagnoseAmbiguous = false;
   }
 
   LookupResult =(LookupResult &) {
@@ -215,17 +219,22 @@ class LookupResult {
 Redecl = std::move(Other.Redecl);
 ExternalRedecl = std::move(Other.ExternalRedecl);
 HideTags = std::move(Other.HideTags);
-Diagnose = std::move(Other.Diagnose);
+DiagnoseAccess = std::move(Other.DiagnoseAccess);
+DiagnoseAmbiguous = std::move(Other.DiagnoseAmbiguous);
 AllowHidden = std::move(Other.AllowHidden);
 Shadowed = std::move(Other.Shadowed);
 TemplateNameLookup = std::move(Other.TemplateNameLookup);
 Other.Paths = nullptr;
-Other.Diagnose = false;
+Other.DiagnoseAccess = false;
+Other.DiagnoseAmbiguous = 

[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-28 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao updated this revision to Diff 545291.
SlaterLatiao marked 2 inline comments as done.
SlaterLatiao added a comment.

Revert last commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenCXX/packed_data_member.cpp

Index: clang/test/CodeGenCXX/packed_data_member.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/packed_data_member.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 --std=c++20 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s --check-prefixes=CHECK
+
+// Tests declaration of packed data members.
+template struct S1 {
+Ts... ts;
+};
+
+template struct S2 {
+T t[2];
+Ts... ts;
+};
+
+// CHECK: %struct.S1 = type { i32 }
+S1 s1;
+// CHECK-NEXT: %struct.S1.0 = type { i32, float, double }
+S1 s2;
+// Test template args as the last arg.
+// CHECK-NEXT: %struct.S2 = type { [2 x i32], float, double }
+S2 s3;
+// Test nested template args.
+// CHECK-NEXT: %struct.S1.1 = type { i32, float, %struct.S1.2 }
+// CHECK-NEXT: %struct.S1.2 = type { double, double }
+S1> s4;
+// Test empty template arg.
+// CHECK-NEXT: %struct.S1.3 = type { i8 }
+S1<> s5;
\ No newline at end of file
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5927,6 +5927,8 @@
  /*ExpectPackInType=*/false);
   }
   break;
+case DeclaratorContext::Member:
+  // Expand for packed data members.
 case DeclaratorContext::TemplateParam:
   // C++0x [temp.param]p15:
   //   If a template-parameter is a [...] is a parameter-declaration that
@@ -5944,7 +5946,6 @@
  ? diag::warn_cxx98_compat_variadic_templates
  : diag::ext_variadic_templates);
   break;
-
 case DeclaratorContext::File:
 case DeclaratorContext::KNRTypeList:
 case DeclaratorContext::ObjCParameter: // FIXME: special diagnostic here?
@@ -5954,7 +5955,6 @@
 case DeclaratorContext::CXXNew:
 case DeclaratorContext::AliasDecl:
 case DeclaratorContext::AliasTemplate:
-case DeclaratorContext::Member:
 case DeclaratorContext::Block:
 case DeclaratorContext::ForInit:
 case DeclaratorContext::SelectionInit:
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3267,42 +3267,75 @@
   continue;
 }
 
-Decl *NewMember = Instantiator.Visit(Member);
-if (NewMember) {
-  if (FieldDecl *Field = dyn_cast(NewMember)) {
-Fields.push_back(Field);
-  } else if (EnumDecl *Enum = dyn_cast(NewMember)) {
-// C++11 [temp.inst]p1: The implicit instantiation of a class template
-// specialization causes the implicit instantiation of the definitions
-// of unscoped member enumerations.
-// Record a point of instantiation for this implicit instantiation.
-if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
-Enum->isCompleteDefinition()) {
-  MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
-  assert(MSInfo && "no spec info for member enum specialization");
-  MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation);
-  MSInfo->setPointOfInstantiation(PointOfInstantiation);
-}
-  } else if (StaticAssertDecl *SA = dyn_cast(NewMember)) {
-if (SA->isFailed()) {
-  // A static_assert failed. Bail out; instantiating this
-  // class is probably not meaningful.
-  Instantiation->setInvalidDecl();
-  break;
+// Instantiate packed data members.
+if (FieldDecl *Field = dyn_cast(Member);
+Field && isa(Field->getType().getTypePtr())) {
+  QualType PatternType = Field->getType()
+ ->castAs()
+ ->getPattern();
+  std::optional NumArgumentsInExpansion =
+  getNumArgumentsInExpansion(Field->getType(), TemplateArgs);
+  assert(NumArgumentsInExpansion && "should not see unknown template argument here");
+  for (unsigned Arg = 0; Arg < NumArgumentsInExpansion; ++Arg) {
+// Generate a new field from PackExpansion field.
+Decl *NewMember = Instantiator.Visit(Member);
+if (NewMember) {
+  FieldDecl *PackedField = dyn_cast(NewMember);
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, Arg);
+  QualType T =
+  SubstType(PatternType, TemplateArgs, PackedField->getLocation(),
+PackedField->getDeclName());
+  PackedField->setType(T);
+  

[PATCH] D156576: Remove rdar links in clang/lib. NFC

2023-07-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: ravikandhadai.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.
Herald added a subscriber: MaskRay.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156576

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaObjCProperty.cpp


Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't supported.
+  // a linker bug (see https://openradar.appspot.com/7198997), and CUDA device
+  // code, where aliases aren't supported.
   if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5983,7 +5983,7 @@
   }
 
   // Note: -fwritable-strings doesn't make the backing store strings of
-  // CFStrings writable. (See )
+  // CFStrings writable.
   auto *GV =
   new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, C, ".str");
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -3329,7 +3329,7 @@
   struct _objc_method_list *instance_methods;
   struct _objc_method_list *class_methods;
   struct _objc_protocol_list *protocols;
-  uint32_t size; // 
+  uint32_t size; // sizeof(struct _objc_category)
   struct _objc_property_list *instance_properties;
   struct _objc_property_list *class_properties;
   };
@@ -4492,8 +4492,7 @@
   indeterminate value.  For the purposes of LLVM IR, it may be
   sufficient to make loads and stores within the @try (to variables
   declared outside the @try) volatile.  This is necessary for
-  optimized correctness, but is not currently being done; this is
-  being tracked as rdar://problem/8160285
+  optimized correctness (note: this was fixed in 
42227edc79b34ba31220d4712d2da).
 
   The basic framework for a @try-catch-finally is as follows:
   {
@@ -5092,7 +5091,8 @@
   eImageInfo_OptimizedByDyld = (1 << 3), // This flag is set by the dyld 
shared cache.
 
   // A flag indicating that the module has no instances of a @synthesize of a
-  // superclass variable. 
+  // superclass variable. This flag used to be consumed by the runtime to work
+  // around miscompile by gcc.
   eImageInfo_CorrectedSynthesize = (1 << 4), // This flag is no longer set by 
clang.
   eImageInfo_ImageIsSimulated= (1 << 5),
   eImageInfo_ClassProperties = (1 << 6)


Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2795,9 +2795,7 @@
 }
 
 // FIXME: Implement warning dependent on NSCopying being
-// implemented. See also:
-// 
-// (please trim this list while you are at it).
+// implemented.
   }
 
   if (!(Attributes & ObjCPropertyAttribute::kind_copy) &&
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5578,8 +5578,8 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA device code, where
-  // aliases aren't supported.
+  // a linker bug (see https://openradar.appspot.com/7198997), and CUDA device
+  // code, where aliases aren't supported.
   if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5983,7 +5983,7 @@
   }
 
   // Note: -fwritable-strings doesn't make the backing store strings of
-  // CFStrings writable. (See )
+  // 

[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-28 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao updated this revision to Diff 545286.
SlaterLatiao added a comment.

- Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-print-method-decl.cpp
  clang/test/CodeGenCXX/data_member_packs.cpp

Index: clang/test/CodeGenCXX/data_member_packs.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/data_member_packs.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 --std=c++20 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s --check-prefixes=CHECK
+
+// Tests declaration data member packs.
+template struct S1 {
+Ts... ts;
+};
+
+template struct S2 {
+T t[2];
+Ts... ts;
+};
+
+// CHECK: %struct.S1 = type { i32 }
+S1 s1;
+// CHECK-NEXT: %struct.S1.0 = type { i32, float, double }
+S1 s2;
+// Test template args as the last arg.
+// CHECK-NEXT: %struct.S2 = type { [2 x i32], float, double }
+S2 s3;
+// Test nested template args.
+// CHECK-NEXT: %struct.S1.1 = type { i32, float, %struct.S1.2 }
+// CHECK-NEXT: %struct.S1.2 = type { double, double }
+S1> s4;
+// Test empty template arg.
+// CHECK-NEXT: %struct.S1.3 = type { i8 }
+S1<> s5;
+// Test duplicate types in template args.
+// CHECK-NEXT: %struct.S1.4 = type { i32, i32 }
+S1 s6;
Index: clang/test/AST/ast-print-method-decl.cpp
===
--- clang/test/AST/ast-print-method-decl.cpp
+++ clang/test/AST/ast-print-method-decl.cpp
@@ -85,3 +85,18 @@
 
   // CHECK-NEXT: };
 };
+
+
+// CHECK: struct DefMethodsWithoutBody {
+struct DefMethodsWithoutBody {
+  // CHECK-NEXT: DefMethodsWithoutBody() = delete;
+  DefMethodsWithoutBody() = delete;
+
+  // CHECK-NEXT: DefMethodsWithoutBody() = default;
+  ~DefMethodsWithoutBody() = default;
+
+  // CHECK-NEXT: void m1() __attribute__((alias("X")));
+  void m1() __attribute__((alias("X")));
+
+  // CHECK-NEXT: };
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5927,6 +5927,8 @@
  /*ExpectPackInType=*/false);
   }
   break;
+case DeclaratorContext::Member:
+  // Expand for packed data members.
 case DeclaratorContext::TemplateParam:
   // C++0x [temp.param]p15:
   //   If a template-parameter is a [...] is a parameter-declaration that
@@ -5944,7 +5946,7 @@
  ? diag::warn_cxx98_compat_variadic_templates
  : diag::ext_variadic_templates);
   break;
-
+  
 case DeclaratorContext::File:
 case DeclaratorContext::KNRTypeList:
 case DeclaratorContext::ObjCParameter: // FIXME: special diagnostic here?
@@ -5954,7 +5956,6 @@
 case DeclaratorContext::CXXNew:
 case DeclaratorContext::AliasDecl:
 case DeclaratorContext::AliasTemplate:
-case DeclaratorContext::Member:
 case DeclaratorContext::Block:
 case DeclaratorContext::ForInit:
 case DeclaratorContext::SelectionInit:
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3267,42 +3267,74 @@
   continue;
 }
 
-Decl *NewMember = Instantiator.Visit(Member);
-if (NewMember) {
-  if (FieldDecl *Field = dyn_cast(NewMember)) {
-Fields.push_back(Field);
-  } else if (EnumDecl *Enum = dyn_cast(NewMember)) {
-// C++11 [temp.inst]p1: The implicit instantiation of a class template
-// specialization causes the implicit instantiation of the definitions
-// of unscoped member enumerations.
-// Record a point of instantiation for this implicit instantiation.
-if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
-Enum->isCompleteDefinition()) {
-  MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
-  assert(MSInfo && "no spec info for member enum specialization");
-  MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation);
-  MSInfo->setPointOfInstantiation(PointOfInstantiation);
-}
-  } else if (StaticAssertDecl *SA = dyn_cast(NewMember)) {
-if (SA->isFailed()) {
-  // A static_assert failed. Bail out; instantiating this
-  // class is probably not meaningful.
-  Instantiation->setInvalidDecl();
-  break;
+// Instantiate packed data members.
+if (FieldDecl *Field = dyn_cast(Member);
+Field && isa(Field->getType().getTypePtr())) {
+  QualType PatternType = Field->getType()
+ ->castAs()
+ ->getPattern();
+  

[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-28 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

As I posted on the RFC thread, I think we have a viable alternative solution to 
address the original motiving use-case.

One might potentially still make a case for implementing the `-fno-coroutines` 
flag for GCC compatibility, but given the concerns raised -- and that the 
use-case is gone -- it may be better to leave it unimplemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-07-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 545283.
shafik added a comment.

Add release note.


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

https://reviews.llvm.org/D155387

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Lookup.h
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
  clang/test/CXX/class.derived/class.member.lookup/p11.cpp
  clang/test/SemaCXX/arrow-operator.cpp

Index: clang/test/SemaCXX/arrow-operator.cpp
===
--- clang/test/SemaCXX/arrow-operator.cpp
+++ clang/test/SemaCXX/arrow-operator.cpp
@@ -4,11 +4,13 @@
 };
 
 struct A {
-  T* operator->(); // expected-note{{candidate function}}
+  T* operator->();
+   // expected-note@-1 {{member found by ambiguous name lookup}}
 };
 
 struct B {
-  T* operator->(); // expected-note{{candidate function}}
+  T* operator->();
+   // expected-note@-1 {{member found by ambiguous name lookup}}
 };
 
 struct C : A, B {
@@ -19,7 +21,8 @@
 struct E; // expected-note {{forward declaration of 'E'}}
 
 void f(C , D& d, E& e) {
-  c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}}
+  c->f();
+  // expected-error@-1 {{member 'operator->' found in multiple base classes of different types}}
   d->f();
   e->f(); // expected-error{{incomplete definition of type}}
 }
Index: clang/test/CXX/class.derived/class.member.lookup/p11.cpp
===
--- /dev/null
+++ clang/test/CXX/class.derived/class.member.lookup/p11.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct B1 {
+  void f();
+  static void f(int);
+  int i; // expected-note 2{{member found by ambiguous name lookup}}
+};
+struct B2 {
+  void f(double);
+};
+struct I1: B1 { };
+struct I2: B1 { };
+
+struct D: I1, I2, B2 {
+  using B1::f;
+  using B2::f;
+  void g() {
+f(); // expected-error {{ambiguous conversion from derived class 'D' to base class 'B1'}}
+f(0); // ok
+f(0.0); // ok
+// FIXME next line should be well-formed
+int B1::* mpB1 = ::i; // expected-error {{non-static member 'i' found in multiple base-class subobjects of type 'B1'}}
+int D::* mpD = ::i; // expected-error {{non-static member 'i' found in multiple base-class subobjects of type 'B1'}}
+  }
+};
Index: clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
===
--- /dev/null
+++ clang/test/CXX/class.derived/class.member.lookup/gh22413.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+  void operator()(int); // expected-note {{member found by ambiguous name lookup}}
+  void f(int); // expected-note {{member found by ambiguous name lookup}}
+};
+struct B {
+  void operator()(); // expected-note {{member found by ambiguous name lookup}}
+  void f() {} // expected-note {{member found by ambiguous name lookup}}
+};
+
+struct C : A, B {};
+
+int f() {
+C c;
+c(); // expected-error {{member 'operator()' found in multiple base classes of different types}}
+c.f(10); //expected-error {{member 'f' found in multiple base classes of different types}}
+return 0;
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -593,7 +593,7 @@
   // postfix-expression and does not name a class template, the name
   // found in the class of the object expression is used, otherwise
   FoundOuter.clear();
-} else if (!Found.isSuppressingDiagnostics()) {
+} else if (!Found.isSuppressingAmbiguousDiagnostics()) {
   //   - if the name found is a class template, it must refer to the same
   // entity as the one found in the class of the object expression,
   // otherwise the program is ill-formed.
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -950,7 +950,7 @@
 LookupResult Members(S, NotEqOp, OpLoc,
  Sema::LookupNameKind::LookupMemberName);
 S.LookupQualifiedName(Members, RHSRec->getDecl());
-Members.suppressDiagnostics();
+Members.suppressAccessDiagnostics();
 for (NamedDecl *Op : Members)
   if (FunctionsCorrespond(S.Context, EqFD, Op->getAsFunction()))
 return false;
@@ -961,7 +961,7 @@
   Sema::LookupNameKind::LookupOperatorName);
   S.LookupName(NonMembers,
S.getScopeForContext(EqFD->getEnclosingNamespaceContext()));
-  NonMembers.suppressDiagnostics();
+  NonMembers.suppressAccessDiagnostics();
   for (NamedDecl *Op : NonMembers) {
 auto *FD = Op->getAsFunction();
 if(auto* UD = dyn_cast(Op))
@@ -7987,7 

[PATCH] D156546: [Clang][WIP]Experimental implementation of packed data members declarations

2023-07-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(just a side note about the title of this patch: I got "packed data members" 
confused and thought this was referring to struct packing 
`__attribute__((packed))` - so perhaps something more like "data member packs" 
would be a more clear term here?)




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3281-3282
+// Generate a new field from PackExpansion field.
+Decl *NewMember = Instantiator.Visit(Member);
+if (NewMember) {
+  FieldDecl *PackedField = dyn_cast(NewMember);





Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3283
+if (NewMember) {
+  FieldDecl *PackedField = dyn_cast(NewMember);
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, Arg);





Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:8-12
+template struct S2 {
+T t[2];
+Ts... ts;
+};
+

Did this test case come out of any particular bug discovered during 
implementation?



Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:14
+// CHECK: %struct.S1 = type { i32 }
+S1 s1;
+// CHECK-NEXT: %struct.S1.0 = type { i32, float, double }

Not sure, but might be worth a test with multiple of the same type in the pack?



Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:27
+S1<> s5;
\ No newline at end of file


(please add the missing newline at the end of the file here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

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


[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-07-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D105759#4543246 , @aaron.ballman 
wrote:

> I'd recommend we change the diagnostic to be a warning that defaults to an 
> error so that users who are caught by the changes can still disable the 
> diagnostic rather than be stuck; for Clang 18, we can explore other solutions 
> to the issue. Would this work for you @hubert.reinterpretcast?

I think there are questions about whether an error (or even warning) by default 
is appropriate. This seems to be a change for C++2c that does not have "DR" 
treatment from the committee. Considering this a warning controlled by 
`c++2c-compat` is a potential direction. Indeed, if we are going to accept the 
code, we might as well allow it as an extension in C++2c modes. With this line 
of logic, I don't see why we would want user-side churn of making a migration 
effort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:663
+} else {
+  llvm::sys::path::remove_dots(AbsPathBuf, /*remove_dot_dot=*/true);
+  CanonicalName = AbsPathBuf.str().copy(CanonicalNameStorage);

MrTrillian wrote:
> benlangmuir wrote:
> > MrTrillian wrote:
> > > benlangmuir wrote:
> > > > MrTrillian wrote:
> > > > > benlangmuir wrote:
> > > > > > Removing .. can change where the path points in the presence of 
> > > > > > symlinks; is this needed?
> > > > > > Removing .. can change where the path points in the presence of 
> > > > > > symlinks; is this needed?
> > > > > 
> > > > > @benlangmuir That's true and not ideal, but `makeAbsolute` will not 
> > > > > resolve `/./` or `/../` in paths, so it's not a canonicalization and 
> > > > > some tests were failing because of that. One alternative would be to 
> > > > > use `makeAbsolute` + `remove_dots` on Windows (where removing dot 
> > > > > dots is semantically correct) and `getRealPath` on Unix, like I do in 
> > > > > lit. Suggestions?
> > > > Wouldn't removing .. have the same issue with symlinks on Windows? I 
> > > > know symlinks are less common there, but it's not clear to me why it 
> > > > would be correct.  I guess you could also check if the paths resolve to 
> > > > the same file after removing ..
> > > > 
> > > > 
> > > @benlangmuir Windows simplifies `\..\` in paths before starting to walk 
> > > the filesystem. 
> > > https://superuser.com/questions/1502360/different-behavior-of-double-dots-and-symlinks-in-windows-and-unix
> > > 
> > > If I detected that the path didn't resolve to the same file after 
> > > removing `..`, what would I do?
> > > 
> > > I think the current logic will only end up using the `else` branch on 
> > > Windows. At least I can't think of a scenario where the root would change 
> > > from using realpath on unix.
> > Thanks, I wasn't aware of that subtlety! I suggest we add a comment about 
> > that here and also mention (or assert) that this is only reachable on 
> > Windows.
> > Thanks, I wasn't aware of that subtlety! I suggest we add a comment about 
> > that here and also mention (or assert) that this is only reachable on 
> > Windows.
> 
> @benlangmuir Accounted for in lastest revision. The root-preserving 
> canonicalization logic is now Windows-only.
Thanks, looks good.


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

https://reviews.llvm.org/D154130

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


[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-07-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This looks good to me. I think we can further refine the handling of duplicate 
diagnostics but I don't think that needs to be done as part of this bugfix.




Comment at: clang/lib/Sema/SemaOverload.cpp:953
 S.LookupQualifiedName(Members, RHSRec->getDecl());
-Members.suppressDiagnostics();
+Members.suppressAccessDiagnostics();
 for (NamedDecl *Op : Members)

Can we get duplicate diagnostics here if this lookup fails due to ambiguity? I 
think we'll perform the same lookup again when looking for candidates if the 
original operator was `!=`.

(I wonder if we can fix that by avoiding the duplicate lookup, rather than by 
suppressing ambiguity diagnostics.)



Comment at: clang/lib/Sema/SemaOverload.cpp:964
S.getScopeForContext(EqFD->getEnclosingNamespaceContext()));
-  NonMembers.suppressDiagnostics();
+  NonMembers.suppressAccessDiagnostics();
   for (NamedDecl *Op : NonMembers) {

There can't be any access diagnostics here because this is a namespace-scope 
lookup. You can just drop this call entirly.



Comment at: clang/lib/Sema/SemaOverload.cpp:15083
   case OR_Ambiguous:
-CandidateSet.NoteCandidates(
-PartialDiagnosticAt(Object.get()->getBeginLoc(),
-PDiag(diag::err_ovl_ambiguous_object_call)
-<< Object.get()->getType()
-<< Object.get()->getSourceRange()),
-*this, OCD_AmbiguousCandidates, Args);
+if (!R.isAmbiguous())
+  CandidateSet.NoteCandidates(

I think we should also check whether the ambiguous viable functions were all 
first declared in the same base class here. If so, then it still makes sense to 
`NoteCandidates`, because the ambiguous lookup had nothing to do with the 
ambiguous overload resolution.



Comment at: clang/lib/Sema/SemaOverload.cpp:15293
   case OR_Ambiguous:
-CandidateSet.NoteCandidates(
-PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_unary)
-   << "->" << Base->getType()
-   << Base->getSourceRange()),
-*this, OCD_AmbiguousCandidates, Base);
+if (!R.isAmbiguous())
+  CandidateSet.NoteCandidates(

(Likewise here.)



Comment at: clang/lib/Sema/SemaOverload.cpp:15191
   OverloadCandidateSet::iterator Best;
   switch (CandidateSet.BestViableFunction(*this, OpLoc, Best)) {
   case OR_Success:

shafik wrote:
> rsmith wrote:
> > shafik wrote:
> > > @rsmith if `R.isAmbiguous()` should we even check the overload 
> > > candidates? 
> > > 
> > > Right now in `clang/test/SemaCXX/arrow-operator.cpp` we are getting both 
> > > an ambiguous name lookup and overload diagnostic. 
> > Hm, I think perhaps the ideal thing to do is: if `BestViableFunction` 
> > returns `OR_Ambiguous`, the lookup was ambiguous, and we found viable 
> > functions in multiple different base classes, then don't produce any 
> > further diagnostics. That way, we still get good error recovery in the case 
> > where the overloading is unambiguous despite the lookup being ambiguous, or 
> > when the overloading is ambiguous for some reason unrelated to the 
> > ambiguous lookup.
> > 
> > (We'd want to do this in all the overloaded operator lookups in this file, 
> > not just for `operator->`.)
> I only found one other location that matched this pattern if you meant a 
> larger change let me know. 
Ideally, we should make `AddMemberOperatorCandidates` (and 
`LookupOverloadedBinOp`) inform its three callers whether its lookup was 
ambiguous, so that they can also suppress the duplicate ambiguity diagnostics, 
for unary operators, binary operators, and subscripting.


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

https://reviews.llvm.org/D155387

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


[PATCH] D155991: [DWARF] Make sure file entry for artificial functions has an MD5 checksum

2023-07-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

See https://reviews.llvm.org/D156571


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155991

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


[PATCH] D156571: [DebugInfo] Alternate MD5 fix, NFC

2023-07-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added reviewers: dblaikie, nikic.
probinson added a project: debug-info.
Herald added a subscriber: StephenFan.
Herald added a project: All.
probinson requested review of this revision.

Should have lower memory and time cost than D155991 
.


https://reviews.llvm.org/D156571

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h


Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -148,7 +148,7 @@
   llvm::BumpPtrAllocator DebugInfoNames;
   StringRef CWDName;
 
-  llvm::StringMap DIFileCache;
+  llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations and global alias variables) that aren't covered
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -397,6 +397,17 @@
 // createFile() below for canonicalization if the source file was specified
 // with an absolute path.
 FileName = TheCU->getFile()->getFilename();
+for (auto It : DIFileCache) {
+  // StringRef operator== does a content comparison.
+  if (FileName == It.first) {
+// Got a string match, use the existing DIFile if possible.
+if (llvm::Metadata *V = It.second)
+  return cast(V);
+// Fall through to create the DIFile but use the original string.
+FileName = It.first;
+break;
+  }
+}
   } else {
 PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 FileName = PLoc.getFilename();


Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -148,7 +148,7 @@
   llvm::BumpPtrAllocator DebugInfoNames;
   StringRef CWDName;
 
-  llvm::StringMap DIFileCache;
+  llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations and global alias variables) that aren't covered
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -397,6 +397,17 @@
 // createFile() below for canonicalization if the source file was specified
 // with an absolute path.
 FileName = TheCU->getFile()->getFilename();
+for (auto It : DIFileCache) {
+  // StringRef operator== does a content comparison.
+  if (FileName == It.first) {
+// Got a string match, use the existing DIFile if possible.
+if (llvm::Metadata *V = It.second)
+  return cast(V);
+// Fall through to create the DIFile but use the original string.
+FileName = It.first;
+break;
+  }
+}
   } else {
 PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 FileName = PLoc.getFilename();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156565#4543414 , @jrtc27 wrote:

> Given GCC defines GNU C++ and regards this as a feature (unless you use 
> things like -pedantic to ask for ISO C++), does it make sense to enable this 
> for GNU C++?

I think GCC should enable -Wvla by default in GNU C++ as well, for the same 
reasons I'm proposing it for Clang. I've filed an issue for it at 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110848

> Every deviation from GCC is a point of friction for adopting Clang over GCC.

It is, but one of the selling points of Clang is that we strive to 
comprehensive diagnostics and that sometimes leads to these deviations with 
GCC. We don't make much of a distinction between GNU++ and C++ modes in Clang 
(~10 uses of `GNUMode` in the frontend), but that is an approach I could take 
should it be necessary. However, I strongly prefer to enable this diagnostic in 
all C++ modes -- VLA use in C++ is deeply weird and easy to overlook, making it 
a bug factory: 
https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+VLA+C%2B%2B


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156565

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian marked an inline comment as done.
MrTrillian added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:663
+} else {
+  llvm::sys::path::remove_dots(AbsPathBuf, /*remove_dot_dot=*/true);
+  CanonicalName = AbsPathBuf.str().copy(CanonicalNameStorage);

benlangmuir wrote:
> MrTrillian wrote:
> > benlangmuir wrote:
> > > MrTrillian wrote:
> > > > benlangmuir wrote:
> > > > > Removing .. can change where the path points in the presence of 
> > > > > symlinks; is this needed?
> > > > > Removing .. can change where the path points in the presence of 
> > > > > symlinks; is this needed?
> > > > 
> > > > @benlangmuir That's true and not ideal, but `makeAbsolute` will not 
> > > > resolve `/./` or `/../` in paths, so it's not a canonicalization and 
> > > > some tests were failing because of that. One alternative would be to 
> > > > use `makeAbsolute` + `remove_dots` on Windows (where removing dot dots 
> > > > is semantically correct) and `getRealPath` on Unix, like I do in lit. 
> > > > Suggestions?
> > > Wouldn't removing .. have the same issue with symlinks on Windows? I know 
> > > symlinks are less common there, but it's not clear to me why it would be 
> > > correct.  I guess you could also check if the paths resolve to the same 
> > > file after removing ..
> > > 
> > > 
> > @benlangmuir Windows simplifies `\..\` in paths before starting to walk the 
> > filesystem. 
> > https://superuser.com/questions/1502360/different-behavior-of-double-dots-and-symlinks-in-windows-and-unix
> > 
> > If I detected that the path didn't resolve to the same file after removing 
> > `..`, what would I do?
> > 
> > I think the current logic will only end up using the `else` branch on 
> > Windows. At least I can't think of a scenario where the root would change 
> > from using realpath on unix.
> Thanks, I wasn't aware of that subtlety! I suggest we add a comment about 
> that here and also mention (or assert) that this is only reachable on Windows.
> Thanks, I wasn't aware of that subtlety! I suggest we add a comment about 
> that here and also mention (or assert) that this is only reachable on Windows.

@benlangmuir Accounted for in lastest revision. The root-preserving 
canonicalization logic is now Windows-only.


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

https://reviews.llvm.org/D154130

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian updated this revision to Diff 545250.
MrTrillian marked an inline comment as done.
MrTrillian added a comment.

@benlangmuir I made the root-preserving canonicalization logic Windows-only now 
that I found how to test for that. It changes the code shape a little but I 
think it's an improvement.


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

https://reviews.llvm.org/D154130

Files:
  clang/include/clang/Basic/FileManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/test/Lexer/case-insensitive-include-win.c
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/lit/discovery.py
  llvm/utils/lit/lit/util.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
  llvm/utils/llvm-lit/llvm-lit.in

Index: llvm/utils/llvm-lit/llvm-lit.in
===
--- llvm/utils/llvm-lit/llvm-lit.in
+++ llvm/utils/llvm-lit/llvm-lit.in
@@ -8,7 +8,7 @@
 
 def map_config(source_dir, site_config):
 global config_map
-source_dir = os.path.realpath(source_dir)
+source_dir = os.path.abspath(source_dir)
 source_dir = os.path.normcase(source_dir)
 site_config = os.path.normpath(site_config)
 config_map[source_dir] = site_config
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-this_dir = os.path.realpath(os.path.dirname(__file__))
+this_dir = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 config.llvm_tools_dir = os.path.join(this_dir, "build")
 import lit.llvm
 
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool-required"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-config.llvm_tools_dir = os.path.realpath(os.path.dirname(__file__))
+config.llvm_tools_dir = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 import lit.llvm
 
 lit.llvm.initialize(lit_config, config)
Index: llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
===
--- llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
+++ llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
@@ -5,5 +5,5 @@
 config.test_format = lit.formats.ShTest()
 
 import os
-config.test_exec_root = os.path.realpath(os.path.dirname(__file__))
+config.test_exec_root = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 config.test_source_root = os.path.join(config.test_exec_root, "tests")
Index: llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
===
--- llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
+++ llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
@@ -2,9 +2,7 @@
 import os
 import sys
 
-main_config = sys.argv[1]
-main_config = os.path.realpath(main_config)
-main_config = os.path.normcase(main_config)
+main_config = lit.util.abs_path_preserve_drive(sys.argv[1])
 
 config_map = {main_config: sys.argv[2]}
 builtin_parameters = {"config_map": config_map}
Index: llvm/utils/lit/lit/util.py
===
--- llvm/utils/lit/lit/util.py
+++ llvm/utils/lit/lit/util.py
@@ -127,6 +127,23 @@
 
 return n
 
+def abs_path_preserve_drive(path):
+"""Return the absolute path without resolving drive mappings on Windows.
+
+"""
+if platform.system() == "Windows":
+# Windows has limitations on path length (MAX_PATH) that
+# can be worked around using substitute drives, which map
+# a drive letter to a longer path on another drive.
+# Since Python 3.8, os.path.realpath resolves sustitute drives,
+# so we should not use it. In Python 3.7, os.path.realpath
+# was implemented as os.path.abspath.
+return os.path.normpath(os.path.abspath(path))
+else:
+# On UNIX, the current directory always has symbolic links resolved,
+# so any program accepting relative paths cannot preserve symbolic
+# links in 

[PATCH] D156357: clang: Add elementwise bitreverse builtin

2023-07-28 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:634
  the most negative integer remains 
the most negative integer
- T __builtin_elementwise_fma(T x, T y, T z)  fused multiply add, (x * y) +  z. 
 floating point types
+ T __builtin_elementwise_fma(T x, T y, T z)  fused multiply add, (x * y) +  z. 
   floating point types
  T __builtin_elementwise_ceil(T x)   return the smallest integral 
value greater than or equal to xfloating point types

arsenm wrote:
> Unrelated but I noticed a couple of the elementwise builtins are missing from 
> this list if you're fixing up the docs for them. Can't remember which off the 
> top of my head
Are you sure? 
I double checked CGBuiltin.cpp and Builtins.def for all 
"builtin_elementwise*"'s, there's only the 24 listed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156357

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


[PATCH] D156357: clang: Add elementwise bitreverse builtin

2023-07-28 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 545251.
bob80905 added a comment.

- add float4 test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156357

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -206,3 +206,10 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_bitreverse() {
+  const int a = 2;
+  int b = 1;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);  
+}
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -269,6 +269,27 @@
   // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
 }
 
+void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_ceil(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_bitreverse();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_bitreverse(f);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}}
+  
+  i = __builtin_elementwise_bitreverse(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_bitreverse(d);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}}
+
+  v = __builtin_elementwise_bitreverse(v);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
+}
+
 void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_ceil(f);
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -323,6 +323,42 @@
   int_as_one = __builtin_elementwise_min(int_as_one, b);
 }
 
+void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2,
+  long long int i1, long long int i2, short si,
+  _BitInt(31) bi1, _BitInt(31) bi2) {
+  
+
+  // CHECK:  [[I1:%.+]] = load i64, ptr %i1.addr, align 8
+  // CHECK-NEXT: call i64 @llvm.bitreverse.i64(i64 [[I1]])
+  i2 = __builtin_elementwise_bitreverse(i1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16
+  // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[VI1]])
+  vi2 = __builtin_elementwise_bitreverse(vi1);
+
+  // CHECK:  [[CVI2:%.+]] = load <8 x i16>, ptr %cvi2, align 16
+  // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[CVI2]])
+  const si8 cvi2 = vi2;
+  vi2 = __builtin_elementwise_bitreverse(cvi2);
+
+  // CHECK:  [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4
+  // CHECK-NEXT: call i31 @llvm.bitreverse.i31(i31 [[BI1]])
+  bi2 = __builtin_elementwise_bitreverse(bi1);
+
+  // CHECK:  [[IA1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4
+  // CHECK-NEXT: call i32 @llvm.bitreverse.i32(i32 [[IA1]])
+  b = __builtin_elementwise_bitreverse(int_as_one);
+
+  // CHECK:   call i32 @llvm.bitreverse.i32(i32 -10)
+  b = __builtin_elementwise_bitreverse(-10);
+
+  // CHECK:  [[SI:%.+]] = load i16, ptr %si.addr, align 2
+  // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32
+  // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.bitreverse.i32(i32 [[SI_EXT]])
+  // CHECK-NEXT: = trunc i32 [[RES]] to i16
+  si = __builtin_elementwise_bitreverse(si);
+}
+
 void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2,
float4 vf1, float4 vf2) {
   // CHECK-LABEL: define void @test_builtin_elementwise_ceil(
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2700,6 +2700,26 @@
 if (SemaBuiltinElementwiseMath(TheCall))
   return ExprError();
 break;
+
+  case Builtin::BI__builtin_elementwise_bitreverse: {
+if 

[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156247#4542769 , @ilya-biryukov 
wrote:

> In D156247#4542155 , @aaron.ballman 
> wrote:
>
>> Given the views expressed on this thread, I think this requires a wider 
>> community discussion to determine whether we want to support this idea or 
>> not, regardless of -cc1 or driver-level option. We should not be adding a 
>> novel language dialect as we're getting ready to cut a release unless the 
>> need and benefits are *very* compelling, and I don't think that's the case 
>> here. We need the time to think about the long-term effects of such a mode, 
>> so I don't think Clang 17 is an appropriate ship vehicle for this change, 
>> especially because Google can carry this patch in your downstream easily 
>> enough.
>
> Google cannot do this with a downstream patch as we need this for toolchains 
> that we do not build from the LLVM sources we integrate.
> If we could do with a local patch, we would have definitely done it.

Good to know! How certain are you that the other toolchains will have been cut 
such that they support this feature given how late in our cycle it is? 
@Mordante had some evidence that Apple Clang is from June, for example.

>> My recommendation is to start an RFC on Discourse. If the community quickly 
>> and decisively agrees this should land in Clang 17 in the next few days, it 
>> might still be reasonable to make the rc2 cutoff, but I'd leave that 
>> decision to the release managers and it would be contingent on strong libc++ 
>> maintainer agreement to whatever direction we go (because they'll be the 
>> most impacted by this decision).
>
> https://discourse.llvm.org/t/rfc-add-a-flag-to-clang-17-to-disable-coroutines-in-c-20
>
> @aaron.ballman could you comment on having a `-cc1` flag without guarantees 
> from libc++ folks that this works (so it imposes no support costs on them)?

Personally (not a code owner decision statement)...
I think it's a bad precedent to add a -cc1 flag knowing we won't support it and 
that only exists to help enforce a coding style decision. I think it's 
especially bad precedent to add features to a release branch without having any 
bake time in the main tree. I don't think we should add any `-fno-` flags for 
standardized language features unless the feature imposes extra cost even when 
not in use. e.g., exceptions and RTTI are very reasonable to disable, but 
allowing arbitrary mixing and matching of language features to create your own 
mutant C++ version seems like a support nightmare in general. I know that 
clang-tidy isn't a great solution for you, but that's where I think this 
functionality belongs just the same even if it isn't ideal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-07-28 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 545247.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142660

Files:
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/lit.cfg.py
  clang/tools/clang-offload-packager/ClangOffloadPackager.cpp
  llvm/include/llvm/Object/Archive.h
  llvm/include/llvm/Object/ArchiveWriter.h
  llvm/lib/ObjCopy/Archive.cpp
  llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
  llvm/lib/Object/Archive.cpp
  llvm/lib/Object/ArchiveWriter.cpp
  llvm/lib/Object/COFFImportFile.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/test/tools/llvm-ranlib/aix-X-option.test
  llvm/test/tools/llvm-ranlib/non-AIX-not-supportedwq-X-option.test
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp

Index: llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
===
--- llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -600,18 +600,17 @@
 
   if (NewMembers.size() == 1)
 return writeArchive(OutputFile, NewMembers.begin()->second.getMembers(),
-/*WriteSymtab=*/true,
+SymtabWritingMode::NormalSymtab,
 /*Kind=*/object::Archive::K_DARWIN, C.Deterministic,
 /*Thin=*/false);
 
   SmallVector, 2> OutputBinaries;
   for (const std::pair  : NewMembers) {
 Expected> OutputBufferOrErr =
-writeArchiveToBuffer(M.second.getMembers(),
- /*WriteSymtab=*/true,
- /*Kind=*/object::Archive::K_DARWIN,
- C.Deterministic,
- /*Thin=*/false);
+writeArchiveToBuffer(
+M.second.getMembers(), SymtabWritingMode::NormalSymtab,
+/*Kind=*/object::Archive::K_DARWIN, C.Deterministic,
+/*Thin=*/false);
 if (!OutputBufferOrErr)
   return OutputBufferOrErr.takeError();
 std::unique_ptr  = OutputBufferOrErr.get();
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -61,15 +61,18 @@
 static StringRef Stem;
 
 static void printRanLibHelp(StringRef ToolName) {
-  outs() << "OVERVIEW: LLVM ranlib\n\n"
- << "Generate an index for archives\n\n"
- << "USAGE: " + ToolName + " archive...\n\n"
- << "OPTIONS:\n"
- << "  -h --help - Display available options\n"
- << "  -v --version  - Display the version of this program\n"
- << "  -D- Use zero for timestamps and uids/gids "
-"(default)\n"
- << "  -U- Use actual timestamps and uids/gids\n";
+  outs()
+  << "OVERVIEW: LLVM ranlib\n\n"
+  << "Generate an index for archives\n\n"
+  << "USAGE: " + ToolName + " archive...\n\n"
+  << "OPTIONS:\n"
+  << "  -h --help - Display available options\n"
+  << "  -v --version  - Display the version of this program\n"
+  << "  -D- Use zero for timestamps and uids/gids "
+ "(default)\n"
+  << "  -U- Use actual timestamps and uids/gids\n"
+  << "  -X{32|64|32_64|any}   - Specifies which archive symbol tables "
+ "should be generated if they do not already exist (AIX OS only)\n";
 }
 
 static void printArHelp(StringRef ToolName) {
@@ -225,7 +228,8 @@
 static bool CompareFullPath = false;  ///< 'P' modifier
 static bool OnlyUpdate = false;   ///< 'u' modifier
 static bool Verbose = false;  ///< 'v' modifier
-static bool Symtab = true;///< 's' modifier
+static SymtabWritingMode Symtab =
+SymtabWritingMode::NormalSymtab;  ///< 's' modifier
 static bool Deterministic = true; ///< 'D' and 'U' modifiers
 static bool Thin = false; ///< 'T' modifier
 static bool AddLibrary = false;   ///< 'L' modifier
@@ -371,11 +375,11 @@
   CompareFullPath = true;
   break;
 case 's':
-  Symtab = true;
+  Symtab = SymtabWritingMode::NormalSymtab;
   MaybeJustCreateSymTab = true;
   break;
 case 'S':
-  Symtab = false;
+  Symtab = SymtabWritingMode::NoSymtab;
   break;
 case 'u':
   OnlyUpdate = true;
@@ -1074,9 +1078,27 @@
   // In summary, we only need to update the symbol table if we have none.
   // This is actually very common because of broken build systems that think
   // they have to run ranlib.
-  if (OldArchive->hasSymbolTable())
-return;
+  if (OldArchive->hasSymbolTable()) {
+if (OldArchive->kind() != object::Archive::K_AIXBIG)
+  return;
 
+// For archives in the Big Archive format, the bit mode option specifies
+// which symbol table to generate. The 

[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

2023-07-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked an inline comment as done.
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2964-2965
   if (FormatTok->is(tok::l_brace)) {
+FormatToken *LBrace = FormatTok;
+LBrace->setFinalizedType(TT_NamespaceLBrace);
+

owenpan wrote:
> Nit.
Of course, this is a remainder of trying to get the `MatchingParen`, will fix 
before commit.


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

https://reviews.llvm.org/D138263

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


[PATCH] D156027: [clang][Interp] Rework how initializers work

2023-07-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:2090
+  assert(Initializing);
+  if (!isa(E)) {
+if (!this->emitDupPtr(E))

aaron.ballman wrote:
> And if it is a member call expression?
For member calls, the layout at this point is:

```
ThisPtr
RVOPtr
RVOPtr
```
(top of the stack is where we're at). The dup here is supposed to dup the RVO 
ptr, but we can't do that for member calls because the top is currently the 
instance pointer. Tha'ts why `VisitCXXMemberCallExpr()` handles this separately.


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

https://reviews.llvm.org/D156027

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


[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-07-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Given GCC defines GNU C++ and regards this as a feature (unless you use things 
like -pedantic to ask for ISO C++), does it make sense to enable this for GNU 
C++? Every deviation from GCC is a point of friction for adopting Clang over 
GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156565

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


[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: ABataev, clang-vendors.
aaron.ballman added a comment.

The patch seems large and scary, but that's because of how often we've had to 
test VLA behavior in C++ code. The OpenMP test cases are mostly opting out of 
VLA warnings mechanically (I verified with @ABataev that this was the desired 
approach) while the non-OpenMP tests were largely updated by hand so that I 
could spot check the diagnostic behavior to ensure it's reasonable. The 
functional changes themselves are quite small.

Adding the clang-vendors group in case this is disruptive for downstreams.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156565

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


[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, erichkeane, clang-language-wg, 
hubert.reinterpretcast, shafik, jyknight.
Herald added subscribers: mattd, pmatos, asb, asavonic, jdoerfert, sbc100, 
dschuff.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added subscribers: jplehr, sstefan1, aheejin.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Clang supports VLAs in C++ as an extension, but we currently only warn on their 
use when you pass `-Wvla`, `-Wvla-extension`, or `-pedantic`. However, VLAs as 
they're expressed in C have been considered by WG21 and rejected, are easy to 
use accidentally to the surprise of users (e.g., 
https://ddanilov.me/default-non-standard-features/), and they have potential 
security implications beyond constant-size arrays 
(https://wiki.sei.cmu.edu/confluence/display/c/ARR32-C.+Ensure+size+arguments+for+variable+length+arrays+are+in+a+valid+range).
 C++ users should strongly consider using other functionality such as 
`std::vector` instead.

This seems like sufficiently compelling evidence to warn users about VLA use by 
default, to this enables the `-Wvla-extension` diagnostic group in C++. The 
warning is still opt-in in C language modes, where support for VLAs is somewhat 
less surprising to users.

Fixes https://github.com/llvm/llvm-project/issues/62836


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156565

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/regression-new-expr-crash.cpp
  clang/test/Analysis/lambdas.cpp
  clang/test/CXX/basic/basic.types/p10.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
  clang/test/FixIt/Inputs/nullability.h
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_masked_ast_print.cpp
  clang/test/OpenMP/parallel_master_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/report_default_DSA.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/single_copyprivate_messages.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_constant_device_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_messages.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
  clang/test/OpenMP/target_in_reduction_codegen.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_18a.cpp
  clang/test/OpenMP/target_map_codegen_18b.cpp
  clang/test/OpenMP/target_map_codegen_18c.cpp
  clang/test/OpenMP/target_map_codegen_18d.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_defaultmap_messages.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp

[PATCH] D156563: [clang][deps] Remove `ModuleDeps::ImportedByMainFile`

2023-07-28 Thread Jan Svoboda 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 rGc75b331fc231: [clang][deps] Remove 
`ModuleDeps::ImportedByMainFile` (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D156563?vs=545234=545238#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156563

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -242,7 +242,7 @@
 
 SmallVector DirectDeps;
 for (const auto  : ModularDeps)
-  if (KV.second->ImportedByMainFile)
+  if (DirectModularDeps.contains(KV.first))
 DirectDeps.push_back(KV.second->ID);
 
 // TODO: Report module maps the same way it's done for modular dependencies.
@@ -364,7 +364,7 @@
 MDC.DirectPrebuiltModularDeps.insert(
 {TopLevelModule, PrebuiltModuleDep{TopLevelModule}});
   else
-DirectModularDeps.insert(TopLevelModule);
+MDC.DirectModularDeps.insert(TopLevelModule);
 }
 
 void ModuleDepCollectorPP::EndOfMainFile() {
@@ -394,9 +394,9 @@
   for (const Module *M :
MDC.ScanInstance.getPreprocessor().getAffectingClangModules())
 if (!MDC.isPrebuiltModule(M))
-  DirectModularDeps.insert(M);
+  MDC.DirectModularDeps.insert(M);
 
-  for (const Module *M : DirectModularDeps)
+  for (const Module *M : MDC.DirectModularDeps)
 handleTopLevelModule(M);
 
   MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);
@@ -408,6 +408,13 @@
   for (auto & : MDC.ModularDeps)
 MDC.Consumer.handleModuleDependency(*I.second);
 
+  for (const Module *M : MDC.DirectModularDeps) {
+auto It = MDC.ModularDeps.find(M);
+// Only report direct dependencies that were successfully handled.
+if (It != MDC.ModularDeps.end())
+  MDC.Consumer.handleDirectModuleDependency(MDC.ModularDeps[M]->ID);
+  }
+
   for (auto & : MDC.FileDeps)
 MDC.Consumer.handleFileDependency(I);
 
@@ -435,7 +442,6 @@
   ModuleDeps  = *ModI.first->second;
 
   MD.ID.ModuleName = M->getFullModuleName();
-  MD.ImportedByMainFile = DirectModularDeps.contains(M);
   MD.IsSystem = M->IsSystem;
 
   ModuleMap  =
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -34,16 +34,12 @@
 Dependencies.push_back(std::string(File));
   }
 
-  void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) override {
-// Same as `handleModuleDependency`.
-  }
-
-  void handleModuleDependency(ModuleDeps MD) override {
-// These are ignored for the make format as it can't support the full
-// set of deps, and handleFileDependency handles enough for implicitly
-// built modules to work.
-  }
-
+  // These are ignored for the make format as it can't support the full
+  // set of deps, and handleFileDependency handles enough for implicitly
+  // built modules to work.
+  void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) override {}
+  void handleModuleDependency(ModuleDeps MD) override {}
+  void handleDirectModuleDependency(ModuleID ID) override {}
   void handleContextHash(std::string Hash) override {}
 
   void printDependencies(std::string ) {
@@ -179,14 +175,13 @@
 
   for (auto & : ClangModuleDeps) {
 auto  = M.second;
-if (MD.ImportedByMainFile)
-  TU.ClangModuleDeps.push_back(MD.ID);
 // TODO: Avoid handleModuleDependency even being called for modules
 //   we've already seen.
 if (AlreadySeen.count(M.first))
   continue;
 TU.ModuleGraph.push_back(std::move(MD));
   }
+  TU.ClangModuleDeps = std::move(DirectModuleDeps);
 
   return TU;
 }
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -136,10 +136,6 @@
   /// determined that the differences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  // Used to track which modules that were discovered were directly imported by
-  // the primary TU.
-  bool ImportedByMainFile = false;
-
   /// Compiler invocation that can be used 

[clang] c75b331 - [clang][deps] Remove `ModuleDeps::ImportedByMainFile`

2023-07-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-28T12:04:35-07:00
New Revision: c75b331fc23192a8249dc5e95e053258f5fb5194

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

LOG: [clang][deps] Remove `ModuleDeps::ImportedByMainFile`

This information is already exposed via `TranslationUnitDeps::ClangModuleDeps` 
on the `DependencyScanningTool` level, and this patch also adds it on the 
`DependencyScanningWorker` level via 
`DependencyConsumer::handleDirectModuleDependency()`.

Besides being redundant, this bit of information is misleading for clients that 
share single `ModuleDeps` instance between multiple TUs (by using the 
`AlreadySeen` set). The module can be imported directly in some TUs but 
transitively in others.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index 3bb9fe6dae7f7c..f2cd781f57d654 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -162,6 +162,10 @@ class FullDependencyConsumer : public DependencyConsumer {
 ClangModuleDeps[MD.ID] = std::move(MD);
   }
 
+  void handleDirectModuleDependency(ModuleID ID) override {
+DirectModuleDeps.push_back(ID);
+  }
+
   void handleContextHash(std::string Hash) override {
 ContextHash = std::move(Hash);
   }
@@ -173,6 +177,7 @@ class FullDependencyConsumer : public DependencyConsumer {
   std::vector Dependencies;
   std::vector PrebuiltModuleDeps;
   llvm::MapVector ClangModuleDeps;
+  std::vector DirectModuleDeps;
   std::vector Commands;
   std::string ContextHash;
   std::vector OutputPaths;

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
index 350acb8f8a79eb..778d579bfb5015 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -56,6 +56,8 @@ class DependencyConsumer {
 
   virtual void handleModuleDependency(ModuleDeps MD) = 0;
 
+  virtual void handleDirectModuleDependency(ModuleID MD) = 0;
+
   virtual void handleContextHash(std::string Hash) = 0;
 };
 

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 30f779bfef8a85..914d55eadefe85 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -136,10 +136,6 @@ struct ModuleDeps {
   /// determined that the 
diff erences are benign for this compilation.
   std::vector ClangModuleDeps;
 
-  // Used to track which modules that were discovered were directly imported by
-  // the primary TU.
-  bool ImportedByMainFile = false;
-
   /// Compiler invocation that can be used to build this module. Does not
   /// include argv[0].
   std::vector BuildArguments;
@@ -172,8 +168,6 @@ class ModuleDepCollectorPP final : public PPCallbacks {
 private:
   /// The parent dependency collector.
   ModuleDepCollector 
-  /// Working set of direct modular dependencies.
-  llvm::SetVector DirectModularDeps;
 
   void handleImport(const Module *Imported);
 
@@ -243,6 +237,8 @@ class ModuleDepCollector final : public DependencyCollector 
{
   llvm::DenseMap ModuleDepsByID;
   /// Direct modular dependencies that have already been built.
   llvm::MapVector DirectPrebuiltModularDeps;
+  /// Working set of direct modular dependencies.
+  llvm::SetVector DirectModularDeps;
   /// Options that control the dependency output generation.
   std::unique_ptr Opts;
   /// The original Clang invocation passed to dependency scanner.

diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index a4959889144196..4219f671658613 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -34,16 +34,12 @@ class MakeDependencyPrinterConsumer : public 
DependencyConsumer {
 

[PATCH] D156492: [clang][deps] Make the C++ API more type-safe

2023-07-28 Thread Jan Svoboda 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 rG8a077cfe23e3: [clang][deps] Make the C++ API more type-safe 
(authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D156492?vs=544938=545237#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156492

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -472,8 +472,7 @@
 mutable size_t InputIndex;
 
 bool operator==(const IndexedModuleID ) const {
-  return std::tie(ID.ModuleName, ID.ContextHash) ==
- std::tie(Other.ID.ModuleName, Other.ID.ContextHash);
+  return ID == Other.ID;
 }
 
 bool operator<(const IndexedModuleID ) const {
@@ -493,7 +492,7 @@
 
 struct Hasher {
   std::size_t operator()(const IndexedModuleID ) const {
-return llvm::hash_combine(IMID.ID.ModuleName, IMID.ID.ContextHash);
+return llvm::hash_value(IMID.ID);
   }
 };
   };
@@ -880,7 +879,7 @@
 
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I) {
 Pool.async([&, I]() {
-  llvm::StringSet<> AlreadySeenModules;
+  llvm::DenseSet AlreadySeenModules;
   while (auto MaybeInputIndex = GetNextInputIndex()) {
 size_t LocalIndex = *MaybeInputIndex;
 const tooling::CompileCommand *Input = [LocalIndex];
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -145,7 +145,7 @@
 llvm::Expected
 DependencyScanningTool::getTranslationUnitDependencies(
 const std::vector , StringRef CWD,
-const llvm::StringSet<> ,
+const llvm::DenseSet ,
 LookupModuleOutputCallback LookupModuleOutput) {
   FullDependencyConsumer Consumer(AlreadySeen);
   CallbackActionController Controller(LookupModuleOutput);
@@ -158,7 +158,7 @@
 
 llvm::Expected DependencyScanningTool::getModuleDependencies(
 StringRef ModuleName, const std::vector ,
-StringRef CWD, const llvm::StringSet<> ,
+StringRef CWD, const llvm::DenseSet ,
 LookupModuleOutputCallback LookupModuleOutput) {
   FullDependencyConsumer Consumer(AlreadySeen);
   CallbackActionController Controller(LookupModuleOutput);
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -17,6 +17,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -296,15 +297,17 @@
 } // end namespace clang
 
 namespace llvm {
+inline hash_code hash_value(const clang::tooling::dependencies::ModuleID ) {
+  return hash_combine(ID.ModuleName, ID.ContextHash);
+}
+
 template <> struct DenseMapInfo {
   using ModuleID = clang::tooling::dependencies::ModuleID;
   static inline ModuleID getEmptyKey() { return ModuleID{"", ""}; }
   static inline ModuleID getTombstoneKey() {
 return ModuleID{"~", "~"}; // ~ is not a valid module name or context hash
   }
-  static unsigned getHashValue(const ModuleID ) {
-return hash_combine(ID.ModuleName, ID.ContextHash);
-  }
+  static unsigned getHashValue(const ModuleID ) { return hash_value(ID); }
   static bool isEqual(const ModuleID , const ModuleID ) {
 return LHS == RHS;
   }
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -13,9 +13,8 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
-#include "llvm/ADT/StringSet.h"
-#include "llvm/ADT/StringMap.h"
 #include 
 #include 
 #include 
@@ -125,17 +124,16 @@
   llvm::Expected
   getTranslationUnitDependencies(const std::vector ,
  

[clang] 8a077cf - [clang][deps] Make the C++ API more type-safe

2023-07-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-28T12:03:54-07:00
New Revision: 8a077cfe23e3856d406bd3633e1a3026609f3537

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

LOG: [clang][deps] Make the C++ API more type-safe

Scanner's C++ API accepts a set of modular dependencies the client has already 
seen and for which it doesn't need the full details. This is currently a set of 
strings, which somewhat implies that it should contain the set of module names. 
However, scanner internally expects the values to be in the format 
"{hash}{name}". Besides not being documented, this is very unintuitive. This 
patch makes this expectation explicit by changing the type to set of `ModuleID`.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index 87a4299c7f1b91..3bb9fe6dae7f7c 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -13,9 +13,8 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
-#include "llvm/ADT/StringSet.h"
-#include "llvm/ADT/StringMap.h"
 #include 
 #include 
 #include 
@@ -125,17 +124,16 @@ class DependencyScanningTool {
   llvm::Expected
   getTranslationUnitDependencies(const std::vector ,
  StringRef CWD,
- const llvm::StringSet<> ,
+ const llvm::DenseSet ,
  LookupModuleOutputCallback 
LookupModuleOutput);
 
   /// Given a compilation context specified via the Clang driver command-line,
   /// gather modular dependencies of module with the given name, and return the
   /// information needed for explicit build.
-  llvm::Expected
-  getModuleDependencies(StringRef ModuleName,
-const std::vector ,
-StringRef CWD, const llvm::StringSet<> ,
-LookupModuleOutputCallback LookupModuleOutput);
+  llvm::Expected getModuleDependencies(
+  StringRef ModuleName, const std::vector ,
+  StringRef CWD, const llvm::DenseSet ,
+  LookupModuleOutputCallback LookupModuleOutput);
 
 private:
   DependencyScanningWorker Worker;
@@ -143,7 +141,7 @@ class DependencyScanningTool {
 
 class FullDependencyConsumer : public DependencyConsumer {
 public:
-  FullDependencyConsumer(const llvm::StringSet<> )
+  FullDependencyConsumer(const llvm::DenseSet )
   : AlreadySeen(AlreadySeen) {}
 
   void handleBuildCommand(Command Cmd) override {
@@ -161,7 +159,7 @@ class FullDependencyConsumer : public DependencyConsumer {
   }
 
   void handleModuleDependency(ModuleDeps MD) override {
-ClangModuleDeps[MD.ID.ContextHash + MD.ID.ModuleName] = std::move(MD);
+ClangModuleDeps[MD.ID] = std::move(MD);
   }
 
   void handleContextHash(std::string Hash) override {
@@ -174,12 +172,11 @@ class FullDependencyConsumer : public DependencyConsumer {
 private:
   std::vector Dependencies;
   std::vector PrebuiltModuleDeps;
-  llvm::MapVector>
-  ClangModuleDeps;
+  llvm::MapVector ClangModuleDeps;
   std::vector Commands;
   std::string ContextHash;
   std::vector OutputPaths;
-  const llvm::StringSet<> 
+  const llvm::DenseSet 
 };
 
 /// A simple dependency action controller that uses a callback. If no callback

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 0a5cbc4f046aac..30f779bfef8a85 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -17,6 +17,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -296,15 +297,17 @@ class ModuleDepCollector final : public 
DependencyCollector {
 } // end namespace clang
 
 namespace llvm {
+inline hash_code hash_value(const clang::tooling::dependencies::ModuleID ) {
+  

[PATCH] D156563: [clang][deps] Remove `ModuleDeps::ImportedByMainFile`

2023-07-28 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.

This flag was always weird to me, thanks for cleaning it up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156563

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


[clang] 9016514 - Revert "[clang][Interp] Implement __builtin_isnan()"

2023-07-28 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-28T20:59:38+02:00
New Revision: 9016514c6bc34330b89dadfcd00e803a44b3cbc8

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

LOG: Revert "[clang][Interp] Implement __builtin_isnan()"

This reverts commit 8ad9dcb3869394e3a4ecb01631646237074723fe.

This breaks builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/46363/steps/6/logs/FAIL__Clang__constant-builtins-fmin_cpp

Revert while I figure out what's going wrong.

Added: 


Modified: 
clang/lib/AST/Interp/Function.cpp
clang/lib/AST/Interp/Function.h
clang/lib/AST/Interp/Interp.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/InterpBuiltin.cpp
clang/test/Sema/constant-builtins-fmin.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Function.cpp 
b/clang/lib/AST/Interp/Function.cpp
index e409002171c4b7..75312999d23d66 100644
--- a/clang/lib/AST/Interp/Function.cpp
+++ b/clang/lib/AST/Interp/Function.cpp
@@ -7,11 +7,10 @@
 
//===--===//
 
 #include "Function.h"
-#include "Opcode.h"
 #include "Program.h"
+#include "Opcode.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/Basic/Builtins.h"
 
 using namespace clang;
 using namespace clang::interp;
@@ -48,9 +47,3 @@ bool Function::isVirtual() const {
 return M->isVirtual();
   return false;
 }
-
-bool Function::needsRuntimeArgPop(const ASTContext ) const {
-  if (!isBuiltin())
-return false;
-  return Ctx.BuiltinInfo.hasCustomTypechecking(getBuiltinID());
-}

diff  --git a/clang/lib/AST/Interp/Function.h b/clang/lib/AST/Interp/Function.h
index 5444c9f59cda7e..644d4cd53b1e19 100644
--- a/clang/lib/AST/Interp/Function.h
+++ b/clang/lib/AST/Interp/Function.h
@@ -171,12 +171,6 @@ class Function final {
 
   unsigned getBuiltinID() const { return F->getBuiltinID(); }
 
-  bool isBuiltin() const { return F->getBuiltinID() != 0; }
-
-  /// Does this function need its arguments to be classified at runtime
-  /// rather than at bytecode-compile-time?
-  bool needsRuntimeArgPop(const ASTContext ) const;
-
   unsigned getNumParams() const { return ParamTypes.size(); }
 
   unsigned getParamOffset(unsigned ParamIndex) const {

diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index e006c196f6ed4e..b891306e6aa405 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -122,18 +122,6 @@ static bool CheckGlobal(InterpState , CodePtr OpPC, 
const Pointer ) {
 namespace clang {
 namespace interp {
 
-bool popBuiltinArgs(InterpState , CodePtr OpPC) {
-  assert(S.Current && 
S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()));
-  const Expr *E = S.Current->getExpr(OpPC);
-  assert(isa(E));
-  const CallExpr *CE = cast(E);
-  for (const auto *A : llvm::reverse(CE->arguments())) {
-PrimType Ty = S.getContext().classify(A->getType()).value_or(PT_Ptr);
-TYPE_SWITCH(Ty, S.Stk.discard());
-  }
-  return true;
-}
-
 bool CheckExtern(InterpState , CodePtr OpPC, const Pointer ) {
   if (!Ptr.isExtern())
 return true;

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 4da5985e3b3d6f..9eae79ba5d1e7a 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -181,9 +181,6 @@ enum class ArithOp { Add, Sub };
 // Returning values
 
//===--===//
 
-/// Pop arguments of builtins defined as func-name(...).
-bool popBuiltinArgs(InterpState , CodePtr OpPC);
-
 template ::T>
 bool Ret(InterpState , CodePtr , APValue ) {
   const T  = S.Stk.pop();
@@ -200,16 +197,8 @@ bool Ret(InterpState , CodePtr , APValue ) {
   }
 
   assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
-  if (!S.checkingPotentialConstantExpression() || S.Current->Caller) {
-// Certain builtin functions are declared as func-name(...), so the
-// parameters are checked in Sema and only available through the CallExpr.
-// The interp::Function we create for them has 0 parameters, so we need to
-// remove them from the stack by checking the CallExpr.
-if (S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()))
-  popBuiltinArgs(S, PC);
-else
-  S.Current->popArgs();
-  }
+  if (!S.checkingPotentialConstantExpression() || S.Current->Caller)
+S.Current->popArgs();
 
   if (InterpFrame *Caller = S.Current->Caller) {
 PC = S.Current->getRetPC();

diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index 01c41339bba8c8..b023d09df48784 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -162,17 +162,6 @@ static bool 

[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-07-28 Thread Anna Thomas via Phabricator via cfe-commits
anna added a comment.

We see a crash bisected to this patch about using an illegal instruction. 
Here's the CPUInfo for the machine:

  CPU info:
  current cpu id: 22
  total 32(physical cores 16) (assigned logical cores 32) (assigned physical 
cores 16) (assigned_sockets:2 of 2) (8 cores per cpu, 2 threads per core) 
family 6 model 45 stepping 7 microcode 0x71a, cmov, cx8, fxsr, mmx, sse, sse2, 
sse3, ssse3, sse4.1, sse4.2, popcnt, vzeroupper, avx, aes, clmul, ht, tsc, 
tscinvbit, tscinv, clflush
  AvgLoads: 0.30, 0.10, 0.18
  CPU Model and flags from /proc/cpuinfo:
  model name  : Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx 
pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology 
nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est 
tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt 
tsc_deadline_timer aes xsave avx lahf_lm epb pti ssbd ibrs ibpb stibp 
tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts md_clear 
flush_l1d
  Online cpus: 0-31
  Offline cpus:
  BIOS frequency limitation: 
  Frequency switch latency (ns): 2
  Available cpu frequencies: 
  Current governor: schedutil
  Core performance/turbo boost: 

I don't see `avxvnniint16` in the flags list nor avx2. So, this (relatively 
new) instruction shouldn't be generated for this machine. Any ideas on why this 
might be happening?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D155369: [clang][Interp] Implement __builtin_isnan()

2023-07-28 Thread Timm Bäder 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 rG8ad9dcb38693: [clang][Interp] Implement __builtin_isnan() 
(authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155369

Files:
  clang/lib/AST/Interp/Function.cpp
  clang/lib/AST/Interp/Function.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/Sema/constant-builtins-fmin.cpp

Index: clang/test/Sema/constant-builtins-fmin.cpp
===
--- clang/test/Sema/constant-builtins-fmin.cpp
+++ clang/test/Sema/constant-builtins-fmin.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -fexperimental-new-constant-interpreter %s
 // expected-no-diagnostics
 
 constexpr double NaN = __builtin_nan("");
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -162,6 +162,17 @@
   return true;
 }
 
+/// Defined as __builtin_isnan(...), to accommodate the fact that it can
+/// take a float, double, long double, etc.
+/// But for us, that's all a Floating anyway.
+static bool interp__builtin_isnan(InterpState , CodePtr OpPC,
+  const InterpFrame *Frame, const Function *F) {
+  const Floating  = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isNan()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -223,6 +234,11 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_isnan:
+if (interp__builtin_isnan(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -181,6 +181,9 @@
 // Returning values
 //===--===//
 
+/// Pop arguments of builtins defined as func-name(...).
+bool popBuiltinArgs(InterpState , CodePtr OpPC);
+
 template ::T>
 bool Ret(InterpState , CodePtr , APValue ) {
   const T  = S.Stk.pop();
@@ -197,8 +200,16 @@
   }
 
   assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
-  if (!S.checkingPotentialConstantExpression() || S.Current->Caller)
-S.Current->popArgs();
+  if (!S.checkingPotentialConstantExpression() || S.Current->Caller) {
+// Certain builtin functions are declared as func-name(...), so the
+// parameters are checked in Sema and only available through the CallExpr.
+// The interp::Function we create for them has 0 parameters, so we need to
+// remove them from the stack by checking the CallExpr.
+if (S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()))
+  popBuiltinArgs(S, PC);
+else
+  S.Current->popArgs();
+  }
 
   if (InterpFrame *Caller = S.Current->Caller) {
 PC = S.Current->getRetPC();
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -122,6 +122,18 @@
 namespace clang {
 namespace interp {
 
+bool popBuiltinArgs(InterpState , CodePtr OpPC) {
+  assert(S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()));
+  const Expr *E = S.Current->getExpr(OpPC);
+  assert(isa(E));
+  const CallExpr *CE = cast(E);
+  for (const auto *A : llvm::reverse(CE->arguments())) {
+PrimType Ty = S.getContext().classify(A->getType()).value_or(PT_Ptr);
+TYPE_SWITCH(Ty, S.Stk.discard());
+  }
+  return true;
+}
+
 bool CheckExtern(InterpState , CodePtr OpPC, const Pointer ) {
   if (!Ptr.isExtern())
 return true;
Index: clang/lib/AST/Interp/Function.h
===
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -171,6 +171,12 @@
 
   unsigned getBuiltinID() const { return F->getBuiltinID(); }
 
+  bool isBuiltin() const { return F->getBuiltinID() != 0; }
+
+  /// Does this function need its arguments to be classified at runtime
+  /// rather than at bytecode-compile-time?
+  bool needsRuntimeArgPop(const ASTContext ) const;
+
   unsigned getNumParams() const { return ParamTypes.size(); }
 
   unsigned getParamOffset(unsigned ParamIndex) const {
Index: clang/lib/AST/Interp/Function.cpp
===
--- clang/lib/AST/Interp/Function.cpp
+++ clang/lib/AST/Interp/Function.cpp
@@ -7,10 +7,11 @@
 

[clang] 8ad9dcb - [clang][Interp] Implement __builtin_isnan()

2023-07-28 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-28T20:49:45+02:00
New Revision: 8ad9dcb3869394e3a4ecb01631646237074723fe

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

LOG: [clang][Interp] Implement __builtin_isnan()

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

Added: 


Modified: 
clang/lib/AST/Interp/Function.cpp
clang/lib/AST/Interp/Function.h
clang/lib/AST/Interp/Interp.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/InterpBuiltin.cpp
clang/test/Sema/constant-builtins-fmin.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Function.cpp 
b/clang/lib/AST/Interp/Function.cpp
index 75312999d23d66..e409002171c4b7 100644
--- a/clang/lib/AST/Interp/Function.cpp
+++ b/clang/lib/AST/Interp/Function.cpp
@@ -7,10 +7,11 @@
 
//===--===//
 
 #include "Function.h"
-#include "Program.h"
 #include "Opcode.h"
+#include "Program.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/Basic/Builtins.h"
 
 using namespace clang;
 using namespace clang::interp;
@@ -47,3 +48,9 @@ bool Function::isVirtual() const {
 return M->isVirtual();
   return false;
 }
+
+bool Function::needsRuntimeArgPop(const ASTContext ) const {
+  if (!isBuiltin())
+return false;
+  return Ctx.BuiltinInfo.hasCustomTypechecking(getBuiltinID());
+}

diff  --git a/clang/lib/AST/Interp/Function.h b/clang/lib/AST/Interp/Function.h
index 644d4cd53b1e19..5444c9f59cda7e 100644
--- a/clang/lib/AST/Interp/Function.h
+++ b/clang/lib/AST/Interp/Function.h
@@ -171,6 +171,12 @@ class Function final {
 
   unsigned getBuiltinID() const { return F->getBuiltinID(); }
 
+  bool isBuiltin() const { return F->getBuiltinID() != 0; }
+
+  /// Does this function need its arguments to be classified at runtime
+  /// rather than at bytecode-compile-time?
+  bool needsRuntimeArgPop(const ASTContext ) const;
+
   unsigned getNumParams() const { return ParamTypes.size(); }
 
   unsigned getParamOffset(unsigned ParamIndex) const {

diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index b891306e6aa405..e006c196f6ed4e 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -122,6 +122,18 @@ static bool CheckGlobal(InterpState , CodePtr OpPC, 
const Pointer ) {
 namespace clang {
 namespace interp {
 
+bool popBuiltinArgs(InterpState , CodePtr OpPC) {
+  assert(S.Current && 
S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()));
+  const Expr *E = S.Current->getExpr(OpPC);
+  assert(isa(E));
+  const CallExpr *CE = cast(E);
+  for (const auto *A : llvm::reverse(CE->arguments())) {
+PrimType Ty = S.getContext().classify(A->getType()).value_or(PT_Ptr);
+TYPE_SWITCH(Ty, S.Stk.discard());
+  }
+  return true;
+}
+
 bool CheckExtern(InterpState , CodePtr OpPC, const Pointer ) {
   if (!Ptr.isExtern())
 return true;

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 9eae79ba5d1e7a..4da5985e3b3d6f 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -181,6 +181,9 @@ enum class ArithOp { Add, Sub };
 // Returning values
 
//===--===//
 
+/// Pop arguments of builtins defined as func-name(...).
+bool popBuiltinArgs(InterpState , CodePtr OpPC);
+
 template ::T>
 bool Ret(InterpState , CodePtr , APValue ) {
   const T  = S.Stk.pop();
@@ -197,8 +200,16 @@ bool Ret(InterpState , CodePtr , APValue ) {
   }
 
   assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
-  if (!S.checkingPotentialConstantExpression() || S.Current->Caller)
-S.Current->popArgs();
+  if (!S.checkingPotentialConstantExpression() || S.Current->Caller) {
+// Certain builtin functions are declared as func-name(...), so the
+// parameters are checked in Sema and only available through the CallExpr.
+// The interp::Function we create for them has 0 parameters, so we need to
+// remove them from the stack by checking the CallExpr.
+if (S.Current && S.Current->getFunction()->needsRuntimeArgPop(S.getCtx()))
+  popBuiltinArgs(S, PC);
+else
+  S.Current->popArgs();
+  }
 
   if (InterpFrame *Caller = S.Current->Caller) {
 PC = S.Current->getRetPC();

diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index b023d09df48784..01c41339bba8c8 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -162,6 +162,17 @@ static bool interp__builtin_fmin(InterpState , CodePtr 
OpPC,
   return true;
 }
 
+/// Defined as __builtin_isnan(...), to accommodate the fact that it can
+/// take a float, double, long double, etc.
+/// But for us, 

[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2023-07-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm requested changes to this revision.
arsenm added a comment.
This revision now requires changes to proceed.
Herald added subscribers: nlopes, StephenFan.
Herald added a project: All.

Should be obsoleted by D147732 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D156563: [clang][deps] Remove `ModuleDeps::ImportedByMainFile`

2023-07-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: benlangmuir.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This information is already exposed via `TranslationUnitDeps::ClangModuleDeps` 
on the `DependencyScanningTool` level, and this patch also adds it on the 
`DependencyScanningWorker` level via 
`DependencyConsumer::handleDirectModuleDependency()`.

Besides being redundant, this bit of information is misleading for clients that 
share single `ModuleDeps` instance between multiple TUs (by using the 
`AlreadySeen` set). The module can be imported directly in some TUs but 
transitively in others.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156563

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -242,7 +242,7 @@
 
 SmallVector DirectDeps;
 for (const auto  : ModularDeps)
-  if (KV.second->ImportedByMainFile)
+  if (DirectModularDeps.contains(KV.first))
 DirectDeps.push_back(KV.second->ID);
 
 // TODO: Report module maps the same way it's done for modular dependencies.
@@ -364,7 +364,7 @@
 MDC.DirectPrebuiltModularDeps.insert(
 {TopLevelModule, PrebuiltModuleDep{TopLevelModule}});
   else
-DirectModularDeps.insert(TopLevelModule);
+MDC.DirectModularDeps.insert(TopLevelModule);
 }
 
 void ModuleDepCollectorPP::EndOfMainFile() {
@@ -394,9 +394,9 @@
   for (const Module *M :
MDC.ScanInstance.getPreprocessor().getAffectingClangModules())
 if (!MDC.isPrebuiltModule(M))
-  DirectModularDeps.insert(M);
+  MDC.DirectModularDeps.insert(M);
 
-  for (const Module *M : DirectModularDeps)
+  for (const Module *M : MDC.DirectModularDeps)
 handleTopLevelModule(M);
 
   MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);
@@ -408,6 +408,13 @@
   for (auto & : MDC.ModularDeps)
 MDC.Consumer.handleModuleDependency(*I.second);
 
+  for (const Module *M : MDC.DirectModularDeps) {
+auto It = MDC.ModularDeps.find(M);
+// Only report direct dependencies that were successfully handled.
+if (It != MDC.ModularDeps.end())
+  MDC.Consumer.handleDirectModuleDependency(MDC.ModularDeps[M]->ID);
+  }
+
   for (auto & : MDC.FileDeps)
 MDC.Consumer.handleFileDependency(I);
 
@@ -435,7 +442,6 @@
   ModuleDeps  = *ModI.first->second;
 
   MD.ID.ModuleName = M->getFullModuleName();
-  MD.ImportedByMainFile = DirectModularDeps.contains(M);
   MD.IsSystem = M->IsSystem;
 
   ModuleMap  =
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -34,16 +34,12 @@
 Dependencies.push_back(std::string(File));
   }
 
-  void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) override {
-// Same as `handleModuleDependency`.
-  }
-
-  void handleModuleDependency(ModuleDeps MD) override {
-// These are ignored for the make format as it can't support the full
-// set of deps, and handleFileDependency handles enough for implicitly
-// built modules to work.
-  }
-
+  // These are ignored for the make format as it can't support the full
+  // set of deps, and handleFileDependency handles enough for implicitly
+  // built modules to work.
+  void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) override {}
+  void handleModuleDependency(ModuleDeps MD) override {}
+  void handleDirectModuleDependency(ModuleID ID) override {}
   void handleContextHash(std::string Hash) override {}
 
   void printDependencies(std::string ) {
@@ -179,14 +175,13 @@
 
   for (auto & : ClangModuleDeps) {
 auto  = M.second;
-if (MD.ImportedByMainFile)
-  TU.ClangModuleDeps.push_back(MD.ID);
 // TODO: Avoid handleModuleDependency even being called for modules
 //   we've already seen.
 if (AlreadySeen.count(M.first))
   continue;
 TU.ModuleGraph.push_back(std::move(MD));
   }
+  TU.ClangModuleDeps = std::move(DirectModuleDeps);
 
   return TU;
 }
Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
===
--- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ 

[PATCH] D156533: [clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body

2023-07-28 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Reverted in 4098e13a7146 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156533

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


[clang] 4098e13 - Revert "[clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body"

2023-07-28 Thread Steven Wu via cfe-commits

Author: Steven Wu
Date: 2023-07-28T11:39:46-07:00
New Revision: 4098e13a71464cc4747528edd8a41e5a4eaa1b23

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

LOG: Revert "[clang][DeclPrinter] Fix missing semicolon in AST print for 
methods that are definitions without having a body"

This reverts commit a3da6284c23affdd9092b2641017e99d85c2d89b. It breaks
tests on macOS as macOS doesn't support attribute alias.

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp
clang/test/AST/ast-print-method-decl.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0608b48f3a880e..bf4d26c723d2e6 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -463,12 +463,12 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool 
Indent) {
 else if (isa(*D) && cast(*D)->hasBody())
   Terminator = nullptr;
 else if (auto FD = dyn_cast(*D)) {
-  if (FD->doesThisDeclarationHaveABody() && !FD->isDefaulted())
+  if (FD->isThisDeclarationADefinition())
 Terminator = nullptr;
   else
 Terminator = ";";
 } else if (auto TD = dyn_cast(*D)) {
-  if (TD->getTemplatedDecl()->doesThisDeclarationHaveABody())
+  if (TD->getTemplatedDecl()->isThisDeclarationADefinition())
 Terminator = nullptr;
   else
 Terminator = ";";

diff  --git a/clang/test/AST/ast-print-method-decl.cpp 
b/clang/test/AST/ast-print-method-decl.cpp
index 3c3b8ceaf86389..505e07dde1a868 100644
--- a/clang/test/AST/ast-print-method-decl.cpp
+++ b/clang/test/AST/ast-print-method-decl.cpp
@@ -85,18 +85,3 @@ struct CurlyCtorInit {
 
   // CHECK-NEXT: };
 };
-
-
-// CHECK: struct DefMethodsWithoutBody {
-struct DefMethodsWithoutBody {
-  // CHECK-NEXT: DefMethodsWithoutBody() = delete;
-  DefMethodsWithoutBody() = delete;
-
-  // CHECK-NEXT: DefMethodsWithoutBody() = default;
-  ~DefMethodsWithoutBody() = default;
-
-  // CHECK-NEXT: void m1() __attribute__((alias("X")));
-  void m1() __attribute__((alias("X")));
-
-  // CHECK-NEXT: };
-};



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


Re: [PATCH] D156533: [clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body

2023-07-28 Thread Timo Stripf via cfe-commits
Sry for breaking builds. Can someone please revert it, I am currently not at 
work.

Am 28.07.2023 20:27 schrieb Nico Weber via Phabricator 
:
thakis added a comment.

This breaks tests on Mac: http://45.33.8.238/macm1/65934/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/D156533/new/

https://reviews.llvm.org/D156533

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


[PATCH] D156533: [clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body

2023-07-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on Mac: http://45.33.8.238/macm1/65934/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/D156533/new/

https://reviews.llvm.org/D156533

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


[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D105759#4543184 , 
@hubert.reinterpretcast wrote:

> In D105759#4541813 , @cor3ntin 
> wrote:
>
>> In D105759#4540716 , 
>> @hubert.reinterpretcast wrote:
>>
 I hope this patch may allow to gather some data on that.
>>>
>>> @cor3ntin, I have reports that applications having encoding prefixes in 
>>> `static_assert` are failing to build. The committee did not adopt the 
>>> subject paper as a "DR resolution". Is it possible to downgrade to a 
>>> warning?
>>
>> You know how frequent it is?
>
> No, but I am concerned that this came up even before we deployed an LLVM 
> 17-based solution (in pre-release testing). I believe that reverting for LLVM 
> 17 is the prudent course of action.

Early reports of user code getting tripped up on this is something we should 
react to while we still can; I'd recommend we change the diagnostic to be a 
warning that defaults to an error so that users who are caught by the changes 
can still disable the diagnostic rather than be stuck; for Clang 18, we can 
explore other solutions to the issue. Would this work for you 
@hubert.reinterpretcast?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D156515: [RemarkUtil] Refactor llvm-remarkutil to include size-diff

2023-07-28 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg accepted this revision.
thegameg added a comment.
This revision is now accepted and ready to land.

Clean, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156515

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


[PATCH] D156492: [clang][deps] Make the C++ API more type-safe

2023-07-28 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h:175
   std::vector PrebuiltModuleDeps;
-  llvm::MapVector>
+  llvm::MapVector>
   ClangModuleDeps;

You can drop the third template argument; it now matches the default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156492

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


[PATCH] D155546: [clang][Interp] Implement __builtin_fmin

2023-07-28 Thread Timm Bäder 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 rGc14c34de4571: [clang][Interp] Implement __builtin_fmin 
(authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D155546?vs=544691=545228#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155546

Files:
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/AST/Interp/builtin-functions.cpp


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -60,3 +60,15 @@
  // expected-note {{read of 
dereferenced one-past-the-end pointer}} \
  // expected-note {{in call to}}
 }
+
+namespace fmin {
+  constexpr float f1 = __builtin_fmin(1.0, 2.0f);
+  static_assert(f1 == 1.0f, "");
+
+  constexpr float min = __builtin_fmin(__builtin_nan(""), 1);
+  static_assert(min == 1, "");
+  constexpr float min2 = __builtin_fmin(1, __builtin_nan(""));
+  static_assert(min2 == 1, "");
+  constexpr float min3 = __builtin_fmin(__builtin_inf(), __builtin_nan(""));
+  static_assert(min3 == __builtin_inf(), "");
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -143,6 +143,25 @@
   return true;
 }
 
+static bool interp__builtin_fmin(InterpState , CodePtr OpPC,
+ const InterpFrame *Frame, const Function *F) {
+  const Floating  = getParam(Frame, 0);
+  const Floating  = getParam(Frame, 1);
+
+  Floating Result;
+
+  // When comparing zeroes, return -0.0 if one of the zeroes is negative.
+  if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
+Result = RHS;
+  else if (LHS.isNan() || RHS < LHS)
+Result = RHS;
+  else
+Result = LHS;
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -195,6 +214,15 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_fmin:
+  case Builtin::BI__builtin_fminf:
+  case Builtin::BI__builtin_fminl:
+  case Builtin::BI__builtin_fminf16:
+  case Builtin::BI__builtin_fminf128:
+if (interp__builtin_fmin(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -60,3 +60,15 @@
  // expected-note {{read of dereferenced one-past-the-end pointer}} \
  // expected-note {{in call to}}
 }
+
+namespace fmin {
+  constexpr float f1 = __builtin_fmin(1.0, 2.0f);
+  static_assert(f1 == 1.0f, "");
+
+  constexpr float min = __builtin_fmin(__builtin_nan(""), 1);
+  static_assert(min == 1, "");
+  constexpr float min2 = __builtin_fmin(1, __builtin_nan(""));
+  static_assert(min2 == 1, "");
+  constexpr float min3 = __builtin_fmin(__builtin_inf(), __builtin_nan(""));
+  static_assert(min3 == __builtin_inf(), "");
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -143,6 +143,25 @@
   return true;
 }
 
+static bool interp__builtin_fmin(InterpState , CodePtr OpPC,
+ const InterpFrame *Frame, const Function *F) {
+  const Floating  = getParam(Frame, 0);
+  const Floating  = getParam(Frame, 1);
+
+  Floating Result;
+
+  // When comparing zeroes, return -0.0 if one of the zeroes is negative.
+  if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
+Result = RHS;
+  else if (LHS.isNan() || RHS < LHS)
+Result = RHS;
+  else
+Result = LHS;
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -195,6 +214,15 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_fmin:
+  case Builtin::BI__builtin_fminf:
+  case Builtin::BI__builtin_fminl:
+  case Builtin::BI__builtin_fminf16:
+  case Builtin::BI__builtin_fminf128:
+if (interp__builtin_fmin(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c14c34d - [clang][Interp] Implement __builtin_fmin

2023-07-28 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-28T20:18:57+02:00
New Revision: c14c34de4571cf3268e3599f5d1fc7318c42aac7

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

LOG: [clang][Interp] Implement __builtin_fmin

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

Added: 


Modified: 
clang/lib/AST/Interp/InterpBuiltin.cpp
clang/test/AST/Interp/builtin-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index e4c0091452e399..b023d09df48784 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -143,6 +143,25 @@ static bool interp__builtin_copysign(InterpState , 
CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_fmin(InterpState , CodePtr OpPC,
+ const InterpFrame *Frame, const Function *F) {
+  const Floating  = getParam(Frame, 0);
+  const Floating  = getParam(Frame, 1);
+
+  Floating Result;
+
+  // When comparing zeroes, return -0.0 if one of the zeroes is negative.
+  if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
+Result = RHS;
+  else if (LHS.isNan() || RHS < LHS)
+Result = RHS;
+  else
+Result = LHS;
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -195,6 +214,15 @@ bool InterpretBuiltin(InterpState , CodePtr OpPC, const 
Function *F) {
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_fmin:
+  case Builtin::BI__builtin_fminf:
+  case Builtin::BI__builtin_fminl:
+  case Builtin::BI__builtin_fminf16:
+  case Builtin::BI__builtin_fminf128:
+if (interp__builtin_fmin(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }

diff  --git a/clang/test/AST/Interp/builtin-functions.cpp 
b/clang/test/AST/Interp/builtin-functions.cpp
index eec6c9ec4bbf81..8ff717217e4728 100644
--- a/clang/test/AST/Interp/builtin-functions.cpp
+++ b/clang/test/AST/Interp/builtin-functions.cpp
@@ -60,3 +60,15 @@ namespace nan {
  // expected-note {{read of 
dereferenced one-past-the-end pointer}} \
  // expected-note {{in call to}}
 }
+
+namespace fmin {
+  constexpr float f1 = __builtin_fmin(1.0, 2.0f);
+  static_assert(f1 == 1.0f, "");
+
+  constexpr float min = __builtin_fmin(__builtin_nan(""), 1);
+  static_assert(min == 1, "");
+  constexpr float min2 = __builtin_fmin(1, __builtin_nan(""));
+  static_assert(min2 == 1, "");
+  constexpr float min3 = __builtin_fmin(__builtin_inf(), __builtin_nan(""));
+  static_assert(min3 == __builtin_inf(), "");
+}



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


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D155997#4543156 , @nikic wrote:

> I'm not a fan of the PGO conditional behavior here. I'd prefer to disable 
> speculation unconditionally if that is feasible. This is basically what 
> D153392  did. While the specific test case 
> there was addressed in a different way, if we take it in conjunction with 
> this one, I think we have enough motivation to do the change.

It looks like D153392  does roughly the same 
disabling in practice, but you are right it doesn't gate on whether we will 
eventually feed back profile info. For the issue I was trying to solve, it was 
because of the PGO based profitability checks in SimplifyCFG speculation, but 
if it makes sense in other cases to disable it until later, then that works for 
me. BTW doesn't look like that patch disables speculation in addPGOInstrPasses, 
which we need for the issue I'm trying to solve.

> Another piece of motivation would be that the EarlyFPM change would allow us 
> to move LowerExpectIntrinsic to the end of EarlyFPM again, which would make 
> expect intrinsics work in Rust again. The pass was moved earlier to make the 
> first SimplifyCFG run take them into account, but that would no longer be a 
> problem if we disable speculation.
>
> And another piece of motivation would be that we could move SimplifyCFG after 
> SROA, where it can be much more effective (but doing so with speculation 
> breaks IPSCCP too much). I think doing that needs some further changes, but 
> it's a move in the right direction.
>
> So I think the EarlyFPM change at least seems like something we should pretty 
> clearly do independently of PGO. The addPGOInstrPasses() change is of course 
> PGO specific anyway. I think only the GlobalCleanupPM change may not be 
> completely clear cut.

For the case I was looking at, with instrumentation PGO, any of the 
pre-feedback SimplifyCFG speculation passes would do the wrong thing without 
that PGO data.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D156533: [clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body

2023-07-28 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

  error: aliases are not supported on darwin

Maybe create a different testcase that is not supported on Darwin?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156533

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


[PATCH] D156533: [clang][DeclPrinter] Fix missing semicolon in AST print for methods that are definitions without having a body

2023-07-28 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

This breaks Darwin bots: 
https://green.lab.llvm.org/green/job/clang-stage1-RA/35102/testReport/junit/Clang/AST/ast_print_method_decl_cpp/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156533

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


[PATCH] D156277: [Parser][ObjC] Fix parser crash on nested top-level block with better recovery path

2023-07-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:125
+  out early in case next top-level block occurs as if the previous one is
+  properly finished.
+  `Issue 64065 `_

"Fixed a crash when parsing top-level ObjC blocks that aren't properly 
terminated.
Clang should now also recover better when an `@end` is missing between blocks."



Comment at: clang/lib/Parse/ParseObjc.cpp:725
+case tok::objc_protocol:
+  goto MISSING_END;
+default:

This use of `goto` is a little too spaghetti-ish for me — we're breaking out of 
a loop and then branching into one case of an `if`/`else` chain.  There are two 
reasonable ways to do this with more structure.  The first is that we can make 
sure that we emit the "missing @end" diagnostic before we break out; to avoid 
code repetition, you can extract that into a helper function.  The second is 
that we could set a flag to tell the code after the loop that we need to emit 
that diagnostic instead of trying to recreate the case analysis that we did in 
the loop.

If you make a little helper function like `isTopLevelObjCKeyword` then you can 
just `break` out instead of having the awkwardness of being inside a `switch`.



Comment at: clang/lib/Parse/ParseObjc.cpp:737
   break;
 } else if (DirectiveKind == tok::objc_not_keyword) {
   Diag(Tok, diag::err_objc_unknown_at);

I would suggest pulling this up to right after (or even before) the 
`isTopLevelObjCKeyword` check.  Then after the check you know that you're 
dealing with a keyword that you actually want to handle, and you  can consume 
both the `@` and the keyword token in one place.



Comment at: clang/lib/Parse/ParseObjc.cpp:827
   // EOF.  In the former case, eat the @end.  In the later case, emit an error.
   if (Tok.is(tok::code_completion)) {
 cutOffParsing();

I don't think this case is actually reachable — we handle code-completion 
within the loop and then return.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156277

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


[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-07-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D105759#4541813 , @cor3ntin wrote:

> In D105759#4540716 , 
> @hubert.reinterpretcast wrote:
>
>>> I hope this patch may allow to gather some data on that.
>>
>> @cor3ntin, I have reports that applications having encoding prefixes in 
>> `static_assert` are failing to build. The committee did not adopt the 
>> subject paper as a "DR resolution". Is it possible to downgrade to a warning?
>
> You know how frequent it is?

No, but I am concerned that this came up even before we deployed an LLVM 
17-based solution (in pre-release testing). I believe that reverting for LLVM 
17 is the prudent course of action.

> Previously with a prefix, it was parsed as a wide (for example) string, and 
> we relied on the fact that L was UTF-16/32 to sometimes print a reasonable 
> diagnostics - and sometimes not https://godbolt.org/z/f3Pj4T5aj
> This is going to be worse when we add -fexec-charset:
>
> - `static_assert(true, L"やあ")` is going to be ill-formed when coded as, eg, 
> EBCDIC because it's not representable, and if it is representable we need to 
> either output mojibake or convert the string back to UTF-8 which we are 
> currently not doing.

This may be the motivation for the prefixes in the applications in the first 
place in the context of other compilers: They may have needed the prefix to 
avoid unrepresentable character issues (e.g., if the other compiler rejects the 
unprefixed string, but manages to emit the error to the terminal because both 
the terminal and the compiler use the source encoding).

> Another solution maybe to lexically ignore prefixes by replacing the string 
> literal token on the fly such that they are still parsed as unevaluated 
> strings and not encoded, i could look into that.

This sounds good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D141918: WIP: [Clang] Emit 'unwindabort' when applicable.

2023-07-28 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:5391
   if (FPtr->hasFnAttribute(llvm::Attribute::NoUnwind))
 CannotThrow = true;
+

Is there coverage for a nounwind callee + an unwindabort call?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141918

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


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-28 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

I'm not a fan of the PGO conditional behavior here. I'd prefer to disable 
speculation unconditionally if that is feasible. This is basically what D153392 
 did. While the specific test case there was 
addressed in a different way, if we take it in conjunction with this one, I 
think we have enough motivation to do the change.

Another piece of motivation would be that the EarlyFPM change would allow us to 
move LowerExpectIntrinsic to the end of EarlyFPM again, which would make expect 
intrinsics work in Rust again. The pass was moved earlier to make the first 
SimplifyCFG run take them into account, but that would no longer be a problem 
if we disable speculation.

And another piece of motivation would be that we could move SimplifyCFG after 
SROA, where it can be much more effective (but doing so with speculation breaks 
IPSCCP too much). I think doing that needs some further changes, but it's a 
move in the right direction.

So I think the EarlyFPM change at least seems like something we should pretty 
clearly do independently of PGO. The addPGOInstrPasses() change is of course 
PGO specific anyway. I think only the GlobalCleanupPM change may not be 
completely clear cut.




Comment at: llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll:1
+;; Check that SimplifyCFG does not attempt speculation until after PGO is
+;; annotated in the IR, and then does not perform it when unprofitable.

aeubanks wrote:
> hmm typically these phase ordering tests use 
> `llvm/utils/update_test_checks.py`, but that doesn't support the 
> llvm-profdata RUN line. I think a non-update_test_checks test is probably 
> fine for this, @nikic does that make sense?
> 
> 
I thought UTC supports unrecognized commands (by just executing them)... If 
not, a non-UTC test is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 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.

LGTM other than my suggestion to add a comment. @tahonermann are all your 
comments addressed at this point?




Comment at: clang/lib/Basic/FileManager.cpp:663
+} else {
+  llvm::sys::path::remove_dots(AbsPathBuf, /*remove_dot_dot=*/true);
+  CanonicalName = AbsPathBuf.str().copy(CanonicalNameStorage);

MrTrillian wrote:
> benlangmuir wrote:
> > MrTrillian wrote:
> > > benlangmuir wrote:
> > > > Removing .. can change where the path points in the presence of 
> > > > symlinks; is this needed?
> > > > Removing .. can change where the path points in the presence of 
> > > > symlinks; is this needed?
> > > 
> > > @benlangmuir That's true and not ideal, but `makeAbsolute` will not 
> > > resolve `/./` or `/../` in paths, so it's not a canonicalization and some 
> > > tests were failing because of that. One alternative would be to use 
> > > `makeAbsolute` + `remove_dots` on Windows (where removing dot dots is 
> > > semantically correct) and `getRealPath` on Unix, like I do in lit. 
> > > Suggestions?
> > Wouldn't removing .. have the same issue with symlinks on Windows? I know 
> > symlinks are less common there, but it's not clear to me why it would be 
> > correct.  I guess you could also check if the paths resolve to the same 
> > file after removing ..
> > 
> > 
> @benlangmuir Windows simplifies `\..\` in paths before starting to walk the 
> filesystem. 
> https://superuser.com/questions/1502360/different-behavior-of-double-dots-and-symlinks-in-windows-and-unix
> 
> If I detected that the path didn't resolve to the same file after removing 
> `..`, what would I do?
> 
> I think the current logic will only end up using the `else` branch on 
> Windows. At least I can't think of a scenario where the root would change 
> from using realpath on unix.
Thanks, I wasn't aware of that subtlety! I suggest we add a comment about that 
here and also mention (or assert) that this is only reachable on Windows.


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

https://reviews.llvm.org/D154130

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


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-07-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll:1
+;; Check that SimplifyCFG does not attempt speculation until after PGO is
+;; annotated in the IR, and then does not perform it when unprofitable.

hmm typically these phase ordering tests use 
`llvm/utils/update_test_checks.py`, but that doesn't support the llvm-profdata 
RUN line. I think a non-update_test_checks test is probably fine for this, 
@nikic does that make sense?





Comment at: 
llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll:22
+; RUN: opt < %s -passes='thinlto-pre-link' 
-pgo-kind=pgo-sample-use-pipeline 
-profile-file=%S/Inputs/simplifycfg-speculate-blocks.sampleprof -S | FileCheck 
%s --check-prefixes=NO,SAMPLE
+; RUN: opt < %s -passes='thinlto-pre-link' 
-pgo-kind=pgo-sample-use-pipeline 
-profile-file=%S/Inputs/simplifycfg-speculate-blocks.sampleprof -S | FileCheck 
%s --check-prefixes=NO,SAMPLE
+

`lto-pre-link`



Comment at: 
llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll:83
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}

the debug info is necessary for sample profile to work I presume?

I think some of this can still be simplified, like `PIC Level`, etc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian marked an inline comment as done.
MrTrillian added inline comments.



Comment at: llvm/utils/lit/lit/LitConfig.py:192
 f = f.f_back.f_back
-file = os.path.abspath(inspect.getsourcefile(f))
+file = lit.util.abs_path_preserve_drive(inspect.getsourcefile(f))
 line = inspect.getlineno(f)

benlangmuir wrote:
> Why are you changing abspath (here and elsewhere)? I understand why you are 
> changing realpath -> lit.util.abs_path_preserve_drive, but what's the issue 
> with bare abspath?
> Why are you changing abspath (here and elsewhere)? I understand why you are 
> changing realpath -> lit.util.abs_path_preserve_drive, but what's the issue 
> with bare abspath?

You're right, this is overzealous. I think it made more sense with an older 
iteration of this code. I removed it.


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

https://reviews.llvm.org/D154130

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:663
+} else {
+  llvm::sys::path::remove_dots(AbsPathBuf, /*remove_dot_dot=*/true);
+  CanonicalName = AbsPathBuf.str().copy(CanonicalNameStorage);

benlangmuir wrote:
> MrTrillian wrote:
> > benlangmuir wrote:
> > > Removing .. can change where the path points in the presence of symlinks; 
> > > is this needed?
> > > Removing .. can change where the path points in the presence of symlinks; 
> > > is this needed?
> > 
> > @benlangmuir That's true and not ideal, but `makeAbsolute` will not resolve 
> > `/./` or `/../` in paths, so it's not a canonicalization and some tests 
> > were failing because of that. One alternative would be to use 
> > `makeAbsolute` + `remove_dots` on Windows (where removing dot dots is 
> > semantically correct) and `getRealPath` on Unix, like I do in lit. 
> > Suggestions?
> Wouldn't removing .. have the same issue with symlinks on Windows? I know 
> symlinks are less common there, but it's not clear to me why it would be 
> correct.  I guess you could also check if the paths resolve to the same file 
> after removing ..
> 
> 
@benlangmuir Windows simplifies `\..\` in paths before starting to walk the 
filesystem. 
https://superuser.com/questions/1502360/different-behavior-of-double-dots-and-symlinks-in-windows-and-unix

If I detected that the path didn't resolve to the same file after removing 
`..`, what would I do?

I think the current logic will only end up using the `else` branch on Windows. 
At least I can't think of a scenario where the root would change from using 
realpath on unix.



Comment at: llvm/utils/lit/lit/TestRunner.py:1282
+# a leading slash.
+substitutions.append(("%:" + letter, colonNormalizePath(path)))
 

benlangmuir wrote:
> This change drops the `+ ".tmp"`  that was previously added to 
> `%t:regex_replacement` and `%:t`.
> This change drops the `+ ".tmp"`  that was previously added to 
> `%t:regex_replacement` and `%:t`.

@benlangmuir Actually not! The `path_substitutions` list uses `("t", tmpName)` 
which includes the `.tmp`, instead of `tmpBase` which doesn't. Looking at the 
original code, there didn't seem to be a reason to use `tmpBase` and re-append 
`.tmp` instead of using `tmpName`.


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

https://reviews.llvm.org/D154130

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-28 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian updated this revision to Diff 545218.
MrTrillian marked 4 inline comments as done.
MrTrillian added a comment.

Reverted some `os.path.abspath` that had been converted to 
`abs_path_preserve_drive`


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

https://reviews.llvm.org/D154130

Files:
  clang/include/clang/Basic/FileManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/test/Lexer/case-insensitive-include-win.c
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/lit/discovery.py
  llvm/utils/lit/lit/util.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
  llvm/utils/llvm-lit/llvm-lit.in

Index: llvm/utils/llvm-lit/llvm-lit.in
===
--- llvm/utils/llvm-lit/llvm-lit.in
+++ llvm/utils/llvm-lit/llvm-lit.in
@@ -8,7 +8,7 @@
 
 def map_config(source_dir, site_config):
 global config_map
-source_dir = os.path.realpath(source_dir)
+source_dir = os.path.abspath(source_dir)
 source_dir = os.path.normcase(source_dir)
 site_config = os.path.normpath(site_config)
 config_map[source_dir] = site_config
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-this_dir = os.path.realpath(os.path.dirname(__file__))
+this_dir = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 config.llvm_tools_dir = os.path.join(this_dir, "build")
 import lit.llvm
 
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool-required"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-config.llvm_tools_dir = os.path.realpath(os.path.dirname(__file__))
+config.llvm_tools_dir = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 import lit.llvm
 
 lit.llvm.initialize(lit_config, config)
Index: llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
===
--- llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
+++ llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
@@ -5,5 +5,5 @@
 config.test_format = lit.formats.ShTest()
 
 import os
-config.test_exec_root = os.path.realpath(os.path.dirname(__file__))
+config.test_exec_root = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 config.test_source_root = os.path.join(config.test_exec_root, "tests")
Index: llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
===
--- llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
+++ llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
@@ -2,9 +2,7 @@
 import os
 import sys
 
-main_config = sys.argv[1]
-main_config = os.path.realpath(main_config)
-main_config = os.path.normcase(main_config)
+main_config = lit.util.abs_path_preserve_drive(sys.argv[1])
 
 config_map = {main_config: sys.argv[2]}
 builtin_parameters = {"config_map": config_map}
Index: llvm/utils/lit/lit/util.py
===
--- llvm/utils/lit/lit/util.py
+++ llvm/utils/lit/lit/util.py
@@ -127,6 +127,23 @@
 
 return n
 
+def abs_path_preserve_drive(path):
+"""Return the absolute path without resolving drive mappings on Windows.
+
+"""
+if platform.system() == "Windows":
+# Windows has limitations on path length (MAX_PATH) that
+# can be worked around using substitute drives, which map
+# a drive letter to a longer path on another drive.
+# Since Python 3.8, os.path.realpath resolves sustitute drives,
+# so we should not use it. In Python 3.7, os.path.realpath
+# was implemented as os.path.abspath.
+return os.path.normpath(os.path.abspath(path))
+else:
+# On UNIX, the current directory always has symbolic links resolved,
+# so any program accepting relative paths cannot preserve symbolic
+# links in paths and we should always use os.path.realpath.
+return 

[PATCH] D155991: [DWARF] Make sure file entry for artificial functions has an MD5 checksum

2023-07-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

> Any memory usage measurements to check this doesn't have a significant 
> adverse impact by copying all the strings?

Not actual measurements, no; but intuitively the size should not be much 
greater than the size of the filename entries in the .debug_line section for 
the CU, which should be KB not MB. (Plus StringMap entry overhead, which is 
constant per node.) Therefore I didn't take the time to measure. But see below 
for a possible alternate approach which would avoid even that much.

> Could/should we do the lookup on the CU filename before it goes into the DI 
> metadata, and store that FileID somewhere for later use?

There's a note in issue 63955 to the effect that I can't find an API to turn a 
filename into a FileID. If there is one that I didn't find, we could use 
FileIDs instead of pointers to name strings.

> FYI this is a 0.5% compile-time regression on `O0` builds 
> (https://llvm-compile-time-tracker.com/compare.php?from=69593aa5c054cec6be6b822c073ccdc63748a68d=7abb5fc618cec66841a8280d2a099a4c9c8cb91b=instructions:u).
>  Is that expected?

That's higher than I expected.

It might be feasible to do this a different way: When an invalid loc comes in, 
search the DIFileCache for a matching string, and use that instead of using the 
CU's copy of the filename. Then we can go back to using pointers as the keys. 
Might eliminate the duplicate DIFile as well. I'll look into that. Then the 
time cost would be incurred only when invalid locs come in, which is a minority 
of lookups (depends on the number of artificial functions generated).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155991

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


[PATCH] D154366: [clang][ExprConstant] Print template arguments when describing stack frame

2023-07-28 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 545216.
hazohelet added a comment.

Added missing tests for method function templates before landing this


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

https://reviews.llvm.org/D154366

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-frame-describe.cpp
  clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
  clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
===
--- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -45,7 +45,7 @@
 }
 
 int i = hh(); // expected-error {{call to immediate function 'examples::hh' is not a constant expression}} \
-   // expected-note {{in call to 'hh()'}}
+   // expected-note {{in call to 'hh()'}}
 
 struct A {
   int x;
@@ -180,7 +180,7 @@
 
 void test_runtime() {
 (void)immediate(0); // expected-error {{call to immediate function 'Aggregate::immediate' is not a constant expression}} \
-// expected-note {{in call to 'immediate(0)'}}
+// expected-note {{in call to 'immediate(0)'}}
 }
 consteval int f(int i) {
 return i;
Index: clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
===
--- clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
+++ clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
@@ -88,11 +88,11 @@
 void ohno() {
   int bar[stack_array<1024>()];
   int foo[stack_array<1025>()]; // expected-warning {{variable length arrays are a C99 feature}} \
-// expected-note {{in call to 'stack_array()'}}
+// expected-note {{in call to 'stack_array<1025>()'}}
 
   constexpr int foo[stack_array<1025>()]; // expected-warning {{variable length arrays are a C99 feature}} \
   // expected-error {{constexpr variable cannot have non-literal type 'const int[stack_array<1025>()]'}} \
-  // expected-note {{in call to 'stack_array()'}}
+  // expected-note {{in call to 'stack_array<1025>()'}}
 }
 
 }
Index: clang/test/SemaCXX/constexpr-frame-describe.cpp
===
--- clang/test/SemaCXX/constexpr-frame-describe.cpp
+++ clang/test/SemaCXX/constexpr-frame-describe.cpp
@@ -58,3 +58,24 @@
 constexpr D d{};
 static_assert(d.c->b.a->foo() == 1); // expected-error {{constant expression}} \
 expected-note {{in call to 'd.c->b.a->foo()'}}
+
+template 
+struct Bar {
+  template 
+  constexpr int fail1() const { return 1 / 0; } // expected-warning {{division by zero}} \
+// expected-note {{division by zero}}
+  template 
+  constexpr int fail2() const { return 1 / 0; } // expected-warning {{division by zero}} \
+// expected-note {{division by zero}}
+  template 
+  constexpr int fail3(Args... args) const { return 1 / 0; } // expected-warning {{division by zero}} \
+// expected-note {{division by zero}}
+};
+
+constexpr Bar bar;
+static_assert(bar.fail1()); // expected-error {{constant expression}} \
+ // expected-note {{in call to 'bar.fail1()'}}
+static_assert(bar.fail2()); // expected-error {{constant expression}} \
+  // expected-note {{in call to 'bar.fail2()'}}
+static_assert(bar.fail3(3, 4UL, bar, )); // expected-error {{constant expression}} \
+ // expected-note {{in call to 'bar.fail3, const Bar *>(3, 4, {}, )'}}
Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
===
--- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
+++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
@@ -117,11 +117,11 @@
 
   constexpr pad pir{4, 4};
   // expected-error@+2 {{constexpr variable 'piw' must be initialized by a constant expression}}
-  // expected-note@+1 {{in call to 'bit_cast(pir)'}}
+  // expected-note@+1 {{in call to 'bit_cast(pir)'}}
   constexpr int piw = bit_cast(pir).x;
 
   // expected-error@+2 {{constexpr variable 'bad' must be initialized by a constant expression}}
-  // expected-note@+1 {{in call to 'bit_cast(pir)'}}
+  // expected-note@+1 {{in call to 'bit_cast(pir)'}}
   constexpr no_pad bad = bit_cast(pir);
 
   

[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

2023-07-28 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet marked 2 inline comments as done.
hazohelet added a comment.

Thanks for the review




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9743-9748
+def warn_tautological_negation_and_compare: Warning<
+  "'&&' against a variable and its negation always evaluates to false">,
+  InGroup, DefaultIgnore;
+def warn_tautological_negation_or_compare: Warning<
+  "'||' against a variable and its negation always evaluates to true">,
+  InGroup, DefaultIgnore;

aaron.ballman wrote:
> Let's combine these if we can. I'm not 100% certain that `%select` is going 
> to like `&&|||` though, so if there's an issue, separate is also fine.
`%select(&&|||)0` doesn't seem to work as we want it to, so I kept it separated


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

https://reviews.llvm.org/D152093

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


[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

2023-07-28 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 545213.
hazohelet added a comment.

Address comments from Aaron

- Reworded diagnostic message


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

https://reviews.llvm.org/D152093

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/CFG.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
  clang/test/Misc/warning-wall.c
  clang/test/SemaCXX/tautological-negation-compare.cpp
  clang/test/SemaCXX/warn-infinite-recursion.cpp

Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -203,3 +203,13 @@
   (void)typeid(unevaluated_recursive_function());
   return 0;
 }
+
+void func1(int i) { // expected-warning {{call itself}}
+  if (i || !i)
+func1(i);
+}
+void func2(int i) { // expected-warning {{call itself}}
+  if (!i && i) {}
+  else
+func2(i);
+}
Index: clang/test/SemaCXX/tautological-negation-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/tautological-negation-compare.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-negation-compare -Wno-constant-logical-operand %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-compare -Wno-constant-logical-operand %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused -Wno-loop-analysis -Wno-constant-logical-operand %s
+
+#define COPY(x) x
+
+void test_int(int x) {
+  if (x || !x) {} // expected-warning {{'||' of a value and its negation always evaluates to true}}
+  if (!x || x) {} // expected-warning {{'||' of a value and its negation always evaluates to true}}
+  if (x && !x) {} // expected-warning {{'&&' of a value and its negation always evaluates to false}}
+  if (!x && x) {} // expected-warning {{'&&' of a value and its negation always evaluates to false}}
+
+  // parentheses are ignored
+  if (x || (!x)) {} // expected-warning {{'||' of a value and its negation always evaluates to true}}
+  if (!(x) || x) {} // expected-warning {{'||' of a value and its negation always evaluates to true}}
+
+  // don't warn on macros
+  if (COPY(x) || !x) {}
+  if (!x || COPY(x)) {}
+  if (x && COPY(!x)) {}
+  if (COPY(!x && x)) {}
+
+  // dont' warn on literals
+  if (1 || !1) {}
+  if (!42 && 42) {}
+
+
+  // don't warn on overloads
+  struct Foo{
+int val;
+Foo operator!() const { return Foo{!val}; }
+bool operator||(const Foo other) const { return val || other.val; }
+bool operator&&(const Foo other) const { return val && other.val; }
+  };
+
+  Foo f{3};
+  if (f || !f) {}
+  if (!f || f) {}
+  if (f.val || !f.val) {} // expected-warning {{'||' of a value and its negation always evaluates to true}}
+  if (!f.val && f.val) {} // expected-warning {{'&&' of a value and its negation always evaluates to false}}
+}
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -55,6 +55,7 @@
 CHECK-NEXT:  -Wtautological-bitwise-compare
 CHECK-NEXT:  -Wtautological-undefined-compare
 CHECK-NEXT:  -Wtautological-objc-bool-compare
+CHECK-NEXT:  -Wtautological-negation-compare
 CHECK-NEXT:-Wtrigraphs
 CHECK-NEXT:-Wuninitialized
 CHECK-NEXT:  -Wsometimes-uninitialized
Index: clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -1393,13 +1393,13 @@
 // CHECK: Succs (2): B2 B1
 // CHECK:   [B4 (NORETURN)]
 // CHECK: 1: ~NoReturn() (Temporary object destructor)
-// CHECK: Preds (1): B5
+// CHECK: Preds (1): B5(Unreachable)
 // CHECK: Succs (1): B0
 // CHECK:   [B5]
 // CHECK: 1: [B8.3] || [B7.2] || [B6.7]
 // CHECK: T: (Temp Dtor) [B6.4]
 // CHECK: Preds (3): B6 B7 B8
-// CHECK: Succs (2): B4 B3
+// CHECK: Succs (2): B4(Unreachable) B3
 // CHECK:   [B6]
 // CHECK: 1: check
 // CHECK: 2: [B6.1] (ImplicitCastExpr, FunctionToPointerDecay, _Bool (*)(const NoReturn &))
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -158,6 +158,17 @@
 return false;
   }
 
+  void logicAlwaysTrue(const BinaryOperator *B, bool isAlwaysTrue) override {
+if (HasMacroID(B))
+  return;
+
+unsigned DiagID = isAlwaysTrue
+  ? diag::warn_tautological_negation_or_compare
+  : 

[PATCH] D156368: [OpenMP] Do not always emit unused extern variables

2023-07-28 Thread Joseph Huber 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 rG141c4e7a9403: [OpenMP] Do not always emit unused extern 
variables (authored by jhuber6).
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

Changed prior to commit:
  https://reviews.llvm.org/D156368?vs=545168=545211#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156368

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  openmp/libomptarget/test/offloading/extern.c


Index: openmp/libomptarget/test/offloading/extern.c
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/extern.c
@@ -0,0 +1,27 @@
+// RUN: %libomptarget-compile-generic -DVAR -c -o %t.o
+// RUN: %libomptarget-compile-generic %t.o && %libomptarget-run-generic | 
%fcheck-generic
+
+#ifdef VAR
+int x = 1;
+#else
+#include 
+#include 
+extern int x;
+
+int main() {
+  int value = 0;
+#pragma omp target map(from : value)
+  value = x;
+  assert(value == 1);
+
+  x = 999;
+#pragma omp target update to(x)
+
+#pragma omp target map(from : value)
+  value = x;
+  assert(value == 999);
+
+  // CHECK: PASS
+  printf ("PASS\n");
+}
+#endif
Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -29,7 +29,6 @@
 // CHECK-DAG: @flag = protected global i8 undef,
 // CHECK-DAG: @dx = {{protected | }}global i32 0,
 // CHECK-DAG: @dy = {{protected | }}global i32 0,
-// CHECK-DAG: @aaa = external global i32,
 // CHECK-DAG: @bbb = {{protected | }}global i32 0,
 // CHECK-DAG: weak constant %struct.__tgt_offload_entry { ptr @bbb,
 // CHECK-DAG: @ccc = external global i32,
@@ -80,7 +79,7 @@
 extern int aaa;
 int bbb = 0;
 extern int ccc;
-int ddd = 0;
+int ddd = ccc;
 #pragma omp end declare target
 
 #pragma omp declare target
@@ -260,8 +259,6 @@
 
 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
 
-// CHECK-DAG: !{i32 1, !"aaa", i32 0, i32 {{[0-9]+}}}
-// CHECK-DAG: !{i32 1, !"ccc", i32 0, i32 {{[0-9]+}}}
 // CHECK-DAG: !{{{.+}}virtual_foo
 
 #ifdef OMP5
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3605,6 +3605,13 @@
 // Emit declaration of the must-be-emitted declare target variable.
 if (std::optional Res =
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD)) {
+
+  // If this variable has external storage and doesn't require special
+  // link handling we defer to its canonical definition.
+  if (VD->hasExternalStorage() &&
+  Res != OMPDeclareTargetDeclAttr::MT_Link)
+return;
+
   bool UnifiedMemoryEnabled =
   getOpenMPRuntime().hasRequiresUnifiedSharedMemory();
   if ((*Res == OMPDeclareTargetDeclAttr::MT_To ||
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10166,6 +10166,13 @@
 
   std::optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+
+  // If this is an 'extern' declaration we defer to the canonical definition 
and
+  // do not emit an offloading entry.
+  if (Res && *Res != OMPDeclareTargetDeclAttr::MT_Link &&
+  VD->hasExternalStorage())
+return;
+
   if (!Res) {
 if (CGM.getLangOpts().OpenMPIsTargetDevice) {
   // Register non-target variables being emitted in device code (debug info


Index: openmp/libomptarget/test/offloading/extern.c
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/extern.c
@@ -0,0 +1,27 @@
+// RUN: %libomptarget-compile-generic -DVAR -c -o %t.o
+// RUN: %libomptarget-compile-generic %t.o && %libomptarget-run-generic | %fcheck-generic
+
+#ifdef VAR
+int x = 1;
+#else
+#include 
+#include 
+extern int x;
+
+int main() {
+  int value = 0;
+#pragma omp target map(from : value)
+  value = x;
+  assert(value == 1);
+
+  x = 999;
+#pragma omp target update to(x)
+
+#pragma omp target map(from : value)
+  value = x;
+  assert(value == 999);
+
+  // CHECK: PASS
+  printf ("PASS\n");
+}
+#endif
Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -29,7 +29,6 @@
 // CHECK-DAG: @flag = protected global i8 undef,
 // CHECK-DAG: @dx = {{protected | }}global i32 0,
 

[clang] 141c4e7 - [OpenMP] Do not always emit unused extern variables

2023-07-28 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-07-28T11:52:05-05:00
New Revision: 141c4e7a9403fed46d84c7f0429295bd28c89368

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

LOG: [OpenMP] Do not always emit unused extern variables

Currently, the precense of the OpenMP target declare metadata requires
that we always codegen a global declaration. This is undesirable in the
case that we could defer or omit this declaration as is common with
unused extern variables. This is important as it allows us, in the
runtime, to rely on static linking semantics to omit unused symbols so
they are not included when the user links it in.

This patch changes the check for always emitting these variables.
Because of this we also need to extend this logic to the generation of
the offloading entries. This has the result of derring the offload entry
generation to the canonical definitoin. So we are effectively assuming
whoever owns the storage for this variable will perform that operation.
This makes an exception for `link` attributes as those require their own
special handling.

Let me know if this is sound in the implementation, I do not have the
largest view of the standards here.

Fixes: https://github.com/llvm/llvm-project/issues/64133

Reviewed By: tianshilei1992

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

Added: 
openmp/libomptarget/test/offloading/extern.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/OpenMP/declare_target_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a4f7eb96c0d9bc..02410c4d2b4250 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10166,6 +10166,13 @@ void 
CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
 
   std::optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+
+  // If this is an 'extern' declaration we defer to the canonical definition 
and
+  // do not emit an offloading entry.
+  if (Res && *Res != OMPDeclareTargetDeclAttr::MT_Link &&
+  VD->hasExternalStorage())
+return;
+
   if (!Res) {
 if (CGM.getLangOpts().OpenMPIsTargetDevice) {
   // Register non-target variables being emitted in device code (debug info

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 908dec42afabeb..332a879349cfc2 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3605,6 +3605,13 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
 // Emit declaration of the must-be-emitted declare target variable.
 if (std::optional Res =
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD)) {
+
+  // If this variable has external storage and doesn't require special
+  // link handling we defer to its canonical definition.
+  if (VD->hasExternalStorage() &&
+  Res != OMPDeclareTargetDeclAttr::MT_Link)
+return;
+
   bool UnifiedMemoryEnabled =
   getOpenMPRuntime().hasRequiresUnifiedSharedMemory();
   if ((*Res == OMPDeclareTargetDeclAttr::MT_To ||

diff  --git a/clang/test/OpenMP/declare_target_codegen.cpp 
b/clang/test/OpenMP/declare_target_codegen.cpp
index 14f5f5c096893a..71c742198af6bf 100644
--- a/clang/test/OpenMP/declare_target_codegen.cpp
+++ b/clang/test/OpenMP/declare_target_codegen.cpp
@@ -29,7 +29,6 @@
 // CHECK-DAG: @flag = protected global i8 undef,
 // CHECK-DAG: @dx = {{protected | }}global i32 0,
 // CHECK-DAG: @dy = {{protected | }}global i32 0,
-// CHECK-DAG: @aaa = external global i32,
 // CHECK-DAG: @bbb = {{protected | }}global i32 0,
 // CHECK-DAG: weak constant %struct.__tgt_offload_entry { ptr @bbb,
 // CHECK-DAG: @ccc = external global i32,
@@ -80,7 +79,7 @@ extern int bbb;
 extern int aaa;
 int bbb = 0;
 extern int ccc;
-int ddd = 0;
+int ddd = ccc;
 #pragma omp end declare target
 
 #pragma omp declare target
@@ -260,8 +259,6 @@ struct TTT {
 
 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
 
-// CHECK-DAG: !{i32 1, !"aaa", i32 0, i32 {{[0-9]+}}}
-// CHECK-DAG: !{i32 1, !"ccc", i32 0, i32 {{[0-9]+}}}
 // CHECK-DAG: !{{{.+}}virtual_foo
 
 #ifdef OMP5

diff  --git a/openmp/libomptarget/test/offloading/extern.c 
b/openmp/libomptarget/test/offloading/extern.c
new file mode 100644
index 00..35cf905ee0cd41
--- /dev/null
+++ b/openmp/libomptarget/test/offloading/extern.c
@@ -0,0 +1,27 @@
+// RUN: %libomptarget-compile-generic -DVAR -c -o %t.o
+// RUN: %libomptarget-compile-generic %t.o && %libomptarget-run-generic | 
%fcheck-generic
+
+#ifdef VAR
+int x = 1;
+#else
+#include 
+#include 
+extern int x;
+
+int main() 

[PATCH] D156509: [clang][Interp] Diagnose unknown parameter values

2023-07-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:550-554
+  if (isa(D)) {
+S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
+S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
+return false;
+  }

aaron.ballman wrote:
> No need for this given all code paths return false.
> 
> However, what should we do for calls to this for something other than a 
> `ParmVarDecl`? Should we issue a generic note so the constant expression 
> fails but we get notified to the missing cases?
I think the `return false;` is basically fine, it will show the usual "is not 
an integral constant expression" error message, and if there's no other note, 
we can investigate and improve diagnostics.


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

https://reviews.llvm.org/D156509

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


[PATCH] D156509: [clang][Interp] Diagnose unknown parameter values

2023-07-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 545193.

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

https://reviews.llvm.org/D156509

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/functions.cpp

Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -std=c++14 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -verify=ref %s
+// RUN: %clang_cc1 -std=c++14 -verify=ref %s
+// RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
 constexpr void doNothing() {}
 constexpr int gimme5() {
@@ -300,3 +304,24 @@
   }
   static_assert((foo(),1) == 1, "");
 }
+
+namespace InvalidReclRefs {
+  void param(bool b) { // ref-note {{declared here}} \
+   // expected-note {{declared here}}
+static_assert(b, ""); // ref-error {{not an integral constant expression}} \
+  // ref-note {{function parameter 'b' with unknown value}} \
+  // expected-error {{not an integral constant expression}} \
+  // expected-note {{function parameter 'b' with unknown value}}
+static_assert(true ? true : b, "");
+  }
+
+#if __cplusplus >= 202002L
+  consteval void param2(bool b) { // ref-note {{declared here}} \
+ // expected-note {{declared here}}
+static_assert(b, ""); // ref-error {{not an integral constant expression}} \
+  // ref-note {{function parameter 'b' with unknown value}} \
+  // expected-error {{not an integral constant expression}} \
+  // expected-note {{function parameter 'b' with unknown value}}
+  }
+#endif
+}
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -54,6 +54,7 @@
 def ArgCastKind : ArgType { let Name = "CastKind"; }
 def ArgCallExpr : ArgType { let Name = "const CallExpr *"; }
 def ArgOffsetOfExpr : ArgType { let Name = "const OffsetOfExpr *"; }
+def ArgDeclRef : ArgType { let Name = "const DeclRefExpr *"; }
 
 //===--===//
 // Classes of types instructions operate on.
@@ -649,3 +650,7 @@
 def InvalidCast : Opcode {
   let Args = [ArgCastKind];
 }
+
+def InvalidDeclRef : Opcode {
+  let Args = [ArgDeclRef];
+}
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -174,6 +174,9 @@
 bool CheckFloatResult(InterpState , CodePtr OpPC, const Floating ,
   APFloat::opStatus Status);
 
+/// Checks why the given DeclRefExpr is invalid.
+bool CheckDeclRef(InterpState , CodePtr OpPC, const DeclRefExpr *DR);
+
 bool CheckBitcast(InterpState , CodePtr OpPC, unsigned IndeterminateBits,
   bool TargetIsUCharOrByte);
 
@@ -1897,6 +1900,12 @@
   return false;
 }
 
+inline bool InvalidDeclRef(InterpState , CodePtr OpPC,
+   const DeclRefExpr *DR) {
+  assert(DR);
+  return CheckDeclRef(S, OpPC, DR);
+}
+
 template ::T>
 inline bool OffsetOf(InterpState , CodePtr OpPC, const OffsetOfExpr *E) {
   std::vector ArrayIndices;
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -541,6 +541,20 @@
   return true;
 }
 
+/// We aleady know the given DeclRefExpr is invalid for some reason,
+/// now figure out why and print appropriate diagnostics.
+bool CheckDeclRef(InterpState , CodePtr OpPC, const DeclRefExpr *DR) {
+  const ValueDecl *D = DR->getDecl();
+  const SourceInfo  = S.Current->getSource(OpPC);
+
+  if (isa(D)) {
+S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
+S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
+  }
+
+  return false;
+}
+
 bool CheckBitcast(InterpState , CodePtr OpPC, unsigned IndeterminateBits,
   bool TargetIsUCharOrByte) {
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2499,7 +2499,7 @@
 return this->emitGetPtrThisField(Offset, E);
   }
 
-  return false;
+  return this->emitInvalidDeclRef(E, E);
 }
 
 template 
___
cfe-commits mailing list

[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3540
+  return RValue::get(Builder.CreateAddrSpaceCast(AI, CGM.Int8PtrTy));
+else
+  return RValue::get(AI);

No return after else



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3558
+  return RValue::get(Builder.CreateAddrSpaceCast(AI, CGM.Int8PtrTy));
+else
+  return RValue::get(AI);

No return after else


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156539

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D156539#4542836 , @rjmccall wrote:

> We should probably write this code to work properly in case we add a target 
> that makes `__builtin_alloca` return a pointer in the private address space.  
> Could you recover the target AS from the type of the expression instead of 
> assuming `LangAS::Default`?

This should happen for opencl today with amdgpu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156539

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We should probably write this code to work properly in case we add a target 
that makes `__builtin_alloca` return a pointer in the private address space.  
Could you recover the target AS from the type of the expression instead of 
assuming `LangAS::Default`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156539

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


[PATCH] D153693: [clang][Interp] Handle InitListExprs of composite type

2023-07-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder abandoned this revision.
tbaeder added a comment.

Abandoning in favor of https://reviews.llvm.org/D156027


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153693

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


[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D156247#4542155 , @aaron.ballman 
wrote:

> Given the views expressed on this thread, I think this requires a wider 
> community discussion to determine whether we want to support this idea or 
> not, regardless of -cc1 or driver-level option. We should not be adding a 
> novel language dialect as we're getting ready to cut a release unless the 
> need and benefits are *very* compelling, and I don't think that's the case 
> here. We need the time to think about the long-term effects of such a mode, 
> so I don't think Clang 17 is an appropriate ship vehicle for this change, 
> especially because Google can carry this patch in your downstream easily 
> enough.

Google cannot do this with a downstream patch as we need this for toolchains 
that we do not build from the LLVM sources we integrate.
If we could do with a local patch, we would have definitely done it.

> My recommendation is to start an RFC on Discourse. If the community quickly 
> and decisively agrees this should land in Clang 17 in the next few days, it 
> might still be reasonable to make the rc2 cutoff, but I'd leave that decision 
> to the release managers and it would be contingent on strong libc++ 
> maintainer agreement to whatever direction we go (because they'll be the most 
> impacted by this decision).

https://discourse.llvm.org/t/rfc-add-a-flag-to-clang-17-to-disable-coroutines-in-c-20

@aaron.ballman could you comment on having a `-cc1` flag without guarantees 
from libc++ folks that this works (so it imposes no support costs on them)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-28 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D156247#4541756 , @ilya-biryukov 
wrote:

> In D156247#4540228 , @Mordante 
> wrote:
>
>> 2. My biggest concern is the timing of this patch. The date of the branching 
>> is know upfront and well communicated by the release managers. This patch 
>> was created after the LLVM-17 branch was created. For libc++ this patch 
>> would be a new feature which has no patch at the moment. This means we're 
>> asked to add a new feature after RC1. In libc++ we normally avoid adding new 
>> features in the release branch.
>
> I am sorry for sending the patch late, we have not thought about it before. I 
> have already mentioned that before in the thread.

I've read that, before my reply. That does not change the fact I feel it is a 
concern.

> We could have foreseen the need for this change before, but we did not and 
> there is nothing I can do to fix it now.

I understand.

>> - a pre-approval by the release managers to apply these changes to the 
>> release branch,
>
> I have asked the release managers above.

Thanks.

>> - a libc++ patch that works with `-fno-coroutines`, which I would be happy 
>> to review.
>
> I will check what needs to be done for libc++ here, I suspect adding `#error` 
> inside `` if the feature macro is not defined should be enough.

This is not enough. There is quite a bit of work involved on the libc++ side. 
Here is a quick list of the things I directly can think of. First the patch in 
Clang needs to be available in our CI:

1. The patch needs to land in LLVM
2. We need to wait for the patch to be available in a build on apt.llvm.org 
(typically this takes one day, but may be longer if the build fails.)
3. We need to update and test our Docker image (this takes a few hours)
4. We need to upload the Docker image to the CI runners and wait for it to 
propagate (takes about 8 hours)

So it will take at least two days to get this working. The CI parts needs a 
libc++ developer who wants to do the work and have time in their schedule to 
work on this. When nobody has time, it will take longer to get the CI working.

Then the patch itself needs to do the following things (the work can be done 
directly, testing requires the CI)

1. Add `#error` inside ``
2. Add a LIBCPP feature flag and propagate that to lit
3. Adjust the tests that would fail with `-fno-coroutine`
4. Add a CI job so we can validate the new feature works

As @cor3ntin pointed out we need to be wary of regressions since other C++ 
features depend on coroutines. So we need a CI job to test whether the feature 
works correctly and do not regress when we add features depending on coroutines.

Maybe that helps a bit more to explain why this is a concern and not something 
we can do quickly on the libc++ side.

In D156247#4542155 , @aaron.ballman 
wrote:

> Given the views expressed on this thread, I think this requires a wider 
> community discussion to determine whether we want to support this idea or 
> not, regardless of -cc1 or driver-level option. We should not be adding a 
> novel language dialect as we're getting ready to cut a release unless the 
> need and benefits are *very* compelling, and I don't think that's the case 
> here. We need the time to think about the long-term effects of such a mode, 
> so I don't think Clang 17 is an appropriate ship vehicle for this change, 
> especially because Google can carry this patch in your downstream easily 
> enough.
>
> My recommendation is to start an RFC on Discourse. If the community quickly 
> and decisively agrees this should land in Clang 17 in the next few days, it 
> might still be reasonable to make the rc2 cutoff, but I'd leave that decision 
> to the release managers and it would be contingent on strong libc++ 
> maintainer agreement to whatever direction we go (because they'll be the most 
> impacted by this decision).

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D155568: [clang][Interp] Make sure we push integers of the correct size

2023-07-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D155568#4525488 , @tbaeder wrote:

> This patch is missing the `Ret` part in `InterpBuiltin()` in the 
> same file. That needs to change to the correct type as well.
>
> I can do that in a follow-up commit. @aaron.ballman Can you come up with a 
> value I can pass to `-triple` so I can actually test that this works?

Oops, sorry on the delayed response, this one slipped under my radar. You 
should be able to use `avr-unknown-unknown`: https://godbolt.org/z/4TsPW41d5


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

https://reviews.llvm.org/D155568

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


[PATCH] D155165: [clang][Interp] Fully serialize Floatings to bytes

2023-07-28 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 aside from some small nits.




Comment at: clang/lib/AST/Interp/Source.h:63-64
   /// Pointer into the code owned by a function.
+public:
   const std::byte *Ptr;
 };

Any chance we can use friendship here as well, rather than exposing the data 
member directly?



Comment at: clang/test/AST/Interp/floats.cpp:142-149
   constexpr long double ld = 3.1425926539;
+
+  constexpr long double f() {
+const long double L = __LDBL_MAX__;
+
+return L;
+  };

Probably makes sense to add a `__float128` test as well given that it's also a 
pretty large float type: https://godbolt.org/z/n8roa96jc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155165

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


  1   2   3   >