[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-09-20 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 373497.
linjamaki edited the summary of this revision.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

Files:
  clang/lib/Basic/Targets/SPIR.h
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp


Index: clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __device__ __attribute__((device))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+// CHECK: %struct.foo_t = type { i32, i32 addrspace(4)* }
+
+// CHECK: @d ={{.*}} addrspace(1) externally_initialized global
+__device__ int d;
+
+// CHECK: @c ={{.*}} addrspace(1) externally_initialized global
+__constant__ int c;
+
+// CHECK: @s ={{.*}} addrspace(3) global
+__shared__ int s;
+
+// CHECK: @foo ={{.*}} addrspace(1) externally_initialized global %struct.foo_t
+__device__ struct foo_t {
+  int i;
+  int* pi;
+} foo;
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z3barPi(i32 addrspace(4)*
+__device__ int* bar(int *x) {
+  return x;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_dv()
+__device__ int* baz_d() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @d to i32 
addrspace(4)*
+  return &d;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_cv()
+__device__ int* baz_c() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @c to i32 
addrspace(4)*
+  return &c;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_sv()
+__device__ int* baz_s() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(3)* @s to i32 
addrspace(4)*
+  return &s;
+}
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -56,9 +56,14 @@
 0, // opencl_generic
 0, // opencl_global_device
 0, // opencl_global_host
-0, // cuda_device
-0, // cuda_constant
-0, // cuda_shared
+// cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V
+// translation). This mapping is enabled when the language mode is HIP.
+1, // cuda_device
+// cuda_constant pointer can be casted to default/"flat" pointer, but in
+// SPIR-V casts between constant and generic pointers are not allowed. For
+// this reason cuda_constant is mapped to SPIR-V CrossWorkgroup.
+1, // cuda_constant
+3, // cuda_shared
 1, // sycl_global
 5, // sycl_global_device
 6, // sycl_global_host
@@ -219,6 +224,16 @@
   bool hasFeature(StringRef Feature) const override {
 return Feature == "spirv";
   }
+
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override {
+BaseSPIRTargetInfo::adjust(Diags, Opts);
+// Guarded so we don't override address space map setting set by
+// BaseSPIRTargetInfo::adjust.
+if (Opts.HIP && Opts.CUDAIsDevice)
+  // Enable address space mapping from HIP to SPIR-V.
+  // See comment on the SPIRDefIsGenMap table.
+  setAddressSpaceMap(/*DefaultIsGeneric=*/true);
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY SPIRV32TargetInfo : public SPIRVTargetInfo {


Index: clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __device__ __attribute__((device))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+// CHECK: %struct.foo_t = type { i32, i32 addrspace(4)* }
+
+// CHECK: @d ={{.*}} addrspace(1) externally_initialized global
+__device__ int d;
+
+// CHECK: @c ={{.*}} addrspace(1) externally_initialized global
+__constant__ int c;
+
+// CHECK: @s ={{.*}} addrspace(3) global
+__shared__ int s;
+
+// CHECK: @foo ={{.*}} addrspace(1) externally_initialized global %struct.foo_t
+__device__ struct foo_t {
+  int i;
+  int* pi;
+} foo;
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z3barPi(i32 addrspace(4)*
+__device__ int* bar(int *x) {
+  return x;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_dv()
+__device__ int* baz_d() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @d to i32 addrspace(4)*
+  return &d;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_cv()
+__device__ int* baz_c() {
+  // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @c to i32 addrspace(4)*
+  return &c;
+}
+
+// CHECK: define{{.*}} spir_func i32 addrspace(4)* @_Z5baz_sv()
+__device_

[PATCH] D110051: [clangd] Deduplicate inlay hints

2021-09-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I will note that I considered handling this in a way specific to explicit 
template instantiations.

However, while I do not have a reduced testcase for it, I've also run into 
duplicate hints in the context of macros.

So, it seemed easier to deduplicate in general; there is no justification for 
showing the same hint multiple times in the same location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110051

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

we prefer verifyFormat because it does some additional checks to ensure if the 
code is altered it still goes to how you expect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D109174: [MSP430][Clang] Infer CPU type from -mcpu= or -mmcu=

2021-09-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Pinging for review.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109174

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-09-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Pinging for review.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108299: [MSP430][Clang] Remove support for -mmcu=msp430

2021-09-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Pinging for review.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108299

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


[clang] ca3bebd - [OpenCL] Supports optional writing to 3d images in C++ for OpenCL 2021

2021-09-20 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-20T10:07:38+01:00
New Revision: ca3bebd8440f9f88f1457dad9c12933b73d9590f

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

LOG: [OpenCL] Supports optional writing to 3d images in C++ for OpenCL 2021

Adds support for a feature macro __opencl_c_3d_image_writes in
C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/unsupported-image.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index f7f428c1e6d8d..df9f203ae4c6b 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1732,10 +1732,6 @@ static QualType 
ConvertDeclSpecToType(TypeProcessingState &state) {
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
-// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
-// unified into one when __opencl_c_3d_image_writes option is enabled in
-// C++ for OpenCL 2021
-bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
 bool IsOpenCLC30Compatible =
 S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
@@ -1756,7 +1752,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
&state) {
   S.getLangOpts())) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result
-  << (IsOpenCLC30
+  << (IsOpenCLC30Compatible
   ? "cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
   : "cl_khr_3d_image_writes");
   declarator.setInvalidType();

diff  --git a/clang/test/Misc/opencl-c-3.0.incorrect_options.cl 
b/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
index 6232806c5c6d9..b3f3ab974ddd0 100644
--- a/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ b/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -8,6 +8,8 @@
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
 
 // CHECK-FP64: error: options cl_khr_fp64 and __opencl_c_fp64 are set to 
diff erent values
 

diff  --git a/clang/test/SemaOpenCL/unsupported-image.cl 
b/clang/test/SemaOpenCL/unsupported-image.cl
index 8db3f61b0146b..53422fa259f29 100644
--- a/clang/test/SemaOpenCL/unsupported-image.cl
+++ b/clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics




[PATCH] D109328: [OpenCL] Supports optional writing to 3d images in C++ for OpenCL 2021

2021-09-20 Thread Justas Janickas 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 rGca3bebd8440f: [OpenCL] Supports optional writing to 3d 
images in C++ for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109328

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/test/Misc/opencl-c-3.0.incorrect_options.cl
===
--- clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -8,6 +8,8 @@
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
 
 // CHECK-FP64: error: options cl_khr_fp64 and __opencl_c_fp64 are set to 
different values
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,10 +1732,6 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
-// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
-// unified into one when __opencl_c_3d_image_writes option is enabled in
-// C++ for OpenCL 2021
-bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
 bool IsOpenCLC30Compatible =
 S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
@@ -1756,7 +1752,7 @@
   S.getLangOpts())) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result
-  << (IsOpenCLC30
+  << (IsOpenCLC30Compatible
   ? "cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
   : "cl_khr_3d_image_writes");
   declarator.setInvalidType();


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown 

[PATCH] D109818: [HIPSPV] Convert HIP kernels to SPIR-V kernels

2021-09-20 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki created this revision.
Herald added subscribers: Anastasia, yaxunl.
linjamaki updated this revision to Diff 372671.
linjamaki added a comment.
Herald added subscribers: dexonsmith, hiraditya.
linjamaki updated this revision to Diff 373494.
linjamaki edited the summary of this revision.
linjamaki published this revision for review.
linjamaki added reviewers: Anastasia, bader.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rebase.


linjamaki added a comment.

Rebase.


This patch translates HIP kernels to SPIR-V kernels when the HIP 
compilation mode is targeting SPIR-S. This involves:

- Setting Cuda calling convention to CC_OpenCLKernel (which maps to SPIR_KERNEL 
in LLVM IR later on).

- Coercing pointer arguments with default address space (AS) qualifier to 
CrossWorkGroup AS (__global in OpenCL). HIPSPV's device code is ultimately 
SPIR-V for OpenCL execution environment (as starter/default) where Generic or 
Function (OpenCL's private) is not supported as storage class for kernel 
pointer types. This leaves the CrossWorkGroup to be the only reasonable choice 
for HIP buffers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109818

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenHIP/hipspv-kernel.cpp

Index: clang/test/CodeGenHIP/hipspv-kernel.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-kernel.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __global__ __attribute__((global))
+
+// CHECK: define {{.*}}spir_kernel void @_Z3fooPff(float addrspace(1)* {{.*}}, float {{.*}})
+__global__ void foo(float *a, float b) {
+  *a = b;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10189,8 +10189,11 @@
 public:
   SPIRABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) { setCCs(); }
 
+  void computeInfo(CGFunctionInfo &FI) const override;
+
 private:
   void setCCs();
+  ABIArgInfo classifyKernelArgumentType(QualType Ty) const;
 };
 } // end anonymous namespace
 namespace {
@@ -10205,6 +10208,7 @@
   }
 
   unsigned getOpenCLKernelCallingConv() const override;
+  void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
 };
 
 } // End anonymous namespace.
@@ -10213,10 +10217,44 @@
   RuntimeCC = llvm::CallingConv::SPIR_FUNC;
 }
 
+ABIArgInfo SPIRABIInfo::classifyKernelArgumentType(QualType Ty) const {
+  if (getContext().getLangOpts().HIP && getTarget().getTriple().isSPIRV()) {
+// Coerce pointer arguments with default address space to CrossWorkGroup
+// pointers for HIPSPV. When the language mode is HIP, the SPIRTargetInfo
+// maps cuda_device to SPIR-V's CrossWorkGroup address space.
+llvm::Type *LTy = CGT.ConvertType(Ty);
+auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
+auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);
+if (LTy->isPointerTy() && LTy->getPointerAddressSpace() == DefaultAS) {
+  LTy = llvm::PointerType::get(
+  cast(LTy)->getElementType(), GlobalAS);
+  return ABIArgInfo::getDirect(LTy, 0, nullptr, false);
+}
+  }
+  return classifyArgumentType(Ty);
+}
+
+void SPIRABIInfo::computeInfo(CGFunctionInfo &FI) const {
+  // The logic is same as in DefaultABIInfo with an exception on the kernel
+  // arguments handling.
+  llvm::CallingConv::ID CC = FI.getCallingConvention();
+
+  if (!getCXXABI().classifyReturnType(FI))
+FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+
+  for (auto &I : FI.arguments()) {
+if (CC == llvm::CallingConv::SPIR_KERNEL) {
+  I.info = classifyKernelArgumentType(I.type);
+} else {
+  I.info = classifyArgumentType(I.type);
+}
+  }
+}
+
 namespace clang {
 namespace CodeGen {
 void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) {
-  DefaultABIInfo SPIRABI(CGM.getTypes());
+  SPIRABIInfo SPIRABI(CGM.getTypes());
   SPIRABI.computeInfo(FI);
 }
 }
@@ -10226,6 +10264,18 @@
   return llvm::CallingConv::SPIR_KERNEL;
 }
 
+void SPIRTargetCodeGenInfo::setCUDAKernelCallingConvention(
+const FunctionType *&FT) const {
+  // Convert HIP kernels to SPIR-V kernels.
+  if (getABIInfo().getContext().getLangOpts().HIP &&
+  getABIInfo().getTarget().getTriple().isSPIRV()) {
+FT = getABIInfo().getContext().adjustFunctionType(
+FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
+return;
+  }
+  TargetCodeGenInfo::setCUDAKernelCallingConvention(FT);
+}
+
 static bool appendType(SmallStringEnc &Enc, QualType QType,
const CodeGen::CodeGenModule &CGM,
TypeStringCache &TSC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cg

[PATCH] D109925: [AST] add warnings for out-of-bounds FP values when using relaxed FP math compile flags

2021-09-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

I don't think the constant evaluator is a right place for such warnings. The 
option `-ffast-math` is a hint to the compiler, which, in particular, tells 
that no operation on Nans/Infs take place. It allows a compiler to generate 
better code. None is pertinent for the constant evaluator, as it already has 
all information necessary for the evaluation and it does not generate any code. 
It does not make sense to add a new mode for constant evaluation as well. To 
make the warnings useful you probably need to check if a constant value is an 
operand of an arithmetic operation.




Comment at: clang/test/AST/warn-fp-values.c:49
+double neg_zero_literal() {
+  return -0.0; // shows warning if compile continues with -emit-llvm
+}

`-ffast-math` does not prohibit using negative zero, it only treat it 
identically to positive zero.


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

https://reviews.llvm.org/D109925

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


[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 373525.
balazske marked 9 inline comments as done.
balazske added a comment.

Fixed review issues.
Added code comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109608

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6406,6 +6406,82 @@
 ToSM.getBufferOrFake(ImportedID, SourceLocation()).getBuffer());
 }
 
+struct ImportAttributes : public ASTImporterOptionSpecificTestBase {
+  void checkAttrImportCommon(const Attr *From, const Attr *To,
+ const Decl *ToD) {
+
+// Verify that dump does not crash because invalid data.
+ToD->dump();
+
+EXPECT_EQ(From->getParsedKind(), To->getParsedKind());
+EXPECT_EQ(From->getSyntax(), To->getSyntax());
+if (From->getAttrName()) {
+  EXPECT_TRUE(To->getAttrName());
+  EXPECT_STREQ(From->getAttrName()->getNameStart(),
+   To->getAttrName()->getNameStart());
+} else {
+  EXPECT_FALSE(To->getAttrName());
+}
+if (From->getScopeName()) {
+  EXPECT_TRUE(To->getScopeName());
+  EXPECT_STREQ(From->getScopeName()->getNameStart(),
+   To->getScopeName()->getNameStart());
+} else {
+  EXPECT_FALSE(To->getScopeName());
+}
+EXPECT_EQ(From->getSpellingListIndex(), To->getSpellingListIndex());
+EXPECT_STREQ(From->getSpelling(), To->getSpelling());
+EXPECT_EQ(From->isInherited(), To->isInherited());
+EXPECT_EQ(From->isImplicit(), To->isImplicit());
+EXPECT_EQ(From->isPackExpansion(), To->isPackExpansion());
+EXPECT_EQ(From->isLateParsed(), To->isLateParsed());
+  }
+
+  template 
+  void importAttr(const char *Code, AT *&FromAttr, AT *&ToAttr) {
+static_assert(std::is_base_of::value, "AT should be an Attr");
+static_assert(std::is_base_of::value, "DT should be a Decl");
+
+Decl *FromTU = getTuDecl(Code, Lang_CXX11, "input.cc");
+DT *FromD =
+FirstDeclMatcher().match(FromTU, namedDecl(hasName("test")));
+ASSERT_TRUE(FromD);
+
+DT *ToD = Import(FromD, Lang_CXX11);
+ASSERT_TRUE(ToD);
+
+FromAttr = FromD->template getAttr();
+ToAttr = ToD->template getAttr();
+ASSERT_TRUE(FromAttr);
+EXPECT_TRUE(ToAttr);
+
+checkAttrImportCommon(FromAttr, ToAttr, ToD);
+  }
+
+  template  void checkImported(const T *From, const T *To) {
+EXPECT_TRUE(To);
+EXPECT_NE(From, To);
+  }
+
+  template 
+  void checkImportVariadicArg(const llvm::iterator_range &From,
+  const llvm::iterator_range &To) {
+for (auto FromI = From.begin(), ToI = To.begin(); FromI != From.end();
+ ++FromI, ++ToI) {
+  ASSERT_NE(ToI, To.end());
+  checkImported(*FromI, *ToI);
+}
+  }
+};
+
+template <>
+void ImportAttributes::checkImported(const Decl *From, const Decl *To) {
+  EXPECT_TRUE(To);
+  EXPECT_NE(From, To);
+  EXPECT_EQ(To->getTranslationUnitDecl(),
+ToAST->getASTContext().getTranslationUnitDecl());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportExprOfAlignmentAttr) {
   // Test if import of these packed and aligned attributes does not trigger an
   // error situation where source location from 'From' context is referenced in
@@ -6466,6 +6542,15 @@
 ToAttr->getAttributeSpellingListIndex());
   EXPECT_EQ(FromAttr->getType()->getName(), ToAttr->getType()->getName());
 }
+
+TEST_P(ImportAttributes, ImportAssertCapability) {
+  AssertCapabilityAttr *FromAttr, *ToAttr;
+  importAttr(
+  "void test(int A1, int A2) __attribute__((assert_capability(A1, A2)));",
+  FromAttr, ToAttr);
+  checkImportVariadicArg(FromAttr->args(), ToAttr->args());
+}
+
 template 
 auto ExtendWithOptions(const T &Values, const std::vector &Args) {
   auto Copy = Values;
@@ -6849,5 +6934,8 @@
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportWithExternalSource,
  DefaultTestValuesForRunOptions);
 
+INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportAttributes,
+ DefaultTestValuesForRunOptions);
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -186,22 +186,6 @@
   return import(*From);
 }
 
