[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: ABataev, JonChesterfield, ggeorgakoudis, 
tianshilei1992.
Herald added subscribers: jfb, guansong, hiraditya, yaxunl.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP, LLVM.

In the spirit of TRegions [0], this patch provides a simpler and uniform
interface for a kernel to set up the device runtime. The OMPIRBuilder is
used for reuse in Flang. A custom state machine will be generated in the
follow up patch.

The "surplus" threads of the "master warp" will not exit early anymore
so we need to use non-aligned barriers. The new runtime will not have an
extra warp but also require these non-aligned barriers.

[0] https://link.springer.com/chapter/10.1007/978-3-030-28596-8_11

This was in parts extracted from D59319 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101976

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

NOTE: not all tests have been updated, only *codegen.cpp ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 343301.
jdoerfert added a comment.

Remove itantium mangle change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

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


[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64

2021-05-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

https://gist.github.com/MaskRay/2d4dfcfc897341163f734afb59f689c6 has more 
information about -fno-semantic-interposition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101873

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


[clang] 5d8d994 - [OpenMP] Make sure classes work on the device as they do on the host

2021-05-06 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-05-06T02:10:30-05:00
New Revision: 5d8d994dfbe38fe86b1d883daa9fd8e47cdc1376

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

LOG: [OpenMP] Make sure classes work on the device as they do on the host

We do provide `operator delete(void*)` in `` but it should be
available by default. This is mostly boilerplate to test it and the
unconditional include of `` in the header we always in include
on the device.

Reviewed By: JonChesterfield

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

Added: 
clang/test/Headers/Inputs/include/new
clang/test/Headers/target_include_new.cpp

Modified: 
clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
clang/lib/Headers/openmp_wrappers/new
clang/test/Headers/Inputs/include/stdlib.h

Removed: 




diff  --git 
a/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h 
b/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
index 406c9748e286e..953857badfc4c 100644
--- a/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
+++ b/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
@@ -39,4 +39,46 @@ extern "C" {
 
 #pragma omp end declare variant
 
+// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the
+// need to `include ` in C++ mode.
+#ifdef __cplusplus
+
+// We require malloc/free.
+#include 
+
+#pragma push_macro("OPENMP_NOEXCEPT")
+#if __cplusplus >= 201103L
+#define OPENMP_NOEXCEPT noexcept
+#else
+#define OPENMP_NOEXCEPT
+#endif
+
+// Device overrides for non-placement new and delete.
+inline void *operator new(__SIZE_TYPE__ size) {
+  if (size == 0)
+size = 1;
+  return ::malloc(size);
+}
+
+inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); 
}
+
+inline void operator delete(void *ptr)OPENMP_NOEXCEPT { ::free(ptr); }
+
+inline void operator delete[](void *ptr) OPENMP_NOEXCEPT {
+  ::operator delete(ptr);
+}
+
+// Sized delete, C++14 only.
+#if __cplusplus >= 201402L
+inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT {
+  ::operator delete(ptr);
+}
+inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT {
+  ::operator delete(ptr);
+}
+#endif
+
+#pragma pop_macro("OPENMP_NOEXCEPT")
+#endif
+
 #endif

diff  --git a/clang/lib/Headers/openmp_wrappers/new 
b/clang/lib/Headers/openmp_wrappers/new
index 1387d925b126d..985ddc567f494 100644
--- a/clang/lib/Headers/openmp_wrappers/new
+++ b/clang/lib/Headers/openmp_wrappers/new
@@ -9,6 +9,8 @@
 #ifndef __CLANG_OPENMP_WRAPPERS_NEW
 #define __CLANG_OPENMP_WRAPPERS_NEW
 
+// We need the system  for the std::nothrow_t. The new/delete operators
+// which do not use nothrow_t are provided without the  header.
 #include_next 
 
 #if defined(__NVPTX__) && defined(_OPENMP)
@@ -22,48 +24,24 @@
 #define OPENMP_NOEXCEPT
 #endif
 
-// Device overrides for non-placement new and delete.
-inline void *operator new(__SIZE_TYPE__ size) {
-  if (size == 0)
-size = 1;
-  return ::malloc(size);
-}
 inline void *operator new(__SIZE_TYPE__ size,
   const std::nothrow_t &) OPENMP_NOEXCEPT {
   return ::operator new(size);
 }
 
-inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); 
}
 inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-inline void operator delete(void *ptr)OPENMP_NOEXCEPT {
-  if (ptr)
-::free(ptr);
-}
 inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-inline void operator delete[](void *ptr) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
 inline void operator delete[](void *ptr,
   const std::nothrow_t &) OPENMP_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-// Sized delete, C++14 only.
-#if __cplusplus >= 201402L
-inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-#endif
-
 #pragma pop_macro("OPENMP_NOEXCEPT")
 #endif
 

diff  --git a/clang/test/Headers/Inputs/include/new 
b/clang/test/Headers/Inputs/include/new
new file mode 100644
index 0..8159d5527cc3a
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/new
@@ -0,0 +1,7 @@
+
+namespace std
+{
+
+struct nothrow_t { explicit nothrow_t() = default; };
+
+}

diff  --git a/clang/test/Headers/Inputs/include/stdlib.h 
b/clang/test/Headers/Inputs/include/stdlib.h
index 516e521df7ec7..47cd80ca84f01 100644
--- a/clang/test/Headers/Inputs/include/stdlib.h
+++ b/clang/test/Headers/Inputs/include/stdlib.h
@@ -1,6 +1,9 @@
 #pragma once
 typedef __SIZE_TYPE__

[clang] 3f14596 - [OpenMP] Ensure the DefaultMapperId has a location

2021-05-06 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-05-06T02:10:36-05:00
New Revision: 3f14596700093bce436ae27178c307e842398b65

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

LOG: [OpenMP] Ensure the DefaultMapperId has a location

A user reported an assertion (below) but without a reproducer. I failed to
create a test myself but from the assertion one can derive the problem.
I set the DefaultMapperId location now to make sure this doesn't cause
trouble.

```
clang-13: .../DeclTemplate.h:1940:
void 
clang::ClassTemplateSpecializationDecl::setPointOfInstantiation(clang::SourceLocation):
Assertion `Loc.isValid() && "point of instantiation must be valid!"' failed.
```

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 9ac3e4878184..068065b5e3be 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5578,9 +5578,6 @@ processImplicitMapsWithDefaultMappers(Sema &S, DSAStackTy 
*Stack,
   if (S.getLangOpts().OpenMP < 50)
 return;
   SmallVector ImplicitMaps;
-  DeclarationNameInfo DefaultMapperId;
-  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
-  &S.Context.Idents.get("default")));
   for (int Cnt = 0, EndCnt = Clauses.size(); Cnt < EndCnt; ++Cnt) {
 auto *C = dyn_cast(Clauses[Cnt]);
 if (!C)
@@ -5636,6 +5633,10 @@ processImplicitMapsWithDefaultMappers(Sema &S, 
DSAStackTy *Stack,
 if (It == Visited.end()) {
   // Try to find the associated user-defined mapper.
   CXXScopeSpec MapperIdScopeSpec;
+  DeclarationNameInfo DefaultMapperId;
+  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
+  &S.Context.Idents.get("default")));
+  DefaultMapperId.setLoc(E->getExprLoc());
   ExprResult ER = buildUserDefinedMapperRef(
   S, Stack->getCurScope(), MapperIdScopeSpec, DefaultMapperId,
   BaseType, /*UnresolvedMapper=*/nullptr);



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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-05-06 Thread Johannes Doerfert 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 rG5d8d994dfbe3: [OpenMP] Make sure classes work on the device 
as they do on the host (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

Files:
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/new
  clang/test/Headers/Inputs/include/new
  clang/test/Headers/Inputs/include/stdlib.h
  clang/test/Headers/target_include_new.cpp

Index: clang/test/Headers/target_include_new.cpp
===
--- /dev/null
+++ clang/test/Headers/target_include_new.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64 -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the need to `include `.
+
+// CHECK: define {{.*}}_ZdlPv
+
+#ifndef HEADER
+#define HEADER
+
+class Base {
+  public:
+virtual ~Base() = default;
+};
+
+class Derived : public Base {
+  public:
+#pragma omp declare target
+Derived();
+#pragma omp end declare target
+};
+
+Derived::Derived() { }
+
+int main(void) {
+  #pragma omp target
+  {
+  }
+  return 0;
+}
+#endif
Index: clang/test/Headers/Inputs/include/stdlib.h
===
--- clang/test/Headers/Inputs/include/stdlib.h
+++ clang/test/Headers/Inputs/include/stdlib.h
@@ -1,6 +1,9 @@
 #pragma once
 typedef __SIZE_TYPE__ size_t;
 
+void *malloc(size_t);
+void free(void*);
+
 #ifndef __cplusplus
 extern int abs(int __x) __attribute__((__const__));
 #endif
Index: clang/test/Headers/Inputs/include/new
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/new
@@ -0,0 +1,7 @@
+
+namespace std
+{
+
+struct nothrow_t { explicit nothrow_t() = default; };
+
+}
Index: clang/lib/Headers/openmp_wrappers/new
===
--- clang/lib/Headers/openmp_wrappers/new
+++ clang/lib/Headers/openmp_wrappers/new
@@ -9,6 +9,8 @@
 #ifndef __CLANG_OPENMP_WRAPPERS_NEW
 #define __CLANG_OPENMP_WRAPPERS_NEW
 
+// We need the system  for the std::nothrow_t. The new/delete operators
+// which do not use nothrow_t are provided without the  header.
 #include_next 
 
 #if defined(__NVPTX__) && defined(_OPENMP)
@@ -22,48 +24,24 @@
 #define OPENMP_NOEXCEPT
 #endif
 
-// Device overrides for non-placement new and delete.
-inline void *operator new(__SIZE_TYPE__ size) {
-  if (size == 0)
-size = 1;
-  return ::malloc(size);
-}
 inline void *operator new(__SIZE_TYPE__ size,
   const std::nothrow_t &) OPENMP_NOEXCEPT {
   return ::operator new(size);
 }
 
-inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); }
 inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-inline void operator delete(void *ptr)OPENMP_NOEXCEPT {
-  if (ptr)
-::free(ptr);
-}
 inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-inline void operator delete[](void *ptr) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
 inline void operator delete[](void *ptr,
   const std::nothrow_t &) OPENMP_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-// Sized delete, C++14 only.
-#if __cplusplus >= 201402L
-inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-#endif
-
 #pragma pop_macro("OPENMP_NOEXCEPT")
 #endif
 
Index: clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
===
--- clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
+++ clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
@@ -39,4 +39,46 @@
 
 #pragma omp end declare variant
 
+// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the
+// need to `include ` in C++ mode.
+#ifdef __cplusplus
+
+// We require malloc/free.
+#include 
+
+#pragma push_macro("OPENMP_NOEXCEP

[PATCH] D100621: [OpenMP] Ensure the DefaultMapperId has a location

2021-05-06 Thread Johannes Doerfert 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 rG3f1459670009: [OpenMP] Ensure the DefaultMapperId has a 
location (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D100621?vs=337997&id=343304#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100621

Files:
  clang/lib/Sema/SemaOpenMP.cpp


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -5578,9 +5578,6 @@
   if (S.getLangOpts().OpenMP < 50)
 return;
   SmallVector ImplicitMaps;
-  DeclarationNameInfo DefaultMapperId;
-  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
-  &S.Context.Idents.get("default")));
   for (int Cnt = 0, EndCnt = Clauses.size(); Cnt < EndCnt; ++Cnt) {
 auto *C = dyn_cast(Clauses[Cnt]);
 if (!C)
@@ -5636,6 +5633,10 @@
 if (It == Visited.end()) {
   // Try to find the associated user-defined mapper.
   CXXScopeSpec MapperIdScopeSpec;
+  DeclarationNameInfo DefaultMapperId;
+  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
+  &S.Context.Idents.get("default")));
+  DefaultMapperId.setLoc(E->getExprLoc());
   ExprResult ER = buildUserDefinedMapperRef(
   S, Stack->getCurScope(), MapperIdScopeSpec, DefaultMapperId,
   BaseType, /*UnresolvedMapper=*/nullptr);


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -5578,9 +5578,6 @@
   if (S.getLangOpts().OpenMP < 50)
 return;
   SmallVector ImplicitMaps;
-  DeclarationNameInfo DefaultMapperId;
-  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
-  &S.Context.Idents.get("default")));
   for (int Cnt = 0, EndCnt = Clauses.size(); Cnt < EndCnt; ++Cnt) {
 auto *C = dyn_cast(Clauses[Cnt]);
 if (!C)
@@ -5636,6 +5633,10 @@
 if (It == Visited.end()) {
   // Try to find the associated user-defined mapper.
   CXXScopeSpec MapperIdScopeSpec;
+  DeclarationNameInfo DefaultMapperId;
+  DefaultMapperId.setName(S.Context.DeclarationNames.getIdentifier(
+  &S.Context.Idents.get("default")));
+  DefaultMapperId.setLoc(E->getExprLoc());
   ExprResult ER = buildUserDefinedMapperRef(
   S, Stack->getCurScope(), MapperIdScopeSpec, DefaultMapperId,
   BaseType, /*UnresolvedMapper=*/nullptr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf729e2b82b3: [OpenMP] Overhaul `declare target` handling 
(authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/OpenMP/irbuilder_for_unsigned.c
  clang/test/OpenMP/irbuilder_nested_openmp_parallel_empty.c
  clang/test/OpenMP/irbuilder_nested_parallel_for.c
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp
  clang/test/OpenMP/threadprivate_codegen.cpp
  clang/test/OpenMP/tile_codegen.cpp
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  llvm/include/llvm/Frontend/OpenMP/OMP.td

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


[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-05-06 Thread Georgy Komarov via Phabricator via cfe-commits
jubnzv added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp:7
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+

probinson wrote:
> probinson wrote:
> > TWeaver wrote:
> > > njames93 wrote:
> > > > TWeaver wrote:
> > > > > Is the missing FileCheck call here on purpose? it seems to me that 
> > > > > the CHECK-MESSAGES aren't actually being verified by this test?
> > > > > 
> > > > > unless I'm missing something.
> > > > > 
> > > > > TIA
> > > > `check_clang_tidy` invokes FileCheck. Does something else make you 
> > > > think these labels are being tested?? 
> > > whilst investigating an unrelated issue on our internal branch, I tried 
> > > editting the check lines in this test and wasn't able to create a 
> > > failure. but if I add
> > > 
> > > '| FileCheck %s -check-prefix=CHECK-MESSAGES' to the run line and then 
> > > edit the checks, I can induce an error.
> > > 
> > > This could be an issue on our internal branch though... :shrug: thanks 
> > > for the speedy reply.
> > I'm suspicious that our downstream problem is because the test is assuming 
> > that the target is Windows, just because the host is.  That's not true for 
> > us (or anyone with a Windows-hosted cross-compiler).  Does clang-tidy 
> > accept a target triple?
> Or possibly the test could be set up to require a Windows target, rather than 
> a Windows host.
I'm not sure that there is a way to pass a target triple to `clang-tidy`.

But `llvm-lit` should not run this test on non-Windows host because of 
`REQUIRES: system-windows`. For example, when I trying to run it on my Debian 
machine (`llvm-lit 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
 -v`) I got the following result:

```
-- Testing: 1 tests, 1 workers --
UNSUPPORTED: Clang Tools :: 
clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp (1 of 1)

Testing Time: 0.01s
  Unsupported: 1
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101259

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


[PATCH] D59319: [OpenMP][Offloading][1/3] A generic and simple target region interface

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert abandoned this revision.
jdoerfert added a comment.
Herald added a subscriber: yaxunl.
Herald added a reviewer: bollu.

replaced by D101976 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59319

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


[PATCH] D101979: [WebAssembly] Fix argument types in SIMD narrowing intrinsics

2021-05-06 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100, 
dschuff.
tlively requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The builtins were updated to take signed parameters in 627a52695537 
, but the
intrinsics that use those builtins were not updated as well. The intrinsic test
did not catch this sign mismatch because it is only reported as an error under
-fno-lax-vector-conversions.