-// Helper for chaining together multiple imports. If an error is detected,
-// subsequent imports will return default constructed nodes, so that failure
-// can be detected with a single conditional branch after a sequence of
-// imports.
-template  T importChecked(Error &Err, const T &From) {
-  // Don't attempt to import nodes if we hi

[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:8425
+
+  const T &value() { return To; }
+};

steakhal wrote:
> So, the `value()` sometimes returns const ref, and other times it returns a 
> mutable raw pointer...
> 
> I suspect, attribute constructors expect simple reference arguments and 
> pointers for lists. And this is why it behaves like this. Am I right about 
> this?
The data returned by `value` is the one that is passed to the attribute 
constructor. It is in exact the same form, and for arrays this is a simple 
pointer to the array data. The array in the attribute has a size parameter too, 
this can be passed separately from this object.

One such "importer" is created for every attribute argument even if it is of an 
array type. For the array size no such object has to be created, only for the 
array data.



Comment at: clang/lib/AST/ASTImporter.cpp:8460-8462
+  template 
+  AttrArgArrayImporter
+  importArrayArg(const llvm::iterator_range &From, unsigned ArraySize) {

steakhal wrote:
> The name `AT` suggests to me that you expect the template type parameter to 
> be a subtype of `class Attr`. However, I suspect it's not always the case.
> For example in case of the `OwnershipAttr` the `args()` returns a sequence of 
> `ParamIdx*` objects. So, in that sense, the `AT` name is not properly 
> justified.
> 
> Restricting template parameter types makes the code cleaner, so I would 
> suggest introducing a metafunction, that you could use in a `static_assert` 
> that you could use to check this requirement as the first instruction in the 
> function.
> 
> ```lang=C++
> template 
> constexpr static bool AttrOrParamIdx = std::is_base_of::value || 
> std::is_same_v;
> 
> static_assert(AttrOrParamIdx);
> ```
In this case `AT` is the element type of the array attribute argument, mostly 
`Expr *` but can be any other. The `AT` should mean "Argument Type". Now is is 
renamed to `T` because it is the only parameter, and every other place `T` is 
used too. I think it is not needed to make a static assert for every possible 
attribute argument type. The class can be still used incorrectly and 
theoretically attribute argument can be of any type, so the assert adds not 
much value.



Comment at: clang/lib/AST/ASTImporter.cpp:8466
+
+  template 
+  Expected createImportedAttr(const T *FromAttr, Arg &&...ImportedArg) 
{

steakhal wrote:
> I think you should be consistently using `typename` or `class`. I'm generally 
> in favor of using `typename` though.
Here the first parameter is really a class, the second not.



Comment at: clang/lib/AST/ASTImporter.cpp:8547-8548
+Expected ToAttrOrErr = AI.createImportedAttr(
+From, AI.importArrayArg(From->args(), From->args_size()).value(),
+From->args_size());
+if (ToAttrOrErr)

steakhal wrote:
> balazske wrote:
> > martong wrote:
> > > Could we hide these arguments?
> > > I mean we probably need a higher abstraction, something like
> > > ```
> > > Expected ToAttrOrErr = AI.createImportedAttr(From);
> > > ```
> > > should be sufficient, isn't it. We do want to import all arguments of all 
> > > kind of attributes, don't we?
> > It should be possible to pass every kind of needed arguments (after it is 
> > imported) to the constructor of the newly created `Attr` object. The 
> > problem is solved here by the `AttrArgImporter` that imports the object and 
> > can store it in a temporary value until it is passed to the constructor. 
> > The temporary value is important if an array is imported. To import the 
> > array the size must be passed to the array importer before, and the size 
> > must be passed to the constructor of the `Attr` too, therefore it exists 2 
> > times in the code. An `AttrArgImporter` can provide only one value to the 
> > constructor of the new `Attr` object. (Probably other solution is possible 
> > with `std::tuple` and `std::apply` but not sure if it is better.)
> What about having two implementations. One for any T that has `args()` and 
> one for anything else and using SFINAE choosing the right one.
> In this context, we should have the appropriate dynamic type, so by using 
> template type deduction on `From` could achieve this dispatch.
> 
> Internally it could do the `AI.importArrayArg(From->args(), 
> From->args_size()).value()` for the `args()` case.
> WDYT?
Probably we can have a specialization for exactly the case when the attribute 
has one parameter called "Args" that is of an array type. We need to check at 
how many attributes this is the case, probably it is only used at the thread 
safety part (relatively) many times.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:6467-6468
+  template 
+  void checkImportVariadicArg(const llvm::iterator_range &From,
+  const llvm::iterator_range &To) {
+for (auto Fr

[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:6414
+// Verify that dump does not crash because invalid data.
+ToD->dump();
+

steakhal wrote:
> Should we dump to the `stderr`?
It would be good to have a "sink stream" that just discards the input. In this 
case it is not needed to allocate memory buffer, the text output of the dump is 
not used. `ASTImporterTest` has already many unneeded output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109608

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


[clang] 15feaaa - Add myself as a code owner for SYCL support

2021-09-20 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2021-09-20T09:32:25+03:00
New Revision: 15feaaa359c7245bb59ff0a2aa3b806682f44286

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

LOG: Add myself as a code owner for SYCL support

Added: 


Modified: 
clang/CODE_OWNERS.TXT

Removed: 




diff  --git a/clang/CODE_OWNERS.TXT b/clang/CODE_OWNERS.TXT
index faf9575a2898..740aeeb7125b 100644
--- a/clang/CODE_OWNERS.TXT
+++ b/clang/CODE_OWNERS.TXT
@@ -8,6 +8,10 @@ beautification by scripts.  The fields are: name (N), email 
(E), web-address
 (W), PGP key ID and fingerprint (P), description (D), and snail-mail address
 (S).
 
+N: Alexey Bader
+E: alexey.ba...@intel.com
+D: SYCL support
+
 N: Aaron Ballman
 E: aa...@aaronballman.com
 D: Clang attributes



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


[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I think I'm convinced.
Thanks.




Comment at: clang/unittests/AST/ASTImporterTest.cpp:6414
+// Verify that dump does not crash because invalid data.
+ToD->dump();
+

balazske wrote:
> steakhal wrote:
> > Should we dump to the `stderr`?
> It would be good to have a "sink stream" that just discards the input. In 
> this case it is not needed to allocate memory buffer, the text output of the 
> dump is not used. `ASTImporterTest` has already many unneeded output.
`llvm::nulls()` returns such a stream.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109608

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


[PATCH] D109315: [clang] Check unsupported types in expressions

2021-09-20 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic reopened this revision.
asavonic added a comment.
This revision is now accepted and ready to land.

This is weird... Buildbot reported that `lock/omp_init_lock.c` test
crashed with SIGSEGV, but I cannot reproduce this on my machine.

I added a check for a null QualType; not sure if it fixes the issue
with the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109315

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


[PATCH] D109315: [clang] Check unsupported types in expressions

2021-09-20 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic updated this revision to Diff 373531.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109315

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/ibm128-unsupported.c
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
  clang/test/SemaSYCL/float128.cpp
  clang/test/SemaSYCL/int128.cpp

Index: clang/test/SemaSYCL/int128.cpp
===
--- clang/test/SemaSYCL/int128.cpp
+++ clang/test/SemaSYCL/int128.cpp
@@ -26,19 +26,22 @@
   // expected-note@+1 3{{'A' defined here}}
   __int128 A;
   Z<__int128> C;
-  // expected-error@+2 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
-  // expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  // expected-error@+3 2{{expression requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
+  // expected-error@+2 {{'A' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
+  // expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
   C.field1 = A;
-  // expected-error@+1 {{'bigfield' requires 128 bit size 'Z::BIGTYPE' (aka '__int128') type support, but device 'spir64' does not support it}}
+  // expected-error@+2 {{expression requires 128 bit size 'Z::BIGTYPE' (aka '__int128') type support, but target 'spir64' does not support it}}
+  // expected-error@+1 {{'bigfield' requires 128 bit size 'Z::BIGTYPE' (aka '__int128') type support, but target 'spir64' does not support it}}
   C.bigfield += 1.0;
 
-  // expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  // expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
   auto foo1 = [=]() {
 __int128 AA;
 // expected-note@+2 {{'BB' defined here}}
-// expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
 auto BB = A;
-// expected-error@+1 {{'BB' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-error@+2 {{expression requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
+// expected-error@+1 {{'BB' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
 BB += 1;
   };
 
@@ -50,7 +53,7 @@
 void foo2(){};
 
 // expected-note@+3 {{'P' defined here}}
-// expected-error@+2 {{'P' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-error@+2 {{'P' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
 // expected-note@+1 2{{'foo' defined here}}
 __int128 foo(__int128 P) { return P; }
 
@@ -58,7 +61,8 @@
   // expected-note@+1 {{'operator __int128' defined here}}
   struct X { operator  __int128() const; } x;
   bool a = false;
-  // expected-error@+1 {{'operator __int128' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+  // expected-error@+2 2{{expression requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
+  // expected-error@+1 {{'operator __int128' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
   a = x == __int128(0);
 }
 
@@ -74,12 +78,14 @@
   host_ok();
   kernel([=]() {
 decltype(CapturedToDevice) D;
-// expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
 auto C = CapturedToDevice;
 Z<__int128> S;
-// expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-error@+2 {{expression requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
+// expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
 S.field1 += 1;
-// expected-error@+1 {{'field' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
+// expected-error@+2 {{expression requires 128 bit size '__int128' type support, but target 'spir64' does not support it}}
+// expected-error@+1 {{'field' requires 128 bit size '__int128' type support, but ta

[clang] eb3af1e - [clang][NFC] Remove dead code

2021-09-20 Thread Andy Wingo via cfe-commits

Author: Andy Wingo
Date: 2021-09-20T11:33:34+02:00
New Revision: eb3af1e77341e82249993a5a8a50779c48e1cb61

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

LOG: [clang][NFC] Remove dead code

Remove code that has no effect in SemaType.cpp:processTypeAttrs.

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

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index df9f203ae4c6..53e41f01f83d 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8310,10 +8310,6 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
   attr.getMacroExpansionLoc());
 }
   }
-
-  if (!state.getSema().getLangOpts().OpenCL ||
-  type.getAddressSpace() != LangAS::Default)
-return;
 }
 
 void Sema::completeExprArrayBound(Expr *E) {



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


[PATCH] D108360: [clang][NFC] Remove dead code

2021-09-20 Thread Andy Wingo 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 rGeb3af1e77341: [clang][NFC] Remove dead code (authored by 
wingo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108360

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8310,10 +8310,6 @@
   attr.getMacroExpansionLoc());
 }
   }
-
-  if (!state.getSema().getLangOpts().OpenCL ||
-  type.getAddressSpace() != LangAS::Default)
-return;
 }
 
 void Sema::completeExprArrayBound(Expr *E) {


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8310,10 +8310,6 @@
   attr.getMacroExpansionLoc());
 }
   }
-
-  if (!state.getSema().getLangOpts().OpenCL ||
-  type.getAddressSpace() != LangAS::Default)
-return;
 }
 
 void Sema::completeExprArrayBound(Expr *E) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-20 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev added a comment.

Hello everyone! Ping :), need more approves for this patch.

@rsmith Thank you for your helpful tips. Can you please review the latest 
change? I fixed some tests and applied clang format suggestions.


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

https://reviews.llvm.org/D106876

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


[PATCH] D108359: [clang][NFC] Fix needless double-parenthisation

2021-09-20 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a reviewer: Anastasia.
wingo added a comment.

Just a little thing I saw while reading code -- if no response in a couple 
weeks I will just abandon the rev


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108359

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


[PATCH] D103874: [IR] Rename the shufflevector's undef mask to poison

2021-09-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/X86/avx-builtins.c:182
   // CHECK-LABEL: test_mm256_castsi128_si256
-  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
   return _mm256_castsi128_si256(A);

efriedma wrote:
> This change might be visible to user code.
Yes the length changing casts are worrying me as well - we could update the 
header to insert zero into the upper elements I suppose, in many cases these 
would be folded away by AVX ops implicitly zeroing the 128-bits. But we'd 
definitely have the potential for regressions.



Comment at: clang/test/CodeGen/X86/avx-builtins.c:1239
   // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> poison, <8 x i32> 

   // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 

   return _mm256_loadu2_m128(A, B);

These look out of date - D109497 changes the loadu2 codegen to be a single 
'concat' shuffle.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103874

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-20 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

Looks like this was committed again, breaking the SystemZ build bots once again:
https://lab.llvm.org/buildbot/#/builders/94/builds/5661


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Thanks for the suggestions/details, @dexonsmith  - I've posted to llvm-dev 
here: https://groups.google.com/g/llvm-dev/c/m9UVRhzJvh4/m/qdd_SyPuCQAJ and 
will wait for some follow-up (or dead silence) before starting along probably 
your latter suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[PATCH] D110065: [AArch64] Add support for the 'R' architecture profile.

2021-09-20 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea created this revision.
labrinea added reviewers: ostannard, miyuki, cfe-commits, llvm-commits.
Herald added subscribers: hiraditya, kristof.beyls.
labrinea requested review of this revision.
Herald added projects: clang, LLVM.

The patch introduces subtarget features to predicate certain instructions and 
system registers that are available only on 'A' profile targets. Those features 
are not present when targeting a generic CPU, which is the default processor. 
That said `-march` has to be explicitly specified on the command line to enable 
them as the target triple will not be enough.

References: https://developer.arm.com/documentation/ddi0600/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110065

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/Driver/aarch64-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/test/CodeGen/AArch64/arm64-crc32.ll
  llvm/test/MC/AArch64/arm64-branch-encoding.s
  llvm/test/MC/AArch64/arm64-system-encoding.s
  llvm/test/MC/AArch64/armv8.1a-lse.s
  llvm/test/MC/AArch64/armv8.1a-pan.s
  llvm/test/MC/AArch64/armv8.1a-rdma.s
  llvm/test/MC/AArch64/armv8.2a-at.s
  llvm/test/MC/AArch64/armv8.2a-crypto.s
  llvm/test/MC/AArch64/armv8.2a-dotprod-errors.s
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.2a-persistent-memory.s
  llvm/test/MC/AArch64/armv8.2a-uao.s
  llvm/test/MC/AArch64/armv8r-inst.s
  llvm/test/MC/AArch64/armv8r-sysreg.s
  llvm/test/MC/AArch64/armv8r-unsupported-inst.s
  llvm/test/MC/AArch64/armv8r-unsupported-sysreg.s
  llvm/test/MC/AArch64/basic-a64-instructions.s
  llvm/test/MC/AArch64/ras-extension.s
  llvm/test/MC/Disassembler/AArch64/arm64-branch.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-complex.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-js.txt
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-dit.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-flag.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-ras.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-tlb.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-trace.txt
  llvm/test/MC/Disassembler/AArch64/armv8.4a-virt.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-predres.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-specrestrict.txt
  llvm/test/MC/Disassembler/AArch64/armv8.5a-ssbs.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-el3.txt
  llvm/test/MC/Disassembler/AArch64/armv8a-fpmul.txt
  llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt

Index: llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
===
--- llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
+++ llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
@@ -1257,27 +1257,21 @@
 0xe1 0xff 0x1f 0xd4
 
 # CHECK: hvc  #{{1|0x1}}
-# CHECK: smc  #{{12000|0x2ee0}}
 # CHECK: brk  #{{12|0xc}}
 # CHECK: hlt  #{{123|0x7b}}
 0x22 0x0 0x0 0xd4
-0x3 0xdc 0x5 0xd4
 0x80 0x1 0x20 0xd4
 0x60 0xf 0x40 0xd4
 
 # CHECK: dcps1#{{42|0x2a}}
 # CHECK: dcps2#{{9|0x9}}
-# CHECK: dcps3#{{1000|0x3e8}}
 0x41 0x5 0xa0 0xd4
 0x22 0x1 0xa0 0xd4
-0x3 0x7d 0xa0 0xd4
 
 # CHECK: dcps1
 # CHECK: dcps2
-# CHECK: dcps3
 0x1 0x0 0xa0 0xd4
 0x2 0x0 0xa0 0xd4
-0x3 0x0 0xa0 0xd4
 
 #--
 # Extract (immediate)
@@ -3258,13 +3252,11 @@
 # CHECK: msr  {{hacr_el2|HACR_EL2}}, x12
 # CHECK: msr  {{mdcr_el3|MDCR_EL3}}, x12
 # CHECK: msr  {{ttbr0_el1|TTBR0_EL1}}, x12
-# CHECK: msr  {{ttbr0_el2|TTBR0_EL2}}, x12
 # CHECK: msr  {{ttbr0_el3|TTBR0_EL3}}, x12
 # CHECK: msr  {{ttbr1_el1|TTBR1_EL1}}, x12
 # CHECK: msr  {{tcr_el1|TCR_EL1}}, x12
 # CHECK: msr  {{tcr_el2|TCR_EL2}}, x12
 # CHECK: msr  {{tcr_el3|TCR_EL3}}, x12
-# CHECK: msr  {{vttbr_el2|VTTBR_EL2}}, x12
 # CHECK: msr  {{vtcr_el2|VTCR_EL2}}, x12
 # CHECK: msr  {{dacr32_el2|DACR32_EL2}}, x12
 # CHECK: msr  {{spsr_el1|SPSR_EL1}}, x12
@@ -3554,13 +3546,11 @@
 # CHECK: mrs  x9, {{hacr_el2|HACR_EL2}}
 # CHECK: mrs  x9, {{mdcr_el3|MDCR_EL3}}
 # CHECK: mrs  x9, {{ttbr0_el1|TTBR0_EL1}}
-# CHECK: mrs  x9, {{ttbr0_el2|TTBR0_EL2}}
 # CHECK: mrs  x9, {{ttbr0_el3|TTBR0_EL3}}
 # CHECK: mrs  x9, {{ttbr1_el1|TTBR1_EL1}}
 # CHECK: mrs  x9, {{tcr_el1|TCR_EL1}}
 # CHECK: mrs  x9, {{tcr_el2|TCR_EL2}}
 # CHECK: mrs  x9, {{tcr_el3|TCR_EL3}}
-# CHECK: mrs  x9, {{vttbr_el2|VTTBR_EL2}}
 # CHECK: mrs  x9, {{vtcr_el2|VTCR_EL2}}
 # CHECK: mrs  x9, {{dacr32_el2|DACR32_E

[PATCH] D106715: Thread safety analysis: Drop special block handling

2021-09-20 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.

Marking this explicitly as accepted, I'd say you're fine to land and we can 
handle any concerns from @delesley post commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106715

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


[PATCH] D106713: Thread safety analysis: Warn when demoting locks on back edges

2021-09-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D106713#3007878 , @aaronpuchert 
wrote:

> @aaron.ballman, since this is reintroducing some warnings after the 
> relaxation in D102026 , should we bring 
> this to Clang 13?

I think that's reasonable; the alternative is that we warn in Clang 12, don't 
warn in Clang 13, then start warning again in Clang 14 which does not seem very 
user friendly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106713

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


[clang] 6d7b3d6 - Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source

2021-09-20 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2021-09-20T12:55:56+01:00
New Revision: 6d7b3d6b3a8dbd62650b6c3dae1fe904a8ae9048

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

LOG: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source

Since https://reviews.llvm.org/D87118, the StaticAnalyzer directory is
added unconditionally. In theory this should not cause the static analyzer
sources to be built unless they are referenced by another target. However,
the clang-cpp target (defined in clang/tools/clang-shlib) uses the
CLANG_STATIC_LIBS global property to determine which libraries need to
be included. To solve this issue, this patch avoids adding libraries to
that property if EXCLUDE_FROM_ALL is set.

In case something like this comes up again: `cmake --graphviz=targets.dot`
is quite useful to see why a target is included as part of `ninja all`.

Reviewed By: thakis

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
clang/lib/StaticAnalyzer/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 5752f4277444..c2d46b743b85 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -100,7 +100,12 @@ macro(add_clang_library name)
   # The Xcode generator doesn't handle object libraries correctly.
   list(APPEND LIBTYPE OBJECT)
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
+if (NOT EXCLUDE_FROM_ALL)
+  # Only include libraries that don't have EXCLUDE_FROM_ALL set. This
+  # ensure that the clang static analyzer libraries are not compiled
+  # as part of clang-shlib if CLANG_ENABLE_STATIC_ANALYZER=OFF.
+  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
+endif()
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
@@ -110,8 +115,11 @@ macro(add_clang_library name)
   endif()
 
   foreach(lib ${libs})
-if(TARGET ${lib})
+   if(TARGET ${lib})
   target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
+  if (EXCLUDE_FROM_ALL)
+continue()
+  endif()
 
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
 get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA 
clang-libraries)

diff  --git a/clang/lib/StaticAnalyzer/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/CMakeLists.txt
index 3d1509254f52..a610252e1de7 100644
--- a/clang/lib/StaticAnalyzer/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/CMakeLists.txt
@@ -1,3 +1,10 @@
+# These directories can significantly impact build time, only build
+# them if anything depends on the clangStaticAnalyzer* libraries.
+if(NOT CLANG_ENABLE_STATIC_ANALYZER)
+  set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
+  set(EXCLUDE_FROM_ALL ON)
+endif()
+
 add_subdirectory(Core)
 add_subdirectory(Checkers)
 add_subdirectory(Frontend)

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index c5a9e0209f13..dca1c2af45bb 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -429,10 +429,13 @@ endfunction(set_windows_version_resource_properties)
 #  This is used to specify that this is a component library of
 #  LLVM which means that the source resides in llvm/lib/ and it is a
 #  candidate for inclusion into libLLVM.so.
+#   EXCLUDE_FROM_ALL
+#  Do not build this library as part of the default target, only
+#  if explicitly requested or when linked against.
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;EXCLUDE_FROM_ALL"
 "OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -535,6 +538,9 @@ function(llvm_add_library name)
 
 # FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
 set(ARG_STATIC)
+if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
+  set_target_properties(${name_static} PROPERTIES EXCLUDE_FROM_ALL ON)
+endif()
   endif()
 
   if(ARG_MODULE)
@@ -546,6 +552,10 @@ function(llvm_add_library name)
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
+set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL ON)
+  endif()
+
   if(ARG_COMPONENT_LIB)
 set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE)
 set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})



___

[PATCH] D109611: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source

2021-09-20 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d7b3d6b3a8d: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building 
all analyzer source (authored by arichardson).

Changed prior to commit:
  https://reviews.llvm.org/D109611?vs=371944&id=373554#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109611

Files:
  clang/cmake/modules/AddClang.cmake
  clang/lib/StaticAnalyzer/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -429,10 +429,13 @@
 #  This is used to specify that this is a component library of
 #  LLVM which means that the source resides in llvm/lib/ and it is a
 #  candidate for inclusion into libLLVM.so.
+#   EXCLUDE_FROM_ALL
+#  Do not build this library as part of the default target, only
+#  if explicitly requested or when linked against.
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;EXCLUDE_FROM_ALL"
 "OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -535,6 +538,9 @@
 
 # FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
 set(ARG_STATIC)
+if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
+  set_target_properties(${name_static} PROPERTIES EXCLUDE_FROM_ALL ON)
+endif()
   endif()
 
   if(ARG_MODULE)
@@ -546,6 +552,10 @@
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
+set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL ON)
+  endif()
+
   if(ARG_COMPONENT_LIB)
 set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE)
 set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})
Index: clang/lib/StaticAnalyzer/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/CMakeLists.txt
@@ -1,3 +1,10 @@
+# These directories can significantly impact build time, only build
+# them if anything depends on the clangStaticAnalyzer* libraries.
+if(NOT CLANG_ENABLE_STATIC_ANALYZER)
+  set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
+  set(EXCLUDE_FROM_ALL ON)
+endif()
+
 add_subdirectory(Core)
 add_subdirectory(Checkers)
 add_subdirectory(Frontend)
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -100,7 +100,12 @@
   # The Xcode generator doesn't handle object libraries correctly.
   list(APPEND LIBTYPE OBJECT)
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
+if (NOT EXCLUDE_FROM_ALL)
+  # Only include libraries that don't have EXCLUDE_FROM_ALL set. This
+  # ensure that the clang static analyzer libraries are not compiled
+  # as part of clang-shlib if CLANG_ENABLE_STATIC_ANALYZER=OFF.
+  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
+endif()
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
@@ -110,8 +115,11 @@
   endif()
 
   foreach(lib ${libs})
-if(TARGET ${lib})
+   if(TARGET ${lib})
   target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
+  if (EXCLUDE_FROM_ALL)
+continue()
+  endif()
 
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
 get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA 
clang-libraries)


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -429,10 +429,13 @@
 #  This is used to specify that this is a component library of
 #  LLVM which means that the source resides in llvm/lib/ and it is a
 #  candidate for inclusion into libLLVM.so.
+#   EXCLUDE_FROM_ALL
+#  Do not build this library as part of the default target, only
+#  if explicitly requested or when linked against.
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
+"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;EXCLUDE_FROM_ALL"
 "OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -535,6 +538,9 @@
 
 # FIXME: Add name_static to any

[PATCH] D109979: [Clang] [Fix] Clang build fails when build directory contains space character

2021-09-20 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109979

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


[clang] fae57a6 - [Clang] [Fix] Clang build fails when build directory contains space character

2021-09-20 Thread Shivam Gupta via cfe-commits

Author: Brain Swift
Date: 2021-09-20T18:19:08+05:30
New Revision: fae57a6a9795eccfa349270b110c09524e341abd

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

LOG: [Clang] [Fix] Clang build fails when build directory contains space 
character

Clang build fails when build directory contains space character.

Error messages:

[ 95%] Linking CXX executable ../../../../bin/clang
clang: error: no such file or directory: 
'Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'
make[2]: *** [bin/clang-14] Error 1
make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs

The path name is actually:
  'Dev Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'

Bugzilla issue - https://bugs.llvm.org/show_bug.cgi?id=51884
Reporter and patch author - Brain Swift 

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/tools/driver/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 7c32aadb8700..1bea470ed301 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@ if (APPLE)
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)



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


[PATCH] D109979: [Clang] [Fix] Clang build fails when build directory contains space character

2021-09-20 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfae57a6a9795: [Clang] [Fix] Clang build fails when build 
directory contains space character (authored by Brain Swift 
, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109979

Files:
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-09-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LGTM, this passed the usual tests and I didn't see any leftover allocations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D110044: Print nullptr_t namespace qualified within std::

2021-09-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> This improves diagnostic (& important to me, DWARF) accuracy

FWIW, I don't think the diagnostic particularly needs more accuracy here -- I 
think users know what `nullptr_t` type is being referred to without the full 
qualification because of other contextual clues in the diagnostic text. 
However, I'm not opposed to the changes as I don't think they make anything 
worse. But I didn't see any tests for DWARF behavioral changes, are those 
changes in a future patch, or should there be some more test coverage?




Comment at: clang/lib/AST/Type.cpp:3045
   case NullPtr:
-return "nullptr_t";
+return "std::nullptr_t";
   case Overload:

Should this be `::std::nullptr_t` to differentiate it from odd things like:
```
namespace my {
namespace std {
class nullptr_t {};
}
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110044

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


[PATCH] D110068: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-20 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit created this revision.
gAlfonso-bit added a reviewer: ahatanak.
gAlfonso-bit requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is no reason to have this here, (since all tests pass) and it isn't even 
a specifier anyway. We can just treat it as a pointer instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110068

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -310,7 +310,6 @@
   SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
 
   // Print qualifiers as appropriate.
-
   bool CanPrefixQualifiers = false;
   bool NeedARCStrongQualifier = false;
   CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -310,7 +310,6 @@
   SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
 
   // Print qualifiers as appropriate.
-
   bool CanPrefixQualifiers = false;
   bool NeedARCStrongQualifier = false;
   CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6de19ea - Thread safety analysis: Drop special block handling

2021-09-20 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-09-20T15:20:15+02:00
New Revision: 6de19ea4b6264e64cea145e00ab66fe1530fc0a0

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

LOG: Thread safety analysis: Drop special block handling

Previous changes like D101202 and D104261 have eliminated the special
status that break and continue once had, since now we're making
decisions purely based on the structure of the CFG without regard for
the underlying source code constructs.

This means we don't gain anything from defering handling for these
blocks. Dropping it moves some diagnostics, though arguably into a
better place. We're working around a "quirk" in the CFG that perhaps
wasn't visible before: while loops have an empty "transition block"
where continue statements and the regular loop exit meet, before
continuing to the loop entry. To get a source location for that, we
slightly extend our handling for empty blocks. The source location for
the transition ends up to be the loop entry then, but formally this
isn't a back edge. We pretend it is anyway. (This is safe: we can always
treat edges as back edges, it just means we allow less and don't modify
the lock set. The other way around it wouldn't be safe.)

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp
clang/test/PCH/thread-safety-attrs.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 41a55f9579bd..d6bb8cf673f7 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -849,6 +849,11 @@ static void findBlockLocations(CFG *CFGraph,
   // location.
   CurrBlockInfo->EntryLoc = CurrBlockInfo->ExitLoc =
   BlockInfo[(*CurrBlock->pred_begin())->getBlockID()].ExitLoc;
+} else if (CurrBlock->succ_size() == 1 && *CurrBlock->succ_begin()) {
+  // The block is empty, and has a single successor. Use its entry
+  // location.
+  CurrBlockInfo->EntryLoc = CurrBlockInfo->ExitLoc =
+  BlockInfo[(*CurrBlock->succ_begin())->getBlockID()].EntryLoc;
 }
   }
 }
@@ -2415,7 +2420,6 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
 // union because the real error is probably that we forgot to unlock M on
 // all code paths.
 bool LocksetInitialized = false;
-SmallVector SpecialBlocks;
 for (CFGBlock::const_pred_iterator PI = CurrBlock->pred_begin(),
  PE  = CurrBlock->pred_end(); PI != PE; ++PI) {
   // if *PI -> CurrBlock is a back edge
@@ -2432,17 +2436,6 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
   // Okay, we can reach this block from the entry.
   CurrBlockInfo->Reachable = true;
 
-  // If the previous block ended in a 'continue' or 'break' statement, then
-  // a 
diff erence in locksets is probably due to a bug in that block, rather
-  // than in some other predecessor. In that case, keep the other
-  // predecessor's lockset.
-  if (const Stmt *Terminator = (*PI)->getTerminatorStmt()) {
-if (isa(Terminator) || isa(Terminator)) {
-  SpecialBlocks.push_back(*PI);
-  continue;
-}
-  }
-
   FactSet PrevLockset;
   getEdgeLockset(PrevLockset, PrevBlockInfo->ExitSet, *PI, CurrBlock);
 
@@ -2450,9 +2443,14 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
 CurrBlockInfo->EntrySet = PrevLockset;
 LocksetInitialized = true;
   } else {
-intersectAndWarn(CurrBlockInfo->EntrySet, PrevLockset,
- CurrBlockInfo->EntryLoc,
- LEK_LockedSomePredecessors);
+// Surprisingly 'continue' doesn't always produce back edges, because
+// the CFG has empty "transition" blocks where they meet with the end
+// of the regular loop body. We still want to diagnose them as loop.
+intersectAndWarn(
+CurrBlockInfo->EntrySet, PrevLockset, CurrBlockInfo->EntryLoc,
+isa_and_nonnull((*PI)->getTerminatorStmt())
+? LEK_LockedSomeLoopIterations
+: LEK_LockedSomePredecessors);
   }
 }
 
@@ -2460,35 +2458,6 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
 if (!CurrBlockInfo->Reachable)
   continue;
 
-// Process continue and break blocks. Assume that the lockset for the
-// resulting block is unaffected by any discrepancies in them.
-for (const auto *PrevBlock : SpecialBlocks) {
-  unsigned PrevBlockID = PrevBlock->getBlockID();
-  CFGBlockInfo *PrevBlockInfo = &BlockInfo[PrevBlockID];
-
-  if (!LocksetInitialized) {
- 

[PATCH] D106715: Thread safety analysis: Drop special block handling

2021-09-20 Thread Aaron Puchert 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 rG6de19ea4b626: Thread safety analysis: Drop special block 
handling (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106715

Files:
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/PCH/thread-safety-attrs.cpp
  clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -280,12 +280,12 @@
 
 void sls_fun_bad_7() {
   sls_mu.Lock();
-  while (getBool()) {
+  while (getBool()) { // \
+expected-warning{{expecting mutex 'sls_mu' to be held at start of each loop}}
 sls_mu.Unlock();
 if (getBool()) {
   if (getBool()) {
-continue; // \
-expected-warning{{expecting mutex 'sls_mu' to be held at start of each loop}}
+continue;
   }
 }
 sls_mu.Lock(); // expected-note {{mutex acquired here}}
@@ -332,13 +332,14 @@
 sls_mu.Unlock();
 if (getBool()) {
   if (getBool()) {
-break; // expected-warning{{mutex 'sls_mu' is not held on every path through here}}
+break;
   }
 }
 sls_mu.Lock();
   }
   sls_mu.Unlock(); // \
-// expected-warning{{releasing mutex 'sls_mu' that was not held}}
+expected-warning{{mutex 'sls_mu' is not held on every path through here}} \
+expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 //-//
@@ -2086,13 +2087,13 @@
   mutex m;
   void test() {
 m.lock();
-while (foo()) {
+while (foo()) { // expected-warning {{expecting mutex 'm' to be held at start of each loop}}
   m.unlock();
   // ...
   if (bar()) {
 // ...
 if (foo())
-  continue; // expected-warning {{expecting mutex 'm' to be held at start of each loop}}
+  continue;
 //...
   }
   // ...
@@ -2822,11 +2823,11 @@
 void loopReleaseContinue() {
   RelockableMutexLock scope(&mu, ExclusiveTraits{}); // expected-note {{mutex acquired here}}
   // We have to warn on this join point despite the lock being managed ...
-  for (unsigned i = 1; i < 10; ++i) {
+  for (unsigned i = 1; i < 10; ++i) { // expected-warning {{expecting mutex 'mu' to be held at start of each loop}}
 x = 1; // ... because we might miss that this doesn't always happen under lock.
 if (i == 5) {
   scope.Unlock();
-  continue; // expected-warning {{expecting mutex 'mu' to be held at start of each loop}}
+  continue;
 }
   }
 }
Index: clang/test/PCH/thread-safety-attrs.cpp
===
--- clang/test/PCH/thread-safety-attrs.cpp
+++ clang/test/PCH/thread-safety-attrs.cpp
@@ -254,12 +254,12 @@
 
 void sls_fun_bad_7() {
   sls_mu.Lock();
-  while (getBool()) {
+  while (getBool()) { // \
+expected-warning{{expecting mutex 'sls_mu' to be held at start of each loop}}
 sls_mu.Unlock();
 if (getBool()) {
   if (getBool()) {
-continue; // \
-expected-warning{{expecting mutex 'sls_mu' to be held at start of each loop}}
+continue;
   }
 }
 sls_mu.Lock(); // expected-note {{mutex acquired here}}
@@ -306,13 +306,14 @@
 sls_mu.Unlock();
 if (getBool()) {
   if (getBool()) {
-break; // expected-warning{{mutex 'sls_mu' is not held on every path through here}}
+break;
   }
 }
 sls_mu.Lock();
   }
   sls_mu.Unlock(); // \
-// expected-warning{{releasing mutex 'sls_mu' that was not held}}
+expected-warning{{mutex 'sls_mu' is not held on every path through here}} \
+expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 #endif
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -849,6 +849,11 @@
   // location.
   CurrBlockInfo->EntryLoc = CurrBlockInfo->ExitLoc =
   BlockInfo[(*CurrBlock->pred_begin())->getBlockID()].ExitLoc;
+} else if (CurrBlock->succ_size() == 1 && *CurrBlock->succ_begin()) {
+  // The block is empty, and has a single successor. Use its entry
+  // location.
+  CurrBlockInfo->EntryLoc = CurrBlockInfo->ExitLoc =
+  BlockInfo[(*CurrBlock->succ_begin())->getBlockID()].EntryLoc;
 }
   }
 }
@@ -2415,7 +2420,6 @@
 // union because the real error is probably that we forgot to unlock M on
 // all code paths.
 bool LocksetInitialized = false;
-SmallVector SpecialBlocks;
 for (CFGBlock::const_pred_iterator PI = CurrBlock->pred_begin(),
  PE  = CurrBlock->pred_end()

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-20 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.

In D103938#3007708 , @ychen wrote:

> In D103938#3006540 , @aaron.ballman 
> wrote:
>
>> There were a few behavioral changes to tests that I had questions about. 
>> Also, can you add an additional test case that shows the behavior when the 
>> left operand of the comma expression is volatile (or do we already have that 
>> covered and I missed it)? e.g.,
>>
>>   int func() {
>> volatile int *ip = (volatile int *)0xFEEDFACE;
>> return (*ip, 1);
>>   }
>>
>> (In this case, we shouldn't diagnose that the left operand has no effect 
>> because reading a volatile variable is an operation with a side effect.)
>
> It seems this is covered by svn157362.

Thanks, LGTM!




Comment at: clang/test/CodeCompletion/pragma-macro-token-caching.c:15
 Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a 
parenthesized string literal}}
-param; // expected-warning {{expression result unused}}
 }

ychen wrote:
> aaron.ballman wrote:
> > Why did we lose this diagnostic?
> CFG analysis thinks it is unreachable, so it is not diagnosed.
Oh, I see now -- the CFG thinks this is unreachable because of the previous 
error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[clang] f988f68 - [Analysis] Add support for vscale in computeKnownBitsFromOperator

2021-09-20 Thread David Sherwood via cfe-commits

Author: David Sherwood
Date: 2021-09-20T15:01:59+01:00
New Revision: f988f680649ad38806897e7aa75e95e9fda88ffd

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

LOG: [Analysis] Add support for vscale in computeKnownBitsFromOperator

In ValueTracking.cpp we use a function called
computeKnownBitsFromOperator to determine the known bits of a value.
For the vscale intrinsic if the function contains the vscale_range
attribute we can use the maximum and minimum values of vscale to
determine some known zero and one bits. This should help to improve
code quality by allowing certain optimisations to take place.

Tests added here:

  Transforms/InstCombine/icmp-vscale.ll

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

Added: 
llvm/test/Transforms/InstCombine/icmp-vscale.ll

Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len.c
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstSimplify/vscale.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
index a5991a5a0151..e73751a2fe86 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
@@ -8,13 +8,13 @@
 // CHECK-LABEL: @test_svcntb(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 4
+// CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 4
 // CHECK-NEXT:ret i64 [[TMP1]]
 //
 // CPP-CHECK-LABEL: @_Z11test_svcntbv(
 // CPP-CHECK-NEXT:  entry:
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 4
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 4
 // CPP-CHECK-NEXT:ret i64 [[TMP1]]
 //
 uint64_t test_svcntb()
@@ -247,13 +247,13 @@ uint64_t test_svcntb_pat_15()
 // CHECK-LABEL: @test_svcntb_pat_16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 4
+// CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 4
 // CHECK-NEXT:ret i64 [[TMP1]]
 //
 // CPP-CHECK-LABEL: @_Z18test_svcntb_pat_16v(
 // CPP-CHECK-NEXT:  entry:
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 4
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 4
 // CPP-CHECK-NEXT:ret i64 [[TMP1]]
 //
 uint64_t test_svcntb_pat_16()

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
index eb3e848a7b53..1e8dc401fa1e 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
@@ -8,13 +8,13 @@
 // CHECK-LABEL: @test_svcntd(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 1
+// CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 1
 // CHECK-NEXT:ret i64 [[TMP1]]
 //
 // CPP-CHECK-LABEL: @_Z11test_svcntdv(
 // CPP-CHECK-NEXT:  entry:
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 1
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 1
 // CPP-CHECK-NEXT:ret i64 [[TMP1]]
 //
 uint64_t test_svcntd()
@@ -261,13 +261,13 @@ uint64_t test_svcntd_pat_15()
 // CHECK-LABEL: @test_svcntd_pat_16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 1
+// CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 1
 // CHECK-NEXT:ret i64 [[TMP1]]
 //
 // CPP-CHECK-LABEL: @_Z18test_svcntd_pat_16v(
 // CPP-CHECK-NEXT:  entry:
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = call i64 @llvm.vscale.i64()
-// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl i64 [[TMP0]], 1
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = shl nuw nsw i64 [[TMP0]], 1
 // CPP-CHECK-NEXT:ret i64 [[TMP1]]
 //
 uint64_t test_svcntd_pat_16()

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
index 50ca8f525387..27a2fdca1abc 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
+++ b/clang/

[PATCH] D109883: [Analysis] Add support for vscale in computeKnownBitsFromOperator

2021-09-20 Thread David Sherwood 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 rGf988f680649a: [Analysis] Add support for vscale in 
computeKnownBitsFromOperator (authored by david-arm).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109883

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len.c
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstCombine/icmp-vscale.ll
  llvm/test/Transforms/InstSimplify/vscale.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll

Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
@@ -17,8 +17,8 @@
 ; CHECK:   vector.body:
 ; CHECK-NEXT:[[POINTER_PHI:%.*]] = phi i32* [ %c, %vector.ph ], [ %[[PTR_IND:.*]], %vector.body ]
 ; CHECK: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
-; CHECK-NEXT:[[TMP6:%.*]] = shl i64 [[TMP5]], 2
-; CHECK-NEXT:[[TMP7:%.*]] = shl i64 [[TMP5]], 4
+; CHECK-NEXT:[[TMP6:%.*]] = shl nuw nsw i64 [[TMP5]], 2
+; CHECK-NEXT:[[TMP7:%.*]] = shl nuw nsw i64 [[TMP5]], 4
 ; CHECK-NEXT:[[TMP8:%.*]] = call  @llvm.experimental.stepvector.nxv4i64()
 ; CHECK-NEXT:[[VECTOR_GEP:%.*]] = shl  [[TMP8]], shufflevector ( insertelement ( poison, i64 1, i32 0),  poison,  zeroinitializer)
 ; CHECK-NEXT:[[TMP9:%.*]] = getelementptr i32, i32* [[POINTER_PHI]],  [[VECTOR_GEP]]
@@ -80,16 +80,16 @@
 ; CHECK-NEXT:%[[LPTR1:.*]] = bitcast i32* %[[LGEP1]] to *
 ; CHECK-NEXT:%{{.*}} = load , * %[[LPTR1]], align 4
 ; CHECK-NEXT:%[[VSCALE1:.*]] = call i32 @llvm.vscale.i32()
-; CHECK-NEXT:%[[TMP1:.*]] = shl i32 %[[VSCALE1]], 2
-; CHECK-NEXT:%[[TMP2:.*]] = sext i32 %[[TMP1]] to i64
+; CHECK-NEXT:%[[TMP1:.*]] = shl nuw nsw i32 %[[VSCALE1]], 2
+; CHECK-NEXT:%[[TMP2:.*]] = zext i32 %[[TMP1]] to i64
 ; CHECK-NEXT:%[[LGEP2:.*]] = getelementptr i32, i32* %[[LGEP1]], i64 %[[TMP2]]
 ; CHECK-NEXT:%[[LPTR2:.*]] = bitcast i32* %[[LGEP2]] to *
 ; CHECK-NEXT:%{{.*}} = load , * %[[LPTR2]], align 4
 ; CHECK: %[[SPTR1:.*]] = bitcast i32* %[[SGEP1]] to *
 ; CHECK-NEXT:store  %{{.*}}, * %[[SPTR1]], align 4
 ; CHECK-NEXT:%[[VSCALE2:.*]] = call i32 @llvm.vscale.i32()
-; CHECK-NEXT:%[[TMP3:.*]] = shl i32 %[[VSCALE2]], 2
-; CHECK-NEXT:%[[TMP4:.*]] = sext i32 %[[TMP3]] to i64
+; CHECK-NEXT:%[[TMP3:.*]] = shl nuw nsw i32 %[[VSCALE2]], 2
+; CHECK-NEXT:%[[TMP4:.*]] = zext i32 %[[TMP3]] to i64
 ; CHECK-NEXT:%[[SGEP2:.*]] = getelementptr i32, i32* %[[SGEP1]], i64 %[[TMP4]]
 ; CHECK-NEXT:%[[SPTR2:.*]] = bitcast i32* %[[SGEP2]] to *
 ; CHECK-NEXT:store  %{{.*}}, * %[[SPTR2]], align 4
@@ -133,7 +133,7 @@
 ; CHECK-NEXT:  %[[APTRS1:.*]] = getelementptr i32, i32* %a,  %[[VECIND1]]
 ; CHECK-NEXT:  %[[GEPA1:.*]] = getelementptr i32, i32* %a, i64 %[[IDX]]
 ; CHECK-NEXT:  %[[VSCALE64:.*]] = call i64 @llvm.vscale.i64()
-; CHECK-NEXT:  %[[VSCALE64X2:.*]] = shl i64 %[[VSCALE64]], 1
+; CHECK-NEXT:  %[[VSCALE64X2:.*]] = shl nuw nsw i64 %[[VSCALE64]], 1
 ; CHECK-NEXT:  %[[TMP3:.*]] = insertelement  poison, i64 %[[VSCALE64X2]], i32 0
 ; CHECK-NEXT:  %[[TMP4:.*]] = shufflevector  %[[TMP3]],  poison,  zeroinitializer
 ; CHECK-NEXT:  %[[TMP5:.*]] = add  %[[TMP4]], %[[STEPVEC]]
@@ -147,8 +147,8 @@
 ; CHECK:   %[[BPTR1:.*]] = bitcast i32** %[[GEPB1]] to *
 ; CHECK-NEXT:  store  %[[APTRS1]], * %[[BPTR1]], align 8
 ; CHECK:   %[[VSCALE32:.*]] = call i32 @llvm.vscale.i32()
-; CHECK-NEXT:  %[[VSCALE32X2:.*]] = shl i32 %[[VSCALE32]], 1
-; CHECK-NEXT:  %[[TMP6:.*]] = sext i32 %[[VSCALE32X2]] to i64
+; CHECK-NEXT:  %[[VSCALE32X2:.*]] = shl nuw nsw i32 %[[VSCALE32]], 1
+; CHECK-NEXT:  %[[TMP6:.*]] = zext i32 %[[VSCALE32X2]] to i64
 ; CHECK-NEXT:  %[[GEPB2:.*]] = getelementptr i32*, i32** %[[GEPB1]], i64 %[[TMP6]]
 ; CHECK-NEXT:  %[[BPTR2:.*]] = bitcast i32** %[[GEPB2]] to *
 ; CHECK-NEXT   store  %[[APTRS2]], * %[[BPTR2]], align 8
Index: llvm/test/Transforms/InstSimplify/vscale.ll
===
--- llvm/test/Transforms/InstSimplify/vscale.ll
+++ llvm/test/Transforms/InstSimplify/vscale.ll
@@ -128,6 +128,18 @@
   ret i32 %r
 }
 
+; Known values of vscale intrinsic
+
+define i64 @vscale64_range4_4() vscale_range(4,4) {
+; CHECK-LABEL: @vscale64_range4_4(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:ret i64

[PATCH] D110037: [X86] Always check the size of SourceTy before getting the next type

2021-09-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 373581.
pengfei marked 2 inline comments as done.
pengfei added a comment.

Address review comments.

Thanks Roman and Michael.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110037

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/va-arg-sse.c


Index: clang/test/CodeGen/X86/va-arg-sse.c
===
--- clang/test/CodeGen/X86/va-arg-sse.c
+++ clang/test/CodeGen/X86/va-arg-sse.c
@@ -34,16 +34,16 @@
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load i8*, i8** [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 
[[FP_OFFSET]]
 // CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 
16
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
<2 x float> }*
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
float }*
 // CHECK-NEXT:[[TMP4:%.*]] = bitcast i8* [[TMP1]] to <2 x float>*
 // CHECK-NEXT:[[TMP5:%.*]] = load <2 x float>, <2 x float>* [[TMP4]], 
align 16
-// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, float 
}, { <2 x float>, float }* [[TMP3]], i32 0, i32 0
 // CHECK-NEXT:store <2 x float> [[TMP5]], <2 x float>* [[TMP6]], align 4
-// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to <2 x float>*
-// CHECK-NEXT:[[TMP8:%.*]] = load <2 x float>, <2 x float>* [[TMP7]], 
align 16
-// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 1
-// CHECK-NEXT:store <2 x float> [[TMP8]], <2 x float>* [[TMP9]], align 4
-// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, <2 x float> }* 
[[TMP3]] to %struct.S*
+// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to float*
+// CHECK-NEXT:[[TMP8:%.*]] = load float, float* [[TMP7]], align 16
+// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, float 
}, { <2 x float>, float }* [[TMP3]], i32 0, i32 1
+// CHECK-NEXT:store float [[TMP8]], float* [[TMP9]], align 4
+// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, float }* [[TMP3]] to 
%struct.S*
 // CHECK-NEXT:[[TMP11:%.*]] = add i32 [[FP_OFFSET]], 32
 // CHECK-NEXT:store i32 [[TMP11]], i32* [[FP_OFFSET_P]], align 4
 // CHECK-NEXT:br label [[VAARG_END:%.*]]
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3438,17 +3438,21 @@
 GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
QualType SourceTy, unsigned SourceOffset) const {
   const llvm::DataLayout &TD = getDataLayout();
+  unsigned SourceSize =
+  (unsigned)getContext().getTypeSize(SourceTy) / 8 - SourceOffset;
   llvm::Type *T0 = getFPTypeAtOffset(IRType, IROffset, TD);
   if (!T0 || T0->isDoubleTy())
 return llvm::Type::getDoubleTy(getVMContext());
 
   // Get the adjacent FP type.
-  llvm::Type *T1 =
-  getFPTypeAtOffset(IRType, IROffset + TD.getTypeAllocSize(T0), TD);
+  llvm::Type *T1 = nullptr;
+  unsigned T0Size = TD.getTypeAllocSize(T0);
+  if (SourceSize > T0Size)
+  T1 = getFPTypeAtOffset(IRType, IROffset + T0Size, TD);
   if (T1 == nullptr) {
 // Check if IRType is a half + float. float type will be in IROffset+4 due
 // to its alignment.
-if (T0->isHalfTy())
+if (T0->isHalfTy() && SourceSize > 4)
   T1 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
 // If we can't get a second FP type, return a simple half or float.
 // avx512fp16-abi.c:pr51813_2 shows it works to return float for
@@ -3461,7 +3465,9 @@
 return llvm::FixedVectorType::get(T0, 2);
 
   if (T0->isHalfTy() && T1->isHalfTy()) {
-llvm::Type *T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
+llvm::Type *T2 = nullptr;
+if (SourceSize > 4)
+  T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
 if (T2 == nullptr)
   return llvm::FixedVectorType::get(T0, 2);
 return llvm::FixedVectorType::get(T0, 4);


Index: clang/test/CodeGen/X86/va-arg-sse.c
===
--- clang/test/CodeGen/X86/va-arg-sse.c
+++ clang/test/CodeGen/X86/va-arg-sse.c
@@ -34,16 +34,16 @@
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load i8*, i8** [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 [[FP_OFFSET]]
 // CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 16
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, <2 x float> }*
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, float }*
 // C

[PATCH] D110037: [X86] Always check the size of SourceTy before getting the next type

2021-09-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/CodeGen/X86/va-arg-sse.c:2
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 %s -O2 -emit-llvm -o - -triple x86_64-unknown-unknown | 
FileCheck %s
 

Meinersbur wrote:
> lebedev.ri wrote:
> > Please don't use `-O*` in clang irgen tests.
> > This should *only* test what IR is produced by clang itself.
> I agree here, testing `-O*` output will break easily with any unrelated 
> change in LLVM.
You are right. The test case looks more clear now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110037

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


[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

In D109607#3008486 , @Meinersbur 
wrote:

> However, my other one that is connected to lab.llvm.org has failed as well 
> and should have sent an email: 
> https://lab.llvm.org/buildbot/#/builders/102/builds/2722. Unfortunately it is 
> slow and packing to many commits together, which I am trying to improve: 
> D110048 

I didn't receive it either. I once suspected my mailbox but haven't had any 
fortune for now. :(

> Independent of that, it seems no other builder running the test-suite on 
> x86_64 (there are armv7, s390x and ppc64le ones)

Thanks for your information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


[PATCH] D110051: [clangd] Deduplicate inlay hints

2021-09-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

I am not aware of how the intersecting hints are handled in the implementation 
on the client side nor in the proposal today. After this patch we might still 
produce them if for whatever reason there are different kinds of hints for the 
same range. Is this OK?




Comment at: clang-tools-extra/clangd/InlayHints.cpp:353
+  // template instantiations.
+  std::sort(Results.begin(), Results.end());
+  Results.erase(std::unique(Results.begin(), Results.end()), Results.end());

nit: You can just do `llvm::sort(Results)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110051

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


[PATCH] D106713: Thread safety analysis: Warn when demoting locks on back edges

2021-09-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a subscriber: tstellar.
aaronpuchert added a comment.

In D106713#3009130 , @aaron.ballman 
wrote:

> In D106713#3007878 , @aaronpuchert 
> wrote:
>
>> @aaron.ballman, since this is reintroducing some warnings after the 
>> relaxation in D102026 , should we bring 
>> this to Clang 13?
>
> I think that's reasonable; the alternative is that we warn in Clang 12, don't 
> warn in Clang 13, then start warning again in Clang 14 which does not seem 
> very user friendly.

@tstellar, could we still bring this into release/13.x? Doesn't fix a crash, 
but it prevents inconsistencies between our releases and I also tested it on a 
pretty large code base. So I'm pretty confident it doesn't regress anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106713

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


[clang] 5dee501 - [analyzer] Move docs of SmartPtr to correct subcategory

2021-09-20 Thread Deep Majumder via cfe-commits

Author: Deep Majumder
Date: 2021-09-20T20:13:04+05:30
New Revision: 5dee50111c13bbc4480401e2eaa67f6bca1b480a

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

LOG: [analyzer] Move docs of SmartPtr to correct subcategory

The docs of alpha.cplusplus.SmartPtr was incorrectly placed under
alpha.deadcode. Moved it to under alpha.cplusplus

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 858c8e1303e8..89190b54e5a5 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1838,6 +1838,20 @@ Method calls on a moved-from object and copying a 
moved-from object will be repo
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+.. _alpha-cplusplus-SmartPtr:
+
+alpha.cplusplus.SmartPtr (C++)
+""
+Check for dereference of null smart pointers.
+
+.. code-block:: cpp
+
+ void deref_smart_ptr() {
+   std::unique_ptr P;
+   *P; // warn: dereference of a default constructed smart unique_ptr
+ }
+
+
 alpha.deadcode
 ^^
 .. _alpha-deadcode-UnreachableCode:
@@ -1872,19 +1886,6 @@ Check unreachable code.
[x retain]; // warn
  }
 