This commit fixes the type mismatch and adds -fno-lax-vector-conversions to the
test to catch similar problems in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101979

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c


Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --force-update
 // REQUIRES: webassembly-registered-target, asserts
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 -Wcast-qual -fno-lax-vector-conversions -Werror | FileCheck %s
 
 #include 
 
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -1197,8 +1197,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__u16x8)__a,
- (__u16x8)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a,
+ (__i16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
@@ -1209,8 +1209,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__u32x4)__a,
- (__u32x4)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a,
+ (__i32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS


Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --force-update
 // REQUIRES: webassembly-registered-target, asserts
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -fno-lax-vector-conversions -Werror | FileCheck %s
 
 #include 
 
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -1197,8 +1197,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__u16x8)__a,
- (__u16x8)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a,
+ (__i16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
@@ -1209,8 +1209,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__u32x4)__a,
- (__u32x4)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a,
+ (__i32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101960: [openmp] Drop requirement on library path environment variables

2021-05-06 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for looking into this!
This also fixes the problem of not being able to find `libomp`, right?




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:648
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
+  const ArgList &Args,

JonChesterfield wrote:
> Similar to other functions in this file, derived from aomp (by deleting some 
> stuff for finding a debug version of the library)
> 
> I can make my peace with runpath instead if people are keen to override this 
> with LD_LIBRARY_PATH. The rest of clang's toolchains wire things up with 
> rpath but that doesn't mean we have to make the same choice here.
I think it would be a shame if this would be the only thing
that *doesn't* support being overriden with `LD_LIBRARY_PATH`.
I'm not sure about `libomptarget`, but it i think it would be good to keep such 
possibility for `libomp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101960

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


[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-06 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Thanks Paul!




Comment at: clang/include/clang/Driver/Options.td:1089
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,

Paul-C-Anagnostopoulos wrote:
> jansvoboda11 wrote:
> > Paul-C-Anagnostopoulos wrote:
> > > jansvoboda11 wrote:
> > > > Were you planning to refactor this too?
> > > You can't use the paste operator (#) there because c2x is a defvar. 
> > > Defvars and undefined identifiers are taken literally by paste, due to 
> > > its frequent use in forming record and class names.
> > > 
> > > This behavior is noted in the Programmer's Reference, but I think I will 
> > > add a more prominent note. I wonder if we should change the behavior so 
> > > defvars are treated normally.
> > I see. In that case, can you please undo the whitespace change?
> Sure, but don't we try to avoid over-long lines in .td files, too?
I think that would be nice, but I'm not sure what's LLVM's policy on making 
whitespace-only changes (it makes `git blame` less useful). If we decide that's 
fine, let's do it in a purely NFC commit.


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

https://reviews.llvm.org/D101766

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


[PATCH] D100625: [clang-tools-extra] Do not use `LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR`

2021-05-06 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.
Herald added a subscriber: cfe-commits.

Apparently Phabricator detected the presence of "revert D100625 
" in my alternative D101851 
's description and marked that as reverting 
this one. Of course, as this hadn't been committed, it cannot have been 
reverted either. Could you confirm that things work for you now, @Abpostelnicu?

In D100625#2697345 , @jpalus wrote:

> Do you mind taking a look at fix proposed in:
>
> https://bugs.llvm.org/show_bug.cgi?id=49990#c3

Sorry for not noticing this before, this is pretty much what I came up with too 
and what's committed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100625

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


[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-06 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

@ggeorgakoudis  `Clang::parallel_for_codegen.cpp` is failing on some of our 
bots:
https://lab.llvm.org/buildbot/#/builders/43/builds/5751
https://lab.llvm.org/buildbot/#/builders/107/builds/7585


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

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


[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-05-06 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko updated this revision to Diff 343321.

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

https://reviews.llvm.org/D91949

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5069,6 +5069,106 @@
 format(Input, Style));
 }
 
+TEST_F(FormatTest, BreakBeforeStructInitialization) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 80;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeStructInitialization = true;
+  Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_No;
+  verifyFormat("struct new_struct struct_name =\n"
+   "{a = 1};",
+   Style);
+  verifyFormat("struct new_struct struct_name =\n"
+   "{a = 1, b = 2};",
+   Style);
+  verifyFormat("struct new_struct struct_name =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("typedef struct Foo =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("static constexpr struct Foo =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("template <> struct Foo =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("struct =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  // BeforeStructInitialization doesn't affect on AfterStruct behavior
+  Style.BraceWrapping.AfterStruct = false;
+  verifyFormat("struct new_struct struct_name {\n"
+   "  a = 1;\n"
+   "  b = 2;\n"
+   "};",
+   Style);
+  Style.BraceWrapping.AfterStruct = true;
+  verifyFormat("struct new_struct struct_name\n"
+   "{\n"
+   "  a = 1;\n"
+   "  b = 2;\n"
+   "};",
+   Style);
+  Style.BraceWrapping.BeforeStructInitialization = false;
+  verifyFormat("struct new_struct struct_name = {a = 1};", Style);
+  verifyFormat("struct new_struct struct_name = {a = 1, b = 2};", Style);
+  verifyFormat("struct new_struct struct_name = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("typedef struct Foo = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("static constexpr struct Foo = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("template <> struct Foo = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("struct = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  // BeforeStructInitialization doesn't affect on AfterStruct behavior
+  Style.BraceWrapping.AfterStruct = false;
+  verifyFormat("struct new_struct struct_name {\n"
+   "  a = 1;\n"
+   "  b = 2;\n"
+   "};",
+   Style);
+  Style.BraceWrapping.AfterStruct = true;
+  verifyFormat("struct new_struct struct_name\n"
+   "{\n"
+   "  a = 1;\n"
+   "  b = 2;\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
@@ -16328,6 +16428,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeStructInitialization);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2702,7 +2702,11 @@
   nextToken();
 }
   }
-  if (FormatTok->Tok.is(tok::l_brace)) {
+  if (FormatTok->Tok.is(tok::equal) &&
+  Style.BraceWrapping.BeforeStructInitialization) {
+nextToken();
+addUn

[PATCH] D100625: [clang-tools-extra] Do not use `LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR`

2021-05-06 Thread Andi via Phabricator via cfe-commits
Abpostelnicu abandoned this revision.
Abpostelnicu added a comment.

In D100625#2741385 , @hvdijk wrote:

> Apparently Phabricator detected the presence of "revert D100625 
> " in my alternative D101851 
> 's description and marked that as reverting 
> this one. Of course, as this hadn't been committed, it cannot have been 
> reverted either. Could you confirm that things work for you now, 
> @Abpostelnicu?
>
> In D100625#2697345 , @jpalus wrote:
>
>> Do you mind taking a look at fix proposed in:
>>
>> https://bugs.llvm.org/show_bug.cgi?id=49990#c3
>
> Sorry for not noticing this before, this is pretty much what I came up with 
> too and what's committed now.

It works just fine, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100625

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


[PATCH] D97687: [SEH] Fix capture of this in lambda functions

2021-05-06 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

Bisecting shows that this started to break

  $ cat test.cc
  void f() noexcept { __try {} __finally {} }
  $ clang-cl -EHs -c test.cc
  clang-cl: ~/github.com/llvm/llvm-project/clang/lib/CodeGen/CGCleanup.h:568: 
void clang::CodeGen::EHScopeStack::popTerminate(): Assertion `!empty() && 
"popping exception stack when not empty"' failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: ~/llvm/inst/bin/clang-cl -EHs -c test.cc
  1. parser at end of file
  2.test.cc:1:6: LLVM IR generation of declaration 'f'
  3.test.cc:1:6: Generating code for declaration 'f'
   #0 0x7f2fd211624d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
~/github.com/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:3
   #1 0x7f2fd2114174 llvm::sys::RunSignalHandlers() 
~/github.com/llvm/llvm-project/llvm/lib/Support/Signals.cpp:71:20
   #2 0x7f2fd20368c8 HandleCrash 
~/github.com/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:75:5
   #3 0x7f2fd20368c8 CrashRecoverySignalHandler(int) 
~/github.com/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:388:62
   #4 0x7f2fd68f91e0 __restore_rt sigaction.c:0:0
   #5 0x7f2fd1a4b9d5 raise 
/usr/src/debug/glibc-2.32-37-g760e1d2878/signal/../sysdeps/unix/sysv/linux/raise.c:50:1
   #6 0x7f2fd1a348a4 abort 
/usr/src/debug/glibc-2.32-37-g760e1d2878/stdlib/abort.c:81:7
   #7 0x7f2fd1a34789 get_sysdep_segment_value 
/usr/src/debug/glibc-2.32-37-g760e1d2878/intl/loadmsgcat.c:509:8
   #8 0x7f2fd1a34789 _nl_load_domain.cold 
/usr/src/debug/glibc-2.32-37-g760e1d2878/intl/loadmsgcat.c:970:34
   #9 0x7f2fd1a44026 .annobin___GI___assert_fail.end assert.c:0:0
  #10 0x7f2fd5871973 
(~/llvm/inst/bin/../lib/libclangCodeGen.so.13git+0x44b973)
  #11 0x7f2fd587612a 
(~/llvm/inst/bin/../lib/libclangCodeGen.so.13git+0x45012a)
  #12 0x7f2fd5a85bbc 
clang::CodeGen::CodeGenFunction::FinishFunction(clang::SourceLocation) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:405:3
  #13 0x7f2fd587f703 
clang::CodeGen::CodeGenFunction::GenerateSEHFinallyFunction(clang::CodeGen::CodeGenFunction&,
 clang::SEHFinallyStmt const&) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CGException.cpp:2005:10
  #14 0x7f2fd587f776 pushCleanup<(anonymous namespace)::PerformSEHFinally, 
llvm::Function*> 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/EHScopeStack.h:273:31
  #15 0x7f2fd587f776 
clang::CodeGen::CodeGenFunction::EnterSEHTryStmt(clang::SEHTryStmt const&) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CGException.cpp:2082:43
  #16 0x7f2fd587fa87 
clang::CodeGen::CodeGenFunction::getJumpDestInCurrentScope(llvm::StringRef) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:1096:59
  #17 0x7f2fd587fa87 
clang::CodeGen::CodeGenFunction::EmitSEHTryStmt(clang::SEHTryStmt const&) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CGException.cpp:1605:65
  #18 0x7f2fd5a21de4 
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
 const&, bool, clang::CodeGen::AggValueSlot) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CGStmt.cpp:447:31
  #19 0x7f2fd5a8499b 
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1185:36
  #20 0x7f2fd5a9214a clang::CodeGen::CodeGenModule::getLangOpts() const 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.h:686:51
  #21 0x7f2fd5a9214a clang::CodeGen::CodeGenFunction::getLangOpts() const 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:1921:67
  #22 0x7f2fd5a9214a 
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, 
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1352:19
  #23 0x7f2fd5ad447c 
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, 
llvm::GlobalValue*) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4791:3
  #24 0x7f2fd5ad0f7b 
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, 
llvm::GlobalValue*) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3177:47
  #25 0x7f2fd5ad8c8a 
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5895:1
  #26 0x7f2fd5b4e9a1 (anonymous 
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:169:67
  #27 0x7f2fd5a70b13 
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) 
~/github.com/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:217:7
  #28 0x7f2fcfbbd814 clang::ParseAST(clang::Sema&, bool, bool) 
~/githu

[PATCH] D101785: [clangd][ObjC] Highlight Objc Ivar refs

2021-05-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks! Can you also add a test to `FindExplicitReferencesTest.All` ? as that's 
where the underlying change lies.

To disambiguate properties and ivars, what if we used modifiers? I suppose we 
can mark properties with `abstract` modifier, but i am not an obj-c person so 
it might be better for you to vet such an idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101785

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