-.. _alpha-cplusplus-SmartPtr:
-
-alpha.cplusplus.SmartPtr (C++)
-""
-Check for dereference of null smart pointers.
-
-.. code-block:: cpp
-
- void deref_smart_ptr() {
-   std::unique_ptr P;
-   *P; // warn: dereference of a default constructed smart unique_ptr
- }
-
 alpha.fuchsia
 ^
 



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


[PATCH] D110032: [analyzer] Move docs of SmartPtr to correct subcategory

2021-09-20 Thread Deep Majumder 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 rG5dee50111c13: [analyzer] Move docs of SmartPtr to correct 
subcategory (authored by RedDocMD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110032

Files:
  clang/docs/analyzer/checkers.rst


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -1838,6 +1838,20 @@
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+.. _alpha-cplusplus-SmartPtr:
+
+alpha.cplusplus.SmartPtr (C++)
+""
+Check for dereference of null smart pointers.
+
+.. code-block:: cpp
+
+ void deref_smart_ptr() {
+   std::unique_ptr P;
+   *P; // warn: dereference of a default constructed smart unique_ptr
+ }
+
+
 alpha.deadcode
 ^^
 .. _alpha-deadcode-UnreachableCode:
@@ -1872,19 +1886,6 @@
[x retain]; // warn
  }
 
-.. _alpha-cplusplus-SmartPtr:
-
-alpha.cplusplus.SmartPtr (C++)
-""
-Check for dereference of null smart pointers.
-
-.. code-block:: cpp
-
- void deref_smart_ptr() {
-   std::unique_ptr P;
-   *P; // warn: dereference of a default constructed smart unique_ptr
- }
-
 alpha.fuchsia
 ^
 


Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -1838,6 +1838,20 @@
a.foo();// warn: method call on a 'moved-from' object 'a'
  }
 
+.. _alpha-cplusplus-SmartPtr:
+
+alpha.cplusplus.SmartPtr (C++)
+""
+Check for dereference of null smart pointers.
+
+.. code-block:: cpp
+
+ void deref_smart_ptr() {
+   std::unique_ptr P;
+   *P; // warn: dereference of a default constructed smart unique_ptr
+ }
+
+
 alpha.deadcode
 ^^
 .. _alpha-deadcode-UnreachableCode:
@@ -1872,19 +1886,6 @@
[x retain]; // warn
  }
 
-.. _alpha-cplusplus-SmartPtr:
-
-alpha.cplusplus.SmartPtr (C++)
-""
-Check for dereference of null smart pointers.
-
-.. code-block:: cpp
-
- void deref_smart_ptr() {
-   std::unique_ptr P;
-   *P; // warn: dereference of a default constructed smart unique_ptr
- }
-
 alpha.fuchsia
 ^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-20 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D109607#3009377 , @pengfei wrote:

> In D109607#3008486 , @Meinersbur 
> wrote:
>
>> However, my other one that is connected to lab.llvm.org has failed as well 
>> and should have sent an email: 
>> https://lab.llvm.org/buildbot/#/builders/102/builds/2722. Unfortunately it 
>> is slow and packing to many commits together, which I am trying to improve: 
>> D110048 
>
> I didn't receive it either. I once suspected my mailbox but haven't had any 
> fortune for now. :(

Might have because that somehow the master thinks the job before the one that 
is breaking is still building, ie. cannot identify whether the failure is new.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


[PATCH] D110037: [X86] Always check the size of SourceTy before getting the next type

2021-09-20 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110037

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-20 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added inline comments.



Comment at: clang/test/CodeGen/target-data.c:256
 
+// RUN: %clang_cc1 -triple s390x-none-zos -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS

MaskRay wrote:
> If you add so many RUN lines at once, please use unittests instead. This 
> would cost some test execution time
We're essentially matching what was available for the systemz elf target (above 
lines) for the z/OS target. Is there a real concern for the execution time here 
for moving it to a separate unit test. If we did, it would seem to "stand out" 
for just the z/OS target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D91948: [WIP][analyzer][doc] Add Container- and IteratorModeling developer docs

2021-09-20 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.
Herald added a subscriber: manas.

Nice work!




Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:125
+The begin and end symbols are conjured and are completely unrelated to the 
region of
+the container. For each region we store the only the begin and end symbols, 
other properties
+are to be computed from these, and their relationships stored in the 
ContstraintManager.





Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:148
+lvalue see `value categories 
`_)
+modeling is not prominent is case containers alone, as no temporary objects 
are considered.
+However, this is an issue to be solved when it comes to modeling iterators.

whisperity wrote:
> I think something is missing for here, I am incapable of decyphering this 
> sentence.
+1



Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:160
+could not reorder expressions containing the the symbol. As an orthogonal 
issue symbol-symbol
+comparisons still cannot be handled properly if the ``ContstraintManager`` 
would also be able
+answer questions like: is symbol A less than symbol B (instead of just 
reporting the possible

Or `...comparisons still cannot be handled properly. If the 
``ContstraintManager`` was also able ... then ...



Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:210
+ - only track an iterator if its generating expression is a function call 
which has at least 1 argument, that is an already tracked iterator (and the 
first iterator parameter's container will be the parent container of the 
returned iterator)
+If either of these heuristics matches the tracking of iterator should be 
skipped.
+

whisperity wrote:
> Should be?
> Is.




Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:222
+
+The iterator offset is abstract, no ``MemRegionVal`` is associated with 
iterator offsets.
+

`:`



Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:227
+
+Functions like find (when alpha.cplusplus.STLAlgorithmModeling is enabled) 
handle cases where an
+element is found, and a case where it is not

whisperity wrote:
> 




Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:264
+int* it = c.begin(); // container-modeling begins by tracking c as a 
container of type Cont
+ // begin() member function call triggers the modeling
+ // iterator-modeling also begins by tracking the 
value of c.begin()





Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:266
+ // iterator-modeling also begins by tracking the 
value of c.begin()
+ // as an iterator
+ // we check if the value has the necessary 
iterator-properties





Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:276
+// position, noting it in the modeling structure 
for c as end position
+// comparion operator== triggers a state-split, 
branch a assuming that
+// it position is equal to the newly created end 
position, branch b

branch 'A'



Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:290
+
+Contrary to the container-modeling, not only lvalue iterators are tracked. 
This is the reason
+why 2 different keys are used in the GDM for iterators. An lvalue iterator has 
a Region

Szelethus wrote:
> whisperity wrote:
> > whisperity wrote:
> > > 
> > Previously, `lvalue` was written as `LValue`!
> Ah, there it is. Move it to where I placed my other inline! :) 
Why don't we track Rvalue containers? It's not clear from this document.



Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:310-313
+Iterators implemented as pointer live generally in the SymbolMap (the map 
containing ``SymbolRef``-s as
+opposed to the map containing the ``const MemRegion*``-s), and can not be only 
represented with LValues (and
+consequently inside the RegionMap), as tracking the value of symbolic offset 
of an iterator must handle
+expressions where there may only be temporaries with no LValues associated 
with them.

Break up this sentence please.



Comment at: clang/docs/analyzer/developer-docs/ContainerModeling.rst:317
+because pointer iterators have only Rvalues that always identifies them 
(across multiple subexpressions),
+class instance variables only have Lvalues for this role. SymbolMap always has 
iterator values that are RValues.
+RegionMap can have it

[clang-tools-extra] 444a5f3 - [clangd] Bail-out when an empty compile flag is encountered

2021-09-20 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-09-20T16:51:56+02:00
New Revision: 444a5f304f6c2c332f18392d2458d74664e98498

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

LOG: [clangd] Bail-out when an empty compile flag is encountered

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

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

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
clang-tools-extra/clangd/unittests/CompilerTests.cpp
clang/lib/Frontend/CreateInvocationFromCommandLine.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f9e283beca64..d707bf69eded 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -198,22 +198,26 @@ CommandMangler CommandMangler::forTests() { return 
CommandMangler(); }
 void CommandMangler::adjust(std::vector &Cmd,
 llvm::StringRef File) const {
   trace::Span S("AdjustCompileFlags");
+  // Most of the modifications below assumes the Cmd starts with a driver name.
+  // We might consider injecting a generic driver name like "cc" or "c++", but
+  // a Cmd missing the driver is probably rare enough in practice and errnous.
+  if (Cmd.empty())
+return;
   auto &OptTable = clang::driver::getDriverOptTable();
   // OriginalArgs needs to outlive ArgList.
   llvm::SmallVector OriginalArgs;
   OriginalArgs.reserve(Cmd.size());
   for (const auto &S : Cmd)
 OriginalArgs.push_back(S.c_str());
-  bool IsCLMode =
-  !OriginalArgs.empty() &&
-  driver::IsClangCL(driver::getDriverMode(
-  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
+  bool IsCLMode = driver::IsClangCL(driver::getDriverMode(
+  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
   // ParseArgs propagates missig arg/opt counts on error, but preserves
   // everything it could parse in ArgList. So we just ignore those counts.
   unsigned IgnoredCount;
   // Drop the executable name, as ParseArgs doesn't expect it. This means
   // indices are actually of by one between ArgList and OriginalArgs.
-  auto ArgList = OptTable.ParseArgs(
+  llvm::opt::InputArgList ArgList;
+  ArgList = OptTable.ParseArgs(
   llvm::makeArrayRef(OriginalArgs).drop_front(), IgnoredCount, 
IgnoredCount,
   /*FlagsToInclude=*/
   IsCLMode ? (driver::options::CLOption | driver::options::CoreOption)

diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index 44a1b1a77db5..809119cda6b1 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -83,6 +83,8 @@ void disableUnsupportedOptions(CompilerInvocation &CI) {
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer 
&D,
 std::vector *CC1Args) {
+  if (Inputs.CompileCommand.CommandLine.empty())
+return nullptr;
   std::vector ArgStrs;
   for (const auto &S : Inputs.CompileCommand.CommandLine)
 ArgStrs.push_back(S.c_str());

diff  --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index c8749ec7f487..4cb6ef9a1661 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -396,6 +396,13 @@ TEST(CommandMangler, StripsMultipleArch) {
   llvm::count_if(Args, [](llvm::StringRef Arg) { return Arg == "-arch"; }),
   1);
 }
+
+TEST(CommandMangler, EmptyArgs) {
+  const auto Mangler = CommandMangler::forTests();
+  std::vector Args = {};
+  // Make sure we don't crash.
+  Mangler.adjust(Args, "foo.cc");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/unittests/CompilerTests.cpp 
b/clang-tools-extra/clangd/unittests/CompilerTests.cpp
index 9a85bfeb2bb8..ab9e85e983d1 100644
--- a/clang-tools-extra/clangd/unittests/CompilerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompilerTests.cpp
@@ -102,6 +102,17 @@ TEST(BuildCompilerInvocation, DropsPlugins) {
   EXPECT_EQ(Opts.ProgramAction, frontend::ActionKind::ParseSyntaxOnly);
   EXPECT_TRUE(Opts.ActionName.empty());
 }
+
+TEST(BuildCompilerInvocation, EmptyArgs) {
+  MockFS FS;
+  IgnoreDiagnostics Diags;
+  TestTU TU;
+  auto Inputs = TU.inputs(FS);
+  Inputs.CompileCommand.CommandLine.clear();
+
+  // No crash.
+  EXPECT_EQ(buildCompilerInvocation(Inputs, Diags), nullptr);
+}
 } // namespace
 } // namespace clangd
 } // namespace clang

diff  --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.c

[PATCH] D109894: [clangd] Bail-out when an empty compile flag is encountered

2021-09-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG444a5f304f6c: [clangd] Bail-out when an empty compile flag 
is encountered (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109894

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang-tools-extra/clangd/unittests/CompilerTests.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp

Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -30,6 +30,7 @@
 ArrayRef ArgList, IntrusiveRefCntPtr Diags,
 IntrusiveRefCntPtr VFS, bool ShouldRecoverOnErorrs,
 std::vector *CC1Args) {
+  assert(!ArgList.empty());
   if (!Diags.get()) {
 // No diagnostics engine was provided, so create our own diagnostics object
 // with the default options.
Index: clang-tools-extra/clangd/unittests/CompilerTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompilerTests.cpp
+++ clang-tools-extra/clangd/unittests/CompilerTests.cpp
@@ -102,6 +102,17 @@
   EXPECT_EQ(Opts.ProgramAction, frontend::ActionKind::ParseSyntaxOnly);
   EXPECT_TRUE(Opts.ActionName.empty());
 }
+
+TEST(BuildCompilerInvocation, EmptyArgs) {
+  MockFS FS;
+  IgnoreDiagnostics Diags;
+  TestTU TU;
+  auto Inputs = TU.inputs(FS);
+  Inputs.CompileCommand.CommandLine.clear();
+
+  // No crash.
+  EXPECT_EQ(buildCompilerInvocation(Inputs, Diags), nullptr);
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -396,6 +396,13 @@
   llvm::count_if(Args, [](llvm::StringRef Arg) { return Arg == "-arch"; }),
   1);
 }
+
+TEST(CommandMangler, EmptyArgs) {
+  const auto Mangler = CommandMangler::forTests();
+  std::vector Args = {};
+  // Make sure we don't crash.
+  Mangler.adjust(Args, "foo.cc");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -83,6 +83,8 @@
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
 std::vector *CC1Args) {
+  if (Inputs.CompileCommand.CommandLine.empty())
+return nullptr;
   std::vector ArgStrs;
   for (const auto &S : Inputs.CompileCommand.CommandLine)
 ArgStrs.push_back(S.c_str());
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -198,22 +198,26 @@
 void CommandMangler::adjust(std::vector &Cmd,
 llvm::StringRef File) const {
   trace::Span S("AdjustCompileFlags");
+  // Most of the modifications below assumes the Cmd starts with a driver name.
+  // We might consider injecting a generic driver name like "cc" or "c++", but
+  // a Cmd missing the driver is probably rare enough in practice and errnous.
+  if (Cmd.empty())
+return;
   auto &OptTable = clang::driver::getDriverOptTable();
   // OriginalArgs needs to outlive ArgList.
   llvm::SmallVector OriginalArgs;
   OriginalArgs.reserve(Cmd.size());
   for (const auto &S : Cmd)
 OriginalArgs.push_back(S.c_str());
-  bool IsCLMode =
-  !OriginalArgs.empty() &&
-  driver::IsClangCL(driver::getDriverMode(
-  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
+  bool IsCLMode = driver::IsClangCL(driver::getDriverMode(
+  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
   // ParseArgs propagates missig arg/opt counts on error, but preserves
   // everything it could parse in ArgList. So we just ignore those counts.
   unsigned IgnoredCount;
   // Drop the executable name, as ParseArgs doesn't expect it. This means
   // indices are actually of by one between ArgList and OriginalArgs.
-  auto ArgList = OptTable.ParseArgs(
+  llvm::opt::InputArgList ArgList;
+  ArgList = OptTable.ParseArgs(
   llvm::makeArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount,
   /*FlagsToInclude=*/
   IsCLMode ? (driver::options::CLOption | driver::options::CoreOption)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/

[clang] 228dd20 - [OpenCL] Supports atomics in C++ for OpenCL 2021

2021-09-20 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-20T16:24:30+01:00
New Revision: 228dd20c3f1e619193c68b288e0d5e8525c3a618

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

LOG: [OpenCL] Supports atomics in C++ for OpenCL 2021

Atomics in C++ for OpenCL 2021 are now handled the same way as in
OpenCL C 3.0. This is a header-only change.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 7cc356015d95..a36e657612e5 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -348,9 +348,9 @@ typedef enum memory_scope {
   memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
 #if defined(__opencl_c_atomic_scope_all_devices)
   memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
-#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
   memory_scope_all_devices = memory_scope_all_svm_devices,
-#endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 #endif // defined(__opencl_c_atomic_scope_all_devices)
 /**
  * Subgroups have 
diff erent requirements on forward progress, so just test

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index e96022859480..705a3231b577 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -13256,7 +13256,7 @@ void __ovld atomic_init(volatile atomic_double *object, 
double value);
 #endif //cl_khr_fp64
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 void __ovld atomic_init(volatile __global atomic_int *object, int value);
 void __ovld atomic_init(volatile __local atomic_int *object, int value);
 void __ovld atomic_init(volatile __global atomic_uint *object, uint value);
@@ -13273,7 +13273,7 @@ void __ovld atomic_init(volatile __global atomic_double 
*object, double value);
 void __ovld atomic_init(volatile __local atomic_double *object, double value);
 #endif //cl_khr_fp64
 #endif
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 
 // atomic_work_item_fence()
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order 
order, memory_scope scope);
@@ -13317,7 +13317,7 @@ uintptr_t __ovld atomic_fetch_add(volatile 
atomic_uintptr_t *object, ptr
diff _t o
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptr
diff _t operand);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 int __ovld atomic_fetch_add(volatile __global atomic_int *object, int operand);
 int __ovld atomic_fetch_add(volatile __local atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile __global atomic_uint *object, uint 
operand);
@@ -13398,7 +13398,7 @@ ulong __ovld atomic_fetch_max(volatile __local 
atomic_ulong *object, ulong opera
 uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *object, 
ptr
diff _t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *object, 
ptr
diff _t operand);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 #endif
 
 #if defined(__opencl_c_atomic_scope_device)
@@ -13436,7 +13436,7 @@ uintptr_t __ovld atomic_fetch_add_explicit(volatile 
atomic_uintptr_t *object, pt
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptr
diff _t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int 
operand, memory_order order);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int 
operand, memory_order order);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, 
uint operand, memory_order order);
@@ -13517,7 +13517,7 @@ ulong __ovld atomic_

[PATCH] D109424: [OpenCL] Supports atomics in C++ for OpenCL 2021

2021-09-20 Thread Justas Janickas 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 rG228dd20c3f1e: [OpenCL] Supports atomics in C++ for OpenCL 
2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109424?vs=371277&id=373599#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109424

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13256,7 +13256,7 @@
 #endif //cl_khr_fp64
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 void __ovld atomic_init(volatile __global atomic_int *object, int value);
 void __ovld atomic_init(volatile __local atomic_int *object, int value);
 void __ovld atomic_init(volatile __global atomic_uint *object, uint value);
@@ -13273,7 +13273,7 @@
 void __ovld atomic_init(volatile __local atomic_double *object, double value);
 #endif //cl_khr_fp64
 #endif
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 
 // atomic_work_item_fence()
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope);
@@ -13317,7 +13317,7 @@
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add(volatile __global atomic_int *object, int operand);
 int __ovld atomic_fetch_add(volatile __local atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile __global atomic_uint *object, uint operand);
@@ -13398,7 +13398,7 @@
 uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *object, ptrdiff_t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif
 
 #if defined(__opencl_c_atomic_scope_device)
@@ -13436,7 +13436,7 @@
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int operand, memory_order order);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int operand, memory_order order);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, uint operand, memory_order order);
@@ -13517,7 +13517,7 @@
 uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif
 
 #if defined(__opencl_c_generic_address_space)
@@ -13554,7 +13554,7 @@
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, uint operand, memory_order order, memory_scope scope);
@@ -13635,7 +13635,7 @@
 uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrd

[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

In D109607#3009412 , @Meinersbur 
wrote:

> In D109607#3009377 , @pengfei wrote:
>
>> In D109607#3008486 , @Meinersbur 
>> wrote:
>>
>>> However, my other one that is connected to lab.llvm.org has failed as well 
>>> and should have sent an email: 
>>> https://lab.llvm.org/buildbot/#/builders/102/builds/2722. Unfortunately it 
>>> is slow and packing to many commits together, which I am trying to improve: 
>>> D110048 
>>
>> I didn't receive it either. I once suspected my mailbox but haven't had any 
>> fortune for now. :(
>
> Might have because that somehow the master thinks the job before the one that 
> is breaking is still building, ie. cannot identify whether the failure is new.

Got it, thanks Michael.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


[clang] 5b47256 - [X86] Add test to show the effect caused by D109607. NFC

2021-09-20 Thread via cfe-commits

Author: Wang, Pengfei
Date: 2021-09-20T23:34:18+08:00
New Revision: 5b47256fa5402a5f7f06513b0d168746d4c46df2

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

LOG: [X86] Add test to show the effect caused by D109607. NFC

Added: 
clang/test/CodeGen/X86/va-arg-sse.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/X86/va-arg-sse.c 
b/clang/test/CodeGen/X86/va-arg-sse.c
new file mode 100644
index ..3f146fc08337
--- /dev/null
+++ b/clang/test/CodeGen/X86/va-arg-sse.c
@@ -0,0 +1,101 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-unknown-unknown | 
FileCheck %s
+
+#include 
+
+struct S { float a[3]; };
+struct S a[5];
+
+// CHECK-LABEL: @check(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[Z_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[ARG:%.*]] = alloca [[STRUCT_S:%.*]], align 4
+// CHECK-NEXT:[[P:%.*]] = alloca %struct.S*, align 8
+// CHECK-NEXT:[[AP:%.*]] = alloca [1 x %struct.__va_list_tag], align 16
+// CHECK-NEXT:[[J:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[K:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP:%.*]] = alloca [[STRUCT_S]], align 4
+// CHECK-NEXT:store i32 [[Z:%.*]], i32* [[Z_ADDR]], align 4
+// CHECK-NEXT:store i32 0, i32* [[J]], align 4
+// CHECK-NEXT:store i32 0, i32* [[K]], align 4
+// CHECK-NEXT:[[ARRAYDECAY:%.*]] = getelementptr inbounds [1 x 
%struct.__va_list_tag], [1 x %struct.__va_list_tag]* [[AP]], i64 0, i64 0
+// CHECK-NEXT:[[ARRAYDECAY1:%.*]] = bitcast %struct.__va_list_tag* 
[[ARRAYDECAY]] to i8*
+// CHECK-NEXT:call void @llvm.va_start(i8* [[ARRAYDECAY1]])
+// CHECK-NEXT:store %struct.S* getelementptr inbounds ([5 x %struct.S], [5 
x %struct.S]* @a, i64 0, i64 2), %struct.S** [[P]], align 8
+// CHECK-NEXT:[[ARRAYDECAY2:%.*]] = getelementptr inbounds [1 x 
%struct.__va_list_tag], [1 x %struct.__va_list_tag]* [[AP]], i64 0, i64 0
+// CHECK-NEXT:[[FP_OFFSET_P:%.*]] = getelementptr inbounds 
[[STRUCT___VA_LIST_TAG:%.*]], %struct.__va_list_tag* [[ARRAYDECAY2]], i32 0, 
i32 1
+// CHECK-NEXT:[[FP_OFFSET:%.*]] = load i32, i32* [[FP_OFFSET_P]], align 4
+// CHECK-NEXT:[[FITS_IN_FP:%.*]] = icmp ule i32 [[FP_OFFSET]], 144
+// CHECK-NEXT:br i1 [[FITS_IN_FP]], label [[VAARG_IN_REG:%.*]], label 
[[VAARG_IN_MEM:%.*]]
+// CHECK:   vaarg.in_reg:
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds 
[[STRUCT___VA_LIST_TAG]], %struct.__va_list_tag* [[ARRAYDECAY2]], i32 0, i32 3
+// CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load i8*, i8** [[TMP0]], align 16
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 
[[FP_OFFSET]]
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 
16
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
<2 x float> }*
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast i8* [[TMP1]] to <2 x float>*
+// CHECK-NEXT:[[TMP5:%.*]] = load <2 x float>, <2 x float>* [[TMP4]], 
align 16
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:store <2 x float> [[TMP5]], <2 x float>* [[TMP6]], align 4
+// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to <2 x float>*
+// CHECK-NEXT:[[TMP8:%.*]] = load <2 x float>, <2 x float>* [[TMP7]], 
align 16
+// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 1
+// CHECK-NEXT:store <2 x float> [[TMP8]], <2 x float>* [[TMP9]], align 4
+// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, <2 x float> }* 
[[TMP3]] to %struct.S*
+// CHECK-NEXT:[[TMP11:%.*]] = add i32 [[FP_OFFSET]], 32
+// CHECK-NEXT:store i32 [[TMP11]], i32* [[FP_OFFSET_P]], align 4
+// CHECK-NEXT:br label [[VAARG_END:%.*]]
+// CHECK:   vaarg.in_mem:
+// CHECK-NEXT:[[OVERFLOW_ARG_AREA_P:%.*]] = getelementptr inbounds 
[[STRUCT___VA_LIST_TAG]], %struct.__va_list_tag* [[ARRAYDECAY2]], i32 0, i32 2
+// CHECK-NEXT:[[OVERFLOW_ARG_AREA:%.*]] = load i8*, i8** 
[[OVERFLOW_ARG_AREA_P]], align 8
+// CHECK-NEXT:[[TMP12:%.*]] = bitcast i8* [[OVERFLOW_ARG_AREA]] to 
%struct.S*
+// CHECK-NEXT:[[OVERFLOW_ARG_AREA_NEXT:%.*]] = getelementptr i8, i8* 
[[OVERFLOW_ARG_AREA]], i32 16
+// CHECK-NEXT:store i8* [[OVERFLOW_ARG_AREA_NEXT]], i8** 
[[OVERFLOW_ARG_AREA_P]], align 8
+// CHECK-NEXT:br label [[VAARG_END]]
+// CHECK:   vaarg.end:
+// CHECK-NEXT:[[VAARG_ADDR:%.*]] = phi %struct.S* [ [[TMP10]], 
[[VAARG_IN_REG]] ], [ [[TMP12]], [[VAARG_IN_MEM]] ]
+//

[clang] 2276733 - [X86] Always check the size of SourceTy before getting the next type

2021-09-20 Thread via cfe-commits

Author: Wang, Pengfei
Date: 2021-09-20T23:34:19+08:00
New Revision: 227673398c2d93d9db02fe5fdb1af10a74251995

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

LOG: [X86] Always check the size of SourceTy before getting the next type

D109607 results in a regression in llvm-test-suite.
The reason is we didn't check the size of SourceTy, so that we will
return wrong SSE type when SourceTy is overlapped.

Reviewed By: Meinersbur

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/X86/va-arg-sse.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 58d43bd36565..bebadc44725c 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -3438,17 +3438,21 @@ llvm::Type *X86_64ABIInfo::
 GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
QualType SourceTy, unsigned SourceOffset) const {
   const llvm::DataLayout &TD = getDataLayout();
+  unsigned SourceSize =
+  (unsigned)getContext().getTypeSize(SourceTy) / 8 - SourceOffset;
   llvm::Type *T0 = getFPTypeAtOffset(IRType, IROffset, TD);
   if (!T0 || T0->isDoubleTy())
 return llvm::Type::getDoubleTy(getVMContext());
 
   // Get the adjacent FP type.
-  llvm::Type *T1 =
-  getFPTypeAtOffset(IRType, IROffset + TD.getTypeAllocSize(T0), TD);
+  llvm::Type *T1 = nullptr;
+  unsigned T0Size = TD.getTypeAllocSize(T0);
+  if (SourceSize > T0Size)
+  T1 = getFPTypeAtOffset(IRType, IROffset + T0Size, TD);
   if (T1 == nullptr) {
 // Check if IRType is a half + float. float type will be in IROffset+4 due
 // to its alignment.
-if (T0->isHalfTy())
+if (T0->isHalfTy() && SourceSize > 4)
   T1 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
 // If we can't get a second FP type, return a simple half or float.
 // avx512fp16-abi.c:pr51813_2 shows it works to return float for
@@ -3461,7 +3465,9 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
 return llvm::FixedVectorType::get(T0, 2);
 
   if (T0->isHalfTy() && T1->isHalfTy()) {
-llvm::Type *T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
+llvm::Type *T2 = nullptr;
+if (SourceSize > 4)
+  T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
 if (T2 == nullptr)
   return llvm::FixedVectorType::get(T0, 2);
 return llvm::FixedVectorType::get(T0, 4);

diff  --git a/clang/test/CodeGen/X86/va-arg-sse.c 
b/clang/test/CodeGen/X86/va-arg-sse.c
index 3f146fc08337..4380d0580e05 100644
--- a/clang/test/CodeGen/X86/va-arg-sse.c
+++ b/clang/test/CodeGen/X86/va-arg-sse.c
@@ -34,16 +34,16 @@ struct S a[5];
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load i8*, i8** [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 
[[FP_OFFSET]]
 // CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 
16
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
<2 x float> }*
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
float }*
 // CHECK-NEXT:[[TMP4:%.*]] = bitcast i8* [[TMP1]] to <2 x float>*
 // CHECK-NEXT:[[TMP5:%.*]] = load <2 x float>, <2 x float>* [[TMP4]], 
align 16
-// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, float 
}, { <2 x float>, float }* [[TMP3]], i32 0, i32 0
 // CHECK-NEXT:store <2 x float> [[TMP5]], <2 x float>* [[TMP6]], align 4
-// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to <2 x float>*
-// CHECK-NEXT:[[TMP8:%.*]] = load <2 x float>, <2 x float>* [[TMP7]], 
align 16
-// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 1
-// CHECK-NEXT:store <2 x float> [[TMP8]], <2 x float>* [[TMP9]], align 4
-// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, <2 x float> }* 
[[TMP3]] to %struct.S*
+// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to float*
+// CHECK-NEXT:[[TMP8:%.*]] = load float, float* [[TMP7]], align 16
+// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, float 
}, { <2 x float>, float }* [[TMP3]], i32 0, i32 1
+// CHECK-NEXT:store float [[TMP8]], float* [[TMP9]], align 4
+// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, float }* [[TMP3]] to 
%struct.S*
 // CHECK-NEXT:[[TMP11:%.*]] = add i32 [[FP_OFFSET]], 32
 // CHECK-NEXT:store i32 [[TMP11]], i32* [[FP_OFFSET_P]], align 4
 // CHECK-NEXT:br label [[VAARG_END:%.*]]



___
cfe-commit

[PATCH] D110037: [X86] Always check the size of SourceTy before getting the next type

2021-09-20 Thread Pengfei Wang 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 rG227673398c2d: [X86] Always check the size of SourceTy before 
getting the next type (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110037

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/va-arg-sse.c


Index: clang/test/CodeGen/X86/va-arg-sse.c
===
--- clang/test/CodeGen/X86/va-arg-sse.c
+++ clang/test/CodeGen/X86/va-arg-sse.c
@@ -34,16 +34,16 @@
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load i8*, i8** [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 
[[FP_OFFSET]]
 // CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 
16
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
<2 x float> }*
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, 
float }*
 // CHECK-NEXT:[[TMP4:%.*]] = bitcast i8* [[TMP1]] to <2 x float>*
 // CHECK-NEXT:[[TMP5:%.*]] = load <2 x float>, <2 x float>* [[TMP4]], 
align 16
-// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds { <2 x float>, float 
}, { <2 x float>, float }* [[TMP3]], i32 0, i32 0
 // CHECK-NEXT:store <2 x float> [[TMP5]], <2 x float>* [[TMP6]], align 4
-// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to <2 x float>*
-// CHECK-NEXT:[[TMP8:%.*]] = load <2 x float>, <2 x float>* [[TMP7]], 
align 16
-// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, <2 x 
float> }, { <2 x float>, <2 x float> }* [[TMP3]], i32 0, i32 1
-// CHECK-NEXT:store <2 x float> [[TMP8]], <2 x float>* [[TMP9]], align 4
-// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, <2 x float> }* 
[[TMP3]] to %struct.S*
+// CHECK-NEXT:[[TMP7:%.*]] = bitcast i8* [[TMP2]] to float*
+// CHECK-NEXT:[[TMP8:%.*]] = load float, float* [[TMP7]], align 16
+// CHECK-NEXT:[[TMP9:%.*]] = getelementptr inbounds { <2 x float>, float 
}, { <2 x float>, float }* [[TMP3]], i32 0, i32 1
+// CHECK-NEXT:store float [[TMP8]], float* [[TMP9]], align 4
+// CHECK-NEXT:[[TMP10:%.*]] = bitcast { <2 x float>, float }* [[TMP3]] to 
%struct.S*
 // CHECK-NEXT:[[TMP11:%.*]] = add i32 [[FP_OFFSET]], 32
 // CHECK-NEXT:store i32 [[TMP11]], i32* [[FP_OFFSET_P]], align 4
 // CHECK-NEXT:br label [[VAARG_END:%.*]]
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3438,17 +3438,21 @@
 GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
QualType SourceTy, unsigned SourceOffset) const {
   const llvm::DataLayout &TD = getDataLayout();
+  unsigned SourceSize =
+  (unsigned)getContext().getTypeSize(SourceTy) / 8 - SourceOffset;
   llvm::Type *T0 = getFPTypeAtOffset(IRType, IROffset, TD);
   if (!T0 || T0->isDoubleTy())
 return llvm::Type::getDoubleTy(getVMContext());
 
   // Get the adjacent FP type.
-  llvm::Type *T1 =
-  getFPTypeAtOffset(IRType, IROffset + TD.getTypeAllocSize(T0), TD);
+  llvm::Type *T1 = nullptr;
+  unsigned T0Size = TD.getTypeAllocSize(T0);
+  if (SourceSize > T0Size)
+  T1 = getFPTypeAtOffset(IRType, IROffset + T0Size, TD);
   if (T1 == nullptr) {
 // Check if IRType is a half + float. float type will be in IROffset+4 due
 // to its alignment.
-if (T0->isHalfTy())
+if (T0->isHalfTy() && SourceSize > 4)
   T1 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
 // If we can't get a second FP type, return a simple half or float.
 // avx512fp16-abi.c:pr51813_2 shows it works to return float for
@@ -3461,7 +3465,9 @@
 return llvm::FixedVectorType::get(T0, 2);
 
   if (T0->isHalfTy() && T1->isHalfTy()) {
-llvm::Type *T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
+llvm::Type *T2 = nullptr;
+if (SourceSize > 4)
+  T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
 if (T2 == nullptr)
   return llvm::FixedVectorType::get(T0, 2);
 return llvm::FixedVectorType::get(T0, 4);


Index: clang/test/CodeGen/X86/va-arg-sse.c
===
--- clang/test/CodeGen/X86/va-arg-sse.c
+++ clang/test/CodeGen/X86/va-arg-sse.c
@@ -34,16 +34,16 @@
 // CHECK-NEXT:[[REG_SAVE_AREA:%.*]] = load i8*, i8** [[TMP0]], align 16
 // CHECK-NEXT:[[TMP1:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 [[FP_OFFSET]]
 // CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds i8, i8* [[TMP1]], i64 16
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast %struct.S* [[TMP]] to { <2 x float>, <2 x float> }*
+// 

[PATCH] D106713: Thread safety analysis: Warn when demoting locks on back edges

2021-09-20 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

@aaronpuchert Can you file a bug?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106713

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


[PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D109345#3008426 , @dblaikie wrote:

> Thanks for the suggestions/details, @dexonsmith  - I've posted to llvm-dev 
> here: https://groups.google.com/g/llvm-dev/c/m9UVRhzJvh4/m/qdd_SyPuCQAJ and 
> will wait for some follow-up (or dead silence) before starting along probably 
> your latter suggestion.

SGTM, thanks David!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D109632#3007615 , @vsapsai wrote:

> I don't remember for sure but I don't think there is a consistent policy 
> about a module storing transitive data or only data it owns. I suspect we 
> might be using both approaches and need to check each case separately.

I imagine we ideally want only owned data, except where there's a significant 
performance benefit for caching transitive data. I know identifier lookup 
tables include transitive data if there are "enough" transitive modules to 
justify it (see @rsmith's commits from 6-8 years ago related to multi-file 
on-disk hash tables).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1434-1436
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}

rmaz wrote:
> rmaz wrote:
> > dexonsmith wrote:
> > > Hmm, I was imagining that the set would be more encapsulated than this, 
> > > not just stored in the same place.
> > > 
> > > I'm wondering if the following could be done in a prep commit:
> > > 
> > > - Change Sema::addMethodToGlobalList to a private member function of 
> > > GlobalMethodPool.
> > > - Make GlobalMethodPool::insert private
> > > - Add `GlobalMethodPool::addMethod(ObjCMethodDecl*,bool,bool)`, which 
> > > does the second half of Sema::AddMethodToGlobalPool (the parts that don't 
> > > need Sema's other fields), and change the latter to call the former.
> > > 
> > > WDYT?
> > Definitely neater, will take a look at this later today.
> This might need a slightly different approach, as for the insert use case we 
> have:
> 
> ```lang=cxx
> Sema &S = *getSema();
>   Sema::GlobalMethodPool::iterator Pos =
>   S.MethodPool.insert(std::make_pair(Sel, 
> Sema::GlobalMethodPool::Lists()))
>   .first;
> 
>   Pos->second.first.setBits(Visitor.getInstanceBits());
>   
> Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
>   Pos->second.second.setBits(Visitor.getFactoryBits());
>   
> Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());
> 
>   // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
>   // when building a module we keep every method individually and may need to
>   // update hasMoreThanOneDecl as we add the methods.
>   addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
>   addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
> ```
> 
> At the moment we fetch a method list, modify its state and then start 
> inserting the methods. If we move to something like 
> `MethodPool.addMethod(ObjCMethodDecl *)` we will have to look up the method 
> list for each insert, and we would need extra methods to set the state first 
> on the method list. How about something like 
> `MethodPool.addMethods(ArrayRef methods, unsigned 
> instanceBits, bool hasMoreThanOneDecl)`? Then we only need two list lookups 
> per selector as before and we can handle the list state update before insert.
>  
That seems reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D106713: Thread safety analysis: Warn when demoting locks on back edges

2021-09-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D106713#3009542 , @tstellar wrote:

> @aaronpuchert Can you file a bug?

Done: https://bugs.llvm.org/show_bug.cgi?id=51913.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106713

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


[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 373618.
mizvekov added a comment.

typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1978,8 +1978,7 @@
   CallOperator->markUsed(Context);
 
   ExprResult Init = PerformC

[PATCH] D109818: [HIPSPV] Convert HIP kernels to SPIR-V kernels

2021-09-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109818

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


[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

2021-09-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1692-1694
+const bool IsOneDimensionalArray =
+!isa(CAT->getElementType());
+if (IsOneDimensionalArray) {

martong wrote:
> aaron.ballman wrote:
> > 
> +1 for Aaron's suggestion, but then it would be really helpful to have an 
> explanatory comment. E.g.:
> ```
> if (!isa(CAT->getElementType())) { // This is a one 
> dimensional array.
> ```
I think that self-descriptive code is better than comments nearby. And it does 
not affect anything in terms of performance.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1696
+  const llvm::APSInt &Idx = CI->getValue();
+  const uint64_t I = static_cast(Idx.getExtValue());
+  // Use `getZExtValue` because array extent can not be negative.

martong wrote:
> aaron.ballman wrote:
> > 
> This `static_cast` seems to be dangerous to me, it might overflow. Can't we 
> compare `Idx` directly to `Extent`? I see that `Idx` is an `APSint` and 
> `Extent` is an `APInt`, but  I think we should be able to handle the 
> comparison on the APInt level b/c that takes care of the signedness. And the 
> overflow situation should be handled as well properly with `APInt`, given 
> from it's name "arbitrary precision int". In this sense I don't see why do we 
> need `I` at all.
We can't get rid of `I` because we use it below anyway in `I >= 
InitList->getNumInits()` and `InitList->getInit(I)`.
I couldn't find any appropriate function to compare without additional checking 
for signedness or bit-width adjusting.
I'll try to improve this snippet.



Comment at: clang/test/Analysis/initialization.c:1
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core.builtin,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-config 
eagerly-assume=false  
-analyzer-checker=core.uninitialized.Assign,debug.ExprInspection -verify %s
 

martong wrote:
> I don't see how this change is related.  How could the tests work before 
> having the `uninitialized.Assign` enabled before?
I've added `glob_invalid_index1` and `glob_invalid_index2` functions which were 
not there before.
 `core.uninitialized.Assign` produces warnings for them.


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

https://reviews.llvm.org/D104285

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-20 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In D91944#3009003 , @uweigand wrote:

> Looks like this was committed again, breaking the SystemZ build bots once 
> again:
> https://lab.llvm.org/buildbot/#/builders/94/builds/5661

I'm going to fix this issue now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative

2021-09-20 Thread Rich Kadel via Phabricator via cfe-commits
richkadel added a comment.

I don't know if this is helpful or not, but we ran into a problem, recently, on 
Fuchsia when upgrading Clang (I believe to LLVM 14), and realized that the LLVM 
tools from Clang's version of LLVM were in compatible with the Rust profraw 
files. Since you're probably using a Rust compiler that's compatible with LLVM 
13 (if not earlier), you may need to make sure you're using Rust's bundled LLVM 
tools (`llvm-profdata` and `llvm-cov`) to process those files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[clang] 3679d20 - [NCF][OpenMP] Fix metadirective test on SystemZ

2021-09-20 Thread via cfe-commits

Author: cchen
Date: 2021-09-20T12:22:54-05:00
New Revision: 3679d2001c87f37101e7f20c646b21e97d8a0867

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

LOG: [NCF][OpenMP] Fix metadirective test on SystemZ

Added: 


Modified: 
clang/test/OpenMP/metadirective_ast_print.c

Removed: 




diff  --git a/clang/test/OpenMP/metadirective_ast_print.c 
b/clang/test/OpenMP/metadirective_ast_print.c
index c09da50ab3ec3..582de7c606da5 100644
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ b/clang/test/OpenMP/metadirective_ast_print.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c -std=c99 -ast-print %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-linux-gnu -x c 
-std=c99 -ast-print %s -o - | FileCheck %s
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c -std=c99 -ast-print %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-linux-gnu -x c 
-std=c99 -ast-print %s -o - | FileCheck %s
 // expected-no-diagnostics
 
 #ifndef HEADER



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


[clang] a077271 - Revert code change of D63497 & D74399 for riscv64-*-linux GCC detection

2021-09-20 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-09-20T10:28:32-07:00
New Revision: a07727199db0525e9d2df41e466a2a1611b3c8e1

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

LOG: Revert code change of D63497 & D74399 for riscv64-*-linux GCC detection

This partially reverts commits 1fc2a47f0b6c415312593e43489cf9ea2507d902 and 
9816e726e747d72e0c5ac92aa20e652031a10448.

See D109727. Replacing config.guess in favor of {gcc,clang} -dumpmachine
can avoid the riscv64-{redhat,suse}-linux GCC detection.

Acked-by: Luís Marques 

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index c28fe78dbf740..79bec347baad5 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2075,6 +2075,12 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   // Declare a bunch of static data sets that we'll select between below. These
   // are specifically designed to always refer to string literals to avoid any
   // lifetime or initialization issues.
+  //
+  // The *Triples variables hard code some triples so that, for example,
+  // --target=aarch64 (incomplete triple) can detect lib/aarch64-linux-gnu.
+  // They are not needed when the user has correct LLVM_DEFAULT_TARGET_TRIPLE
+  // and always uses the full --target (e.g. --target=aarch64-linux-gnu).  The
+  // lists should shrink over time. Please don't add more elements to *Triples.
   static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
   static const char *const AArch64Triples[] = {
   "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
@@ -2182,9 +2188,7 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"};
   static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
"riscv64-linux-gnu",
-   "riscv64-unknown-elf",
-   "riscv64-redhat-linux",
-   "riscv64-suse-linux"};
+   "riscv64-unknown-elf"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
   static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",



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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-20 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

The SystemZ issue is due to the fact that we assumed that `device(cpu)` should 
be evaluated to true and `device(gpu)` should be evaluated to false in the test 
so the test should be fixed by specifying the triple. 
(https://github.com/llvm/llvm-project/commit/3679d2001c87f37101e7f20c646b21e97d8a0867)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D110083: [clang-offload-bundler][docs][NFC] Add archive unbundling documentation

2021-09-20 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: yaxunl, jdoerfert, grokos.
saiislam requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add documentation of unbundling of heterogeneous device archives to
create device specific archives, as introduced by D93525 
. Also, add
documentation for supported text file formats.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110083

Files:
  clang/docs/ClangOffloadBundler.rst

Index: clang/docs/ClangOffloadBundler.rst
===
--- clang/docs/ClangOffloadBundler.rst
+++ clang/docs/ClangOffloadBundler.rst
@@ -30,9 +30,62 @@
 offload kind (see :ref:`clang-offload-kind-table`) to load the offload code
 objects appropriate to the devices present when the host program is executed.
 
+Supported File Formats
+==
+Several text and binary file formats are supported for bundling/unbundling. See
+:ref:`supported-file-formats-table` for a list of currently supported formats.
+
+  .. table:: Supported File Formats
+ :name: supported-file-formats-table
+
+ +++-+
+ | File Format| File Extension | Text/Binary |
+ +++=+
+ | CPP output |i   | Text|
+ +++-+
+ | C++ CPP output |   ii   | Text|
+ +++-+
+ | CUDA/HIP output|   cui  | Text|
+ +++-+
+ | Dependency |d   | Text|
+ +++-+
+ | LLVM   |   ll   | Text|
+ +++-+
+ | LLVM Bitcode   |   bc   |Binary   |
+ +++-+
+ | Assembler  |s   | Text|
+ +++-+
+ | Object |o   |Binary   |
+ +++-+
+ | Archive of objects |a   |Binary   |
+ +++-+
+ | Precompiled header |   gch  |Binary   |
+ +++-+
+ | Clang AST file |   ast  |Binary   |
+ +++-+
+
+.. _clang-bundled-code-object-layout-text:
+
+Bundled Text File Layout
+
+
+The format of the bundled files is currently very simple: text formats are
+concatenated with comments that have a magic string and bundle entry ID in
+between.
+
+::
+
+  "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ 1st Bundle Entry ID"
+  Bundle 1
+  "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ 1st Bundle Entry ID"
+  ...
+  "Comment OFFLOAD_BUNDLER_MAGIC_STR__START__ Nth Bundle Entry ID"
+  Bundle N
+  "Comment OFFLOAD_BUNDLER_MAGIC_STR__END__ 1st Bundle Entry ID"
+
 .. _clang-bundled-code-object-layout:
 
-Bundled Code Object Layout
+Bundled Binary File Layout
 ==
 
 The layout of a bundled code object is defined by the following table:
@@ -209,3 +262,35 @@
   supported.
 
 Most other targets do not support target IDs.
+
+Archive Unbundling
+==
+
+Unbundling of heterogeneous device archive is done to create device specific
+archives. Heterogeneous Device Archive is in a format compatible with GNU ar
+utility and contains a collection of bundled device binaries where each bundle
+file will contain device binaries for a host and one or more targets. The
+output device specific archive is in a format compatible with GNU ar utility
+and contains a collection of device binaries for a specific target.
+
+  Heterogeneous Device Archive, HDA = {F1.X, F2.X, ..., FN.Y}
+  where, Fi = Bundle{Host-DeviceBinary, T1-DeviceBinary, T2-DeviceBinary, ...,
+ Tm-DeviceBinary},
+ Ti = {Target i, qualified using Bundle Entry ID},
+ X/Y = \*.bc for AMDGPU and \*.cubin for NVPTX
+
+  Device Specific Archive, DSA(Tk) = {F1-Tk-DeviceBinary.X, F2-Tk-DeviceBinary.X, ...
+  FN-Tk-DeviceBinary.Y}
+  where, Fi-Tj-DeviceBinary.X represents device binary of i-th bundled device
+  binary file for target Tj.
+
+clang-offload-bundler extracts compatible device binaries for a given target
+from the bundled device binaries in a heterogeneous device archive and creates
+a target specific device archive without bundling.
+
+clang-offlocad-bundler determines whether a device binary is compatible with a
+target by comparing bundle ID's. Two bundle ID's are considered compatible if:
+
+  * Thei

[PATCH] D110084: [PowerPC] Support for vector bool int128 on vector comparison builtins

2021-09-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: PowerPC, saghir, nemanjai.
Conanap added projects: PowerPC, clang, LLVM.
Herald added a subscriber: kbarton.
Conanap requested review of this revision.

This patch implements support for the type `vector bool int128`
for arguments on vector comparison builtins, which would
otherwise crash due to ambiguity.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110084

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -19,6 +19,7 @@
 vector unsigned long long vulla, vullb, vullc;
 vector signed __int128 vsi128a, vsi128b, vsi128c;
 vector unsigned __int128 vui128a, vui128b, vui128c;
+vector bool __int128 vbi128a, vbi128b;
 vector float vfa, vfb;
 vector double vda, vdb;
 float fa;
@@ -1637,6 +1638,13 @@
   return vec_cmpeq(vui128a, vui128b);
 }
 
+vector bool __int128 test_vec_cmpeq_bool_int128(void) {
+  // CHECK-LABEL: @test_vec_cmpeq_bool_int128(
+  // CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpequq(<1 x i128>
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_cmpeq(vbi128a, vbi128b);
+}
+
 vector bool __int128 test_vec_cmpne_s128(void) {
   // CHECK-LABEL: @test_vec_cmpne_s128(
   // CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpequq(<1 x i128>
@@ -1653,6 +1661,14 @@
   return vec_cmpne(vui128a, vui128b);
 }
 
+vector bool __int128 test_vec_cmpne_bool_int128(void) {
+  // CHECK-LABEL: @test_vec_cmpne_bool_int128(
+  // CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpequq(<1 x i128>
+  // CHECK-NEXT: %neg.i = xor <1 x i128> %4, 
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_cmpne(vbi128a, vbi128b);
+}
+
 vector bool __int128 test_vec_cmpgt_s128(void) {
   // CHECK-LABEL: @test_vec_cmpgt_s128(
   // CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpgtsq(<1 x i128>
@@ -1727,6 +1743,13 @@
   return vec_any_eq(vsi128a, vsi128b);
 }
 
+int test_vec_any_eq_bool_int128(void) {
+  // CHECK-LABEL: @test_vec_any_eq_bool_int128(
+  // CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 1, <1 x i128> %2, <1 x i128> %3)
+  // CHECK-NEXT: ret i32
+  return vec_any_eq(vbi128a, vbi128b);
+}
+
 int test_vec_any_ne_s128(void) {
   // CHECK-LABEL: @test_vec_any_ne_s128(
   // CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 3, <1 x i128> %2, <1 x i128> %3)
@@ -1741,6 +1764,13 @@
   return vec_any_ne(vui128a, vui128b);
 }
 
+int test_vec_any_ne_bool_int128(void) {
+  // CHECK-LABEL: @test_vec_any_ne_bool_int128(
+  // CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 3, <1 x i128> %2, <1 x i128> %3)
+  // CHECK-NEXT: ret i32
+  return vec_any_ne(vbi128a, vbi128b);
+}
+
 int test_vec_any_lt_s128(void) {
   // CHECK-LABEL: @test_vec_any_lt_s128(
   // CHECK: call i32 @llvm.ppc.altivec.vcmpgtsq.p(i32 1, <1 x i128> %2, <1 x i128> %3)
@@ -1811,6 +1841,13 @@
   return vec_all_eq(vui128a, vui128b);
 }
 
+int test_vec_all_eq_bool_int128(void) {
+  // CHECK-LABEL: @test_vec_all_eq_bool_int128
+  // CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 2, <1 x i128> %2, <1 x i128> %3)
+  // CHECK-NEXT: ret i32
+  return vec_all_eq(vbi128a, vbi128b);
+}
+
 int test_vec_all_ne_s128(void) {
   // CHECK-LABEL: @test_vec_all_ne_s128(
   // CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 0, <1 x i128> %2, <1 x i128> %3)
@@ -1825,6 +1862,13 @@
   return vec_all_ne(vui128a, vui128b);
 }
 
+int test_vec_all_ne_bool_int128(void) {
+  // CHECK-LABEL: test_vec_all_ne_bool_int128
+  // CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 0, <1 x i128> %2, <1 x i128> %3)
+  // CHECK-NEXT: ret i32
+  return vec_all_ne(vbi128a, vbi128b);
+}
+
 int test_vec_all_lt_s128(void) {
   // CHECK-LABEL: @test_vec_all_lt_s128(
   // CHECK: call i32 @llvm.ppc.altivec.vcmpgtsq.p(i32 2, <1 x i128> %2, <1 x i128> %3)
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -1805,6 +1805,11 @@
   return (vector bool __int128)__builtin_altivec_vcmpequq(
   (vector bool __int128)__a, (vector bool __int128)__b);
 }
+
+static __inline__ vector bool __int128 __ATTRS_o_ai
+vec_cmpeq(vector bool __int128 __a, vector bool  __int128 __b) {
+  return (vector bool __int128)__builtin_altivec_vcmpequq(__a, __b);
+}
 #endif
 
 #ifdef __POWER9_VECTOR__
@@ -1882,6 +1887,11 @@
   return (vector bool __int128) ~(__builtin_altivec_vcmpequq(
   (vector bool __int128)__a, (vector bool __int128)__b));
 }
+
+static __inline__ vector bool __int128 __ATTRS_o_ai
+vec_cmpne(vector bool __int128 __a, vector bool __int128 __b) {
+  return (vector bool __int128) ~(__builtin_altivec_vcmpequq(__a, __b));
+}
 #endif
 
 /* vec_cmpnez */
@@ -14865,6 +14875,11 @@
   vector unsigned __int128 __b) {
   return __builtin_altivec_vcmpequq_p(__CR6_LT, 

[clang] 63e0d03 - Diagnose -Wunused-value based on CFG reachability

2021-09-20 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2021-09-20T10:43:34-07:00
New Revision: 63e0d038fc20c894a3d541effa1bc2b1fdea37b9

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

LOG: Diagnose -Wunused-value based on CFG reachability

While at it, add the diagnosis message "left operand of comma operator has no 
effect" (used by GCC) for comma operator.

This also makes Clang diagnose in the constant evaluation context which aligns 
with GCC/MSVC behavior. (https://godbolt.org/z/7zxb8Tx96)

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/Analysis/dead-stores.c
clang/test/CXX/basic/basic.link/p8.cpp
clang/test/CXX/drs/dr14xx.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/CXX/drs/dr7xx.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
clang/test/CodeCompletion/pragma-macro-token-caching.c
clang/test/Frontend/fixed_point_crash.c
clang/test/PCH/cxx-explicit-specifier.cpp
clang/test/Parser/cxx-ambig-decl-expr.cpp
clang/test/Parser/cxx0x-ambig.cpp
clang/test/Parser/cxx1z-init-statement.cpp
clang/test/Parser/objc-messaging-1.m
clang/test/Parser/objc-try-catch-1.m
clang/test/Parser/objcxx11-attributes.mm
clang/test/Sema/const-eval.c
clang/test/Sema/exprs.c
clang/test/Sema/i-c-e.c
clang/test/Sema/sizeless-1.c
clang/test/Sema/switch-1.c
clang/test/Sema/vla-2.c
clang/test/Sema/warn-type-safety.c
clang/test/Sema/warn-unused-value.c
clang/test/SemaCXX/attr-annotate.cpp
clang/test/SemaCXX/builtin-constant-p.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/test/SemaCXX/constant-expression.cpp
clang/test/SemaCXX/expression-traits.cpp
clang/test/SemaCXX/matrix-type-operators.cpp
clang/test/SemaCXX/overloaded-operator.cpp
clang/test/SemaCXX/sizeless-1.cpp
clang/test/SemaCXX/vector.cpp
clang/test/SemaCXX/warn-comma-operator.cpp
clang/test/SemaCXX/warn-unused-value.cpp
clang/test/SemaTemplate/derived.cpp
clang/test/SemaTemplate/lambda-capture-pack.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3cadd986b8ae4..530e8cf2e9725 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8565,6 +8565,9 @@ def err_typecheck_choose_expr_requires_constant : Error<
   "'__builtin_choose_expr' requires a constant expression">;
 def warn_unused_expr : Warning<"expression result unused">,
   InGroup;
+def warn_unused_comma_left_operand : Warning<
+  "left operand of comma operator has no effect">,
+  InGroup;
 def warn_unused_voidptr : Warning<
   "expression result unused; should this cast be to 'void'?">,
   InGroup;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 93d5558b8267c..fc0b6919bd50b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4912,7 +4912,7 @@ class Sema final {
 
   /// DiagnoseUnusedExprResult - If the statement passed in is an expression
   /// whose result is unused, warn.
-  void DiagnoseUnusedExprResult(const Stmt *S);
+  void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
   void DiagnoseUnusedNestedTypedefs(const RecordDecl *D);
   void DiagnoseUnusedDecl(const NamedDecl *ND);
 
@@ -5118,6 +5118,16 @@ class Sema final {
   /// conversion.
   ExprResult tryConvertExprToType(Expr *E, QualType Ty);
 
+  /// Conditionally issue a diagnostic based on the statement's reachability
+  /// analysis evaluation context.
+  ///
+  /// \param Statement If Statement is non-null, delay reporting the
+  /// diagnostic until the function body is parsed, and then do a basic
+  /// reachability analysis to determine if the statement is reachable.
+  /// If it is unreachable, the diagnostic will not be emitted.
+  bool DiagIfReachable(SourceLocation Loc, ArrayRef Stmts,
+   const PartialDiagnostic &PD);
+
   /// Conditionally issue a diagnostic based on the current
   /// evaluation context.
   ///

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7991e4c5e8b0a..83ff35b056e2e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -28,6 +28,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "

[PATCH] D103938: Diagnose -Wunused-value based on CFG reachability

2021-09-20 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63e0d038fc20: Diagnose -Wunused-value based on CFG 
reachability (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Analysis/dead-stores.c
  clang/test/CXX/basic/basic.link/p8.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/drs/dr20xx.cpp
  clang/test/CXX/drs/dr7xx.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/CodeCompletion/pragma-macro-token-caching.c
  clang/test/Frontend/fixed_point_crash.c
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/Parser/cxx-ambig-decl-expr.cpp
  clang/test/Parser/cxx0x-ambig.cpp
  clang/test/Parser/cxx1z-init-statement.cpp
  clang/test/Parser/objc-messaging-1.m
  clang/test/Parser/objc-try-catch-1.m
  clang/test/Parser/objcxx11-attributes.mm
  clang/test/Sema/const-eval.c
  clang/test/Sema/exprs.c
  clang/test/Sema/i-c-e.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/switch-1.c
  clang/test/Sema/vla-2.c
  clang/test/Sema/warn-type-safety.c
  clang/test/Sema/warn-unused-value.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaCXX/builtin-constant-p.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/constant-expression.cpp
  clang/test/SemaCXX/expression-traits.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/overloaded-operator.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/vector.cpp
  clang/test/SemaCXX/warn-comma-operator.cpp
  clang/test/SemaCXX/warn-unused-value.cpp
  clang/test/SemaTemplate/derived.cpp
  clang/test/SemaTemplate/lambda-capture-pack.cpp

Index: clang/test/SemaTemplate/lambda-capture-pack.cpp
===
--- clang/test/SemaTemplate/lambda-capture-pack.cpp
+++ clang/test/SemaTemplate/lambda-capture-pack.cpp
@@ -18,7 +18,7 @@
 namespace PR41576 {
   template  constexpr int f(Xs ...xs) {
 return [&](auto ...ys) { // expected-note {{instantiation}}
-  return ((xs + ys), ...); // expected-warning {{unused}}
+  return ((xs + ys), ...); // expected-warning {{left operand of comma operator has no effect}}
 }(1, 2);
   }
   static_assert(f(3, 4) == 6); // expected-note {{instantiation}}
Index: clang/test/SemaTemplate/derived.cpp
===
--- clang/test/SemaTemplate/derived.cpp
+++ clang/test/SemaTemplate/derived.cpp
@@ -49,6 +49,6 @@
 
   class A {
 TFP m_p;
-void Enable() { 0, A(); } // expected-warning {{unused}}
+void Enable() { 0, A(); } // expected-warning {{left operand of comma operator has no effect}}
   };
 }
Index: clang/test/SemaCXX/warn-unused-value.cpp
===
--- clang/test/SemaCXX/warn-unused-value.cpp
+++ clang/test/SemaCXX/warn-unused-value.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++17 %s
 
 // PR4806
 namespace test0 {
@@ -138,3 +139,26 @@
   (void)arr3;
   (void)arr4;
 }
+
+#if __cplusplus >= 201103L // C++11 or later
+namespace test5 {
+int v[(5, 6)]; // expected-warning {{left operand of comma operator has no effect}}
+void foo() {
+  new double[false ? (1, 2) : 3]
+// FIXME: We shouldn't diagnose the unreachable constant expression
+// here.
+[false ? (1, 2) : 3]; // expected-warning {{left operand of comma operator has no effect}}
+}
+} // namespace test5
+#endif
+
+#if __cplusplus >= 201703L // C++11 or later
+namespace test6 {
+auto b() {
+  if constexpr (false)
+return (1,0);
+  else
+return (1.0,0.0); // expected-warning {{left operand of comma operator has no effect}}
+}
+} // namespace test6
+#endif
Index: clang/test/SemaCXX/warn-comma-operator.cpp
===
--- clang/test/SemaCXX/warn-comma-operator.cpp
+++ clang/test/SemaCXX/warn-comma-operator.cpp
@@ -242,8 +242,8 @@
 
 template 
 class Foo {
-  typedef bool_seq<(xs::value, true)...> all_true;
-  typedef bool_seq<(xs::value, false)...> all_false;
+  typedef bool_seq<((void)xs::value, true)...> all_true;
+  typedef bool_seq<((void)xs::value, false)...> all_false;
   typedef bool_seq seq;
 };
 
Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp

[PATCH] D109652: [PowerPC] Restrict various P10 options to P10 only.

2021-09-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap accepted this revision.
Conanap added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109652

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


[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

2021-09-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 373656.
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

- Resolve the final issue I had regarding overlapping replacements (was adding 
double spaces between keywords),
- Add ability to add a warning into the documentation for modifying code. (as 
agreed via the RFC)

This now needs a reviewer and if we want to proceed someone has to be brave 
enough to accept it ;-)

F19136751: image.png 


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

https://reviews.llvm.org/D69764

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/QualifierAlignmentFixer.h
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -0,0 +1,803 @@
+//===- unittest/Format/QualifierFixerTest.cpp - Formatting unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "FormatTestUtils.h"
+#include "TestLexer.h"
+#include "gtest/gtest.h"
+
+#include "../../lib/Format/QualifierAlignmentFixer.h"
+
+#define DEBUG_TYPE "format-qualifier-fixer-test"
+
+using testing::ScopedTrace;
+
+namespace clang {
+namespace format {
+namespace {
+
+#define CHECK_PARSE(TEXT, FIELD, VALUE)\
+  EXPECT_NE(VALUE, Style.FIELD) << "Initial value already the same!";  \
+  EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+#define FAIL_PARSE(TEXT, FIELD, VALUE) \
+  EXPECT_NE(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+class QualifierFixerTest : public ::testing::Test {
+protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
+  TokenList annotate(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+return TestLexer(Allocator, Buffers, Style).annotate(Code);
+  }
+  llvm::SpecificBumpPtrAllocator Allocator;
+  std::vector> Buffers;
+
+  std::string format(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle(),
+ StatusCheck CheckComplete = SC_ExpectComplete) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(0, Code.size()));
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
+ReplacementCount = Replaces.size();
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
+return getStyleWithColumns(getLLVMStyle(), ColumnLimit);
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+ llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(Code, Style));
+if (Style.Language == FormatStyle::LK_Cpp) {
+  // Objective-C++ is a superset of C++, so everything checked for C++
+  // needs to be checked for Objective-C++ as well.
+  FormatStyle ObjCStyle = Style;
+  ObjCStyle.Language = FormatStyle::LK_ObjC;
+  EXPECT_EQ(Expected.str(), format(test::messUp(Code), ObjCStyle));
+}
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
+ const FormatStyle &Style =

[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

2021-09-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 373657.
MyDeveloperDay added a comment.

Missed dump_format_style.py update


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

https://reviews.llvm.org/D69764

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/QualifierAlignmentFixer.h
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -0,0 +1,803 @@
+//===- unittest/Format/QualifierFixerTest.cpp - Formatting unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "FormatTestUtils.h"
+#include "TestLexer.h"
+#include "gtest/gtest.h"
+
+#include "../../lib/Format/QualifierAlignmentFixer.h"
+
+#define DEBUG_TYPE "format-qualifier-fixer-test"
+
+using testing::ScopedTrace;
+
+namespace clang {
+namespace format {
+namespace {
+
+#define CHECK_PARSE(TEXT, FIELD, VALUE)\
+  EXPECT_NE(VALUE, Style.FIELD) << "Initial value already the same!";  \
+  EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+#define FAIL_PARSE(TEXT, FIELD, VALUE) \
+  EXPECT_NE(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+class QualifierFixerTest : public ::testing::Test {
+protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
+  TokenList annotate(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+return TestLexer(Allocator, Buffers, Style).annotate(Code);
+  }
+  llvm::SpecificBumpPtrAllocator Allocator;
+  std::vector> Buffers;
+
+  std::string format(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle(),
+ StatusCheck CheckComplete = SC_ExpectComplete) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(0, Code.size()));
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
+ReplacementCount = Replaces.size();
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
+return getStyleWithColumns(getLLVMStyle(), ColumnLimit);
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+ llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(Code, Style));
+if (Style.Language == FormatStyle::LK_Cpp) {
+  // Objective-C++ is a superset of C++, so everything checked for C++
+  // needs to be checked for Objective-C++ as well.
+  FormatStyle ObjCStyle = Style;
+  ObjCStyle.Language = FormatStyle::LK_ObjC;
+  EXPECT_EQ(Expected.str(), format(test::messUp(Code), ObjCStyle));
+}
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+_verifyFormat(File, Line, Code, test::messUp(Code), Style);
+  }
+
+  void _verifyIncompleteFormat(const char *File, int Line, llvm::StringRef Code,
+   const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+EXPECT_EQ(Code.str(),
+  format(test::messUp(Code), 

[PATCH] D109996: [PowerPC] Fix signature of lxvp and stxvp builtins

2021-09-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap accepted this revision as: Conanap.
Conanap added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109996

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


[PATCH] D109780: [PowerPC] Add range check for vec_genpcvm builtins

2021-09-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap accepted this revision.
Conanap added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109780

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


[PATCH] D110089: [CUDA] Implement experimental support for texture lookups.

2021-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: jlebar, yaxunl, hliao.
Herald added subscribers: bixia, mgorny.
Herald added a reviewer: a.sidorin.
tra requested review of this revision.
Herald added a project: clang.

The patch Implements support for testure lookups (mostly) in a header file.

The patch has been tested on a source file with all possible combinations of 
argument types supported by CUDA headers, 
compiled and verified that the generated instructions and their parameters 
match the code generated by NVCC. 
Unfortunately, compiling texture code requires CUDA headers and can't be tested 
in clang itself. 
The test will need to be added to the test-suite later.

While generated code compiles and seems to match NVCC, I do not have any code 
that uses textures that I could test correctness of the implementation.

The gory details of the implementation follow.



User-facing texture lookup API relies on NVCC's `__nv_tex_surf_handler` builtin 
which is actually a set of overloads. 
The catch is that it's overloaded not only by the argument types, but also by 
the value of the first argument.

Implementing it in the compiler itself would be rather messy as there are a lot 
of texture lookup variants.

Implementing texture lookups in C++ is somewhat more maintainable. 
If we could use string literals as a template parameter, the implementation 
could be done completely in the headers. 
Unfortunately, literal classes as template parameters are only available in 
C++20.

One alternative would be to use run-time dispatch, but, given that texture 
lookup is a single instruction, the overhead would be 
substantial-to-prohibitive.
As an alternative, this patch introduces `__nvvm_texture_op` builtin which maps 
known texture operations to an integer, which is then used to parametrize 
texture operations.

A lot of texture operations are fairly uniform, with the differences only in 
the instruction suffix. 
Unfortunately, inline assembly requires its input to be a string literal, so we 
can not rely on templates to generate it and have to resort to preprocessor to 
do the job.

Another quirk is that historically there were two ways to refer to a texture. 
Newer Api uses `cudaTextureObject_t` which is an opaque scalar value.
Older APIs were using an object of  `texture<>` type which was magically 
converted to an opaque texture handle (essentially the `cudaTextureObject_t`). 
There's no good way to do this conversion explicitly, which would require 
implementing each texture lookup twice, for each way to refer to a texture.
However, we can cheat a bit by introducing a dummy inline assembly. 
Nominally it accepts `texture<>` as input, but compiler will convert it to 
`cudaTextureObject_t`, so generated assembly will just return correct handle.
This allows both reference styles to use the same implementation.

Overall code structure :

- `struct __FT;` // maps texture data type to the 4-element texture fetch 
result type.
- `class __tex_fetch_v4<__op>; `// implements `run` methods for specific 
texture data types.
- `class __convert;` // converts result of __tex_fetch_v4 into 
expected return type (usually a smaller slice of 4-element fetch result
- `__tex_fetch<__op,...>();` // Calls appropriate `__convert(__text_fetch_v4()) 
variants.`
- `#define __nv_tex_surf_handler(__op, __ptr, ...) ;` calls appropriate 
__tex_fetch<>
- `__IMPL*` macros do the boilerplate generation of __tex_fetch_v4 variants.

  


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110089

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Headers/__clang_cuda_texture_intrinsics.h
  clang/lib/Sema/SemaChecking.cpp

Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1447,6 +1447,9 @@
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
 return CheckRISCVBuiltinFunctionCall(TI, BuiltinID, TheCall);
+  case llvm::Triple::nvptx:
+  case llvm::Triple::nvptx64:
+return CheckNVPTXBuiltinFunctionCall(BuiltinID, TheCall);
   }
 }
 