[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Overall, it looks promising. But I don't quite get this test.
There is no invocation yaml in the temp directory. So, you are probably not 
testing the right thing.
You wanted to test if the invocation yaml exists, and could be opened **but the 
parsing fails**.
You should demonstrate that when a parsing error happens, the error code has 
recoded and it won't try to reparse the invocation yaml again and again.


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

https://reviews.llvm.org/D101763

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


[clang] a437bef - [clang-format] Add more support for C# 8 nullables

2021-05-06 Thread Marek Kurdej via cfe-commits

Author: Eliza Velasquez
Date: 2021-05-06T11:58:38+02:00
New Revision: a437befa8f8580b3b4f2226b208a05da078c8b20

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

LOG: [clang-format] Add more support for C# 8 nullables

This adds support for the null-coalescing assignment and null-forgiving
operators.

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving

Reviewed By: krasimir, curdeius

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/FormatTokenLexer.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 2f53b338379d7..95353482467fb 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -112,9 +112,6 @@ namespace format {
   TYPE(UntouchableMacroFunc)   
\
   TYPE(CSharpStringLiteral)
\
   TYPE(CSharpNamedArgumentColon)   
\
-  TYPE(CSharpNullable) 
\
-  TYPE(CSharpNullCoalescing)   
\
-  TYPE(CSharpNullConditional)  
\
   TYPE(CSharpNullConditionalLSquare)   
\
   TYPE(CSharpGenericTypeConstraint)
\
   TYPE(CSharpGenericTypeConstraintColon)   
\

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index e9b096370dbb1..b6825c3ec9829 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -92,20 +92,47 @@ void FormatTokenLexer::tryMergePreviousTokens() {
   if (Style.isCpp() && tryTransformTryUsageForC())
 return;
 
+  if (Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
+static const tok::TokenKind NullishCoalescingOperator[] = {tok::question,
+   tok::question};
+static const tok::TokenKind NullPropagatingOperator[] = {tok::question,
+ tok::period};
+static const tok::TokenKind FatArrow[] = {tok::equal, tok::greater};
+
+if (tryMergeTokens(FatArrow, TT_JsFatArrow))
+  return;
+if (tryMergeTokens(NullishCoalescingOperator,
+   TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
+  return;
+}
+if (tryMergeTokens(NullPropagatingOperator, TT_JsNullPropagatingOperator)) 
{
+  // Treat like a regular "." access.
+  Tokens.back()->Tok.setKind(tok::period);
+  return;
+}
+if (tryMergeNullishCoalescingEqual()) {
+  return;
+}
+  }
+
   if (Style.isCSharp()) {
+static const tok::TokenKind CSharpNullConditionalLSquare[] = {
+tok::question, tok::l_square};
+
 if (tryMergeCSharpKeywordVariables())
   return;
 if (tryMergeCSharpStringLiteral())
   return;
-if (tryMergeCSharpDoubleQuestion())
-  return;
-if (tryMergeCSharpNullConditional())
-  return;
 if (tryTransformCSharpForEach())
   return;
-static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
-if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
+if (tryMergeTokens(CSharpNullConditionalLSquare,
+   TT_CSharpNullConditionalLSquare)) {
+  // Treat like a regular "[" operator.
+  Tokens.back()->Tok.setKind(tok::l_square);
   return;
+}
   }
 
   if (tryMergeNSStringLiteral())
@@ -117,16 +144,9 @@ void FormatTokenLexer::tryMergePreviousTokens() {
tok::equal};
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
-static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
 static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
 static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
tok::starequal};
-static const tok::TokenKind JSNullPropagatingOperator[] = {tok::question,
-  

[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-06 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa437befa8f85: [clang-format] Add more support for C# 8 
nullables (authored by exv, committed by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -358,6 +358,39 @@
   verifyFormat("return _name ?? \"DEF\";");
 }
 
+TEST_F(FormatTestCSharp, CSharpNullCoalescingAssignment) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeAssignmentOperators = true;
+
+  verifyFormat(R"(test ??= ABC;)", Style);
+  verifyFormat(R"(test ??= true;)", Style);
+
+  Style.SpaceBeforeAssignmentOperators = false;
+
+  verifyFormat(R"(test??= ABC;)", Style);
+  verifyFormat(R"(test??= true;)", Style);
+}
+
+TEST_F(FormatTestCSharp, CSharpNullForgiving) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("var test = null!;", Style);
+  verifyFormat("string test = someFunctionCall()! + \"ABC\"!", Style);
+  verifyFormat("int test = (1! + 2 + bar! + foo())!", Style);
+  verifyFormat(R"(test ??= !foo!;)", Style);
+  verifyFormat("test = !bar! ?? !foo!;", Style);
+  verifyFormat("bool test = !(!true && !true! || !null && !null! || !false && "
+   "!false! && !bar()! + (!foo()))!",
+   Style);
+
+  // Check that line break keeps identifier with the bang.
+  Style.ColumnLimit = 14;
+
+  verifyFormat("var test =\n"
+   "foo!;",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, AttributesIndentation) {
   FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
   Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1055,13 +1055,6 @@
 CurrentToken->Previous->setType(TT_OverloadedOperator);
   break;
 case tok::question:
-  if (Tok->is(TT_CSharpNullConditionalLSquare)) {
-if (!parseSquare())
-  return false;
-break;
-  }
-  if (Tok->isOneOf(TT_CSharpNullConditional, TT_CSharpNullCoalescing))
-break;
   if (Style.Language == FormatStyle::LK_JavaScript && Tok->Next &&
   Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
  tok::r_brace)) {
@@ -1085,7 +1078,7 @@
 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
  Tok->Next->Next->is(tok::equal))) {
-  Tok->setType(TT_CSharpNullable);
+  Tok->setType(TT_JsTypeOptionalQuestion);
   break;
 }
   }
@@ -1571,39 +1564,29 @@
   // The token type is already known.
   return;
 
-if (Style.isCSharp() && CurrentToken->is(tok::question)) {
-  if (CurrentToken->TokenText == "??") {
-Current.setType(TT_CSharpNullCoalescing);
-return;
-  }
-  if (CurrentToken->TokenText == "?.") {
-Current.setType(TT_CSharpNullConditional);
-return;
-  }
-  if (CurrentToken->TokenText == "?[") {
-Current.setType(TT_CSharpNullConditionalLSquare);
-return;
-  }
-}
-
-if (Style.Language == FormatStyle::LK_JavaScript) {
-  if (Current.is(tok::exclaim)) {
-if (Current.Previous &&
-(Keywords.IsJavaScriptIdentifier(
- *Current.Previous, /* AcceptIdentifierName= */ true) ||
- Current.Previous->isOneOf(
- tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
- Keywords.kw_type, Keywords.kw_get, Keywords.kw_set) ||
- Current.Previous->Tok.isLiteral())) {
-  Current.setType(TT_JsNonNullAssertion);
-  return;
-}
-if (Current.Next &&
-Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
+if ((Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) &&
+Current.is(tok::exclaim)) {
+  if (Current.Previous) {
+bool IsIdentifier =
+Style.Language == FormatStyle::LK_JavaScript
+? Keywords.IsJavaScriptIdentifier(
+  *Current.Previous, /* AcceptIdentifierName= */ true)
+: Current.Previous->is(tok::identifier);
+if (IsIdentifier ||
+Current.Previous->isOneOf(
+tok::kw_namespace, tok::r_pare

[clang] ec725b3 - [clang-format] Fix C# nullable-related errors

2021-05-06 Thread Marek Kurdej via cfe-commits

Author: Eliza Velasquez
Date: 2021-05-06T12:11:15+02:00
New Revision: ec725b307f3fdc5656459047bab6e69669d9534f

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

LOG: [clang-format] Fix C# nullable-related errors

This fixes two errors:

Previously, clang-format was splitting up type identifiers from the
nullable ?. This changes this behavior so that the type name sticks with
the operator.

Additionally, nullable operators attached to return types in interface
functions were not parsed correctly. Digging deeper, it looks like
interface bodies were being parsed differently than classes and structs,
causing MustBeDeclaration to be incorrect for interface members. They
now share the same logic.

One other change is reintroducing the CSharpNullable type independent of
JsTypeOptionalQuestion. Despite having a similar semantic purpose, their
actual syntax differs quite a bit.

Reviewed By: MyDeveloperDay, curdeius

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 95353482467f..fefbf449de41 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -112,6 +112,7 @@ namespace format {
   TYPE(UntouchableMacroFunc)   
\
   TYPE(CSharpStringLiteral)
\
   TYPE(CSharpNamedArgumentColon)   
\
+  TYPE(CSharpNullable) 
\
   TYPE(CSharpNullConditionalLSquare)   
\
   TYPE(CSharpGenericTypeConstraint)
\
   TYPE(CSharpGenericTypeConstraintColon)   
\

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 260d09bbae46..71faca64e0b3 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1078,7 +1078,7 @@ class AnnotatingParser {
 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
  Tok->Next->Next->is(tok::equal))) {
-  Tok->setType(TT_JsTypeOptionalQuestion);
+  Tok->setType(TT_CSharpNullable);
   break;
 }
   }
@@ -3161,7 +3161,7 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
   return Style.SpacesInSquareBrackets;
 
 // No space before ? in nullable types.
-if (Right.is(TT_JsTypeOptionalQuestion))
+if (Right.is(TT_CSharpNullable))
   return false;
 
 // No space before null forgiving '!'.
@@ -3818,6 +3818,10 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
 // Only break after commas for generic type constraints.
 if (Line.First->is(TT_CSharpGenericTypeConstraint))
   return Left.is(TT_CSharpGenericTypeConstraintComma);
+// Keep nullable operators attached to their identifiers.
+if (Right.is(TT_CSharpNullable)) {
+  return false;
+}
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends,
  Keywords.kw_implements))

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index e424fcb34219..72cbf3de78fb 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1316,15 +1316,7 @@ void UnwrappedLineParser::parseStructuralElement() {
 case tok::kw_struct:
 case tok::kw_union:
 case tok::kw_class:
-  // parseRecord falls through and does not yet add an unwrapped line as a
-  // record declaration or definition can start a structural element.
-  parseRecord();
-  // This does not apply for Java, JavaScript and C#.
-  if (Style.Language == FormatStyle::LK_Java ||
-  Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
-if (FormatTok->is(tok::semi))
-  nextToken();
-addUnwrappedLine();
+  if (parseStructLike()) {
 return;
   }
   break;
@@ -1438,6 +1430,13 @@ void UnwrappedLineParser::parseStructuralElement() {
 return;
   }
 
+  if (FormatTok->is(Keywords.kw_interface)) {
+if (parseStructLike()) {
+  return;
+}
+break;
+  }
+
   if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
 

[PATCH] D101860: [clang-format] Fix C# nullable-related errors

2021-05-06 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec725b307f3f: [clang-format] Fix C# nullable-related errors 
(authored by exv, committed by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101860

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -848,6 +848,21 @@
   verifyFormat(R"(var x = (int?)y;)", Style); // Cast to a nullable type.
 
   verifyFormat(R"(var x = new MyContainer();)", Style); // Generics.
+
+  verifyFormat(R"(//
+public interface I {
+  int? Function();
+})",
+   Style); // Interface methods.
+
+  Style.ColumnLimit = 10;
+  verifyFormat(R"(//
+public VeryLongType? Function(
+int arg1,
+int arg2) {
+  //
+})",
+   Style); // ? sticks with identifier.
 }
 
 TEST_F(FormatTestCSharp, CSharpArraySubscripts) {
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -114,6 +114,7 @@
   void parseNew();
   void parseAccessSpecifier();
   bool parseEnum();
+  bool parseStructLike();
   void parseConcept();
   void parseRequires();
   void parseRequiresExpression(unsigned int OriginalLevel);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1316,15 +1316,7 @@
 case tok::kw_struct:
 case tok::kw_union:
 case tok::kw_class:
-  // parseRecord falls through and does not yet add an unwrapped line as a
-  // record declaration or definition can start a structural element.
-  parseRecord();
-  // This does not apply for Java, JavaScript and C#.
-  if (Style.Language == FormatStyle::LK_Java ||
-  Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
-if (FormatTok->is(tok::semi))
-  nextToken();
-addUnwrappedLine();
+  if (parseStructLike()) {
 return;
   }
   break;
@@ -1438,6 +1430,13 @@
 return;
   }
 
+  if (FormatTok->is(Keywords.kw_interface)) {
+if (parseStructLike()) {
+  return;
+}
+break;
+  }
+
   if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
 parseStatementMacro();
 return;
@@ -2525,6 +2524,21 @@
   // "} n, m;" will end up in one unwrapped line.
 }
 
+bool UnwrappedLineParser::parseStructLike() {
+  // parseRecord falls through and does not yet add an unwrapped line as a
+  // record declaration or definition can start a structural element.
+  parseRecord();
+  // This does not apply to Java, JavaScript and C#.
+  if (Style.Language == FormatStyle::LK_Java ||
+  Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
+if (FormatTok->is(tok::semi))
+  nextToken();
+addUnwrappedLine();
+return true;
+  }
+  return false;
+}
+
 namespace {
 // A class used to set and restore the Token position when peeking
 // ahead in the token source.
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1078,7 +1078,7 @@
 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
  Tok->Next->Next->is(tok::equal))) {
-  Tok->setType(TT_JsTypeOptionalQuestion);
+  Tok->setType(TT_CSharpNullable);
   break;
 }
   }
@@ -3161,7 +3161,7 @@
   return Style.SpacesInSquareBrackets;
 
 // No space before ? in nullable types.
-if (Right.is(TT_JsTypeOptionalQuestion))
+if (Right.is(TT_CSharpNullable))
   return false;
 
 // No space before null forgiving '!'.
@@ -3818,6 +3818,10 @@
 // Only break after commas for generic type constraints.
 if (Line.First->is(TT_CSharpGenericTypeConstraint))
   return Left.is(TT_CSharpGenericTypeConstraintComma);
+// Keep nullable operators attached to their identifiers.
+if (Right.is(TT_CSharpNullable)) {
+  return false;
+}
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends,
  Keywords.kw_implements))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib

[clang] cdf3396 - [clang-format] Rename common types between C#/JS

2021-05-06 Thread Marek Kurdej via cfe-commits

Author: Eliza Velasquez
Date: 2021-05-06T12:12:58+02:00
New Revision: cdf33962d9768fbd8d6b193aff463a21eaa984f3

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

LOG: [clang-format] Rename common types between C#/JS

Reviewed By: curdeius

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index fefbf449de41..2a06b6f2f7e6 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -46,6 +46,7 @@ namespace format {
   TYPE(DesignatedInitializerLSquare)   
\
   TYPE(DesignatedInitializerPeriod)
\
   TYPE(DictLiteral)
\
+  TYPE(FatArrow)   
\
   TYPE(ForEachMacro)   
\
   TYPE(FunctionAnnotationRParen)   
\
   TYPE(FunctionDeclarationName)
\
@@ -61,17 +62,12 @@ namespace format {
   TYPE(JsComputedPropertyName) 
\
   TYPE(JsExponentiation)   
\
   TYPE(JsExponentiationEqual)  
\
-  TYPE(JsFatArrow) 
\
-  TYPE(JsNonNullAssertion) 
\
-  TYPE(JsNullishCoalescingOperator)
\
-  TYPE(JsNullPropagatingOperator)  
\
+  TYPE(JsPipePipeEqual)
\
   TYPE(JsPrivateIdentifier)
\
   TYPE(JsTypeColon)
\
   TYPE(JsTypeOperator) 
\
   TYPE(JsTypeOptionalQuestion) 
\
   TYPE(JsAndAndEqual)  
\
-  TYPE(JsPipePipeEqual)
\
-  TYPE(JsNullishCoalescingEqual)   
\
   TYPE(LambdaArrow)
\
   TYPE(LambdaLBrace)   
\
   TYPE(LambdaLSquare)  
\
@@ -80,6 +76,10 @@ namespace format {
   TYPE(MacroBlockBegin)
\
   TYPE(MacroBlockEnd)  
\
   TYPE(NamespaceMacro) 
\
+  TYPE(NonNullAssertion)   
\
+  TYPE(NullCoalescingEqual)
\
+  TYPE(NullCoalescingOperator) 
\
+  TYPE(NullPropagatingOperator)
\
   TYPE(ObjCBlockLBrace)
\
   TYPE(ObjCBlockLParen)
\
   TYPE(ObjCDecl)   
\

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index b6825c3ec982..0faa18c34828 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -99,15 +99,14 @@ void FormatTokenLexer::tryMergePreviousTokens() {
  tok::period};
 static const tok::TokenKind FatArrow[] = {tok::equal, tok::greater};
 
-if (tryMergeTokens(FatArrow, TT_JsFatArrow))
+if (tryMergeTokens(FatArrow, TT_FatArrow))
   return;
-if (tryMergeTokens(NullishCoalescingOperator,
-   TT_JsNullishCoalescingOperator)) {
+if (tryMergeTokens(NullishCoalescingOperator, TT_NullCoalescingOperator)) {
   // Treat like the "||" operator (as opposed to the ternary ?).
   Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
 }
-if (tryMergeTokens(NullPropagatingOperator, TT_JsNullPropagatingOperator)) 
{
+if (tryMergeTokens(NullPropagatingOperator, TT_NullPropagatingOperator)) {
   // Tr

[PATCH] D101862: [clang-format] Rename common types between C#/JS

2021-05-06 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcdf33962d976: [clang-format] Rename common types between 
C#/JS (authored by exv, committed by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101862

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1480,9 +1480,9 @@
 }
 case tok::equal:
   // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
-  // TT_JsFatArrow. The always start an expression or a child block if
+  // TT_FatArrow. The always start an expression or a child block if
   // followed by a curly.
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 nextToken();
 if (FormatTok->is(tok::l_brace)) {
   // C# may break after => if the next character is a newline.
@@ -1588,7 +1588,7 @@
   --Line->Level;
   break;
 case tok::equal:
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 ++Line->Level;
 do {
   nextToken();
@@ -1791,7 +1791,7 @@
   // replace this by using parseAssigmentExpression() inside.
   do {
 if (Style.isCSharp()) {
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 nextToken();
 // Fat arrows can be followed by simple expressions or by child blocks
 // in curly braces.
@@ -1807,7 +1807,7 @@
 tryToParseJSFunction();
 continue;
   }
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 nextToken();
 // Fat arrows can be followed by simple expressions or by child blocks
 // in curly braces.
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1365,7 +1365,7 @@
 if (!CurrentToken->isOneOf(
 TT_LambdaLSquare, TT_LambdaLBrace, TT_AttributeMacro,
 TT_ForEachMacro, TT_TypenameMacro, TT_FunctionLBrace,
-TT_ImplicitStringLiteral, TT_InlineASMBrace, TT_JsFatArrow,
+TT_ImplicitStringLiteral, TT_InlineASMBrace, TT_FatArrow,
 TT_LambdaArrow, TT_NamespaceMacro, TT_OverloadedOperator,
 TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral,
 TT_UntouchableMacroFunc, TT_ConstraintJunctions,
@@ -1578,13 +1578,13 @@
 tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
 Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
-  Current.setType(TT_JsNonNullAssertion);
+  Current.setType(TT_NonNullAssertion);
   return;
 }
   }
   if (Current.Next &&
   Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
-Current.setType(TT_JsNonNullAssertion);
+Current.setType(TT_NonNullAssertion);
 return;
   }
 }
@@ -2174,7 +2174,7 @@
 return prec::Assignment;
   if (Current->is(TT_LambdaArrow))
 return prec::Comma;
-  if (Current->is(TT_JsFatArrow))
+  if (Current->is(TT_FatArrow))
 return prec::Assignment;
   if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName) ||
   (Current->is(tok::comment) && NextNonComment &&
@@ -3145,7 +3145,7 @@
   return true;
 
 // Spaces around '=>'.
-if (Left.is(TT_JsFatArrow) || Right.is(TT_JsFatArrow))
+if (Left.is(TT_FatArrow) || Right.is(TT_FatArrow))
   return true;
 
 // No spaces around attribute target colons
@@ -3165,7 +3165,7 @@
   return false;
 
 // No space before null forgiving '!'.
-if (Right.is(TT_JsNonNullAssertion))
+if (Right.is(TT_NonNullAssertion))
   return false;
 
 // No space between consecutive commas '[,,]'.
@@ -3193,7 +3193,7 @@
 Right.is(tok::l_paren))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(TT_JsFatArrow))
+if (Left.is(TT_FatArrow))
   return true;
 // for await ( ...
 if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) && Left.Previous &&
@@ -3204,7 +3204,7 @@
   const FormatToken *Next = Right.MatchingParen->getNextNonComment();
   // An async arrow function, for example: `x = async () => foo();`,
   // as opposed to calling a function called async: `x = async();`
-  if (Next && Next->is(TT_JsFatArrow))
+  if (Next && Next->is(TT_FatArrow))
 return true;
 }
 if ((Left.is(TT_TemplateString) && Left.TokenText.en

[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Andy Wingo via Phabricator via cfe-commits
wingo marked an inline comment as done.
wingo added a comment.

Thanks for the review!

Regarding the address space name -- the intention with "object" was to rhyme a 
bit with "object capabilities", somehow, but I see that it is confusing.

How about `WASM_ADDRESS_SPACE_MANAGED` ?  I.e. this address space is for 
"managed" variables.  Doesn't mean that the variables are under GC control 
(though they may be), but rather that the wasm implementation manages their 
storage itself, instead of having them be in linear memory.  Will post a 
renamed patch, lmk what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Andy Wingo via Phabricator via cfe-commits
wingo added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISD.def:48
+
+// Reference Types
+HANDLE_MEM_NODETYPE(GLOBAL_GET)

tlively wrote:
> sbc100 wrote:
> > Is this just for ref types or also for global that hold integers too (like 
> > `__stack_pointer`)
> Yep, it's for arbitrary types (see the tests), so this comment should be 
> updated.
FWIW I think you would be able to define `__stack_pointer` from IR via
```
@__stack_pointer = external addrspace(1) global i32
```

and then to use it:

```
%current_sp = load i32, i32 addrspace(1)* @__stack_pointer
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 343344.
wingo added a comment.

Rename "object" address space to "managed"; address feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/global-get.ll
  llvm/test/CodeGen/WebAssembly/global-set.ll

Index: llvm/test/CodeGen/WebAssembly/global-set.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-set.ll
@@ -0,0 +1,57 @@
+; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define void @set_i32_global(i32 %v) {
+; CHECK-LABEL: set_i32_global:
+; CHECK-NEXT: functype   set_i32_global (i32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i32_global
+; CHECK-NEXT: end_function
+  store i32 %v, i32 addrspace(1)* @i32_global
+  ret void
+}
+
+define void @set_i64_global(i64 %v) {
+; CHECK-LABEL: set_i64_global:
+; CHECK-NEXT: functype   set_i64_global (i64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i64_global
+; CHECK-NEXT: end_function
+  store i64 %v, i64 addrspace(1)* @i64_global
+  ret void
+}
+
+define void @set_f32_global(float %v) {
+; CHECK-LABEL: set_f32_global:
+; CHECK-NEXT: functype   set_f32_global (f32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f32_global
+; CHECK-NEXT: end_function
+  store float %v, float addrspace(1)* @f32_global
+  ret void
+}
+
+define void @set_f64_global(double %v) {
+; CHECK-LABEL: set_f64_global:
+; CHECK-NEXT: functype   set_f64_global (f64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f64_global
+; CHECK-NEXT: end_function
+  store double %v, double addrspace(1)* @f64_global
+  ret void
+}
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/test/CodeGen/WebAssembly/global-get.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-get.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define i32 @return_i32_global() {
+; CHECK-LABEL: return_i32_global:
+; CHECK-NEXT: functype   return_i32_global () -> (i32)
+; CHECK-NEXT: global.get i32_global
+; CHECK-NEXT: end_function
+  %v = load i32, i32 addrspace(1)* @i32_global
+  ret i32 %v
+}
+
+define i64 @return_i64_global() {
+; CHECK-LABEL: return_i64_global:
+; CHECK-NEXT: functype   return_i64_global () -> (i64)
+; CHECK-NEXT: global.get i64_global
+; CHECK-NEXT: end_function
+  %v = load i64, i64 addrspace(1)* @i64_global
+  ret i64 %v
+}
+
+define float @return_f32_global() {
+; CHECK-LABEL: return_f32_global:
+; CHECK-NEXT: functype   return_f32_global () -> (f32)
+; CHECK-NEXT: global.get f32_global
+; CHECK-NEXT: end_function
+  %v = load float, float addrspace(1)* @f32_global
+  ret float %v
+}
+
+define double @return_f64_global() {
+; CHECK-LABEL: return_f64_global:
+; CHECK-NEXT: functype   return_f64_global () -> (f64)
+; CHECK-NEXT: global.get f64_global
+; CHECK-NEXT: end_function
+  %v = load double, double addrspace(1)* @f64_global
+  ret double %v
+}
+
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHEC

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D101462#2733726 , @flip1995 wrote:

>> I'll keep this open for a few days as it touches too many things.
>
> Sounds good 👍
>
>> but you'll need to provide your name and email
>
> ~~I used `arc diff`. The commits I made with `git` have my name and email 
> attached. But it seems like `arc` doesn't use them? I'll figure it out 
> tomorrow, can't be that hard, I hope.~~
>
> Ah you just need that to commit it. In that case: "Philipp Krones 
> "

Pushed:) You are right. A diff applied with `arc diff` can be fetched locally 
with `arc patch D101462` with the author information.
(Sometimes `arc patch` fail refuse to apply and then I'll have no idea how to 
get the author information.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-06 Thread Fangrui Song 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 rG632ebc4ab437: [MC] Untangle MCContext and MCObjectFileInfo 
(authored by flip1995, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -169,8 +169,8 @@
   mai->setRelaxELFRelocations(true);
 
   llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.InitMCObjectFileInfo(triple, false, ctx, false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
+  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -112,9 +112,9 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(
-new MCContext(MUPMAI.get(), MRI.get(), &MOFI, &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(Triple, false, *Ctx, false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
+&SrcMgr, &MCOptions));
+MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 struct Context {
-  const char *Triple = "x86_64-pc-linux";
+  const char *TripleName = "x86_64-pc-linux";
   std::unique_ptr MRI;
   std::unique_ptr MAI;
   std::unique_ptr Ctx;
@@ -33,14 +33,15 @@
 
 // If we didn't build x86, do not run the test.
 std::string Error;
-const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
+const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
 if (!TheTarget)
   return;
 
-MRI.reset(TheTarget->createMCRegInfo(Triple));
+MRI.reset(TheTarget->createMCRegInfo(TripleName));
 MCTargetOptions MCOptions;
-MAI.reset(TheTarget->createMCAsmInfo(*MRI, Triple, MCOptions));
-Ctx = std::make_unique(MAI.get(), MRI.get(), nullptr);
+MAI.reset(TheTarg

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-06 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D101462#2739404 , @MaskRay wrote:

> In D101462#2733726 , @flip1995 
> wrote:
>
>>> I'll keep this open for a few days as it touches too many things.
>>
>> Sounds good 👍
>>
>>> but you'll need to provide your name and email
>>
>> ~~I used `arc diff`. The commits I made with `git` have my name and email 
>> attached. But it seems like `arc` doesn't use them? I'll figure it out 
>> tomorrow, can't be that hard, I hope.~~
>>
>> Ah you just need that to commit it. In that case: "Philipp Krones 
>> "
>
> Pushed:) You are right. A diff applied with `arc diff` can be fetched locally 
> with `arc patch D101462` with the author information.
> (Sometimes `arc patch` fail refuse to apply and then I'll have no idea how to 
> get the author information.)

`arc amend` lets you replace the metadata with the same thing `arc patch` adds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-05-06 Thread C. Bland via Phabricator via cfe-commits
blandcr added a comment.

@jakar I did a bit of sleuthing (google `catskul github`, which I feel a little 
weird about but whatever) and I think I found their changes in a fork:
https://github.com/catskul/llvm-project/tree/catskul/dangling-parenthesis-as-bracket-alignment
It seems there are a few different branches that might be what you're looking 
for. I think what probably happened was they never received a response for what 
to rebase the changes off of so this end up falling by the wayside.

@catskul I'm not sure what the proper etiquette is for this kind of searching 
but given the easily associated identity I'm going to assume it's probably OK. 
If you do want me to edit the comment to remove the link to your GH profile 
just let me know.


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

https://reviews.llvm.org/D33029

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


[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-06 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie updated this revision to Diff 343346.
OikawaKirie added a comment.

In D101763#2741536 , @steakhal wrote:

> Overall, it looks promising. But I don't quite get this test.
> There is no invocation yaml in the temp directory. So, you are probably not 
> testing the right thing.
> You wanted to test if the invocation yaml exists, and could be opened **but 
> the parsing fails**.
> You should demonstrate that when a parsing error happens, the error code has 
> recoded and it won't try to reparse the invocation yaml again and again.

The main idea of the test case is that the mocked `open` function will dump a 
log every time when the invocation list file is opened to be read. If a second 
open operation is detected in the log, it means the list is parsed again.

As the behavior of missing the invocation list file or failing to parse it are 
the same (both returns the error), the previous version checks whether function 
`open` will be called again after a file-not-found error.
In this update, I use an empty invocation list to really trigger an 
`invocation_list_empty` error and check whether the invocation list file will 
be read again via function `open`.
Compared with the previous version, opening the invocation list will not be 
manually failed, and a real parsing error is triggered instead.


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

https://reviews.llvm.org/D101763

Files:
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/test/Analysis/multiple-invocation-list-parsing.cpp

Index: clang/test/Analysis/multiple-invocation-list-parsing.cpp
===
--- /dev/null
+++ clang/test/Analysis/multiple-invocation-list-parsing.cpp
@@ -0,0 +1,56 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// Compile the mocked `open` function.
+// RUN: %host_cxx %s -fPIC -shared -o %t/mock_open.so
+
+// RUN: echo "void bar(); void foo() { bar(); bar(); }" > %t/importer.c
+// RUN: echo "void bar() {}" > %t/importee.c
+// RUN: echo '[{"directory":"%t", "command":"cc -c %t/importee.c", "file":"%t/importee.c"}]' > %t/compile_commands.json
+// RUN: %clang_extdef_map -p %t "%t/importee.c" > %t/externalDefMap.txt
+// RUN: echo "" > %t/invocations.yaml
+
+// Run the test code.
+// RUN: LD_PRELOAD=%t/mock_open.so \
+// RUN: %clang_cc1 -fsyntax-only -analyze \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t \
+// RUN:   -analyzer-config ctu-invocation-list=invocations.yaml \
+// RUN:   %t/importer.c | FileCheck %s
+
+// REQUIRES: shell, system-linux
+
+// Check the log for the second open of the invocation list.
+// CHECK: {{Mocking file invocations.yaml: 1}}
+// CHECK-NOT: {{Mocking file invocations.yaml: 2}}
+
+#define _GNU_SOURCE 1
+#include 
+#include 
+
+#include 
+#include 
+#include 
+using namespace std;
+
+extern "C" int open(const char *name, int flag, ...) {
+  // Log how many times the invocation list is opened.
+  if ("invocations.yaml" == string(name)) {
+static unsigned N = 0;
+cout << "Mocking file invocations.yaml: " << ++N << endl;
+  }
+
+  // The original open function will be called to open the files.
+  using open_t = int (*)(const char *, int, mode_t);
+  static open_t o_open = nullptr;
+  if (!o_open)
+o_open = reinterpret_cast(dlsym(RTLD_NEXT, "open"));
+  assert(o_open && "Cannot find function `open'.");
+
+  va_list vl;
+  va_start(vl, flag);
+  auto mode = va_arg(vl, mode_t);
+  va_end(vl);
+  return o_open(name, flag, mode);
+}
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -667,12 +667,15 @@
   /// Lazily initialize the invocation list member used for on-demand parsing.
   if (InvocationList)
 return llvm::Error::success();
+  else if (index_error_code::success != PreviousParsingResult)
+return llvm::make_error(PreviousParsingResult);
 
   llvm::ErrorOr> FileContent =
   llvm::MemoryBuffer::getFile(InvocationListFilePath);
-  if (!FileContent)
-return llvm::make_error(
-index_error_code::invocation_list_file_not_found);
+  if (!FileContent) {
+PreviousParsingResult = index_error_code::invocation_list_file_not_found;
+return llvm::make_error(PreviousParsingResult);
+  }
   std::unique_ptr ContentBuffer = std::move(*FileContent);
   assert(ContentBuffer && "If no error was produced after loading, the pointer "
   "should not be nullptr.");
@@ -680,8 +683,13 @@
   llvm::Expected ExpectedInvocationList =
   parseInvocationList(ContentBuffer->getBuffer(), PathStyle);
 
-  if (!ExpectedInvocationList)
-return ExpectedInvocationList.takeError();
+  // Handle the error to store the code for ne

[PATCH] D101986: [InstSimplify] Remove redundant {insert,extract}_vector intrinsic chains

2021-05-06 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis created this revision.
joechrisellis added reviewers: bsmith, DavidTruby, peterwaller-arm.
Herald added a subscriber: hiraditya.
joechrisellis requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This commit removes some redundant {insert,extract}_vector intrinsic
chains by implementing the following patterns as instsimplifies:

  (insert_vector _, (extract_vector X, 0), 0) -> X
  (extract_vector (insert_vector _, X, 0), 0) -> X


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101986

Files:
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/extract-vector.ll
  llvm/test/Transforms/InstSimplify/insert-vector.ll

Index: llvm/test/Transforms/InstSimplify/insert-vector.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/insert-vector.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define  @redundant_extract_insert_chain( %pg,  %x) {
+; CHECK-LABEL: @redundant_extract_insert_chain(
+; CHECK-NEXT:ret  [[X:%.*]]
+;
+  %extracted = call <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv16i8( %x, i64 0)
+  %inserted = call  @llvm.experimental.vector.insert.nxv16i8.v32i8( undef, <32 x i8> %extracted, i64 0)
+  ret  %inserted
+}
+
+define  @non_redundant_extract_insert_chain( %pg,  %x) {
+; CHECK-LABEL: @non_redundant_extract_insert_chain(
+; CHECK-NEXT:[[EXTRACTED:%.*]] = call <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv32i8( [[X:%.*]], i64 0)
+; CHECK-NEXT:[[INSERTED:%.*]] = call  @llvm.experimental.vector.insert.nxv16i8.v32i8( undef, <32 x i8> [[EXTRACTED]], i64 0)
+; CHECK-NEXT:ret  [[INSERTED]]
+;
+  %extracted = call <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv32i8( %x, i64 0)
+  %inserted = call  @llvm.experimental.vector.insert.nxv16i8.v32i8( undef, <32 x i8> %extracted, i64 0)
+  ret  %inserted
+}
+
+declare <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv16i8(, i64)
+declare <32 x i8> @llvm.experimental.vector.extract.v32i8.nxv32i8(, i64)
+declare  @llvm.experimental.vector.insert.nxv16i8.v32i8(, <32 x i8>, i64)
Index: llvm/test/Transforms/InstSimplify/extract-vector.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/extract-vector.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define <16 x i8> @redundant_insert_extract_chain(<16 x i8> %x) {
+; CHECK-LABEL: @redundant_insert_extract_chain(
+; CHECK-NEXT:ret <16 x i8> [[X:%.*]]
+;
+  %inserted = call  @llvm.experimental.vector.insert.nxv32i8.v16i8( undef, <16 x i8> %x, i64 0)
+  %extracted = call <16 x i8> @llvm.experimental.vector.extract.v16i8.nxv32i8( %inserted, i64 0)
+  ret <16 x i8> %extracted
+}
+
+define <8 x i8> @non_redundant_insert_extract_chain(<16 x i8> %x) {
+; CHECK-LABEL: @non_redundant_insert_extract_chain(
+; CHECK-NEXT:[[INSERTED:%.*]] = call  @llvm.experimental.vector.insert.nxv32i8.v16i8( undef, <16 x i8> [[X:%.*]], i64 0)
+; CHECK-NEXT:[[EXTRACTED:%.*]] = call <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv32i8( [[INSERTED]], i64 0)
+; CHECK-NEXT:ret <8 x i8> [[EXTRACTED]]
+;
+  %inserted = call  @llvm.experimental.vector.insert.nxv32i8.v16i8( undef, <16 x i8> %x, i64 0)
+  %extracted = call <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv32i8( %inserted, i64 0)
+  ret <8 x i8> %extracted
+}
+
+declare <16 x i8> @llvm.experimental.vector.extract.v16i8.nxv32i8(, i64)
+declare <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv32i8(, i64)
+declare  @llvm.experimental.vector.insert.nxv32i8.v16i8(, <16 x i8>, i64)
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5625,6 +5625,19 @@
 
 break;
   }
+  case Intrinsic::experimental_vector_extract: {
+Type *ReturnType = F->getReturnType();
+
+// (extract_vector (insert_vector _, X, 0), 0) -> X
+unsigned IdxN = cast(Op1)->getZExtValue();
+Value *X = nullptr;
+if (match(Op0, m_Intrinsic(
+   m_Value(), m_Value(X), m_Zero())) &&
+IdxN == 0 && X->getType() == ReturnType)
+  return X;
+
+break;
+  }
   default:
 break;
   }
@@ -5720,6 +5733,21 @@
 
 return nullptr;
   }
+  case Intrinsic::experimental_vector_insert: {
+Value *SubVec = Call->getArgOperand(1);
+Value *Idx = Call->getArgOperand(2);
+Type *ReturnType = F->getReturnType();
+
+// (insert_vector _, (extract_vector X, 0), 0) -> X
+unsigned IdxN = cast(Idx)->get

[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Okay, so you 'just' want an indication for the given open call. What about 
using `strace`?
`strace -e trace=openat %clang_cc1 ... 2>&1 | grep '"invocations.yaml"' | 
FileCheck %s`

This way the given test file could contain the contents of the `importer.c`.


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

https://reviews.llvm.org/D101763

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


[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

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

LGTM!




Comment at: clang-tools-extra/clang-tidy/utils/Aliasing.cpp:45-48
+return llvm::any_of(LE->captures(), [Var](const LambdaCapture &C) {
+  return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&
+ C.getCapturedVar() == Var;
+});

NoQ wrote:
> aaron.ballman wrote:
> > Should this use `capturesByRef()` from https://reviews.llvm.org/D101787?
> Yes and https://reviews.llvm.org/D101787 already converts this code to use 
> `capturesByRef()` as soon as it introduces it!
Ah! It wasn't clear to me that's how this patch was stacking up, thanks for the 
explanation.


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

https://reviews.llvm.org/D96215

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


[PATCH] D101787: [clang-tidy] Aliasing: Add more support for lambda captures.

2021-05-06 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!


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

https://reviews.llvm.org/D101787

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


[PATCH] D101973: [OpenMP][NFC] Remove SIMD check lines for non-simd tests

2021-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101973

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


[PATCH] D101790: [clang-tidy] Aliasing: Add support for passing the variable into a function by reference.

2021-05-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I agree that all the comments labeled `FIXME` are ones where I'd expect to see 
the diagnostic triggered.


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

https://reviews.llvm.org/D101790

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu:65-68
+  asm volatile("barrier.sync %0;"
+   :
+   : "r"(barrier)
+   : "memory");

Why not `__syncthreads`? It is safer to use `__syncthreads` as it is 
`convergent`. Would be good to mark this code somehow as `convergent` too to 
avoid incorrect optimizations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

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


[PATCH] D101926: [amdgpu-arch] Fix rpath to run from build dir

2021-05-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

It does indeed fix that comment from D99949 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101926

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 343360.
wingo added a comment.

yarr, shiver me timbers, fix me typos


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/global-get.ll
  llvm/test/CodeGen/WebAssembly/global-set.ll

Index: llvm/test/CodeGen/WebAssembly/global-set.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-set.ll
@@ -0,0 +1,57 @@
+; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define void @set_i32_global(i32 %v) {
+; CHECK-LABEL: set_i32_global:
+; CHECK-NEXT: functype   set_i32_global (i32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i32_global
+; CHECK-NEXT: end_function
+  store i32 %v, i32 addrspace(1)* @i32_global
+  ret void
+}
+
+define void @set_i64_global(i64 %v) {
+; CHECK-LABEL: set_i64_global:
+; CHECK-NEXT: functype   set_i64_global (i64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i64_global
+; CHECK-NEXT: end_function
+  store i64 %v, i64 addrspace(1)* @i64_global
+  ret void
+}
+
+define void @set_f32_global(float %v) {
+; CHECK-LABEL: set_f32_global:
+; CHECK-NEXT: functype   set_f32_global (f32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f32_global
+; CHECK-NEXT: end_function
+  store float %v, float addrspace(1)* @f32_global
+  ret void
+}
+
+define void @set_f64_global(double %v) {
+; CHECK-LABEL: set_f64_global:
+; CHECK-NEXT: functype   set_f64_global (f64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f64_global
+; CHECK-NEXT: end_function
+  store double %v, double addrspace(1)* @f64_global
+  ret void
+}
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/test/CodeGen/WebAssembly/global-get.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-get.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define i32 @return_i32_global() {
+; CHECK-LABEL: return_i32_global:
+; CHECK-NEXT: functype   return_i32_global () -> (i32)
+; CHECK-NEXT: global.get i32_global
+; CHECK-NEXT: end_function
+  %v = load i32, i32 addrspace(1)* @i32_global
+  ret i32 %v
+}
+
+define i64 @return_i64_global() {
+; CHECK-LABEL: return_i64_global:
+; CHECK-NEXT: functype   return_i64_global () -> (i64)
+; CHECK-NEXT: global.get i64_global
+; CHECK-NEXT: end_function
+  %v = load i64, i64 addrspace(1)* @i64_global
+  ret i64 %v
+}
+
+define float @return_f32_global() {
+; CHECK-LABEL: return_f32_global:
+; CHECK-NEXT: functype   return_f32_global () -> (f32)
+; CHECK-NEXT: global.get f32_global
+; CHECK-NEXT: end_function
+  %v = load float, float addrspace(1)* @f32_global
+  ret float %v
+}
+
+define double @return_f64_global() {
+; CHECK-LABEL: return_f64_global:
+; CHECK-NEXT: functype   return_f64_global () -> (f64)
+; CHECK-NEXT: global.get f64_global
+; CHECK-NEXT: end_function
+  %v = load double, double addrspace(1)* @f64_global
+  ret double %v
+}
+
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_globa

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-05-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

I could not find anything in the cmake files which could point to the issue 
mentioned here. @davezarzycki, are you on fedora/redhat?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D77598: Integral template argument suffix and cast printing

2021-05-06 Thread Pratyush Das via Phabricator via cfe-commits
reikdas updated this revision to Diff 343363.
reikdas added a comment.

Address @rsmith comments


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

https://reviews.llvm.org/D77598

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/StmtDataCollectors.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/Analysis/eval-predefined-exprs.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p12.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p13.cpp
  clang/test/CodeGenCXX/debug-info-codeview-template-literal.cpp
  clang/test/CodeGenCXX/debug-info-codeview-template-type.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/cxx1z-ast-print.cpp
  clang/test/SemaCXX/matrix-type-builtins.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/test/SemaTemplate/delegating-constructors.cpp
  clang/test/SemaTemplate/matrix-type.cpp
  clang/test/SemaTemplate/temp_arg_enum_printing.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/tools/libclang/CIndex.cpp
  
clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
@@ -20,7 +20,7 @@
 llvm::raw_string_ostream Stream(ArgStr);
 const TemplateArgument &Arg = ArgLoc.getArgument();
 
-Arg.print(Context->getPrintingPolicy(), Stream);
+Arg.print(Context->getPrintingPolicy(), Stream, /*IncludeType*/ true);
 Match(Stream.str(), ArgLoc.getLocation());
 return ExpectedLocationVisitor::
   TraverseTemplateArgumentLoc(ArgLoc);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5185,8 +5185,9 @@
 SmallString<128> Str;
 llvm::raw_svector_ostream OS(Str);
 OS << *ClassSpec;
-printTemplateArgumentList(OS, ClassSpec->getTemplateArgs().asArray(),
-  Policy);
+printTemplateArgumentList(
+OS, ClassSpec->getTemplateArgs().asArray(), Policy,
+ClassSpec->getSpecializedTemplate()->getTemplateParameters());
 return cxstring::createDup(OS.str());
   }
 
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -528,3 +528,33 @@
 x1.f(x2);
   }
 }
+
+namespace TypeSuffix {
+  template  struct A {};
+  template <> struct A<1> { using type = int; }; // expected-note {{'A<1>::type' declared here}}
+  A<1L>::type a; // expected-error {{no type named 'type' in 'TypeSuffix::A<1L>'; did you mean 'A<1>::type'?}}
+
+  template  struct B {};
+  template <> struct B<1> { using type = int; }; // expected-note {{'B<1>::type' declared here}}
+  B<2>::type b;  // expected-error {{no type named 'type' in 'TypeSuffix::B<2>'; did you mean 'B<1>::type'?}}
+
+  template  struct C {};
+  template <> struct C<'a'> { using type = signed char; }; // expected-note {{'C<'a'>::type' declared here}}
+  C<(signed char)'a'>::type c; // expected-error {{no type named 'type' in 'TypeSuffix::C<(signed char)'a'>'; did you mean 'C<'a'>::type'?}}
+
+  template  struct D {};
+  template <> struct D<'a'> { using type = signed char; }; // expected-note {{'D<'a'>::type' declared here}}
+  D<'b'>::type d;  // expected-error {{no type named 'type' in 'TypeSuffix::D<'b'>'; did you mean 'D<'a'>::type'?}}
+
+  template  struct E {};
+  template <> struct E<'a'> { using type = unsigned char; }; // expected-note {{'E<'a'>::type' declared here}}
+  E<(unsigned char)'a'>::type e; // expected-error {{no type named 'type' in 'TypeSuffix::E<(unsigned char)'a'>'; did you mean 'E<'a'>::type'?}}
+
+  template  struct F {};
+  template <> struct F<'a'> { using type = unsi

[clang] b24e9f8 - [amdgpu-arch] Fix rpath to run from build dir

2021-05-06 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-05-06T13:07:00+01:00
New Revision: b24e9f82b71f325214c41fdc3f106207cc2244a6

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

LOG: [amdgpu-arch] Fix rpath to run from build dir

[amdgpu-arch] Fix rpath to run from build dir

Prior to this, amdgpu-arch has RUNPATH set to $ORIGIN/../lib which works
for some installs, but not from the build directory where clang executes
the tool from when running tests.

This cmake option adds the location of the rocr runtime to the RUNPATH
(note, it amends RUNPATH here, despite the cmake option referring to RPATH)
to create a binary that runs from build or install location.

Before:
RUNPATH [$ORIGIN/../lib]
After:
RUNPATH [$ORIGIN/../lib:$HOME/llvm-install/lib]

Credit to Greg for knowing this trick and pointing to examples of it in use
for the aomp build scripts.

Reviewed By: pdhaliwal

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

Added: 


Modified: 
clang/tools/amdgpu-arch/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/amdgpu-arch/CMakeLists.txt 
b/clang/tools/amdgpu-arch/CMakeLists.txt
index fca58c4060edd..caead440c5ccf 100644
--- a/clang/tools/amdgpu-arch/CMakeLists.txt
+++ b/clang/tools/amdgpu-arch/CMakeLists.txt
@@ -14,4 +14,6 @@ endif()
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
+set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+
 clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)



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


[PATCH] D101926: [amdgpu-arch] Fix rpath to run from build dir

2021-05-06 Thread Jon Chesterfield 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 rGb24e9f82b71f: [amdgpu-arch] Fix rpath to run from build dir 
(authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101926

Files:
  clang/tools/amdgpu-arch/CMakeLists.txt


Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -14,4 +14,6 @@
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
+set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+
 clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)


Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -14,4 +14,6 @@
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
+set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+
 clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-06 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 343367.
wingo added a comment.

Rename "object" to "managed", and add test for stack id


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,76 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ %reloaded = load i32, %i32_cell %retval
+ ; The DAG combiner infers that %reloaded is the same as %arg and
+ ; ultimately causes "local.get 0" to be emitted instead of
+ ; "local.get 1".
+ ; CHECK-NEXT: local.get 0
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 0
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ store float %arg, %f32_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 0
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s --check-prefix=CHECKCG
+; RUN: llc -mtriple=wasm32-unknown-unknown -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECKISEL
+
+%f32_cell = type float addrspace(1)*
+
+; CHECKISEL-LABEL: name: ir_local_f32
+; CHECKISEL:   stack:
+; CHECKISEL:   id: 0, name: retval, type: default, offset: 1, size: 1, alignment: 4,
+; CHECKISEL-NEXT:  stack-id: managed
+
+; CHECKCG-LABEL: ir_local_f32:
+; CHECKCG-NEXT: .functype ir_local_f32 (f32) -> (f32)
+; CHECKCG-NEXT: .local f32
+; CHECKCG-NEXT: local.get 0
+; CHECKCG-NEXT: local.set 1
+
+define float @ir_local_f32(float %arg) {
+ %retval = alloca float, addrspace(1)
+ store float %arg, %f32_cell %retval
+ %reloaded = load float, %f32_cell %retval
+ ret float %reloaded
+}
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -120,8 +120,8 @@
 Optional CM, CodeGenOpt::Level OL, bool JIT)

[PATCH] D101168: [C++4OpenCL] Add clang extension for non-portable kernel parameters

2021-05-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Closed by https://reviews.llvm.org/rGe994e74bca49831eb649e7c67955e9de7a1784b6


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

https://reviews.llvm.org/D101168

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


[clang] c28a602 - [OpenCL] Remove subgroups pragma in enqueue kernel and pipe builtins.

2021-05-06 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-05-06T13:59:38+01:00
New Revision: c28a602329a78db5c02cc85679b5035aaf6753b4

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

LOG: [OpenCL] Remove subgroups pragma in enqueue kernel and pipe builtins.

This patch simplifies the parser and makes the language semantics
consistent. There is no extension pragma requirement in the spec
for the subgroup functions in enqueue kernel or pipes and all other
builtin functions are available without the pragama.

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaOpenCL/cl20-device-side-enqueue.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 38cda657bac8b..415773e62ad52 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -838,8 +838,7 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg) {
 }
 
 static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
-  if (!S.getOpenCLOptions().isAvailableOption("cl_khr_subgroups",
-  S.getLangOpts())) {
+  if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
 S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
 << 1 << Call->getDirectCallee() << "cl_khr_subgroups";
 return true;

diff  --git a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl 
b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
index d25a03504c03a..5cfdfb3cdc5ca 100644
--- a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
@@ -212,8 +213,8 @@ kernel void work_group_size_tests() {
   size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // 
expected-error{{too many arguments to function call, expected 1, have 2}}
 }
 
+#ifdef cl_khr_subgroups
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
-
 kernel void foo(global unsigned int *buf)
 {
   ndrange_t n;
@@ -231,7 +232,7 @@ kernel void bar(global unsigned int *buf)
 }
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : disable
-
+#else
 kernel void foo1(global unsigned int *buf)
 {
   ndrange_t n;
@@ -243,3 +244,4 @@ kernel void bar1(global unsigned int *buf)
   ndrange_t n;
   buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error 
{{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires 
cl_khr_subgroups support}}
 }
+#endif // ifdef cl_khr_subgroups



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


[PATCH] D100984: [OpenCL] Remove the need for subgroups extension pragma in enqueue kernel and pipe builtins

2021-05-06 Thread Anastasia Stulova 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 rGc28a602329a7: [OpenCL] Remove subgroups pragma in enqueue 
kernel and pipe builtins. (authored by Anastasia).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100984

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaOpenCL/cl20-device-side-enqueue.cl


Index: clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
===
--- clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
@@ -212,8 +213,8 @@
   size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // 
expected-error{{too many arguments to function call, expected 1, have 2}}
 }
 
+#ifdef cl_khr_subgroups
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
-
 kernel void foo(global unsigned int *buf)
 {
   ndrange_t n;
@@ -231,7 +232,7 @@
 }
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : disable
-
+#else
 kernel void foo1(global unsigned int *buf)
 {
   ndrange_t n;
@@ -243,3 +244,4 @@
   ndrange_t n;
   buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error 
{{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires 
cl_khr_subgroups support}}
 }
+#endif // ifdef cl_khr_subgroups
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -838,8 +838,7 @@
 }
 
 static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
-  if (!S.getOpenCLOptions().isAvailableOption("cl_khr_subgroups",
-  S.getLangOpts())) {
+  if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
 S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
 << 1 << Call->getDirectCallee() << "cl_khr_subgroups";
 return true;


Index: clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
===
--- clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
@@ -212,8 +213,8 @@
   size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
 }
 
+#ifdef cl_khr_subgroups
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
-
 kernel void foo(global unsigned int *buf)
 {
   ndrange_t n;
@@ -231,7 +232,7 @@
 }
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : disable
-
+#else
 kernel void foo1(global unsigned int *buf)
 {
   ndrange_t n;
@@ -243,3 +244,4 @@
   ndrange_t n;
   buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups support}}
 }
+#endif // ifdef cl_khr_subgroups
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -838,8 +838,7 @@
 }
 
 static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
-  if (!S.getOpenCLOptions().isAvailableOption("cl_khr_subgroups",
-  S.getLangOpts())) {
+  if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
 S.Diag(Call->getBeginLoc(), diag::err_opencl_requ

[clang] d40a0b8 - [TableGen] [Clang] Clean up Options.td and add asserts.

2021-05-06 Thread Paul C. Anagnostopoulos via cfe-commits

Author: Paul C. Anagnostopoulos
Date: 2021-05-06T09:32:25-04:00
New Revision: d40a0b8af771f9b37dd2985fc692443c0ac5473e

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

LOG: [TableGen] [Clang] Clean up Options.td and add asserts.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b17eb50835ff8..78cc0a4e53a5f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -274,10 +274,10 @@ class MigratorOpts
 // Use this only when the option cannot be declared via BoolFOption.
 multiclass OptInFFlag flags=[]> {
-  def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText;
+  def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>,
+   Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-  Group, HelpText;
+  Group, HelpText;
 }
 
 // A boolean option which is opt-out in CC1. The negative option exists in CC1 
and
@@ -286,9 +286,9 @@ multiclass OptInFFlag flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText;
-  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-  Group, HelpText;
+   Group, HelpText;
+  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>,
+  Group, HelpText;
 }
 
 // Creates a positive and negative flags where both of them are prefixed with
@@ -297,9 +297,9 @@ multiclass OptOutFFlag {
   def m#NAME : Flag<["-"], "m"#name>, Group,
-HelpText;
+HelpText;
   def mno_#NAME : Flag<["-"], "mno-"#name>, Group,
-HelpText;
+HelpText;
 }
 
 
//===--===//
@@ -349,8 +349,8 @@ class BothFlags option_flags, string help 
= ""> {
 class ApplySuffix {
   FlagDef Result
 = FlagDef;
+  flag.OptionFlags # suffix.OptionFlags,
+  flag.Help # suffix.Help, flag.ImpliedBy>;
 }
 
 // Definition of the command line flag with positive spelling, e.g. "-ffoo".
@@ -368,16 +368,16 @@ class FlagDefExpanded
   : FlagDef {
   // Name of the TableGen record.
-  string RecordName = prefix#!cond(flag.Polarity : "", true : "no_")#name;
+  string RecordName = prefix # !if(flag.Polarity, "", "no_") # name;
 
   // Spelling of the flag.
-  string Spelling = prefix#!cond(flag.Polarity : "", true : "no-")#spelling;
+  string Spelling = prefix # !if(flag.Polarity, "", "no-") # spelling;
 
   // Can the flag be implied by another flag?
   bit CanBeImplied = !not(!empty(flag.ImpliedBy));
 
   // C++ code that will be assigned to the keypath when the flag is present.
-  code ValueAsCode = !cond(flag.Value : "true", true: "false");
+  code ValueAsCode = !if(flag.Value, "true", "false");
 }
 
 // TableGen record for a single marshalled flag.
@@ -406,11 +406,19 @@ multiclass BoolOption.Result, 
prefix,
  NAME, spelling_base>;
 
-  // TODO: Assert that the flags have 
diff erent polarity.
-  // TODO: Assert that the flags have 
diff erent value.
-  // TODO: Assert that only one of the flags can be implied.
+  // The flags must have 
diff erent polarity, 
diff erent values, and only
+  // one can be implied.
+  assert !xor(flag1.Polarity, flag2.Polarity),
+ "the flags must have 
diff erent polarity: flag1: " #
+ flag1.Polarity # ", flag2: " # flag2.Polarity;
+  assert !ne(flag1.Value, flag2.Value),
+ "the flags must have 
diff erent values: flag1: " #
+ flag1.Value # ", flag2: " # flag2.Value;
+  assert !not(!and(flag1.CanBeImplied, flag2.CanBeImplied)),
+ "only one of the flags can be implied: flag1: " #
+ flag1.CanBeImplied # ", flag2: " # flag2.CanBeImplied;
 
-  defvar implied = !cond(flag1.CanBeImplied: flag1, true: flag2);
+  defvar implied = !if(flag1.CanBeImplied, flag1, flag2);
 
   def flag1.RecordName : MarshalledFlagRec;
   def flag2.RecordName : MarshalledFlagRec;
@@ -1921,8 +1929,9 @@ def flax_vector_conversions_EQ : Joined<["-"], 
"flax-vector-conversions=">, Grou
 "LangOptions::LaxVectorConversionKind::Integer",
 "LangOptions::LaxVectorConversionKind::All"]>,
   MarshallingInfoEnum,
-  !strconcat(open_cl.KeyPath, " ? 
LangOptions::LaxVectorConversionKind::None"
-  " : 
LangOptions::LaxVectorConversionKind::All")>;
+  open_cl.KeyPath #
+  " ? LangOptions::LaxVectorConversionKind::None" #
+  " : LangOptions::LaxVectorConversionKind::All">;

[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-06 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd40a0b8af771: [TableGen] [Clang] Clean up Options.td and add 
asserts. (authored by Paul-C-Anagnostopoulos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101766

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -274,10 +274,10 @@
 // Use this only when the option cannot be declared via BoolFOption.
 multiclass OptInFFlag flags=[]> {
-  def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText;
+  def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>,
+   Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-  Group, HelpText;
+  Group, HelpText;
 }
 
 // A boolean option which is opt-out in CC1. The negative option exists in CC1 and
@@ -286,9 +286,9 @@
 multiclass OptOutFFlag flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText;
-  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-  Group, HelpText;
+   Group, HelpText;
+  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>,
+  Group, HelpText;
 }
 
 // Creates a positive and negative flags where both of them are prefixed with
@@ -297,9 +297,9 @@
 multiclass SimpleMFlag {
   def m#NAME : Flag<["-"], "m"#name>, Group,
-HelpText;
+HelpText;
   def mno_#NAME : Flag<["-"], "mno-"#name>, Group,
-HelpText;
+HelpText;
 }
 
 //===--===//
@@ -349,8 +349,8 @@
 class ApplySuffix {
   FlagDef Result
 = FlagDef;
+  flag.OptionFlags # suffix.OptionFlags,
+  flag.Help # suffix.Help, flag.ImpliedBy>;
 }
 
 // Definition of the command line flag with positive spelling, e.g. "-ffoo".
@@ -368,16 +368,16 @@
   : FlagDef {
   // Name of the TableGen record.
-  string RecordName = prefix#!cond(flag.Polarity : "", true : "no_")#name;
+  string RecordName = prefix # !if(flag.Polarity, "", "no_") # name;
 
   // Spelling of the flag.
-  string Spelling = prefix#!cond(flag.Polarity : "", true : "no-")#spelling;
+  string Spelling = prefix # !if(flag.Polarity, "", "no-") # spelling;
 
   // Can the flag be implied by another flag?
   bit CanBeImplied = !not(!empty(flag.ImpliedBy));
 
   // C++ code that will be assigned to the keypath when the flag is present.
-  code ValueAsCode = !cond(flag.Value : "true", true: "false");
+  code ValueAsCode = !if(flag.Value, "true", "false");
 }
 
 // TableGen record for a single marshalled flag.
@@ -406,11 +406,19 @@
   defvar flag2 = FlagDefExpanded.Result, prefix,
  NAME, spelling_base>;
 
-  // TODO: Assert that the flags have different polarity.
-  // TODO: Assert that the flags have different value.
-  // TODO: Assert that only one of the flags can be implied.
+  // The flags must have different polarity, different values, and only
+  // one can be implied.
+  assert !xor(flag1.Polarity, flag2.Polarity),
+ "the flags must have different polarity: flag1: " #
+ flag1.Polarity # ", flag2: " # flag2.Polarity;
+  assert !ne(flag1.Value, flag2.Value),
+ "the flags must have different values: flag1: " #
+ flag1.Value # ", flag2: " # flag2.Value;
+  assert !not(!and(flag1.CanBeImplied, flag2.CanBeImplied)),
+ "only one of the flags can be implied: flag1: " #
+ flag1.CanBeImplied # ", flag2: " # flag2.CanBeImplied;
 
-  defvar implied = !cond(flag1.CanBeImplied: flag1, true: flag2);
+  defvar implied = !if(flag1.CanBeImplied, flag1, flag2);
 
   def flag1.RecordName : MarshalledFlagRec;
   def flag2.RecordName : MarshalledFlagRec;
@@ -1921,8 +1929,9 @@
 "LangOptions::LaxVectorConversionKind::Integer",
 "LangOptions::LaxVectorConversionKind::All"]>,
   MarshallingInfoEnum,
-  !strconcat(open_cl.KeyPath, " ? LangOptions::LaxVectorConversionKind::None"
-  " : LangOptions::LaxVectorConversionKind::All")>;
+  open_cl.KeyPath #
+  " ? LangOptions::LaxVectorConversionKind::None" #
+  " : LangOptions::LaxVectorConversionKind::All">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group,
   Alias, AliasArgs<["integer"]>;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ed87f51 - [PowerPC] Provide some P8-specific altivec overloads for P7

2021-05-06 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-05-06T08:37:36-05:00
New Revision: ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8

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

LOG: [PowerPC] Provide some P8-specific altivec overloads for P7

This adds additional support for XL compatibility. There are a number
of functions in altivec.h that produce a single instruction (or a
very short sequence) for Power8 but can be done on Power7 without
scalarization. XL provides these implementations.
This patch adds the following overloads for doubleword vectors:
vec_add
vec_cmpeq
vec_cmpgt
vec_cmpge
vec_cmplt
vec_cmple
vec_sl
vec_sr
vec_sra

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index cb4f35caf4d4b..0441c57e3da28 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -309,6 +309,26 @@ static __inline__ vector unsigned char 
__attribute__((__always_inline__))
 vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
   return __builtin_altivec_vadduqm(__a, __b);
 }
+#elif defined(__VSX__)
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_add(vector signed long long __a, vector signed long long __b) {
+  vector unsigned int __res =
+  (vector unsigned int)__a + (vector unsigned int)__b;
+  vector unsigned int __carry = __builtin_altivec_vaddcuw(
+  (vector unsigned int)__a, (vector unsigned int)__b);
+#ifdef __LITTLE_ENDIAN__
+  __carry = __builtin_shufflevector(__carry, __carry, 3, 0, 1, 2);
+#else
+  __carry = __builtin_shufflevector(__carry, __carry, 1, 2, 3, 0);
+#endif
+  return (vector signed long long)(__res + __carry);
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_add(vector unsigned long long __a, vector unsigned long long __b) {
+  return (vector unsigned long long)vec_add((vector signed long long)__a,
+(vector signed long long)__b);
+}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
@@ -1730,7 +1750,31 @@ vec_cmpeq(vector bool long long __a, vector bool long 
long __b) {
   return (vector bool long long)__builtin_altivec_vcmpequd(
   (vector long long)__a, (vector long long)__b);
 }
+#else
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector signed long long __a, vector signed long long __b) {
+  vector bool int __wordcmp =
+  vec_cmpeq((vector signed int)__a, (vector signed int)__b);
+#ifdef __LITTLE_ENDIAN__
+  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
+  return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 
1,
+1, 3, 3);
+#else
+  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
+  return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 
0,
+0, 2, 2);
+#endif
+}
 
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
+  return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector bool long long __a, vector bool long long __b) {
+  return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
+}
 #endif
 
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2018,6 +2062,24 @@ vec_cmpne(vector unsigned long long __a, vector unsigned 
long long __b) {
   return (vector bool long long)
 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long 
long)__b));
 }
+#else
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpne(vector bool long long __a, vector bool long long __b) {
+  return (vector bool long long)~(
+  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpne(vector signed long long __a, vector signed long long __b) {
+  return (vector bool long long)~(
+  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
+  return (vector bool long long)~(
+  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
+}
 #endif
 
 #ifdef __VSX__
@@ -2070,6 +2132,46 @@ static __inline__ vector bool long long __ATTRS_o_ai
 vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
   return (vector bool long long)__builtin_alti

[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64

2021-05-06 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

In D101873#2741299 , @MaskRay wrote:

> https://gist.github.com/MaskRay/2d4dfcfc897341163f734afb59f689c6 has more 
> information about -fno-semantic-interposition.
>
>> Can Clang default to -fno-semantic-interposition?
>
> I think we can probably make non-x86 default to -fno-semantic-interposition 
> (dso_local inference, given D72197 . x86 may 
> find default -fno-semantic-interposition too aggressive.

Thanks for the link, and the explanation that -fno-semantic-interposition is 
not the default.

I'm not (yet) convinced that we could make -fno-semantic-interposition the 
default, primarily due to data and not functions, I agree that interpositioning 
functions is rarely used. For data the classic example for symbol-interposition 
was errno, a shared library can't know if any other library or executable will 
define it so it must define, but it must use only one value for the definition. 
I'm not sure if that still holds in today's environment with shared C libraries 
used by practically everything but I think the principle still applies.

Looking at the gist I've got one concern for AArch64 and Arm. The ABI relies on 
thunks which are only defined for symbols of type STT_FUNC. Changing branches 
to STT_FUNC to STT_SECTION will break long range thunks on AArch64 and 
interworking for Arm (there is a possibility that the bottom bit for STT_FUNC 
may get used in the future for AArch64 as well). This is solvable by keeping 
the local label and setting STT_FUNC on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101873

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


[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-06 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

The failing test line is:

  // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -O1 -fopenmp-simd 
-emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK10

It passes if you have the X86 backend enabled but fails if you do not. Our bots 
usually have only Arm or AArch64 enabled.

When you have the X86 backend:

  ; Function Attrs: nofree norecurse nosync nounwind mustprogress
  define void @_Z14static_chunkedPfS_S_S_(float* nocapture %a, float* nocapture 
readonly %b, float* nocapture readonly %c, float* nocapture readonly %d) 
local_unnamed_addr #1 {
  entry:
%arrayidx.0 = getelementptr inbounds float, float* %b, i64 131071
%arrayidx2.0 = getelementptr inbounds float, float* %c, i64 131071
%arrayidx4.0 = getelementptr inbounds float, float* %d, i64 131071
%arrayidx7.0 = getelementptr inbounds float, float* %a, i64 131071
%indvars.iv.next.0 = add nuw nsw i64 131071, 127
br label %for.body
  
  for.cond.cleanup: ; preds = %for.body
ret void

When you don't:

  ; Function Attrs: nofree norecurse nosync nounwind mustprogress
  define void @_Z14static_chunkedPfS_S_S_(float* nocapture %a, float* nocapture 
readonly %b, float* nocapture readonly %c, float* nocapture readonly %d) 
local_unnamed_addr #1 {
  entry:
br label %for.body
  
  for.cond.cleanup: ; preds = %for.body
ret void

This is one of a few differences, I'll see if I can post a diff in a way that 
makes sense to read.

Either way this seems like a bug given that clang usually doesn't require the 
llvm backend for a particular target. (which is why things like the target 
parser are always enabled) But I'm new to OpenMP so please correct me if not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

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


[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-05-06 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

Looks good, but please wait for others to state their opinion.


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

https://reviews.llvm.org/D91949

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3399
+by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled, returning floating point evaluation
+method to the default setting.





Comment at: clang/docs/UsersManual.rst:1486
+   Valid values are: ``source``, ``double``, and ``extended``.
+   The default value is target specific, typically ``source``.  Details:
+





Comment at: clang/include/clang/Basic/LangOptions.h:226
 
+  /// Possible float expression evaluation method choies.
+  enum FPEvalMethodKind {





Comment at: clang/include/clang/Lex/Preprocessor.h:181
   IdentifierInfo *Ident__is_target_environment;// __is_target_environment
+  IdentifierInfo *Ident__FLT_EVAL_METHOD__;// __FLT_EVAL_METHOD__
 

Otherwise, when `LexExpandSpecialBuiltins` is `false`, I think this winds up 
being an uninitialized pointer value.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2803
 
+// Validate and pass through -ffp-float-precision option.
+case options::OPT_ffp_eval_method_EQ: {





Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1743
 });
-  } else if (II == Ident__has_include ||
- II == Ident__has_include_next) {
+  } else if (II == Ident__has_include || II == Ident__has_include_next) {
 // The argument to these two builtins should be a parenthesized

Unrelated formatting change?



Comment at: clang/lib/Sema/Sema.cpp:216
+// Use setting from TargetInfo.
+PP.setCurrentFltEvalMethod(static_cast(
+ctxt.getTargetInfo().getFloatEvalMethod()));

I don't think this cast is needed, is it? (It might make sense for the 
`getFloatEvalMethod()` return type to be `int` rather than `unisnged` though, 
given that we support negative values for implementation-defined semantics?)



Comment at: clang/lib/Sema/Sema.cpp:220
+// Set initial value of __FLT_EVAL_METHOD__ from the command line.
+PP.setCurrentFltEvalMethod(getLangOpts().getFPEvalMethod());
 }

Heh, so we have:

`setCurrentFltEvalMethod`
`getFloatEvalMethod`
`getFPEvalMethod`

I think we should pick a consistent spelling for `float evaluation method` and 
go with it. I don't know that work needs to happen as part of this patch (it 
can be a follow-up), but I think it'd help with readability.



Comment at: clang/test/CodeGen/fp-floatcontrol-pragma.cpp:240
+
+float mySub(float x, float y) {
+  // CHECK: define {{.*}}float {{.*}}mySub{{.*}}

Can we also get some tests that show how this behaves with the less common 
floating-point types like float16, bfloat16, float128, half?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


Re: [clang] ed87f51 - [PowerPC] Provide some P8-specific altivec overloads for P7

2021-05-06 Thread Nico Weber via cfe-commits
Looks like this breaks tests: http://45.33.8.238/linux/45985/step_7.txt ,
https://lab.llvm.org/buildbot/#/builders/139/builds/3818

(Is there a phab link for this?)

On Thu, May 6, 2021 at 9:37 AM Nemanja Ivanovic via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Nemanja Ivanovic
> Date: 2021-05-06T08:37:36-05:00
> New Revision: ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8
>
> URL:
> https://github.com/llvm/llvm-project/commit/ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8
> DIFF:
> https://github.com/llvm/llvm-project/commit/ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8.diff
>
> LOG: [PowerPC] Provide some P8-specific altivec overloads for P7
>
> This adds additional support for XL compatibility. There are a number
> of functions in altivec.h that produce a single instruction (or a
> very short sequence) for Power8 but can be done on Power7 without
> scalarization. XL provides these implementations.
> This patch adds the following overloads for doubleword vectors:
> vec_add
> vec_cmpeq
> vec_cmpgt
> vec_cmpge
> vec_cmplt
> vec_cmple
> vec_sl
> vec_sr
> vec_sra
>
> Added:
>
>
> Modified:
> clang/lib/Headers/altivec.h
> clang/test/CodeGen/builtins-ppc-vsx.c
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
> index cb4f35caf4d4b..0441c57e3da28 100644
> --- a/clang/lib/Headers/altivec.h
> +++ b/clang/lib/Headers/altivec.h
> @@ -309,6 +309,26 @@ static __inline__ vector unsigned char
> __attribute__((__always_inline__))
>  vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
>return __builtin_altivec_vadduqm(__a, __b);
>  }
> +#elif defined(__VSX__)
> +static __inline__ vector signed long long __ATTRS_o_ai
> +vec_add(vector signed long long __a, vector signed long long __b) {
> +  vector unsigned int __res =
> +  (vector unsigned int)__a + (vector unsigned int)__b;
> +  vector unsigned int __carry = __builtin_altivec_vaddcuw(
> +  (vector unsigned int)__a, (vector unsigned int)__b);
> +#ifdef __LITTLE_ENDIAN__
> +  __carry = __builtin_shufflevector(__carry, __carry, 3, 0, 1, 2);
> +#else
> +  __carry = __builtin_shufflevector(__carry, __carry, 1, 2, 3, 0);
> +#endif
> +  return (vector signed long long)(__res + __carry);
> +}
> +
> +static __inline__ vector unsigned long long __ATTRS_o_ai
> +vec_add(vector unsigned long long __a, vector unsigned long long __b) {
> +  return (vector unsigned long long)vec_add((vector signed long long)__a,
> +(vector signed long long)__b);
> +}
>  #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
>
>  static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
> @@ -1730,7 +1750,31 @@ vec_cmpeq(vector bool long long __a, vector bool
> long long __b) {
>return (vector bool long long)__builtin_altivec_vcmpequd(
>(vector long long)__a, (vector long long)__b);
>  }
> +#else
> +static __inline__ vector bool long long __ATTRS_o_ai
> +vec_cmpeq(vector signed long long __a, vector signed long long __b) {
> +  vector bool int __wordcmp =
> +  vec_cmpeq((vector signed int)__a, (vector signed int)__b);
> +#ifdef __LITTLE_ENDIAN__
> +  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
> +  return (vector bool long long)__builtin_shufflevector(__wordcmp,
> __wordcmp, 1,
> +1, 3, 3);
> +#else
> +  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
> +  return (vector bool long long)__builtin_shufflevector(__wordcmp,
> __wordcmp, 0,
> +0, 2, 2);
> +#endif
> +}
>
> +static __inline__ vector bool long long __ATTRS_o_ai
> +vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
> +  return vec_cmpeq((vector signed long long)__a, (vector signed long
> long)__b);
> +}
> +
> +static __inline__ vector bool long long __ATTRS_o_ai
> +vec_cmpeq(vector bool long long __a, vector bool long long __b) {
> +  return vec_cmpeq((vector signed long long)__a, (vector signed long
> long)__b);
> +}
>  #endif
>
>  static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
> @@ -2018,6 +2062,24 @@ vec_cmpne(vector unsigned long long __a, vector
> unsigned long long __b) {
>return (vector bool long long)
>  ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long
> long)__b));
>  }
> +#else
> +static __inline__ vector bool long long __ATTRS_o_ai
> +vec_cmpne(vector bool long long __a, vector bool long long __b) {
> +  return (vector bool long long)~(
> +  vec_cmpeq((vector signed long long)__a, (vector signed long
> long)__b));
> +}
> +
> +static __inline__ vector bool long long __ATTRS_o_ai
> +vec_cmpne(vector signed long long __a, vector signed long long __b) {
> +  return (vector bool long long)~(
> +  vec_cmpeq((vector signed long long)__a, (vector signed long
> 

Re: [clang] ed87f51 - [PowerPC] Provide some P8-specific altivec overloads for P7

2021-05-06 Thread Nico Weber via cfe-commits
Reverted in 3761b9a2345aff197707d23a68d4a178489f60e4 for now.

On Thu, May 6, 2021 at 9:58 AM Nico Weber  wrote:

> Looks like this breaks tests: http://45.33.8.238/linux/45985/step_7.txt ,
> https://lab.llvm.org/buildbot/#/builders/139/builds/3818
>
> (Is there a phab link for this?)
>
> On Thu, May 6, 2021 at 9:37 AM Nemanja Ivanovic via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Nemanja Ivanovic
>> Date: 2021-05-06T08:37:36-05:00
>> New Revision: ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8.diff
>>
>> LOG: [PowerPC] Provide some P8-specific altivec overloads for P7
>>
>> This adds additional support for XL compatibility. There are a number
>> of functions in altivec.h that produce a single instruction (or a
>> very short sequence) for Power8 but can be done on Power7 without
>> scalarization. XL provides these implementations.
>> This patch adds the following overloads for doubleword vectors:
>> vec_add
>> vec_cmpeq
>> vec_cmpgt
>> vec_cmpge
>> vec_cmplt
>> vec_cmple
>> vec_sl
>> vec_sr
>> vec_sra
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/Headers/altivec.h
>> clang/test/CodeGen/builtins-ppc-vsx.c
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
>> index cb4f35caf4d4b..0441c57e3da28 100644
>> --- a/clang/lib/Headers/altivec.h
>> +++ b/clang/lib/Headers/altivec.h
>> @@ -309,6 +309,26 @@ static __inline__ vector unsigned char
>> __attribute__((__always_inline__))
>>  vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
>>return __builtin_altivec_vadduqm(__a, __b);
>>  }
>> +#elif defined(__VSX__)
>> +static __inline__ vector signed long long __ATTRS_o_ai
>> +vec_add(vector signed long long __a, vector signed long long __b) {
>> +  vector unsigned int __res =
>> +  (vector unsigned int)__a + (vector unsigned int)__b;
>> +  vector unsigned int __carry = __builtin_altivec_vaddcuw(
>> +  (vector unsigned int)__a, (vector unsigned int)__b);
>> +#ifdef __LITTLE_ENDIAN__
>> +  __carry = __builtin_shufflevector(__carry, __carry, 3, 0, 1, 2);
>> +#else
>> +  __carry = __builtin_shufflevector(__carry, __carry, 1, 2, 3, 0);
>> +#endif
>> +  return (vector signed long long)(__res + __carry);
>> +}
>> +
>> +static __inline__ vector unsigned long long __ATTRS_o_ai
>> +vec_add(vector unsigned long long __a, vector unsigned long long __b) {
>> +  return (vector unsigned long long)vec_add((vector signed long long)__a,
>> +(vector signed long
>> long)__b);
>> +}
>>  #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
>>
>>  static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
>> @@ -1730,7 +1750,31 @@ vec_cmpeq(vector bool long long __a, vector bool
>> long long __b) {
>>return (vector bool long long)__builtin_altivec_vcmpequd(
>>(vector long long)__a, (vector long long)__b);
>>  }
>> +#else
>> +static __inline__ vector bool long long __ATTRS_o_ai
>> +vec_cmpeq(vector signed long long __a, vector signed long long __b) {
>> +  vector bool int __wordcmp =
>> +  vec_cmpeq((vector signed int)__a, (vector signed int)__b);
>> +#ifdef __LITTLE_ENDIAN__
>> +  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
>> +  return (vector bool long long)__builtin_shufflevector(__wordcmp,
>> __wordcmp, 1,
>> +1, 3, 3);
>> +#else
>> +  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
>> +  return (vector bool long long)__builtin_shufflevector(__wordcmp,
>> __wordcmp, 0,
>> +0, 2, 2);
>> +#endif
>> +}
>>
>> +static __inline__ vector bool long long __ATTRS_o_ai
>> +vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
>> +  return vec_cmpeq((vector signed long long)__a, (vector signed long
>> long)__b);
>> +}
>> +
>> +static __inline__ vector bool long long __ATTRS_o_ai
>> +vec_cmpeq(vector bool long long __a, vector bool long long __b) {
>> +  return vec_cmpeq((vector signed long long)__a, (vector signed long
>> long)__b);
>> +}
>>  #endif
>>
>>  static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float
>> __a,
>> @@ -2018,6 +2062,24 @@ vec_cmpne(vector unsigned long long __a, vector
>> unsigned long long __b) {
>>return (vector bool long long)
>>  ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long
>> long)__b));
>>  }
>> +#else
>> +static __inline__ vector bool long long __ATTRS_o_ai
>> +vec_cmpne(vector bool long long __a, vector bool long long __b) {
>> +  return (vector bool long long)~(
>> +  vec_cmpeq((vector signed long long)__a, (vector signed long
>> long)

[clang] 3761b9a - Revert "[PowerPC] Provide some P8-specific altivec overloads for P7"

2021-05-06 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-05-06T10:01:16-04:00
New Revision: 3761b9a2345aff197707d23a68d4a178489f60e4

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

LOG: Revert "[PowerPC] Provide some P8-specific altivec overloads for P7"

This reverts commit ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8.
Breaks check-clang, see e.g.
https://lab.llvm.org/buildbot/#/builders/139/builds/3818

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 0441c57e3da28..cb4f35caf4d4b 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -309,26 +309,6 @@ static __inline__ vector unsigned char 
__attribute__((__always_inline__))
 vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
   return __builtin_altivec_vadduqm(__a, __b);
 }
-#elif defined(__VSX__)
-static __inline__ vector signed long long __ATTRS_o_ai
-vec_add(vector signed long long __a, vector signed long long __b) {
-  vector unsigned int __res =
-  (vector unsigned int)__a + (vector unsigned int)__b;
-  vector unsigned int __carry = __builtin_altivec_vaddcuw(
-  (vector unsigned int)__a, (vector unsigned int)__b);
-#ifdef __LITTLE_ENDIAN__
-  __carry = __builtin_shufflevector(__carry, __carry, 3, 0, 1, 2);
-#else
-  __carry = __builtin_shufflevector(__carry, __carry, 1, 2, 3, 0);
-#endif
-  return (vector signed long long)(__res + __carry);
-}
-
-static __inline__ vector unsigned long long __ATTRS_o_ai
-vec_add(vector unsigned long long __a, vector unsigned long long __b) {
-  return (vector unsigned long long)vec_add((vector signed long long)__a,
-(vector signed long long)__b);
-}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
@@ -1750,31 +1730,7 @@ vec_cmpeq(vector bool long long __a, vector bool long 
long __b) {
   return (vector bool long long)__builtin_altivec_vcmpequd(
   (vector long long)__a, (vector long long)__b);
 }
-#else
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpeq(vector signed long long __a, vector signed long long __b) {
-  vector bool int __wordcmp =
-  vec_cmpeq((vector signed int)__a, (vector signed int)__b);
-#ifdef __LITTLE_ENDIAN__
-  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
-  return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 
1,
-1, 3, 3);
-#else
-  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
-  return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 
0,
-0, 2, 2);
-#endif
-}
 
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
-  return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
-}
-
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpeq(vector bool long long __a, vector bool long long __b) {
-  return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
-}
 #endif
 
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2062,24 +2018,6 @@ vec_cmpne(vector unsigned long long __a, vector unsigned 
long long __b) {
   return (vector bool long long)
 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long 
long)__b));
 }