@@ -3559,6 +3562,28 @@
   return false;
 }
 
+static bool CheckNVVMTextureOp(Sema &S, unsigned BuiltinID, CallExpr *TheCall) {
+  // First argument of the __nvvm_texture_op must be a string literal.
+  ExprResult Arg = TheCall->getArg(0);
+  auto ArgExpr = Arg.get();
+  Expr::EvalResult ArgResult;
+  if (!ArgExpr->EvaluateAsConstantExpr(ArgResult, S.Context))
+return S.Diag(ArgExpr->getExprLoc(), diag::err_expr_not_string_literal)
+   << ArgExpr->getType();
+  return false;
+}
+
+bool Sema::CheckNVPTXBuiltinFunctionCall(unsigned BuiltinID,
+ CallExpr *TheCall) {
+  // position of memory order and scope arguments i

[PATCH] D109652: [PowerPC] Restrict various P10 options to P10 only.

2021-09-20 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:566-569
+  if (llvm::find(FeaturesVec, "+pcrel") != FeaturesVec.end()) {
+Diags.Report(diag::err_opt_not_valid_without_opt) << "-mpcrel"
+  << "-mprefixed";
+  }

I think this need more thought:
```
$ clang -mcpu=pwr9 -mprefixed -mpcrel test.c -o test
error: option '-mpcrel' cannot be specified without '-mprefixed'
error: option '-mprefixed' cannot be specified without '-mcpu=pwr10'

$ clang -mcpu=pwr9 -mpcrel test.c -o test
error: option '-mpcrel' cannot be specified without '-mprefixed'
```

For this, the first err makes not sense since both `-mprefixed` and `-mpcrel` 
is specified:
```
$ clang -mcpu=pwr9 -mprefixed -mpcrel test.c -o test
error: option '-mpcrel' cannot be specified without '-mprefixed'
error: option '-mprefixed' cannot be specified without '-mcpu=pwr10'
```
Shouldn't it just give:
```
$ clang -mcpu=pwr9 -mprefixed -mpcrel test.c -o test
error: option '-mpcrel' cannot be specified without '-mcpu=pwr10 -mprefixed'
```


For this:
```
$ clang -mcpu=pwr9 -mpcrel test.c -o test
error: option '-mpcrel' cannot be specified without '-mprefixed'
```
I think it's better if it says:
```
$ clang -mcpu=pwr9 -mpcrel test.c -o test
error: option '-mpcrel' cannot be specified without '-mcpu=pwr10 -mprefixed'
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109652

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


[PATCH] D109996: [PowerPC] Fix signature of lxvp and stxvp builtins

2021-09-20 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision as: lei.
lei added a comment.

LTGM
Thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109996

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


[PATCH] D109780: [PowerPC] Add range check for vec_genpcvm builtins

2021-09-20 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei added a comment.

LGTM.
Thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109780

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


[PATCH] D110092: [clang][NFC] encapsulate global method list in GlobalMethodPool

2021-09-20 Thread Richard Howell via Phabricator via cfe-commits
rmaz created this revision.
rmaz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change moves the `addMethodToGlobalList` function to be a
private member function of the `GlobalMethodPool` class. This
is a preparatory step to allow for de-duplication of inserted
methods.

Two public methods are added to handle the existing use cases
for adding methods to a global list: `addMethodsForSelector`
and `addMethod`. The former is required to avoid the overhead
of looking up the `Methods` map for each insert when adding
multiple methods for a single selector when deserializing AST
files. It also allows for modifying the list properties first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110092

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8178,14 +8178,6 @@
 } // namespace serialization
 } // namespace clang
 
-/// Add the given set of methods to the method list.
-static void addMethodsToPool(Sema &S, ArrayRef Methods,
- ObjCMethodList &List) {
-  for (unsigned I = 0, N = Methods.size(); I != N; ++I) {
-S.addMethodToGlobalList(&List, Methods[I]);
-  }
-}
-
 void ASTReader::ReadMethodPool(Selector Sel) {
   // Get the selector generation and update it to the current generation.
   unsigned &Generation = SelectorGeneration[Sel];
@@ -8208,20 +8200,12 @@
 return;
 
   Sema &S = *getSema();
-  Sema::GlobalMethodPool::iterator Pos =
-  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
-  .first;
-
-  Pos->second.first.setBits(Visitor.getInstanceBits());
-  Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
-  Pos->second.second.setBits(Visitor.getFactoryBits());
-  Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());
-
-  // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
-  // when building a module we keep every method individually and may need to
-  // update hasMoreThanOneDecl as we add the methods.
-  addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
-  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
+  S.MethodPool.addMethodsForSelector(Sel, Visitor.getInstanceMethods(), true,
+ Visitor.getInstanceBits(),
+ Visitor.instanceHasMoreThanOneDecl());
+  S.MethodPool.addMethodsForSelector(Sel, Visitor.getFactoryMethods(), false,
+ Visitor.getFactoryBits(),
+ Visitor.factoryHasMoreThanOneDecl());
 }
 
 void ASTReader::updateOutOfDateSelector(Selector Sel) {
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3300,8 +3300,8 @@
   return MethodInterface == MethodInListInterface;
 }
 
-void Sema::addMethodToGlobalList(ObjCMethodList *List,
- ObjCMethodDecl *Method) {
+void Sema::GlobalMethodPool::addMethodToGlobalList(ObjCMethodList *List,
+   ObjCMethodDecl *Method) {
   // Record at the head of the list whether there were 0, 1, or >= 2 methods
   // inside categories.
   if (ObjCCategoryDecl *CD =
@@ -3322,11 +3322,11 @@
   ObjCMethodList *ListWithSameDeclaration = nullptr;
   for (; List; Previous = List, List = List->getNext()) {
 // If we are building a module, keep all of the methods.
-if (getLangOpts().isCompilingModule())
+if (SemaRef.getLangOpts().isCompilingModule())
   continue;
 
-bool SameDeclaration = MatchTwoMethodDeclarations(Method,
-  List->getMethod());
+bool SameDeclaration =
+SemaRef.MatchTwoMethodDeclarations(Method, List->getMethod());
 // Looking for method with a type bound requires the correct context exists.
 // We need to insert a method into the list if the context is different.
 // If the method's declaration matches the list
@@ -3389,7 +3389,7 @@
 
   // We have a new signature for an existing method - add it.
   // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
-  ObjCMethodList *Mem = BumpAlloc.Allocate();
+  ObjCMethodList *Mem = SemaRef.BumpAlloc.Allocate();
 
   // We insert it right before ListWithSameDeclaration.
   if (ListWithSameDeclaration) {
@@ -3425,17 +3425,9 @@
   if (ExternalSource)
 ReadMethodPool(Method->getSelector());
 
-  GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
-  if (Pos == MethodPool.end())
-Pos = Met

[PATCH] D110092: [clang][NFC] encapsulate global method list in GlobalMethodPool

2021-09-20 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 373675.
rmaz added a comment.

remove unnecessary empty check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110092

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8178,14 +8178,6 @@
 } // namespace serialization
 } // namespace clang
 
-/// Add the given set of methods to the method list.
-static void addMethodsToPool(Sema &S, ArrayRef Methods,
- ObjCMethodList &List) {
-  for (unsigned I = 0, N = Methods.size(); I != N; ++I) {
-S.addMethodToGlobalList(&List, Methods[I]);
-  }
-}
-
 void ASTReader::ReadMethodPool(Selector Sel) {
   // Get the selector generation and update it to the current generation.
   unsigned &Generation = SelectorGeneration[Sel];
@@ -8208,20 +8200,12 @@
 return;
 
   Sema &S = *getSema();
-  Sema::GlobalMethodPool::iterator Pos =
-  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
-  .first;
-
-  Pos->second.first.setBits(Visitor.getInstanceBits());
-  Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
-  Pos->second.second.setBits(Visitor.getFactoryBits());
-  Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());
-
-  // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
-  // when building a module we keep every method individually and may need to
-  // update hasMoreThanOneDecl as we add the methods.
-  addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
-  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
+  S.MethodPool.addMethodsForSelector(Sel, Visitor.getInstanceMethods(), true,
+ Visitor.getInstanceBits(),
+ Visitor.instanceHasMoreThanOneDecl());
+  S.MethodPool.addMethodsForSelector(Sel, Visitor.getFactoryMethods(), false,
+ Visitor.getFactoryBits(),
+ Visitor.factoryHasMoreThanOneDecl());
 }
 
 void ASTReader::updateOutOfDateSelector(Selector Sel) {
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3300,8 +3300,8 @@
   return MethodInterface == MethodInListInterface;
 }
 
-void Sema::addMethodToGlobalList(ObjCMethodList *List,
- ObjCMethodDecl *Method) {
+void Sema::GlobalMethodPool::addMethodToGlobalList(ObjCMethodList *List,
+   ObjCMethodDecl *Method) {
   // Record at the head of the list whether there were 0, 1, or >= 2 methods
   // inside categories.
   if (ObjCCategoryDecl *CD =
@@ -3322,11 +3322,11 @@
   ObjCMethodList *ListWithSameDeclaration = nullptr;
   for (; List; Previous = List, List = List->getNext()) {
 // If we are building a module, keep all of the methods.
-if (getLangOpts().isCompilingModule())
+if (SemaRef.getLangOpts().isCompilingModule())
   continue;
 
-bool SameDeclaration = MatchTwoMethodDeclarations(Method,
-  List->getMethod());
+bool SameDeclaration =
+SemaRef.MatchTwoMethodDeclarations(Method, List->getMethod());
 // Looking for method with a type bound requires the correct context exists.
 // We need to insert a method into the list if the context is different.
 // If the method's declaration matches the list
@@ -3389,7 +3389,7 @@
 
   // We have a new signature for an existing method - add it.
   // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
-  ObjCMethodList *Mem = BumpAlloc.Allocate();
+  ObjCMethodList *Mem = SemaRef.BumpAlloc.Allocate();
 
   // We insert it right before ListWithSameDeclaration.
   if (ListWithSameDeclaration) {
@@ -3425,17 +3425,9 @@
   if (ExternalSource)
 ReadMethodPool(Method->getSelector());
 
-  GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
-  if (Pos == MethodPool.end())
-Pos = MethodPool
-  .insert(std::make_pair(Method->getSelector(),
- GlobalMethodPool::Lists()))
-  .first;
-
   Method->setDefined(impl);
-
-  ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
-  addMethodToGlobalList(&Entry, Method);
+  assert(Method->isInstanceMethod() == instance);
+  MethodPool.addMethod(Method);
 }
 
 /// Determines if this is an "acceptable" loose mismatch in the global
Index: clang/lib/Sema/Sema.cpp

[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

2021-09-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 373681.
MyDeveloperDay added a comment.

Remove debug code
Tidy a few comments
Remove Qualifier Order defaults (must be specified for Custom)


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

https://reviews.llvm.org/D69764

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/QualifierAlignmentFixer.h
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -0,0 +1,803 @@
+//===- unittest/Format/QualifierFixerTest.cpp - Formatting unit tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "FormatTestUtils.h"
+#include "TestLexer.h"
+#include "gtest/gtest.h"
+
+#include "../../lib/Format/QualifierAlignmentFixer.h"
+
+#define DEBUG_TYPE "format-qualifier-fixer-test"
+
+using testing::ScopedTrace;
+
+namespace clang {
+namespace format {
+namespace {
+
+#define CHECK_PARSE(TEXT, FIELD, VALUE)\
+  EXPECT_NE(VALUE, Style.FIELD) << "Initial value already the same!";  \
+  EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+#define FAIL_PARSE(TEXT, FIELD, VALUE) \
+  EXPECT_NE(0, parseConfiguration(TEXT, &Style).value());  \
+  EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
+
+class QualifierFixerTest : public ::testing::Test {
+protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
+  TokenList annotate(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+return TestLexer(Allocator, Buffers, Style).annotate(Code);
+  }
+  llvm::SpecificBumpPtrAllocator Allocator;
+  std::vector> Buffers;
+
+  std::string format(llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle(),
+ StatusCheck CheckComplete = SC_ExpectComplete) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(0, Code.size()));
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
+ReplacementCount = Replaces.size();
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  FormatStyle getStyleWithColumns(FormatStyle Style, unsigned ColumnLimit) {
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  FormatStyle getLLVMStyleWithColumns(unsigned ColumnLimit) {
+return getStyleWithColumns(getLLVMStyle(), ColumnLimit);
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+ llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(Code, Style));
+if (Style.Language == FormatStyle::LK_Cpp) {
+  // Objective-C++ is a superset of C++, so everything checked for C++
+  // needs to be checked for Objective-C++ as well.
+  FormatStyle ObjCStyle = Style;
+  ObjCStyle.Language = FormatStyle::LK_ObjC;
+  EXPECT_EQ(Expected.str(), format(test::messUp(Code), ObjCStyle));
+}
+  }
+
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
+_verifyFormat(File, Line, Code, test::messUp(Code), Style);
+  }
+
+  void _verifyIncompleteFormat(const char *File, int Line, llvm::StringRef Code,
+   const FormatStyle &Style = getLLVMStyle()) {
+ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+  

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-20 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D91944#3009868 , @cchen wrote:

> The SystemZ issue is due to the fact that we assumed that `device(cpu)` 
> should be evaluated to true and `device(gpu)` should be evaluated to false in 
> the test so the test should be fixed by specifying the triple. 
> (https://github.com/llvm/llvm-project/commit/3679d2001c87f37101e7f20c646b21e97d8a0867)

Thanks, it looks like this fixed the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D110083: [clang-offload-bundler][docs][NFC] Add archive unbundling documentation

2021-09-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/docs/ClangOffloadBundler.rst:296
+  * Their target triple are the same
+  * Their GPUArch are the same

This does not match our final view of compatibility. Is this intentional? 
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110083

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


[PATCH] D105765: Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all

2021-09-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake:509
 set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
-  ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
+  ${COMPILER_RT_OUTPUT_LIBRARY_DIR}/macho_embedded)
 set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR

It looks like this change broke the `macho_embedded` layout for Darwin's 
compiler-rt build, so now the clang driver isn unable to find these libraries.

I will commit a change that uses `COMPILER_RT_OUTPUT_DIR` again for the 
`macho_embedded` libraries.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105765

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


[PATCH] D110083: [clang-offload-bundler][docs][NFC] Add archive unbundling documentation

2021-09-20 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked an inline comment as done.
saiislam added inline comments.



Comment at: clang/docs/ClangOffloadBundler.rst:296
+  * Their target triple are the same
+  * Their GPUArch are the same

yaxunl wrote:
> This does not match our final view of compatibility. Is this intentional? 
> Thanks.
Yes, I have intentionally removed the TargetID related compatibility testing. 
Plan is to introduce it with an upcoming patch for supporting TargetID in 
OpenMP. So, all changes in the clang driver and offload-bundler for TargetID 
will be introduced in one go.  D106870 is supposed to put most of the necessary 
infrastructure in place so that TargetID support can be cleanly added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110083

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


[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

2021-09-20 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Really nice!

No attributes in there, do you think it would be difficult to add them? We can 
definitely do that in another change to move this one forward.




Comment at: clang/include/clang/Format/Format.h:1863-1864
+  /// \warning
+  ///  ``QualifierAlignment`` COULD lead to incorrect code generation, use with
+  ///  caution.
+  /// \endwarning

I would drop that use with caution. I think without the warning is big enough, 
and with it's too much.



Comment at: clang/lib/Format/Format.cpp:2938
 namespace internal {
+
 std::pair

Nit: Unrelated (and unnecessary) change.



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:28
+
+static void replaceToken(const SourceManager &SourceMgr,
+ tooling::Replacements &Fixes,

Out of curiosity, on what premise do you choose a static member function that 
is only used in this file or a local free function? I would always choose the 
latter (with an anon namespace), to keep the header smaller.



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:57
+
+  std::string NewText = " " + Qualifier + " ";
+  NewText += Next->TokenText;

Does not need to be addressed here, but does LLVM have a string builder or so? 
This produces a lot of (de-)allocations.



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:129
+
+bool LeftRightQualifierAlignmentFixer::isQualifierOrType(
+const FormatToken *Tok) {

I would prefer to match the order of functions in the header with the order in 
the cpp.



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:161
+return Tok;
+  FormatToken *Const = Tok;
+

This name is legacy from just `const volatile` formatting?



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:347
+   QualifierToken);
+  else if (Alignment == FormatStyle::QAS_Left)
+Tok = analyzeLeft(SourceMgr, Keywords, Fixes, Tok, Qualifier,

Only else and assert? It does nothing if Alignment is something different, or?



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:366
+  // Split the Order list by type and reverse the left side
+  bool left = true;
+  for (const auto &s : Order) {

Couldn't you just
```
LeftOrder.assign(std::reverse_iterator(type) /*maybe with a next or prev, 
haven't thought too much about it*/, Order.rend());
RightOrder.assign(std::next(type), Order.end());
```
?



Comment at: clang/lib/Format/QualifierAlignmentFixer.h:24
+
+typedef std::function(
+const Environment &)>

I don't know what the LLVM style is on that, but I prefer `using` anytime over 
`typedef`.



Comment at: clang/lib/Format/QualifierAlignmentFixer.h:30
+  // Left to Right ordering requires multiple passes
+  SmallVector Passes;
+  StringRef &Code;

Has the 8 some meaning? Then maybe give it a name. Or is it just coincidence 
that you repeat the 8 for QualifierTokens?



Comment at: clang/unittests/Format/FormatTest.cpp:18233
 
+#define FAIL_PARSE(TEXT, FIELD, VALUE) 
\
+  EXPECT_NE(0, parseConfiguration(TEXT, &Style).value());  
\

Unused?


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

https://reviews.llvm.org/D69764

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


[PATCH] D110083: [clang-offload-bundler][docs][NFC] Add archive unbundling documentation

2021-09-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110083

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


[PATCH] D110029: [OpenMP][Offloading] Use bitset to indicate execution mode instead of value

2021-09-20 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 373696.
tianshilei1992 added a comment.
Herald added a subscriber: mgorny.

fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110029

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  llvm/test/Transforms/OpenMP/is_spmd_exec_mode_fold.ll
  llvm/test/Transforms/OpenMP/spmdization.ll
  llvm/test/Transforms/OpenMP/spmdization_assumes.ll
  llvm/test/Transforms/OpenMP/spmdization_guarding.ll
  openmp/libomptarget/plugins/cuda/CMakeLists.txt
  openmp/libomptarget/plugins/cuda/src/rtl.cpp

Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -28,6 +28,8 @@
 
 #include "MemoryManager.h"
 
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+
 // Utility for retrieving and printing CUDA error string.
 #ifdef OMPTARGET_DEBUG
 #define CUDA_ERR_STRING(err)   \
@@ -71,22 +73,14 @@
   std::vector<__tgt_offload_entry> Entries;
 };
 
-enum ExecutionModeType {
-  SPMD, // constructors, destructors,
-// combined constructs (`teams distribute parallel for [simd]`)
-  GENERIC,  // everything else
-  SPMD_GENERIC, // Generic kernel with SPMD execution
-  NONE
-};
-
 /// Use a single entity to encode a kernel and a set of flags.
 struct KernelTy {
   CUfunction Func;
 
   // execution mode of kernel
-  // 0 - SPMD mode (without master warp)
-  // 1 - Generic mode (with master warp)
-  // 2 - SPMD mode execution with Generic mode semantics.
+  // ExecutionMode | 0x2 - SPMD mode (without master warp)
+  // ExecutionMode | 0x1 - Generic mode (with master warp)
+  // ExecutionMode | 0x3 - SPMD mode execution with Generic mode semantics.
   int8_t ExecutionMode;
 
   /// Maximal number of threads per block for this kernel.
@@ -866,7 +860,7 @@
  DPxPTR(E - HostBegin), E->name, DPxPTR(Func));
 
   // default value GENERIC (in case symbol is missing from cubin file)
-  int8_t ExecModeVal = ExecutionModeType::GENERIC;
+  int8_t ExecModeVal = 1;
   std::string ExecModeNameStr(E->name);
   ExecModeNameStr += "_exec_mode";
   const char *ExecModeName = ExecModeNameStr.c_str();
@@ -889,12 +883,6 @@
   CUDA_ERR_STRING(Err);
   return nullptr;
 }
-
-if (ExecModeVal < 0 || ExecModeVal > 2) {
-  DP("Error wrong exec_mode value specified in cubin file: %d\n",
- ExecModeVal);
-  return nullptr;
-}
   } else {
 DP("Loading global exec_mode '%s' - symbol missing, using default "
"value GENERIC (1)\n",
@@ -1097,12 +1085,28 @@
 
 KernelTy *KernelInfo = reinterpret_cast(TgtEntryPtr);
 
+const bool IsSPMDGenericMode =
+(KernelInfo->ExecutionMode &
+ static_cast(
+ llvm::omp::OMPTargetExecutionModeMaskType::Generic)) &&
+(KernelInfo->ExecutionMode &
+ static_cast(llvm::omp::OMPTargetExecutionModeMaskType::SPMD));
+const bool IsSPMDMode =
+!IsSPMDGenericMode &&
+(KernelInfo->ExecutionMode &
+ static_cast(llvm::omp::OMPTargetExecutionModeMaskType::SPMD));
+const bool IsGenericMode =
+!IsSPMDGenericMode &&
+(KernelInfo->ExecutionMode &
+ static_cast(
+ llvm::omp::OMPTargetExecutionModeMaskType::Generic));
+
 int CudaThreadsPerBlock;
 if (ThreadLimit > 0) {
   DP("Setting CUDA threads per block to requested %d\n", ThreadLimit);
   CudaThreadsPerBlock = ThreadLimit;
   // Add master warp if necessary
-  if (KernelInfo->ExecutionMode == GENERIC) {
+  if (IsGenericMode) {
 DP("Adding master warp: +%d threads\n", DeviceData[DeviceId].WarpSize);
 CudaThreadsPerBlock += DeviceData[DeviceId].WarpSize;
   }
@@ -1135,13 +1139,21 @@
 unsigned int CudaBlocksPerGrid;
 if (TeamNum <= 0) {
   if (LoopTripCount > 0 && EnvNumTeams < 0) {
-if (KernelInfo->ExecutionMode == SPMD) {
+if (IsSPMDGenericMode) {
+  // If we reach this point, then we are executing a kernel that was
+  // transformed from Generic-mode to SPMD-mode. This kernel has
+  // SPMD-mode execution, but needs its blocks to be scheduled
+  // differently because the current loop trip count only applies to the
+  // `teams distribute` region and will create var too few blocks usin

[PATCH] D109611: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source

2021-09-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks the build for us:

  Running cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON 
'-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld;chrometools;clang-tools-extra' 
-DLLVM_CHECK_ENABLED_PROJECTS=OFF 
'-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Mips;PowerPC;SystemZ;WebAssembly;X86' 
-DLLVM_ENABLE_PIC=OFF -DLLVM_ENABLE_UNWIND_TABLES=OFF 
-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF 
-DCLANG_PLUGIN_SUPPORT=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF 
-DCLANG_ENABLE_ARCMT=OFF '-DBUG_REPORT_URL=https://crbug.com and run 
tools/clang/scripts/process_crashreports.py (only works inside Google) which 
will upload a report' -DLLVM_INCLUDE_GO_TESTS=OFF 
-DENABLE_X86_RELAX_RELOCATIONS=NO -DLLVM_ENABLE_DIA_SDK=OFF 
'-DCOMPILER_RT_SANITIZERS_TO_BUILD=asan;dfsan;msan;hwasan;tsan;cfi' 
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF 
-DLLVM_LOCAL_RPATH=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib64
 
'-DCOMPILER_RT_TEST_COMPILER_CFLAGS=--gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty
 
-Wl,-rpath,/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib64
 
-Wl,-rpath,/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib32'
 -DLLVM_ENABLE_LIBXML2=FORCE_ON 
-DCMAKE_C_COMPILER=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/bin/gcc
 
-DCMAKE_CXX_COMPILER=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/bin/g++
 -DCOMPILER_RT_BUILD_CRT=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF 
-DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_ORC=OFF 
-DCOMPILER_RT_BUILD_PROFILE=ON -DCOMPILER_RT_BUILD_SANITIZERS=ON 
-DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_BUILTINS=OFF 
-DCMAKE_C_FLAGS=-DLLVM_FORCE_HEAD_REVISION 
-DCMAKE_CXX_FLAGS=-DLLVM_FORCE_HEAD_REVISION -DCMAKE_EXE_LINKER_FLAGS= 
-DCMAKE_SHARED_LINKER_FLAGS= -DCMAKE_MODULE_LINKER_FLAGS= 
-DCMAKE_INSTALL_PREFIX=/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts
 -DCHROMIUM_TOOLS_SRC=/b/s/w/ir/cache/builder/src/tools/clang 
'-DCHROMIUM_TOOLS=translation_unit;blink_gc_plugin;plugins' 
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu 
/b/s/w/ir/cache/builder/src/third_party/llvm/llvm
  
  
  -- Configuring done
  CMake Error: install(EXPORT "ClangTargets" ...) includes target "clangTidy" 
which requires target "clangStaticAnalyzerCore" that is not in any export set.
  CMake Error: install(EXPORT "ClangTargets" ...) includes target "clangTidy" 
which requires target "clangStaticAnalyzerFrontend" that is not in any export 
set.
  CMake Error: install(EXPORT "ClangTargets" ...) includes target 
"clangTidyMPIModule" which requires target "clangStaticAnalyzerCheckers" that 
is not in any export set.
  CMake Error in 
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/cmake/modules/CMakeLists.txt:
export called with target "clangTidy" which requires target
"clangStaticAnalyzerCore" that is not in any export set.
  
  
  CMake Error in 
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/cmake/modules/CMakeLists.txt:
export called with target "clangTidy" which requires target
"clangStaticAnalyzerFrontend" that is not in any export set.
  
  
  CMake Error in 
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/cmake/modules/CMakeLists.txt:
export called with target "clangTidyMPIModule" which requires target
"clangStaticAnalyzerCheckers" that is not in any export set.

Are we holding it wrong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109611

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


[PATCH] D109611: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source

2021-09-20 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D109611#3010353 , @thakis wrote:

> This breaks the build for us:
>
>   Running cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
> -DLLVM_ENABLE_ASSERTIONS=ON 
> '-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld;chrometools;clang-tools-extra' 
> -DLLVM_CHECK_ENABLED_PROJECTS=OFF 
> '-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Mips;PowerPC;SystemZ;WebAssembly;X86' 
> -DLLVM_ENABLE_PIC=OFF -DLLVM_ENABLE_UNWIND_TABLES=OFF 
> -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF 
> -DCLANG_PLUGIN_SUPPORT=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF 
> -DCLANG_ENABLE_ARCMT=OFF '-DBUG_REPORT_URL=https://crbug.com and run 
> tools/clang/scripts/process_crashreports.py (only works inside Google) which 
> will upload a report' -DLLVM_INCLUDE_GO_TESTS=OFF 
> -DENABLE_X86_RELAX_RELOCATIONS=NO -DLLVM_ENABLE_DIA_SDK=OFF 
> '-DCOMPILER_RT_SANITIZERS_TO_BUILD=asan;dfsan;msan;hwasan;tsan;cfi' 
> -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF 
> -DLLVM_LOCAL_RPATH=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib64
>  
> '-DCOMPILER_RT_TEST_COMPILER_CFLAGS=--gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty
>  
> -Wl,-rpath,/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib64
>  
> -Wl,-rpath,/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib32'
>  -DLLVM_ENABLE_LIBXML2=FORCE_ON 
> -DCMAKE_C_COMPILER=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/bin/gcc
>  
> -DCMAKE_CXX_COMPILER=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/bin/g++
>  -DCOMPILER_RT_BUILD_CRT=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF 
> -DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_ORC=OFF 
> -DCOMPILER_RT_BUILD_PROFILE=ON -DCOMPILER_RT_BUILD_SANITIZERS=ON 
> -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_BUILTINS=OFF 
> -DCMAKE_C_FLAGS=-DLLVM_FORCE_HEAD_REVISION 
> -DCMAKE_CXX_FLAGS=-DLLVM_FORCE_HEAD_REVISION -DCMAKE_EXE_LINKER_FLAGS= 
> -DCMAKE_SHARED_LINKER_FLAGS= -DCMAKE_MODULE_LINKER_FLAGS= 
> -DCMAKE_INSTALL_PREFIX=/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts
>  -DCHROMIUM_TOOLS_SRC=/b/s/w/ir/cache/builder/src/tools/clang 
> '-DCHROMIUM_TOOLS=translation_unit;blink_gc_plugin;plugins' 
> -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu 
> /b/s/w/ir/cache/builder/src/third_party/llvm/llvm
>   
>   
>   -- Configuring done
>   CMake Error: install(EXPORT "ClangTargets" ...) includes target "clangTidy" 
> which requires target "clangStaticAnalyzerCore" that is not in any export set.
>   CMake Error: install(EXPORT "ClangTargets" ...) includes target "clangTidy" 
> which requires target "clangStaticAnalyzerFrontend" that is not in any export 
> set.
>   CMake Error: install(EXPORT "ClangTargets" ...) includes target 
> "clangTidyMPIModule" which requires target "clangStaticAnalyzerCheckers" that 
> is not in any export set.
>   CMake Error in 
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/cmake/modules/CMakeLists.txt:
> export called with target "clangTidy" which requires target
> "clangStaticAnalyzerCore" that is not in any export set.
>   
>   
>   CMake Error in 
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/cmake/modules/CMakeLists.txt:
> export called with target "clangTidy" which requires target
> "clangStaticAnalyzerFrontend" that is not in any export set.
>   
>   
>   CMake Error in 
> /b/s/w/ir/cache/builder/src/third_party/llvm/clang/cmake/modules/CMakeLists.txt:
> export called with target "clangTidyMPIModule" which requires target
> "clangStaticAnalyzerCheckers" that is not in any export set.
>
> Are we holding it wrong?

Hmm that sounds like it might be awkward to fix. I'll try to look into it ASAP 
(tomorrow morning UK time). In the mean time feel free to revert if this is a 
blocker for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109611

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


[PATCH] D110041: [clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils.

2021-09-20 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110041

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/target-data.c:256
 
+// RUN: %clang_cc1 -triple s390x-none-zos -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS

anirudhp wrote:
> MaskRay wrote:
> > If you add so many RUN lines at once, please use unittests instead. This 
> > would cost some test execution time
> We're essentially matching what was available for the systemz elf target 
> (above lines) for the z/OS target. Is there a real concern for the execution 
> time here for moving it to a separate unit test. If we did, it would seem to 
> "stand out" for just the z/OS target.
This is a real concern. Perhaps you can also move the SYstemZ ELF tests to a 
unit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[clang] 9197834 - Revert "Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source"

2021-09-20 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-20T16:18:03-04:00
New Revision: 9197834535364efff505580ef940ad41cd293275

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

LOG: Revert "Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source"

This reverts commit 6d7b3d6b3a8dbd62650b6c3dae1fe904a8ae9048.
Breaks running cmake with `-DCLANG_ENABLE_STATIC_ANALYZER=OFF`
without turning off CLANG_TIDY_ENABLE_STATIC_ANALYZER.
See comments on https://reviews.llvm.org/D109611 for details.

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
clang/lib/StaticAnalyzer/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index c2d46b743b856..5752f4277444e 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -100,12 +100,7 @@ macro(add_clang_library name)
   # The Xcode generator doesn't handle object libraries correctly.
   list(APPEND LIBTYPE OBJECT)
 endif()
-if (NOT EXCLUDE_FROM_ALL)
-  # Only include libraries that don't have EXCLUDE_FROM_ALL set. This
-  # ensure that the clang static analyzer libraries are not compiled
-  # as part of clang-shlib if CLANG_ENABLE_STATIC_ANALYZER=OFF.
-  set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
-endif()
+set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
@@ -115,11 +110,8 @@ macro(add_clang_library name)
   endif()
 
   foreach(lib ${libs})
-   if(TARGET ${lib})
+if(TARGET ${lib})
   target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
-  if (EXCLUDE_FROM_ALL)
-continue()
-  endif()
 
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
 get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA 
clang-libraries)

diff  --git a/clang/lib/StaticAnalyzer/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/CMakeLists.txt
index a610252e1de7a..3d1509254f52f 100644
--- a/clang/lib/StaticAnalyzer/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/CMakeLists.txt
@@ -1,10 +1,3 @@
-# These directories can significantly impact build time, only build
-# them if anything depends on the clangStaticAnalyzer* libraries.
-if(NOT CLANG_ENABLE_STATIC_ANALYZER)
-  set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
-  set(EXCLUDE_FROM_ALL ON)
-endif()
-
 add_subdirectory(Core)
 add_subdirectory(Checkers)
 add_subdirectory(Frontend)

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index dca1c2af45bb1..c5a9e0209f13b 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -429,13 +429,10 @@ endfunction(set_windows_version_resource_properties)
 #  This is used to specify that this is a component library of
 #  LLVM which means that the source resides in llvm/lib/ and it is a
 #  candidate for inclusion into libLLVM.so.
-#   EXCLUDE_FROM_ALL
-#  Do not build this library as part of the default target, only
-#  if explicitly requested or when linked against.
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;EXCLUDE_FROM_ALL"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
 "OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -538,9 +535,6 @@ function(llvm_add_library name)
 
 # FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
 set(ARG_STATIC)
-if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
-  set_target_properties(${name_static} PROPERTIES EXCLUDE_FROM_ALL ON)
-endif()
   endif()
 
   if(ARG_MODULE)
@@ -552,10 +546,6 @@ function(llvm_add_library name)
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
-  if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
-set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL ON)
-  endif()
-
   if(ARG_COMPONENT_LIB)
 set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE)
 set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})



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


  1   2   >