-#else
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpne(vector bool long long __a, vector bool long long __b) {
-  return (vector bool long long)~(
-  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
-}
-
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpne(vector signed long long __a, vector signed long long __b) {
-  return (vector bool long long)~(
-  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
-}
-
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
-  return (vector bool long long)~(
-  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
-}
 #endif
 
 #ifdef __VSX__
@@ -2132,46 +2070,6 @@ static __inline__ vector bool long long __ATTRS_o_ai
 vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
   return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b);
 }
-#else
-static __inline__ vector bool long long __ATTRS_o_ai
-vec_cmpgt(vector signed long long __a, vector signed long long __b) {
-  vector signed int __sgtw =
-  vec_cmpgt((vector signed int)__a, (vector signed 

[clang] e4b790c - [OpenMP] Temporarily require X86 target for parallel_for_codegen.cpp test

2021-05-06 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2021-05-06T14:16:43Z
New Revision: e4b790c5e3653053819182a67c593bc65de860ac

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

LOG: [OpenMP] Temporarily require X86 target for parallel_for_codegen.cpp test

Since https://reviews.llvm.org/D101849 this test has been failing
on bots that only enable either Arm or AArch64 targets.

See: https://lab.llvm.org/buildbot/#/builders/107/builds/7601

Temporarily requires X86 for this test while the difference is figured out.

Added: 


Modified: 
clang/test/OpenMP/parallel_for_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/parallel_for_codegen.cpp 
b/clang/test/OpenMP/parallel_for_codegen.cpp
index 9abcd2190eb1..1ecee5bf40ac 100644
--- a/clang/test/OpenMP/parallel_for_codegen.cpp
+++ b/clang/test/OpenMP/parallel_for_codegen.cpp
@@ -24,6 +24,10 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -DOMP5 -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck %s --check-prefix=CHECK13
 // RUN: %clang_cc1 -fopenmp-simd -DOMP5 -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -DOMP5 -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck %s --check-prefix=CHECK14
+
+/// The RUN using flags "-triple x86_64-apple-darwin10 -O1 -fopenmp-simd" 
generates 
diff erent IR when there is no X86 backend.
+// REQUIRES: x86-registered-target
+
 #ifndef HEADER
 #define HEADER
 



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


[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-06 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

I've required X86 target for this test to get our bots green again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

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


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-05-06 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 343399.
nicovank marked 7 inline comments as done.
nicovank added a comment.

Fix some style comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -27,54 +48,230 @@
 
   template 
   void emplace_back(Args &&... args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&... args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&... args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&... args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&... args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-05-06 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:294
+  } else {
+if ((MakeCall ? MakeCall->getNumArgs() : CtorCall->getNumArgs()) == 0) {
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(

kuhar wrote:
> Can you pull this ternary expression into a variable so that it does not have 
> to repeated when the diagnostic is emitted?
This is a bit tricky, since `MakeCall` is a `CallExpr` and `CtorCall` is a 
`CXXConstructExpr`, and they have no common base class. Even if I pull it out 
it'll be a lot of repetition.

I think there may be some elegant way to join the previous removal hints with 
these, but haven't had time to think about it. I'll probably post another 
update by the end of this week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471

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


[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D101849#2741980 , @DavidSpickett 
wrote:

> I've required X86 target for this test to get our bots green again.

We can have that as a workaround sure.

> Either way this seems like a bug given that clang usually doesn't require the 
> llvm backend for a particular target.

I agree, something is amiss.

> We will probably remove the fopenmp-simd check lines again now, but this is 
> still something we might want to investigate, non-determinism has the 
> tendency to come back and bite you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu:65-68
+  asm volatile("barrier.sync %0;"
+   :
+   : "r"(barrier)
+   : "memory");

ABataev wrote:
> Why not `__syncthreads`? It is safer to use `__syncthreads` as it is 
> `convergent`. Would be good to mark this code somehow as `convergent` too to 
> avoid incorrect optimizations
The problem is that syncthreads is basically a `bar.sync` which is a 
`barrier.sync.aligned`, if I understood everything properly. This worked so far 
because the "main thread" (lane 0, last warp) was alone in it's warp and all 
other threads have been terminated. Now, we simplify the control flow (and 
later get rid of the last warp) such that the threads of the last warp and the 
main thread will hit different barriers. The former hit the one in the state 
machine while the latter will be in `parallel_51`. The `.aligned` version 
doesn't allow that. Does that make sense?

I'm not concerned about convergent though, we solved that wholesale: We mark 
all functions that clang compiles for the GPU via openmp-target as convergent 
(IIRC). The entire device runtime is certainly convergent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

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


[PATCH] D101785: [clangd][ObjC] Highlight Objc Ivar refs

2021-05-06 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 343409.
dgoldman added a comment.

Add another test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101785

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


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,21 @@
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]] {
+  int $Field_decl[[_someProperty]];
+}
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = _someProperty;
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1607,6 +1607,21 @@
"5: targets = {t}, decl\n"
"6: targets = {t}\n"
"7: targets = {}\n"},
+   // Objective-C: instance variables
+   {
+   R"cpp(
+@interface I {
+@public
+  I *_z;
+}
+@end
+I *f;
+void foo() {
+  $0^f->$1^_z = 0;
+}
+  )cpp",
+   "0: targets = {f}\n"
+   "1: targets = {I::_z}\n"},
// Objective-C: properties
{
R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -780,6 +780,13 @@
   explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)});
 }
 
+void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OIRE->getLocation(),
+  /*IsDecl=*/false,
+  {OIRE->getDecl()}});
+}
+
 void VisitObjCMessageExpr(const ObjCMessageExpr *E) {
   // The name may have several tokens, we can only report the first.
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,21 @@
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]] {
+  int $Field_decl[[_someProperty]];
+}
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = _someProperty;
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1607,6 +1607,21 @@
"5: targets = {t}, decl\n"
"6: targets = {t}\n"
"7: targets = {}\n"},
+   // Objective-C: instance variables
+   {
+   R"cpp(
+@interface I {
+@public
+  I *_z;
+}
+@end
+I *f;
+void foo() {
+  $0^f->$1^_z = 0;
+}
+  )cpp",
+   "0: targets = {f}\n"
+   "1: targets = {I::_z}\n"},
// Objective-C: properties
{
R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp

[PATCH] D101785: [clangd][ObjC] Highlight Objc Ivar refs

2021-05-06 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D101785#2741535 , @kadircet wrote:

> Thanks! Can you also add a test to `FindExplicitReferencesTest.All` ? as 
> that's where the underlying change lies.
>
> To disambiguate properties and ivars, what if we used modifiers? I suppose we 
> can mark properties with `abstract` modifier, but i am not an obj-c person so 
> it might be better for you to vet such an idea.

Done. I don't think a modifier would make sense though - they're not really 
abstract. I think it would be better if there was a Field token type, like the 
Field symbol kind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101785

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


[clang] 1faf3b1 - [PowerPC] Re-commit ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8

2021-05-06 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-05-06T09:50:12-05:00
New Revision: 1faf3b195e71dbc469d658d450949439dbf92f9f

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

LOG: [PowerPC] Re-commit ed87f512bb9eb5c1d44e9a1182ffeaf23d6c5ae8

This was reverted in 3761b9a2345aff197707d23a68d4a178489f60e4 just
as I was about to commit the fix. This patch inlcudes the
necessary fix.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index cb4f35caf4d4b..e28d234880fbb 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -309,6 +309,26 @@ static __inline__ vector unsigned char 
__attribute__((__always_inline__))
 vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
   return __builtin_altivec_vadduqm(__a, __b);
 }
+#elif defined(__VSX__)
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_add(vector signed long long __a, vector signed long long __b) {
+  vector unsigned int __res =
+  (vector unsigned int)__a + (vector unsigned int)__b;
+  vector unsigned int __carry = __builtin_altivec_vaddcuw(
+  (vector unsigned int)__a, (vector unsigned int)__b);
+#ifdef __LITTLE_ENDIAN__
+  __carry = __builtin_shufflevector(__carry, __carry, 3, 0, 1, 2);
+#else
+  __carry = __builtin_shufflevector(__carry, __carry, 1, 2, 3, 0);
+#endif
+  return (vector signed long long)(__res + __carry);
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_add(vector unsigned long long __a, vector unsigned long long __b) {
+  return (vector unsigned long long)vec_add((vector signed long long)__a,
+(vector signed long long)__b);
+}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
@@ -1730,7 +1750,31 @@ vec_cmpeq(vector bool long long __a, vector bool long 
long __b) {
   return (vector bool long long)__builtin_altivec_vcmpequd(
   (vector long long)__a, (vector long long)__b);
 }
+#elif defined(__VSX__)
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector signed long long __a, vector signed long long __b) {
+  vector bool int __wordcmp =
+  vec_cmpeq((vector signed int)__a, (vector signed int)__b);
+#ifdef __LITTLE_ENDIAN__
+  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
+  return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 
1,
+1, 3, 3);
+#else
+  __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
+  return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 
0,
+0, 2, 2);
+#endif
+}
 
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
+  return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector bool long long __a, vector bool long long __b) {
+  return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
+}
 #endif
 
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2018,6 +2062,24 @@ vec_cmpne(vector unsigned long long __a, vector unsigned 
long long __b) {
   return (vector bool long long)
 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long 
long)__b));
 }
+#elif defined(__VSX__)
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpne(vector bool long long __a, vector bool long long __b) {
+  return (vector bool long long)~(
+  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpne(vector signed long long __a, vector signed long long __b) {
+  return (vector bool long long)~(
+  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
+}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
+  return (vector bool long long)~(
+  vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
+}
 #endif
 
 #ifdef __VSX__
@@ -2070,6 +2132,46 @@ static __inline__ vector bool long long __ATTRS_o_ai
 vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
   return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b);
 }
+#elif defined(__VSX__)
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpgt(vector signed long long __a, vector signed long long __b) 

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-06 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 created this revision.
Herald added subscribers: dcaballe, cota, teijeong, dexonsmith, rdzhabarov, 
tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, 
lucyrfox, mgester, arpith-jacob, csigg, antiagainst, shauheen, rriddle, 
mehdi_amini, rupprecht, gbedwell, hiraditya.
Herald added a reviewer: andreadb.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
flip1995 updated this revision to Diff 343324.
flip1995 edited the summary of this revision.
flip1995 added a comment.
Herald added subscribers: luismarques, s.egerton, PkmX, simoncook.
flip1995 published this revision for review.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, 
nicolasvasilache.
Herald added a reviewer: herhut.
Herald added projects: clang, MLIR, LLVM.

rebased


This MCObjectFileInfo is then used to determine things like section
alignment.

For example, this commit removes the hard-coded 4-byte alignment for
text sections and uses the alignment defined by the target specific
MCObjectFileInfo.

This is a follow up to https://reviews.llvm.org/D101462 and prepares for the
RISCV backend defining the text section alignment depending on the enabled
extensions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101921

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -168,9 +168,11 @@
   target->createMCAsmInfo(*mri, this->triple, mcOptions));
   mai->setRelaxELFRelocations(true);
 
-  llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), /*MOFI=*/nullptr, &srcMgr,
+  &mcOptions);
+  std::unique_ptr mofi(target->createMCObjectFileInfo(
+  ctx, /*PIC=*/false, /*LargeCodeModel=*/false));
+  ctx.setObjectFileInfo(mofi.get());
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -62,6 +62,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MOFI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -74,7 +75,6 @@
   const Target *TheTarget;
 
   const MCTargetOptions MCOptions;
-  MCObjectFileInfo MOFI;
 
   SystemZAsmLexerTest() {
 // We will use the SystemZ triple, because of missing
@@ -112,9 +112,11 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, STI.get(),
-&SrcMgr, &MCOptions));
-MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get(), &SrcMgr, &MCOptions));
+MOFI.reset(TheTarget->createMCObjectFileInfo(*Ctx, /*PIC=*/false,
+ /*LargeCodeModel=*/false));
+Ctx->setObjectFileInfo(MOFI.get());
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -332,9 +332,11 @@
   if (!MII)
 exitWithError("no instruction info for target " + TripleName, FileName);
 
-  MCObjectFileInfo MOFI;
-  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
-  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
+  MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), /*MOFI=*/nullptr,
+STI.get());
+  std::unique_ptr MOFI(
+  TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/fals

[PATCH] D101785: [clangd][ObjC] Highlight Objc Ivar refs

2021-05-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101785

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


[PATCH] D96524: [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64

2021-05-06 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 343417.
azabaznov added a comment.

Rebased to use `::validateOpenCLTarget`. Decided to use explicit simulatneous 
extensions/feature disabling in command line due to API spec limitations:

clGetDeviceInfo: Will not describe support for the cl_khr_3d_image_writes 
extension if device does not support writing to 3D image objects.

Will update docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96524

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenOpenCL/printf.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/extensions.cl
  clang/test/SemaOpenCL/fp64-fp16-options.cl

Index: clang/test/SemaOpenCL/fp64-fp16-options.cl
===
--- clang/test/SemaOpenCL/fp64-fp16-options.cl
+++ clang/test/SemaOpenCL/fp64-fp16-options.cl
@@ -4,6 +4,7 @@
 
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 
 // Test with some extensions enabled or disabled by cmd-line args
 //
@@ -15,12 +16,18 @@
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 //
 // Concatenating
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 
 // Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
 // disables all extensions by default, but supported core extensions for a
@@ -72,20 +79,33 @@
 void f2(void) {
   double d;
 #ifdef NOFP64
-// expected-error@-2{{use of type 'double' requires cl_khr_fp64 support}}
+#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ == 300)
+// expected-error@-3{{use of type 'double' requires __opencl_c_fp64 support}}
+#else
+// expected-error@-5{{use of type 'double' requires cl_khr_fp64 support}}
+#endif
 #endif
 
   typedef double double4 __attribute__((ext_vector_type(4)));
   double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
 #ifdef NOFP64
-// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 support}}
-// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 support}}
+#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ == 300)
+// expected-error@-4 {{use of type 'double' requires __opencl_c_fp64 support}}
+// expected-error@-4 {{use of type 'double4' (vector of 4 'double' values) requires __opencl_c_fp64 support}}
+#else
+// expected-error@-7 {{use of type 'double' requires cl_khr_fp64 support}}
+// expected-error@-7 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 support}}
+#endif
 #endif
 
   (void) 1.0;
 
 #ifdef NOFP64
-// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}}
+#if (defined(__OPENCL_C_VERSI

[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-05-06 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

> This change removes the requirement on pragma when atomic types from the 
> extensions are supported because the behavior is not conformant. With this 
> change, the developers can use atomic types from the extensions if they are 
> supported without enabling the pragma because disabling the pragma doesn't do 
> anything useful but only prevents the use of already available identifiers 
> for types and issues extra diagnostics. This makes semantics consistent with 
> the atomic functions that are also available when the extension is supported 
> without any need for the pragma.

That sounds reasonable to me. Decreasing code complexity and reducing the 
"surprise-factor" for users by being more consistent is good indeed.




Comment at: clang/test/Parser/opencl-atomics-cl20.cl:12
 void atomic_types_test() {
-// OpenCL v2.0 s6.13.11.6 defines supported atomic types.
+  // OpenCL v2.0 s6.13.11.6 defines supported atomic types.
+

nit: there are a few tabs in this files you may want to remove before 
submitting.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:34
   atomic_ptrdiff_t pd;
-// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier
-// are not supported by OpenCL.
-  _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}}
-}
-#ifndef CL20
-// expected-error@-16 {{use of undeclared identifier 'atomic_int'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_long'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_float'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_double'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}}
-#elif !EXT
-// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned 
long)') requires cl_khr_int64_extended_atomics support}}
-// expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_base_atomics support}}
-// expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_extended_atomics support}}
-#if __LP64__
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_extended_atomics support}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics support}}
-// expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics support}}
+#if !defined(LANG_VER_OK) || !defined(cl_khr_int64_base_atomics)
+// expected-error@-8 {{use of undeclared identifier 'atomic_long'}}

Shouldn't that be 
```
!(defined(cl_khr_int64_extended_atomics) && defined(cl_khr_int64_base_atomics))
```
for atomic_long and atomic_ulong, and covering double for atomic_double?

Alternatively, if the goal isn't to have 100% coverage in this test of all 
these variations (which would be fine I believe), then a comment could clarify 
the intent.


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

https://reviews.llvm.org/D100976

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG




Comment at: openmp/libomptarget/deviceRTLs/interface.h:421
+ bool UseGenericStateMachine,
+   bool RequiresFullRuntime);
+EXTERN void __kmpc_target_deinit(ident_t *Ident, bool IsSPMD,

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

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


[PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-06 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

IIUC it will get replaced by D101950 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101236

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


[PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Just to be clear, I am not sure when/if D101950 
 is ready. It's mostly blocked by me not 
having the time to work on it, so depending how my schedule is this might land 
soon or far in the future. Just linked it here as this (temporary) workaround 
would be on the list of things I would revert when D101950 
 lands. But in the meantime I'm ok with this 
workaround patch as I said above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101236

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield requested changes to this revision.
JonChesterfield added a comment.
This revision now requires changes to proceed.

What are the required semantics of the barrier operations? Amdgcn builds them 
on shared memory, so probably needs a change to the corresponding target_impl 
to match


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

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


[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D101976#2742166 , @JonChesterfield 
wrote:

> What are the required semantics of the barrier operations? Amdgcn builds them 
> on shared memory, so probably needs a change to the corresponding target_impl 
> to match

I have *not* tested AMDGCN but I was not expecting a problem. The semantics I 
need here is: 
 warp N, thread 0 hits a barrier instruction I0
 warp N, threads 1-31 hit  a barrier instruction I1
 the entire warp synchronizes and moves on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

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


[PATCH] D101843: [OpenCL] Add clang extension for bitfields

2021-05-06 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1748
+With this extension it is possible to enable bitfields in structs
+or unions using regular OpenCL extension pragma mechanism detailed in
+`the OpenCL Extension Specification, section 1.2





Comment at: clang/lib/Sema/SemaDecl.cpp:16798
 }
 // OpenCL v1.2 s6.9.c: bitfields are not supported.
+if (BitWidth && !getOpenCLOptions().isAvailableOption(





Comment at: clang/test/SemaOpenCL/unsupported.cl:11
+#ifndef BITFIELDS_EXT
+// expected-error@-2 {{bit-fields are not supported in OpenCL}}
+#endif

The extension has "bitfields" in the name but most diagnostics (including this 
one) spell it as "bit-fields".  I wonder what the least surprising name would 
be?  It seems Clang tends to use the hyphenated form in diagnostics and the 
non-hyphenated form in e.g. option names (e.g. `fsigned-bitfields`), so using 
the non-hyphenated form in the extension name is probably fine.


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

https://reviews.llvm.org/D101843

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


[clang-tools-extra] 159dd44 - [clangd][ObjC] Highlight Objc Ivar refs

2021-05-06 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2021-05-06T11:41:49-04:00
New Revision: 159dd447fe98f558879343d660b5bfe90779609f

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

LOG: [clangd][ObjC] Highlight Objc Ivar refs

Treat them just like we do for properties - as a `property` semantic
token although ideally we could differentiate the two.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index d4cb2fe79111..4789d28ecf48 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -780,6 +780,13 @@ llvm::SmallVector refInStmt(const Stmt *S,
   explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)});
 }
 
+void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OIRE->getLocation(),
+  /*IsDecl=*/false,
+  {OIRE->getDecl()}});
+}
+
 void VisitObjCMessageExpr(const ObjCMessageExpr *E) {
   // The name may have several tokens, we can only report the first.
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f32081ac472c..beca7c292583 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1607,6 +1607,21 @@ TEST_F(FindExplicitReferencesTest, All) {
"5: targets = {t}, decl\n"
"6: targets = {t}\n"
"7: targets = {}\n"},
+   // Objective-C: instance variables
+   {
+   R"cpp(
+@interface I {
+@public
+  I *_z;
+}
+@end
+I *f;
+void foo() {
+  $0^f->$1^_z = 0;
+}
+  )cpp",
+   "0: targets = {f}\n"
+   "1: targets = {I::_z}\n"},
// Objective-C: properties
{
R"cpp(

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 815ef92c932e..a2e8f797ad28 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,21 @@ sizeof...($TemplateParameter[[Elements]]);
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]] {
+  int $Field_decl[[_someProperty]];
+}
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = _someProperty;
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {



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


[PATCH] D101785: [clangd][ObjC] Highlight Objc Ivar refs

2021-05-06 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG159dd447fe98: [clangd][ObjC] Highlight Objc Ivar refs 
(authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101785

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


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,21 @@
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]] {
+  int $Field_decl[[_someProperty]];
+}
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = _someProperty;
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1607,6 +1607,21 @@
"5: targets = {t}, decl\n"
"6: targets = {t}\n"
"7: targets = {}\n"},
+   // Objective-C: instance variables
+   {
+   R"cpp(
+@interface I {
+@public
+  I *_z;
+}
+@end
+I *f;
+void foo() {
+  $0^f->$1^_z = 0;
+}
+  )cpp",
+   "0: targets = {f}\n"
+   "1: targets = {I::_z}\n"},
// Objective-C: properties
{
R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -780,6 +780,13 @@
   explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)});
 }
 
+void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  OIRE->getLocation(),
+  /*IsDecl=*/false,
+  {OIRE->getDecl()}});
+}
+
 void VisitObjCMessageExpr(const ObjCMessageExpr *E) {
   // The name may have several tokens, we can only report the first.
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -687,6 +687,21 @@
 @implementation $Class[[Foo]]($Namespace_decl[[Bar]])
 @end
   )cpp",
+  R"cpp(
+// ObjC: Properties and Ivars.
+@interface $Class_decl[[Foo]] {
+  int $Field_decl[[_someProperty]];
+}
+@property(nonatomic, assign) int $Field_decl[[someProperty]];
+@end
+@implementation $Class_decl[[Foo]]
+@synthesize someProperty = _someProperty;
+- (int)$Method_decl[[doSomething]] {
+  self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1;
+  self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1;
+}
+@end
+  )cpp",
   // Member imported from dependent base
   R"cpp(
 template  struct $Class_decl[[Base]] {
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1607,6 +1607,21 @@
"5: targets = {t}, decl\n"
"6: targets = {t}\n"
"7: targets = {}\n"},
+   // Objective-C: instance variables
+   {
+   R"cpp(
+@interface I {
+@public
+  I *_z;
+}
+@end
+I *f;
+void foo() {
+  $0^f->$1^_z = 0;
+}
+  )cpp",
+   "0: targets = {f}\n"
+   "1: targets = {I::_z}\n"},
// Objective-C: properties
{
   

[PATCH] D101952: [OpenMP] Fix non-determinism in clang copyin codegen

2021-05-06 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Thanks! I'll test our Arm build and revert the requires once I've confirmed it 
passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101952

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


[PATCH] D101952: [OpenMP] Fix non-determinism in clang copyin codegen

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D101952#2742237 , @DavidSpickett 
wrote:

> Thanks! I'll test our Arm build and revert the requires once I've confirmed 
> it passes.

This is not the fix you need.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101952

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


[PATCH] D101960: [openmp] Drop requirement on library path environment variables

2021-05-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Yes. Libomp and libomptarget are in the same directory, so the rpath/runpath 
change catches both of them. Libomptarget then needs to find the plugins to 
load, either through library path or something equivalent to the above.




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:648
 
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
+  const ArgList &Args,

lebedev.ri wrote:
> JonChesterfield wrote:
> > Similar to other functions in this file, derived from aomp (by deleting 
> > some stuff for finding a debug version of the library)
> > 
> > I can make my peace with runpath instead if people are keen to override 
> > this with LD_LIBRARY_PATH. The rest of clang's toolchains wire things up 
> > with rpath but that doesn't mean we have to make the same choice here.
> I think it would be a shame if this would be the only thing
> that *doesn't* support being overriden with `LD_LIBRARY_PATH`.
> I'm not sure about `libomptarget`, but it i think it would be good to keep 
> such possibility for `libomp`.
The search order is 'rpath' then 'LD_LIBRARY_PATH' then 'runpath'. Presently we 
set no default at all and require the user to set LD_LIBRARY_PATH or manually 
link the right library. So using runpath here is backwards compatible, in that 
all the scripts out there that use LD_LIBRARY_PATH will continue to work. That 
may force our hand here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101960

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


[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-06 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added a comment.

In D101849#2741980 , @DavidSpickett 
wrote:

> I've required X86 target for this test to get our bots green again.

Thanks David for the workaround. I agree with Johannes's comments below. It 
looks like a bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

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


[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-05-06 Thread Douglas Yung via Phabricator via cfe-commits
dyung added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp:7
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+

jubnzv wrote:
> probinson wrote:
> > probinson wrote:
> > > TWeaver wrote:
> > > > njames93 wrote:
> > > > > TWeaver wrote:
> > > > > > Is the missing FileCheck call here on purpose? it seems to me that 
> > > > > > the CHECK-MESSAGES aren't actually being verified by this test?
> > > > > > 
> > > > > > unless I'm missing something.
> > > > > > 
> > > > > > TIA
> > > > > `check_clang_tidy` invokes FileCheck. Does something else make you 
> > > > > think these labels are being tested?? 
> > > > whilst investigating an unrelated issue on our internal branch, I tried 
> > > > editting the check lines in this test and wasn't able to create a 
> > > > failure. but if I add
> > > > 
> > > > '| FileCheck %s -check-prefix=CHECK-MESSAGES' to the run line and then 
> > > > edit the checks, I can induce an error.
> > > > 
> > > > This could be an issue on our internal branch though... :shrug: thanks 
> > > > for the speedy reply.
> > > I'm suspicious that our downstream problem is because the test is 
> > > assuming that the target is Windows, just because the host is.  That's 
> > > not true for us (or anyone with a Windows-hosted cross-compiler).  Does 
> > > clang-tidy accept a target triple?
> > Or possibly the test could be set up to require a Windows target, rather 
> > than a Windows host.
> I'm not sure that there is a way to pass a target triple to `clang-tidy`.
> 
> But `llvm-lit` should not run this test on non-Windows host because of 
> `REQUIRES: system-windows`. For example, when I trying to run it on my Debian 
> machine (`llvm-lit 
> clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
>  -v`) I got the following result:
> 
> ```
> -- Testing: 1 tests, 1 workers --
> UNSUPPORTED: Clang Tools :: 
> clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp (1 of 1)
> 
> Testing Time: 0.01s
>   Unsupported: 1
> ```
Our problem is the opposite, we are running a cross compiler hosted on Windows, 
but targeting a non-Windows platform (PS4 in our case).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101259

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


[PATCH] D101974: [Utils][WIP] Refactor script for cc tests

2021-05-06 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 343438.
ggeorgakoudis added a comment.

Update regex for removing old checklines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101974

Files:
  clang/utils/refactor_cc_tests.py

Index: clang/utils/refactor_cc_tests.py
===
--- /dev/null
+++ clang/utils/refactor_cc_tests.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python3
+
+import argparse
+import re
+import subprocess
+import sys
+import multiprocessing
+from itertools import repeat
+from itertools import starmap
+
+def run_update_cc(filename, llvm_util_dir, llvm_bin):
+# Probably we don't need to those arguments since we added a NOTE line.
+update_cc = [ llvm_util_dir + '/update_cc_test_checks.py', '--llvm-bin', llvm_bin,
+'--include-generated-func',
+'--function-signature',
+'--replace-value-regex', '\"__omp_offloading_[0-9a-z]+_[0-9a-z]+\"',
+'\"reduction_size[.].+[.]\"',
+'\"pl_cond[.].+[.|,]\"',
+'--prefix-filecheck-ir-name', '_',
+filename]
+
+# Run update_cc_test_checks.py.
+print('Running update_cc')
+popen = subprocess.Popen(update_cc, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+stdout, stderr = popen.communicate()
+if popen.returncode != 0:
+sys.stderr.write('Failed to run update_cc '+ ' '.join(update_cc) + '\n')
+sys.stderr.write(stderr)
+sys.stderr.write(stdout)
+return popen.returncode
+
+return popen.returncode
+
+def refactor(filename, llvm_util_dir, llvm_bin):
+input_lines = ''
+print('Processing file ', filename, '...')
+with open(filename, 'r') as f:
+output_lines = ''
+cnt = 1
+check_prefix_set = {'CHECK'}
+for line in f:
+input_lines += line
+# Modify run line.
+if line.startswith('// RUN'):
+# Process FileCheck in line.
+if 'FileCheck' in line:
+m = re.findall(r'--?check-prefix(?:es)?(?:\s|=)(.+?)\s+', line)
+# Extract check prefixes to remove check lines.
+check_prefix_list = []
+for i in m:
+check_prefix_list += i.split(',')
+check_prefix_set.update(set(check_prefix_list))
+# Delete all check prefixes.
+if m:
+line = re.sub(r'(?:-|--)check-prefix(?:es|)(?:\s|=).+?\s+', r'', line)
+
+# Generate implicit check.
+if '-fopenmp-simd' in line and not re.search(r'\b-fopenmp\b', line):
+line = line[:-1] + ' --implicit-check-not="{{__kmpc|__tgt}}"\n'
+# Generate check prefix using the counter.
+else:
+line = line[:-1] + ' --check-prefix=CHECK%d\n'%(cnt)
+cnt += 1
+
+# Replace generic triple.
+# TODO: add ms_abi_triple
+if '%itanium_abi_triple' in line:
+line = re.sub(r'%itanium_abi_triple', 'x86_64-unknown-linux', line)
+
+if 'clang' in line and not '-triple' in line:
+line = re.sub(r'clang(_cc1|xx)?\s+', r'clang\g<1> -triple x86_64-unknown-linux ', line)
+output_lines += line
+elif line.startswith('// NOTE:'):
+# Skip NOTE line, script will add its own.
+continue
+else:
+check_prefix_regex = '(' + '|'.join(check_prefix_set) + ')'
+# Discard check line.
+if re.match(r'\s*//\s*%s'%(check_prefix_regex), line):
+continue
+
+# Skip empty comment lines to match update_cc handling.
+line_strip = line.strip()
+if line_strip == '//':
+pass
+# Keep line.
+else:
+output_lines += line
+# Add NOTE to avoid omp_offloading line number problems
+NOTE = ('// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py'
+' UTC_ARGS: --function-signature --include-generated-funcs'
+' --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]"'
+' --prefix-filecheck-ir-name _\n')
+output_lines = NOTE + output_lines
+
+with open(filename, 'w') as f:
+f.write(output_lines)
+
+# Run update_cc_test_checks.py.
+ret = run_update_cc(filename, llvm_util_dir, llvm_bin)
+if ret == 0:
+# Done, return 1.
+return 1
+else:
+with open(filename, 'w') as f:
+  f.write(input_lines)
+# Failed, return 0.
+return 0
+
+def main():
+parser = argparse.ArgumentPars

[PATCH] D93525: [clang-offload-bundler] Add unbundling of archives containing bundled object files into device specific archives

2021-05-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Can we split this patch now and make progress?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93525

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


[PATCH] D102001: [Index] Ignore nullptr decls for indexing

2021-05-06 Thread Alex Hoppen via Phabricator via cfe-commits
ahoppen created this revision.
Herald added a subscriber: arphaman.
ahoppen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We can end up with a call to `indexTopLevelDecl(D)` with `D == nullptr` in 
non-assert builds e.g. when indexing a module in `indexModule` and

- `ASTReader::GetDecl` returns `nullptr` if `Index >= DeclsLoaded.size()`, thus 
returning `nullptr`

> `ModuleDeclIterator::operator*` returns `nullptr`
===

> we call `IndexCtx.indexTopLevelDecl` with `nullptr`
=

Be resilient and just ignore the `nullptr` decls during indexing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102001

Files:
  clang/lib/Index/IndexDecl.cpp


Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -759,7 +759,7 @@
 }
 
 bool IndexingContext::indexTopLevelDecl(const Decl *D) {
-  if (D->getLocation().isInvalid())
+  if (!D || D->getLocation().isInvalid())
 return true;
 
   if (isa(D))


Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -759,7 +759,7 @@
 }
 
 bool IndexingContext::indexTopLevelDecl(const Decl *D) {
-  if (D->getLocation().isInvalid())
+  if (!D || D->getLocation().isInvalid())
 return true;
 
   if (isa(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b198b9b - [WebAssembly] Fix argument types in SIMD narrowing intrinsics

2021-05-06 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-05-06T10:07:45-07:00
New Revision: b198b9b8974b19c9e8493f8d70c85ac54182597a

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

LOG: [WebAssembly] Fix argument types in SIMD narrowing intrinsics

The builtins were updated to take signed parameters in 627a52695537, but the
intrinsics that use those builtins were not updated as well. The intrinsic test
did not catch this sign mismatch because it is only reported as an error under
-fno-lax-vector-conversions.

This commit fixes the type mismatch and adds -fno-lax-vector-conversions to the
test to catch similar problems in the future.

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index e6fb0496e514..cd11f096dd95 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -1197,8 +1197,8 @@ wasm_i8x16_narrow_i16x8(v128_t __a, v128_t __b) {
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__u16x8)__a,
- (__u16x8)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a,
+ (__i16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
@@ -1209,8 +1209,8 @@ wasm_i16x8_narrow_i32x4(v128_t __a, v128_t __b) {
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__u32x4)__a,
- (__u32x4)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a,
+ (__i32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS

diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index f5076ae3af30..409da99d43a7 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --force-update
 // REQUIRES: webassembly-registered-target, asserts
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 -Wcast-qual -fno-lax-vector-conversions -Werror | FileCheck %s
 
 #include 
 



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


[PATCH] D101979: [WebAssembly] Fix argument types in SIMD narrowing intrinsics

2021-05-06 Thread Thomas Lively 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 rGb198b9b8974b: [WebAssembly] Fix argument types in SIMD 
narrowing intrinsics (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101979

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c


Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --force-update
 // REQUIRES: webassembly-registered-target, asserts
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown 
-msimd128 -Wcast-qual -fno-lax-vector-conversions -Werror | FileCheck %s
 
 #include 
 
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -1197,8 +1197,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__u16x8)__a,
- (__u16x8)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a,
+ (__i16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
@@ -1209,8 +1209,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__u32x4)__a,
- (__u32x4)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a,
+ (__i32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS


Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --force-update
 // REQUIRES: webassembly-registered-target, asserts
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -fno-lax-vector-conversions -Werror | FileCheck %s
 
 #include 
 
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -1197,8 +1197,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__u16x8)__a,
- (__u16x8)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a,
+ (__i16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
@@ -1209,8 +1209,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__u32x4)__a,
- (__u32x4)__b);
+  return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a,
+ (__i32x4)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-05-06 Thread Andrew Somerville via Phabricator via cfe-commits
catskul added a comment.

It's all good for me. Sorry for slow responses. My time to work on this is few 
and far between. I'm happy if anyone picks it up or any energy put into this. 
Would love to see it land.


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

https://reviews.llvm.org/D33029

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


[PATCH] D101793: [clang][AST] Improve AST Reader/Writer memory footprint

2021-05-06 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

In D101793#2735336 , @yaxunl wrote:

> Decls in Sema::DeclsToCheckForDeferredDiags is supposed to be unique. 
> Therefore the fact that '1,734,387,685 out of 1,734,404,000 elements are the 
> same' is surprising. Did this happen when you compile the source code and 
> write AST? What language was the source code? C++, OpenMP, or CUDA? What was 
> the decl that got duplicated? Thanks.

Sorry for the late reply.

This happens during a single compilation instance, and emits a module file from 
a big list of module map files and headers. I believe the code is pure C++. 
Because of the huge amount of duplications, the memory RSS shoots to over 50GB. 
I'll update once having more information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101793

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

This LGTM! `MANAGED` sounds like a good address space name to me. @sbc100, do 
you have any final comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.

managed seems reasonable yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1279
+  if (const GlobalAddressSDNode *GA = dyn_cast(Op))
+return WebAssembly::isManagedAddressSpace(GA->getAddressSpace());
+

Actually, should we enforce that these LLVM IR globals be thread_local, since 
the resulting Wasm globals will be thread_local? I don't know if that will 
affect any optimizations, but it seems like a more accurate modeling. If we do 
that, `CoalesceLocalsAndStripAtomics::stripThreadLocals` in 
WebAssemblyTargetMachine.cpp will have to be updated to not strip the thread 
locals corresponding to Wasm globals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1279
+  if (const GlobalAddressSDNode *GA = dyn_cast(Op))
+return WebAssembly::isManagedAddressSpace(GA->getAddressSpace());
+

tlively wrote:
> Actually, should we enforce that these LLVM IR globals be thread_local, since 
> the resulting Wasm globals will be thread_local? I don't know if that will 
> affect any optimizations, but it seems like a more accurate modeling. If we 
> do that, `CoalesceLocalsAndStripAtomics::stripThreadLocals` in 
> WebAssemblyTargetMachine.cpp will have to be updated to not strip the thread 
> locals corresponding to Wasm globals.
I'd be fine handling this in a follow-up if you want to get this landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-06 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added inline comments.



Comment at: llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h:39
+  // pointers are lowered to global.get / global.set or local.get / local.set,
+  // as appropriate.
+  WASM_ADDRESS_SPACE_MANAGED = 1

Sorry to throw more paint at the bikeshed here, but as someone who's only 
following along at a high-level here, I found it confusing whether this is 
talking about the wasm globals themselves, or the objects referred to by 
reference values in the wasm globals. I think the feature here is talking about 
the wasm globals themselves, but "managed" initially made me think it might be 
talking about the objects they reference, which in a browser context especially 
are "managed" in every sense of the word.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1279
+  if (const GlobalAddressSDNode *GA = dyn_cast(Op))
+return WebAssembly::isManagedAddressSpace(GA->getAddressSpace());
+

tlively wrote:
> tlively wrote:
> > Actually, should we enforce that these LLVM IR globals be thread_local, 
> > since the resulting Wasm globals will be thread_local? I don't know if that 
> > will affect any optimizations, but it seems like a more accurate modeling. 
> > If we do that, `CoalesceLocalsAndStripAtomics::stripThreadLocals` in 
> > WebAssemblyTargetMachine.cpp will have to be updated to not strip the 
> > thread locals corresponding to Wasm globals.
> I'd be fine handling this in a follow-up if you want to get this landed.
Note that this will be true of Worker-based threads, but not of the expected 
future "wasm native threads". I wonder if this means that clang/llvm will 
(eventually) need to be aware of this difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


  1   2   >