[PATCH] D93003: [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-11 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard updated this revision to Diff 323222.
rprichard added a comment.

Rebase and fix merge conflict in gn file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93003

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  libunwind/src/assembly.h
  libunwind/src/config.h
  llvm/utils/gn/secondary/libunwind/src/BUILD.gn

Index: llvm/utils/gn/secondary/libunwind/src/BUILD.gn
===
--- llvm/utils/gn/secondary/libunwind/src/BUILD.gn
+++ llvm/utils/gn/secondary/libunwind/src/BUILD.gn
@@ -111,7 +111,7 @@
   if (!invoker.export) {
 cflags = [ "-fvisibility=hidden" ]
 cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
-defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
+defines = [ "_LIBUNWIND_HIDE_SYMBOLS" ]
   }
   deps = [ "//compiler-rt/lib/builtins" ]
   configs += [ ":unwind_config" ]
Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -52,7 +52,8 @@
   #endif
 #endif
 
-#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+  // The CMake file passes -fvisibility=hidden to control ELF/Mach-O visibility.
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
@@ -70,11 +71,15 @@
 #define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name
 
 #if defined(__APPLE__)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name)
+#else
+#define _LIBUNWIND_ALIAS_VISIBILITY(name)
+#endif
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
   __asm__(".globl " SYMBOL_NAME(aliasname));   \
   __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \
-  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname\
-  __attribute__((weak_import));
+  _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname));
 #elif defined(__ELF__)
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
   extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname\
Index: libunwind/src/assembly.h
===
--- libunwind/src/assembly.h
+++ libunwind/src/assembly.h
@@ -70,12 +70,15 @@
 #if defined(__APPLE__)
 
 #define SYMBOL_IS_FUNC(name)
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .private_extern name
-#define WEAK_SYMBOL(name) .weak_reference name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_ALIAS(name, aliasname)\
   .globl SYMBOL_NAME(aliasname) SEPARATOR  \
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 
 #define NO_EXEC_STACK_DIRECTIVE
@@ -87,17 +90,23 @@
 #else
 #define SYMBOL_IS_FUNC(name) .type name,@function
 #endif
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .hidden name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_SYMBOL(name) .weak name
 
 #if defined(__hexagon__)
-#define WEAK_ALIAS(name, aliasname) \
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+#define WEAK_ALIAS(name, aliasname)\
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
+  WEAK_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR\
   .equiv SYMBOL_NAME(aliasname), SYMBOL_NAME(name)
 #else
 #define WEAK_ALIAS(name, aliasname)\
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
+  WEAK_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR\
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 #endif
 
@@ -119,7 +128,7 @@
   .section .drectve,"yn" SEPARATOR \
   .ascii "-export:", #name, "\0" SEPARATOR \
   .text
-#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
 #define EXPORT_SYMBOL(name)
 #else
 #define EXPORT_SYMBOL(name) EXPORT_SYMBOL2(name)
Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -160,11 

[PATCH] D93003: [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-11 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard updated this revision to Diff 323221.
rprichard edited the summary of this revision.
rprichard added a comment.

Update libunwind/src/BUILD.gn for macro name change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93003

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  libunwind/src/assembly.h
  libunwind/src/config.h
  llvm/utils/gn/secondary/libunwind/src/BUILD.gn

Index: llvm/utils/gn/secondary/libunwind/src/BUILD.gn
===
--- llvm/utils/gn/secondary/libunwind/src/BUILD.gn
+++ llvm/utils/gn/secondary/libunwind/src/BUILD.gn
@@ -98,7 +98,7 @@
 if (libunwind_hermetic_static_library) {
   cflags = [ "-fvisibility=hidden" ]
   cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
-  defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
+  defines = [ "_LIBUNWIND_HIDE_SYMBOLS" ]
 }
 deps = [ "//compiler-rt/lib/builtins" ]
 configs += [ ":unwind_config" ]
Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -52,7 +52,8 @@
   #endif
 #endif
 
-#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+  // The CMake file passes -fvisibility=hidden to control ELF/Mach-O visibility.
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
@@ -70,11 +71,15 @@
 #define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name
 
 #if defined(__APPLE__)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name)
+#else
+#define _LIBUNWIND_ALIAS_VISIBILITY(name)
+#endif
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
   __asm__(".globl " SYMBOL_NAME(aliasname));   \
   __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \
-  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname\
-  __attribute__((weak_import));
+  _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname));
 #elif defined(__ELF__)
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
   extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname\
Index: libunwind/src/assembly.h
===
--- libunwind/src/assembly.h
+++ libunwind/src/assembly.h
@@ -70,12 +70,15 @@
 #if defined(__APPLE__)
 
 #define SYMBOL_IS_FUNC(name)
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .private_extern name
-#define WEAK_SYMBOL(name) .weak_reference name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_ALIAS(name, aliasname)\
   .globl SYMBOL_NAME(aliasname) SEPARATOR  \
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 
 #define NO_EXEC_STACK_DIRECTIVE
@@ -87,17 +90,23 @@
 #else
 #define SYMBOL_IS_FUNC(name) .type name,@function
 #endif
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .hidden name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_SYMBOL(name) .weak name
 
 #if defined(__hexagon__)
-#define WEAK_ALIAS(name, aliasname) \
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+#define WEAK_ALIAS(name, aliasname)\
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
+  WEAK_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR\
   .equiv SYMBOL_NAME(aliasname), SYMBOL_NAME(name)
 #else
 #define WEAK_ALIAS(name, aliasname)\
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
+  WEAK_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR\
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 #endif
 
@@ -119,7 +128,7 @@
   .section .drectve,"yn" SEPARATOR \
   .ascii "-export:", #name, "\0" SEPARATOR \
   .text
-#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
 #define EXPORT_SYMBOL(name)
 #else
 #define EXPORT_SYMBOL(name) EXPORT_SYMBOL2(name)
Index: libunwind/src/CMakeLists.txt
===
--- 

[PATCH] D96538: [SYCL] Ignore file-scope asm during device-side SYCL compilation.

2021-02-11 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96538

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


[PATCH] D96248: [OpenMP][AMDGPU] Add support for linking libomptarget bitcode

2021-02-11 Thread Pushpinder Singh 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 rG79401b43ce4e: [OpenMP][AMDGPU] Add support for linking 
libomptarget bitcode (authored by Pushpinder Singh 
pushpinderdhaliwa...@gmail.com, committed by pdhaliwal).

Changed prior to commit:
  https://reviews.llvm.org/D96248?vs=322638=323219#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96248

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc
  clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx906.bc
  clang/test/Driver/amdgpu-openmp-toolchain.c

Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,11 +1,11 @@
 // REQUIRES: amdgpu-registered-target
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
+// RUN:   env LIBRARY_PATH=%S/Inputs/hip_dev_lib %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // verify the tools invocations
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}}
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}}
-// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-emit-llvm-bc"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
 // CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc"
 // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
 // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
@@ -34,3 +34,9 @@
 // CHECK-PHASES: 15: assembler, {14}, object, (host-openmp)
 // CHECK-PHASES: 16: linker, {4, 15}, image, (host-openmp)
 
+// handling of --libomptarget-amdgcn-bc-path
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 --libomptarget-amdgcn-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
+// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
+// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -749,56 +749,10 @@
 CudaVersionToString(CudaInstallation.version(;
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
-SmallVector LibraryPaths;
-// Add user defined library paths from LIBRARY_PATH.
-llvm::Optional LibPath =
-llvm::sys::Process::GetEnv("LIBRARY_PATH");
-if (LibPath) {
-  SmallVector Frags;
-  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
-  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
-  for (StringRef Path : Frags)
-LibraryPaths.emplace_back(Path.trim());
-}
-
-// Add path to lib / lib64 folder.
-SmallString<256> DefaultLibPath =
-llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
-
-// First check whether user specifies bc library
-if (const Arg *A =
-DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_bc_path_EQ)) {
-  std::string 

[clang] 79401b4 - [OpenMP][AMDGPU] Add support for linking libomptarget bitcode

2021-02-11 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-02-12T00:42:41-05:00
New Revision: 79401b43ce4e3aa856c50e78b38327e3ff4ae9eb

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

LOG: [OpenMP][AMDGPU] Add support for linking libomptarget bitcode

This patch uses the existing logic of CUDA for searching libomptarget
and extracts it to a common method.

Reviewed By: JonChesterfield, tianshilei1992

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

Added: 
clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc
clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx906.bc

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Cuda.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 00a2cae52e9b..6a37a15c6564 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -261,7 +261,7 @@ def err_drv_omp_host_target_not_supported : Error<
 def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
   "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading, please use -fopenmp=libomp or 
-fopenmp=libiomp5.">;
 def err_drv_omp_offload_target_missingbcruntime : Error<
-  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-nvptx-bc-path to specify nvptx bitcode 
library.">;
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e2a955ea0243..bcb9916a4abd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -942,6 +942,8 @@ def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
"file path and command line options) | 'random' (ID's generated as "
"random numbers) | 'none' (disabled). Default is 'hash'. This 
option "
"will be overriden by option '-cuid=[ID]' if it is specified." >;
+def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgcn-bc-path=">, Group,
+  HelpText<"Path to libomptarget-amdgcn bitcode library">;
 def libomptarget_nvptx_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-bc-path=">, Group,
   HelpText<"Path to libomptarget-nvptx bitcode library">;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 43b07360625f..53d25c05b623 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -190,6 +190,12 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   CC1Args.push_back(DriverArgs.MakeArgStringRef(GpuArch));
   CC1Args.push_back("-fcuda-is-device");
   CC1Args.push_back("-emit-llvm-bc");
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
+  std::string BitcodeSuffix = "amdgcn-" + GpuArch.str();
+  addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
+ getTriple());
 }
 
 llvm::opt::DerivedArgList *AMDGPUOpenMPToolChain::TranslateArgs(

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index bcaea71dca94..1cbf5e5dfb4e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1627,3 +1627,63 @@ void tools::addMachineOutlinerArgs(const Driver ,
 }
   }
 }
+
+void tools::addOpenMPDeviceRTL(const Driver ,
+   const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList ,
+   StringRef BitcodeSuffix,
+   const llvm::Triple ) {
+  SmallVector LibraryPaths;
+  // Add user defined library paths from LIBRARY_PATH.
+  llvm::Optional LibPath =
+  llvm::sys::Process::GetEnv("LIBRARY_PATH");
+  if (LibPath) {
+SmallVector Frags;
+const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+for 

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 323218.
ahatanak retitled this revision from "[ObjC][ARC] Use operand bundle 
'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the 
IR" to "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 
explicitly emitting retainRV or claimRV calls in the IR".
ahatanak edited the summary of this revision.
ahatanak added a comment.

- Renamed the operand bundle name to `clang.arc.attachedcall`. I also tried to 
pass the address of the ARC function as the argument, but the verifier doesn't 
allow taking addresses of intrinsics.

- Removed the call to `@llvm.objc.clang.arc.noop.use`, which in some cases was 
preventing the inliner to attach the operand bundle to a call in the callee 
function, when the operand bundle is removed from a call (see 
`BundledRetainClaimRVs::eraseInst`).

- Make sure `emitOptimizedARCReturnCall` doesn't drop any existing operand 
bundle on a call when adding the new operand bundle to the call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenObjC/arc-rv-attr.m
  clang/test/CodeGenObjC/arc-unsafeclaim.m
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/ObjCARCUtil.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.h
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
  llvm/test/CodeGen/AArch64/call-rv-marker.ll
  llvm/test/Transforms/DeadArgElim/deadretval.ll
  llvm/test/Transforms/Inline/inline-retainRV-call.ll
  llvm/test/Transforms/ObjCARC/contract-marker-funclet.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Transforms/ObjCARC/contract.ll
  llvm/test/Transforms/ObjCARC/intrinsic-use.ll
  llvm/test/Transforms/ObjCARC/rv.ll
  llvm/test/Transforms/SCCP/clang-arc-rv.ll
  llvm/test/Transforms/TailCallElim/deopt-bundle.ll
  llvm/test/Verifier/operand-bundles.ll

Index: llvm/test/Verifier/operand-bundles.ll
===
--- llvm/test/Verifier/operand-bundles.ll
+++ llvm/test/Verifier/operand-bundles.ll
@@ -1,10 +1,13 @@
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
+%0 = type opaque
+declare void @g()
+declare %0* @foo0()
+declare i8 @foo1()
+
 ; Operand bundles uses are like regular uses, and need to be dominated
 ; by their defs.
 
-declare void @g()
-
 define void @f0(i32* %ptr) {
 ; CHECK: Instruction does not dominate all uses!
 ; CHECK-NEXT:  %x = add i32 42, 1
@@ -60,3 +63,15 @@
   %x = add i32 42, 1
   ret void
 }
+
+define void @f_clang_arc_attachedcall() {
+; CHECK: Multiple "clang.arc.attachedcall" operand bundles
+; CHECK-NEXT: call %0* @foo0() [ "clang.arc.attachedcall"(i64 0), "clang.arc.attachedcall"(i64 0) ]
+; CHECK-NEXT: must call a function returning a pointer
+; CHECK-NEXT: call i8 @foo1() [ "clang.arc.attachedcall"(i64 0) ]
+
+  call %0* @foo0() [ "clang.arc.attachedcall"(i64 0) ]
+  call %0* @foo0() [ "clang.arc.attachedcall"(i64 0), "clang.arc.attachedcall"(i64 0) ]
+  call i8 @foo1() [ "clang.arc.attachedcall"(i64 0) ]
+  ret void
+}
Index: llvm/test/Transforms/TailCallElim/deopt-bundle.ll
===
--- llvm/test/Transforms/TailCallElim/deopt-bundle.ll
+++ llvm/test/Transforms/TailCallElim/deopt-bundle.ll
@@ -55,3 +55,13 @@
 exit:
   ret void
 }
+
+; CHECK-LABEL: @test_clang_arc_attachedcall(
+; CHECK: tail call i8* @getObj(
+
+declare i8* @getObj()
+
+define i8* @test_clang_arc_attachedcall() {
+  %r = call i8* @getObj() [ "clang.arc.attachedcall"(i64 0) ]
+  ret i8* %r
+}
Index: llvm/test/Transforms/SCCP/clang-arc-rv.ll
===
--- /dev/null
+++ llvm/test/Transforms/SCCP/clang-arc-rv.ll
@@ -0,0 +1,24 @@
+; RUN: opt < %s -ipsccp -S | FileCheck %s
+; Return value can't be zapped if there is a call that has operand bundle
+; "clang.arc.attachedcall".
+
+@g0 = global i8 zeroinitializer, align 1
+
+; CHECK-LABEL: @foo(
+; CHECK: ret i8* @g0
+
+define internal i8* @foo() {
+  

[PATCH] D96573: [Clang][ASan] Teach Clang to not emit ASan module destructors when compiling with `-mkernel` or `-fapple-kext`.

2021-02-11 Thread Dan Liew via Phabricator via cfe-commits
delcypher created this revision.
delcypher added reviewers: arphaman, kubamracek, yln, aralisza, kcc, vitalybuka.
delcypher requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rdar://71609176


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96573

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/darwin-asan-mkernel-kext.c


Index: clang/test/Driver/darwin-asan-mkernel-kext.c
===
--- /dev/null
+++ clang/test/Driver/darwin-asan-mkernel-kext.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -mkernel -### \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
+// RUN:   -### %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
+// RUN:   -mkernel -### %s 2>&1 | FileCheck %s
+
+// CHECK: "-fsanitize-address-destructor-kind=none"
+
+// Check it's possible to override the driver's decision.
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
+// RUN:   -mkernel -### -fsanitize-address-destructor-kind=global %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-OVERRIDE %s
+
+// CHECK-OVERRIDE: "-fsanitize-address-destructor-kind=global"
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -825,6 +825,12 @@
   AsanInvalidPointerSub = true;
 }
 
+if (TC.getTriple().isOSDarwin() &&
+(Args.hasArg(options::OPT_mkernel) ||
+ Args.hasArg(options::OPT_fapple_kext))) {
+  AsanDtorKind = llvm::AsanDtorKind::None;
+}
+
 if (const auto *Arg =
 Args.getLastArg(options::OPT_sanitize_address_destructor_kind_EQ)) 
{
   auto parsedAsanDtorKind = AsanDtorKindFromString(Arg->getValue());


Index: clang/test/Driver/darwin-asan-mkernel-kext.c
===
--- /dev/null
+++ clang/test/Driver/darwin-asan-mkernel-kext.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -mkernel -### \
+// RUN:   %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
+// RUN:   -### %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
+// RUN:   -mkernel -### %s 2>&1 | FileCheck %s
+
+// CHECK: "-fsanitize-address-destructor-kind=none"
+
+// Check it's possible to override the driver's decision.
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
+// RUN:   -mkernel -### -fsanitize-address-destructor-kind=global %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-OVERRIDE %s
+
+// CHECK-OVERRIDE: "-fsanitize-address-destructor-kind=global"
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -825,6 +825,12 @@
   AsanInvalidPointerSub = true;
 }
 
+if (TC.getTriple().isOSDarwin() &&
+(Args.hasArg(options::OPT_mkernel) ||
+ Args.hasArg(options::OPT_fapple_kext))) {
+  AsanDtorKind = llvm::AsanDtorKind::None;
+}
+
 if (const auto *Arg =
 Args.getLastArg(options::OPT_sanitize_address_destructor_kind_EQ)) {
   auto parsedAsanDtorKind = AsanDtorKindFromString(Arg->getValue());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96572: [Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.

2021-02-11 Thread Dan Liew via Phabricator via cfe-commits
delcypher updated this revision to Diff 323213.
delcypher added a comment.

clang-format fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96572

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/Sanitizers.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/asan-destructor-kind.cpp
  clang/test/Driver/fsanitize-address-destructor-kind.c

Index: clang/test/Driver/fsanitize-address-destructor-kind.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-address-destructor-kind.c
@@ -0,0 +1,20 @@
+// Option should not be passed to the frontend by default.
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address %s \
+// RUN:   -### 2>&1 | \
+// RUN:   FileCheck %s
+// CHECK-NOT: -fsanitize-address-destructor-kind
+
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=none %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-NONE-ARG %s
+// CHECK-NONE-ARG: "-fsanitize-address-destructor-kind=none"
+
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=global %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-GLOBAL-ARG %s
+// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor-kind=global"
+
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=bad_arg %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-INVALID-ARG %s
+// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
Index: clang/test/CodeGen/asan-destructor-kind.cpp
===
--- /dev/null
+++ clang/test/CodeGen/asan-destructor-kind.cpp
@@ -0,0 +1,49 @@
+// Frontend rejects invalid option
+// RUN: not %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=bad_arg -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-BAD-ARG
+// CHECK-BAD-ARG: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
+
+// Default is global dtor
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
+// RUN:   -fno-legacy-pass-manager %s \
+// RUN:   | FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+//
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
+// RUN:   -flegacy-pass-manager %s \
+// RUN:   | FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+
+// Explictly ask for global dtor
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+//
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+
+// CHECK-GLOBAL-DTOR: llvm.global_dtor{{.+}}asan.module_dtor
+// CHECK-GLOBAL-DTOR: define internal void @asan.module_dtor
+
+// Explictly ask for no dtors
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
+//
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
+
+int global;
+
+int main() {
+  return global;
+}
+
+// CHECK-NONE-DTOR-NOT: llvm.global_dtor{{.+}}asan.module_dtor
+// CHECK-NONE-DTOR-NOT: define internal void @asan.module_dtor
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1511,6 +1511,19 @@
 
   Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true);
 
+  if (LangOptsRef.Sanitize.has(SanitizerKind::Address)) {
+if (Arg *A =
+Args.getLastArg(options::OPT_sanitize_address_destructor_kind_EQ)) {
+  auto destructorKind = AsanDtorKindFromString(A->getValue());
+  if (destructorKind == llvm::AsanDtorKind::Invalid) {
+

[PATCH] D96572: [Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.

2021-02-11 Thread Dan Liew via Phabricator via cfe-commits
delcypher created this revision.
delcypher added reviewers: arphaman, kubamracek, yln, aralisza, kcc, vitalybuka.
Herald added subscribers: dexonsmith, dang.
Herald added a reviewer: jansvoboda11.
delcypher requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The new `-fsanitize-address-destructor-kind=` option allows control over how 
module
destructors are emitted by ASan.

The new option is consumed by both the driver and the frontend and is 
propagated into
codegen options by the frontend.

Both the legacy and new pass manager code have been updated to consume the new 
option
from the codegen options.

It would be nice if the new utility functions (`AsanDtorKindToString` and
`AsanDtorKindFromString`) could live in LLVM instead of Clang so they could be
consumed by other language frontends. Unfortunately that doesn't work because
the clang driver doesn't link against the LLVM instrumentation library.

rdar://71609176


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96572

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/Sanitizers.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/asan-destructor-kind.cpp
  clang/test/Driver/fsanitize-address-destructor-kind.c

Index: clang/test/Driver/fsanitize-address-destructor-kind.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-address-destructor-kind.c
@@ -0,0 +1,20 @@
+// Option should not be passed to the frontend by default.
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address %s \
+// RUN:   -### 2>&1 | \
+// RUN:   FileCheck %s
+// CHECK-NOT: -fsanitize-address-destructor-kind
+
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=none %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-NONE-ARG %s
+// CHECK-NONE-ARG: "-fsanitize-address-destructor-kind=none"
+
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=global %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-GLOBAL-ARG %s
+// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor-kind=global"
+
+// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=bad_arg %s -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-INVALID-ARG %s
+// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
Index: clang/test/CodeGen/asan-destructor-kind.cpp
===
--- /dev/null
+++ clang/test/CodeGen/asan-destructor-kind.cpp
@@ -0,0 +1,49 @@
+// Frontend rejects invalid option
+// RUN: not %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=bad_arg -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-BAD-ARG
+// CHECK-BAD-ARG: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
+
+// Default is global dtor
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
+// RUN:   -fno-legacy-pass-manager %s \
+// RUN:   | FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+//
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
+// RUN:   -flegacy-pass-manager %s \
+// RUN:   | FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+
+// Explictly ask for global dtor
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+//
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
+
+// CHECK-GLOBAL-DTOR: llvm.global_dtor{{.+}}asan.module_dtor
+// CHECK-GLOBAL-DTOR: define internal void @asan.module_dtor
+
+// Explictly ask for no dtors
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
+//
+// RUN: %clang_cc1 -fsanitize=address \
+// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
+// RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
+
+int global;
+

[PATCH] D96367: Partially Revert "scan-view: Remove Reporter.py and associated AppleScript files"

2021-02-11 Thread Tom Stellard 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 rGe3cd3a3c9152: Partially Revert scan-view: Remove 
Reporter.py and associated AppleScript… (authored by tstellar).

Changed prior to commit:
  https://reviews.llvm.org/D96367?vs=322492=323204#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96367

Files:
  clang/tools/scan-view/CMakeLists.txt
  clang/tools/scan-view/share/Reporter.py

Index: clang/tools/scan-view/share/Reporter.py
===
--- /dev/null
+++ clang/tools/scan-view/share/Reporter.py
@@ -0,0 +1,183 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Methods for reporting bugs."""
+
+import subprocess, sys, os
+
+__all__ = ['ReportFailure', 'BugReport', 'getReporters']
+
+#
+
+class ReportFailure(Exception):
+"""Generic exception for failures in bug reporting."""
+def __init__(self, value):
+self.value = value
+
+# Collect information about a bug.
+
+class BugReport(object):
+def __init__(self, title, description, files):
+self.title = title
+self.description = description
+self.files = files
+
+# Reporter interfaces.
+
+import os
+
+import email, mimetypes, smtplib
+from email import encoders
+from email.message import Message
+from email.mime.base import MIMEBase
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+
+#======#
+# ReporterParameter
+#======#
+
+class ReporterParameter(object):
+  def __init__(self, n):
+self.name = n
+  def getName(self):
+return self.name
+  def getValue(self,r,bugtype,getConfigOption):
+ return getConfigOption(r.getName(),self.getName())
+  def saveConfigValue(self):
+return True
+
+class TextParameter (ReporterParameter):
+  def getHTML(self,r,bugtype,getConfigOption):
+return """\
+
+%s:
+
+"""%(self.getName(),r.getName(),self.getName(),self.getValue(r,bugtype,getConfigOption))
+
+class SelectionParameter (ReporterParameter):
+  def __init__(self, n, values):
+ReporterParameter.__init__(self,n)
+self.values = values
+
+  def getHTML(self,r,bugtype,getConfigOption):
+default = self.getValue(r,bugtype,getConfigOption)
+return """\
+
+%s:
+%s
+"""%(self.getName(),r.getName(),self.getName(),'\n'.join(["""\
+%s"""%(o[0],
+ o[0] == default and ' selected="selected"' or '',
+ o[1]) for o in self.values]))
+
+#======#
+# Reporters
+#======#
+
+class EmailReporter(object):
+def getName(self):
+return 'Email'
+
+def getParameters(self):
+return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP Port']]
+
+# Lifted from python email module examples.
+def attachFile(self, outer, path):
+# Guess the content type based on the file's extension.  Encoding
+# will be ignored, although we should check for simple things like
+# gzip'd or compressed files.
+ctype, encoding = mimetypes.guess_type(path)
+if ctype is None or encoding is not None:
+# No guess could be made, or the file is encoded (compressed), so
+# use a generic bag-of-bits type.
+ctype = 'application/octet-stream'
+maintype, subtype = ctype.split('/', 1)
+if maintype == 'text':
+fp = open(path)
+# Note: we should handle calculating the charset
+msg = MIMEText(fp.read(), _subtype=subtype)
+fp.close()
+else:
+fp = open(path, 'rb')
+msg = MIMEBase(maintype, subtype)
+msg.set_payload(fp.read())
+fp.close()
+# Encode the payload using Base64
+encoders.encode_base64(msg)
+# Set the filename parameter
+msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(path))
+outer.attach(msg)
+
+def fileReport(self, report, parameters):
+mainMsg = """\
+BUG REPORT
+---
+Title: %s
+Description: %s
+"""%(report.title, report.description)
+
+if not parameters.get('To'):
+raise ReportFailure('No "To" address specified.')
+if not parameters.get('From'):
+raise ReportFailure('No "From" address specified.')
+
+msg = MIMEMultipart()
+msg['Subject'] = 'BUG REPORT: %s'%(report.title)
+# FIXME: Get config parameters
+msg['To'] = parameters.get('To')
+msg['From'] = parameters.get('From')
+msg.preamble = mainMsg
+
+

[clang] e3cd3a3 - Partially Revert "scan-view: Remove Reporter.py and associated AppleScript files"

2021-02-11 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2021-02-11T19:10:46-08:00
New Revision: e3cd3a3c91524c957e06bb0170343548f02b6842

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

LOG: Partially Revert "scan-view: Remove Reporter.py and associated AppleScript 
files"

This reverts some of commit dbb01536f6f49fa428f170e34466072ef439b3e9.

The Reporter module was still being used by the ScanView.py module and deleting
it caused scan-view to fail.  This commit adds back Reporter.py but removes the
code the references the AppleScript files which were removed in
dbb01536f6f49fa428f170e34466072ef439b3e9.

Reviewed By: NoQ

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

Added: 
clang/tools/scan-view/share/Reporter.py

Modified: 
clang/tools/scan-view/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/scan-view/CMakeLists.txt 
b/clang/tools/scan-view/CMakeLists.txt
index dd3d33439299..eccc6b83195b 100644
--- a/clang/tools/scan-view/CMakeLists.txt
+++ b/clang/tools/scan-view/CMakeLists.txt
@@ -5,6 +5,7 @@ set(BinFiles
 
 set(ShareFiles
   ScanView.py
+  Reporter.py
   startfile.py
   bugcatcher.ico)
 

diff  --git a/clang/tools/scan-view/share/Reporter.py 
b/clang/tools/scan-view/share/Reporter.py
new file mode 100644
index ..31a14fb0cf74
--- /dev/null
+++ b/clang/tools/scan-view/share/Reporter.py
@@ -0,0 +1,183 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""Methods for reporting bugs."""
+
+import subprocess, sys, os
+
+__all__ = ['ReportFailure', 'BugReport', 'getReporters']
+
+#
+
+class ReportFailure(Exception):
+"""Generic exception for failures in bug reporting."""
+def __init__(self, value):
+self.value = value
+
+# Collect information about a bug.
+
+class BugReport(object):
+def __init__(self, title, description, files):
+self.title = title
+self.description = description
+self.files = files
+
+# Reporter interfaces.
+
+import os
+
+import email, mimetypes, smtplib
+from email import encoders
+from email.message import Message
+from email.mime.base import MIMEBase
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+
+#======#
+# ReporterParameter
+#======#
+
+class ReporterParameter(object):
+  def __init__(self, n):
+self.name = n
+  def getName(self):
+return self.name
+  def getValue(self,r,bugtype,getConfigOption):
+ return getConfigOption(r.getName(),self.getName())
+  def saveConfigValue(self):
+return True
+
+class TextParameter (ReporterParameter):
+  def getHTML(self,r,bugtype,getConfigOption):
+return """\
+
+%s:
+
+"""%(self.getName(),r.getName(),self.getName(),self.getValue(r,bugtype,getConfigOption))
+
+class SelectionParameter (ReporterParameter):
+  def __init__(self, n, values):
+ReporterParameter.__init__(self,n)
+self.values = values
+
+  def getHTML(self,r,bugtype,getConfigOption):
+default = self.getValue(r,bugtype,getConfigOption)
+return """\
+
+%s:
+%s
+"""%(self.getName(),r.getName(),self.getName(),'\n'.join(["""\
+%s"""%(o[0],
+ o[0] == default and ' 
selected="selected"' or '',
+ o[1]) for o in self.values]))
+
+#======#
+# Reporters
+#======#
+
+class EmailReporter(object):
+def getName(self):
+return 'Email'
+
+def getParameters(self):
+return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP 
Port']]
+
+# Lifted from python email module examples.
+def attachFile(self, outer, path):
+# Guess the content type based on the file's extension.  Encoding
+# will be ignored, although we should check for simple things like
+# gzip'd or compressed files.
+ctype, encoding = mimetypes.guess_type(path)
+if ctype is None or encoding is not None:
+# No guess could be made, or the file is encoded (compressed), so
+# use a generic bag-of-bits type.
+ctype = 'application/octet-stream'
+maintype, subtype = ctype.split('/', 1)
+if maintype == 'text':
+fp = open(path)
+# Note: we should handle calculating the charset
+msg = MIMEText(fp.read(), _subtype=subtype)
+fp.close()
+else:
+fp = open(path, 'rb')
+msg = MIMEBase(maintype, subtype)
+msg.set_payload(fp.read())
+fp.close()
+# Encode the payload using Base64
+   

[PATCH] D96456: [ThinLTO, NewPM] Register sanitizers with OptimizerLastPassBuilderHook

2021-02-11 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1070-1071
+// ThinLTOIndexFile is provideds so we must be in ThinLTO PostLink.
+// For -O0 ThinLTO PreLink does basic optimization and triggers
+// OptimizerLastEPCallbacks. PostLink will not
+// run optimizations and this callback should

We could fix this. It doesn't make sense for only -O0 to run 
OptimizerLastEPCallbacks prelink. Would that help simplify this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

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


[PATCH] D96456: [ThinLTO, NewPM] Register sanitizers with OptimizerLastPassBuilderHook

2021-02-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1328
+CodeGenOpts.ThinLTOIndexFile.empty()) {
+  // This is testing distributed ThinLTO PostLink. O0 called optimized in
+  // PreLink.

vitalybuka wrote:
> tejohnson wrote:
> > I don't understand what you mean by "O0 called optimized"?
> > Also maybe make it clear that the first sentence goes with the second check?
> > 
> > Also, it isn't clear to me how this is preventing the sanitizers from being 
> > added in the ThinLTO pre-link compiles for optimized compiles, as shown in 
> > your tests. Unlike regular LTO pre-link optimized builds, which are still 
> > getting the sanitizers.
> Reworded:
> OptimizerLastEPCallbacks is good for anything that not SkipThinLTOPostLink
> We need protection only for OptimizerLastEPCallbacks+O0
> Reworded:
> OptimizerLastEPCallbacks is good for anything that not SkipThinLTOPostLink
> We need protection only for OptimizerLastEPCallbacks+O0
We need special protection only against (SkipThinLTOPostLink && O0)



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

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


[PATCH] D96456: [ThinLTO, NewPM] Register sanitizers with OptimizerLastPassBuilderHook

2021-02-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1328
+CodeGenOpts.ThinLTOIndexFile.empty()) {
+  // This is testing distributed ThinLTO PostLink. O0 called optimized in
+  // PreLink.

tejohnson wrote:
> I don't understand what you mean by "O0 called optimized"?
> Also maybe make it clear that the first sentence goes with the second check?
> 
> Also, it isn't clear to me how this is preventing the sanitizers from being 
> added in the ThinLTO pre-link compiles for optimized compiles, as shown in 
> your tests. Unlike regular LTO pre-link optimized builds, which are still 
> getting the sanitizers.
Reworded:
OptimizerLastEPCallbacks is good for anything that not SkipThinLTOPostLink
We need protection only for OptimizerLastEPCallbacks+O0



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1541
+  Triple TargetTriple(M->getTargetTriple());
+  Conf.OptimizerLastPassBuilderHook = [&](PassBuilder ) {
+addSanitizers(TargetTriple, CGOpts, LOpts, PB);

tejohnson wrote:
> This will add sanitizers for the ThinLTO post-link compiles in a distributed 
> build environment. Does something need to set these up for ThinLTO post-link 
> compiles in the in-process ThinLTO case? In that case thinBackend() is 
> invoked via LTO.cpp through the linker.
Yes. And I don't have good idea how to handle that.
Maybe addSanitizer() needs to be moved into 
PassBuilder, but not sure how to get CodeGenOpts and LangOpts there.

For now this patch does not brake that case as it's already broken. Maybe we 
can resolve this later if needed.



Comment at: llvm/include/llvm/LTO/Config.h:53
+  std::function OptimizerLastPassBuilderHook;
+  /// For adding passes that run right before codegen (NewPM only).
   std::function PreCodeGenPassesHook;

tejohnson wrote:
> This one should say legacy PM only
Codegen one is invoked on codegen PM which is different from opt PM
For now codegen PM is always legacy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

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


[PATCH] D96456: [ThinLTO, NewPM] Add Config::OptPassBuilderHook

2021-02-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 323202.
vitalybuka marked 5 inline comments as done.
vitalybuka added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thinlto-distributed-sanitizers.ll
  clang/test/Driver/asan.c
  clang/test/Driver/dfsan.c
  clang/test/Driver/msan.c
  clang/test/Driver/sancov.c
  clang/test/Driver/tsan.c
  llvm/include/llvm/LTO/Config.h
  llvm/lib/LTO/LTOBackend.cpp

Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -253,6 +253,9 @@
   PB.registerLoopAnalyses(LAM);
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
+  if (Conf.OptimizerLastPassBuilderHook)
+Conf.OptimizerLastPassBuilderHook(PB);
+
   ModulePassManager MPM(Conf.DebugPassManager);
 
   if (!Conf.DisableVerify)
Index: llvm/include/llvm/LTO/Config.h
===
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -48,6 +48,8 @@
   TargetOptions Options;
   std::vector MAttrs;
   std::vector PassPlugins;
+  /// For adding passes that run by optimizer (NewPM only).
+  std::function OptimizerLastPassBuilderHook;
   /// For adding passes that run right before codegen.
   std::function PreCodeGenPassesHook;
   Optional RelocModel = Reloc::PIC_;
Index: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -19,9 +19,10 @@
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=NOTSAN
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 
 int foo(int *a) { return *a; }
 // CHECK: __tsan_init
+// NOTSAN-NOT: __tsan
Index: clang/test/Driver/sancov.c
===
--- clang/test/Driver/sancov.c
+++ clang/test/Driver/sancov.c
@@ -3,7 +3,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=NOSANCOV
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 
@@ -20,3 +20,4 @@
 
 int foo(int *a) { return *a; }
 // CHECK: _sancov_
+// NOSANCOV-NOT: _sancov
Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -1,51 +1,55 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 

[PATCH] D94640: adds more checks to -Wfree-nonheap-object

2021-02-11 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/test/Analysis/free.c:84
+  // expected-warning@-1{{Argument to free() is a block, which is not memory 
allocated by malloc()}}
+  // expected-warning@-2{{attempt to call free on non-heap object : block 
expression}}
 }

aaron.ballman wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > The formatting for this diagnostic is somewhat unfortunate in that it has 
> > > the leading space before the `:`. I think that changing the diagnostic to 
> > > use a `%select` would be an improvement.
> > I'm having a *lot* of difficulty getting `%select` to work. Here's what 
> > I've tried, but the space in `%select{ %2` is being ignored :(
> > 
> > ```
> > : Warning<"attempt to call %0 on non-heap object%select{ %2|: block 
> > expression}1">,
> > ```
> We could cheat a little bit. :-D
> 
> `Warning<"attempt to call %0 on non-heap %select{object %2|object: block 
> expression}1">`
> 
> (The diagnostic should probably be updated to distinguish between block 
> expressions and lambda expressions, which may add another layer of `%select` 
> not shown here.)
That doesn't fix the issue, which is that everything before `%2` is deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94640

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


[PATCH] D86547: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z

2021-02-11 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

I checked this, and it seems good to me although I would like someone else to 
also take a look.

In D86547#2287353 , @atrosinenko wrote:

> In D86547#2284095 , @MaskRay wrote:
>
>> The `(aWidth - 1) - clzsi(a)` change is correct, but why is the ctz change?
>
> `d.s.low` and `d.s.high` are `su_int`. While some helpers from `libgcc` are 
> documented with `int`, `long`, etc. types //for simplicity// and use machine 
> modes under the hood, the `__builtin_ctz()` function (as well as clz), on the 
> other hand, seems to **really** accept an `int`-sized argument:

I can confirm this. This is why I introduced the `clzsi` and `ctzsi` macros in 
D78662 . They are not intended for use with 
plain `int` types, but for use with `si_int` / `su_int` types (that are always 
32-bit, unlike `int`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86547

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


[clang] 686b65f - [Msan, NewPM] Reduce size of msan binaries

2021-02-11 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-02-11T16:07:18-08:00
New Revision: 686b65f85f22c70e082753cd05e8572d22e3991c

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

LOG: [Msan, NewPM] Reduce size of msan binaries

EarlyCSEPass called after msan redices code size by about 10%.
Similar optimization exists for legacy pass manager in
addGeneralOptsForMemorySanitizer.

Reviewed By: eugenis

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/Driver/msan.c

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 57efa63a2aad..74c01fec6944 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -76,6 +76,7 @@
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Scalar/EarlyCSE.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
@@ -1079,8 +1080,22 @@ static void addSanitizers(const Triple ,
 
 MPM.addPass(
 MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
-MPM.addPass(createModuleToFunctionPassAdaptor(
-MemorySanitizerPass({TrackOrigins, Recover, CompileKernel})));
+FunctionPassManager FPM(CodeGenOpts.DebugPassManager);
+FPM.addPass(
+MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
+if (Level != PassBuilder::OptimizationLevel::O0) {
+  // MemorySanitizer inserts complex instrumentation that mostly
+  // follows the logic of the original code, but operates on
+  // "shadow" values. It can benefit from re-running some
+  // general purpose optimization passes.
+  FPM.addPass(EarlyCSEPass());
+  // TODO: Consider add more passes like in
+  // addGeneralOptsForMemorySanitizer. EarlyCSEPass makes visible
+  // 
diff erence on size. It's not clear if the rest is still
+  // usefull. InstCombinePass breakes
+  // compiler-rt/test/msan/select_origin.cpp.
+}
+MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 };
 MSanPass(SanitizerKind::Memory, false);

diff  --git a/clang/test/Driver/msan.c b/clang/test/Driver/msan.c
index d7cbf5372d31..8b69ca574eac 100644
--- a/clang/test/Driver/msan.c
+++ b/clang/test/Driver/msan.c
@@ -1,49 +1,51 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefixes=CHECK
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O0
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O1
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O1
+// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O1
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefixes=CHECK,O0
+// 

[PATCH] D96406: [Msan, NewPM] Reduce size of msan binaries

2021-02-11 Thread Vitaly Buka 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 rG686b65f85f22: [Msan, NewPM] Reduce size of msan binaries 
(authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D96406?vs=322644=323181#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96406

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/msan.c

Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -1,49 +1,51 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
+// RUN: %clang -O3 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
+// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK,O0
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK,O1
+// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK,O0
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK,O1
 
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
+// RUN: %clang 

[PATCH] D86546: [compiler-rt][builtins] Use explicitly-sized integer types for LibCalls

2021-02-11 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

This looks good to me, although I would like someone else to take a look as 
well. I can confirm that these changes fix an issue on AVR: this patch 
(together with D86547 ) make `__floatsisf` 
correct on AVR while it would previously do something incorrect.

What I am somewhat worried about is that some of these functions 
(`__floatsisf`, `__floatunsisf`) do not have tests. I think the test for the 
*vfp variants could be shared between the *vfp and non-*vfp variants. But I 
think this is best done separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86546

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


[clang] f2f59d2 - [NFC] Extract function which registers sanitizer passes

2021-02-11 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-02-11T15:29:48-08:00
New Revision: f2f59d2a060788f17040ad924ee2d11da0e215c8

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

LOG: [NFC] Extract function which registers sanitizer passes

Reviewed By: aeubanks

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 28edff80e647..57efa63a2aad 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1058,6 +1058,70 @@ static PassBuilder::OptimizationLevel mapToLevel(const 
CodeGenOptions ) {
   }
 }
 
+static void addSanitizers(const Triple ,
+  const CodeGenOptions ,
+  const LangOptions , PassBuilder ) {
+  PB.registerOptimizerLastEPCallback([&](ModulePassManager ,
+ PassBuilder::OptimizationLevel Level) 
{
+if (CodeGenOpts.SanitizeCoverageType ||
+CodeGenOpts.SanitizeCoverageIndirectCalls ||
+CodeGenOpts.SanitizeCoverageTraceCmp) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
+  CodeGenOpts.SanitizeCoverageBlocklistFiles));
+}
+
+auto MSanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+  if (LangOpts.Sanitize.has(Mask)) {
+int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
+bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+
+MPM.addPass(
+MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+MemorySanitizerPass({TrackOrigins, Recover, CompileKernel})));
+  }
+};
+MSanPass(SanitizerKind::Memory, false);
+MSanPass(SanitizerKind::KernelMemory, true);
+
+if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+  MPM.addPass(ThreadSanitizerPass());
+  MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
+}
+
+auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+  if (LangOpts.Sanitize.has(Mask)) {
+bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
+bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
+bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
+MPM.addPass(RequireAnalysisPass());
+MPM.addPass(ModuleAddressSanitizerPass(
+CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+AddressSanitizerPass(CompileKernel, Recover, UseAfterScope)));
+  }
+};
+ASanPass(SanitizerKind::Address, false);
+ASanPass(SanitizerKind::KernelAddress, true);
+
+auto HWASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+  if (LangOpts.Sanitize.has(Mask)) {
+bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+MPM.addPass(HWAddressSanitizerPass(CompileKernel, Recover));
+  }
+};
+HWASanPass(SanitizerKind::HWAddress, false);
+HWASanPass(SanitizerKind::KernelHWAddress, true);
+
+if (LangOpts.Sanitize.has(SanitizerKind::DataFlow)) {
+  MPM.addPass(DataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
+}
+  });
+}
+
 /// A clean version of `EmitAssembly` that uses the new pass manager.
 ///
 /// Not all features are currently supported in this system, but where
@@ -1249,87 +1313,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 FPM.addPass(BoundsCheckingPass());
   });
 
-if (CodeGenOpts.SanitizeCoverageType ||
-CodeGenOpts.SanitizeCoverageIndirectCalls ||
-CodeGenOpts.SanitizeCoverageTraceCmp) {
-  PB.registerOptimizerLastEPCallback(
-  [this](ModulePassManager , PassBuilder::OptimizationLevel Level) 
{
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
-CodeGenOpts.SanitizeCoverageBlocklistFiles));
-  });
-}
-
-auto MSanPass = [&](SanitizerMask Mask, bool CompileKernel) {
-  if (LangOpts.Sanitize.has(Mask)) {
-int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
-bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
-PB.registerOptimizerLastEPCallback(
-[CompileKernel, TrackOrigins, Recover](
-ModulePassManager , PassBuilder::OptimizationLevel Level) {
-  

[PATCH] D96481: [NFC] Extract function which registers sanitizer passes

2021-02-11 Thread Vitaly Buka 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 rGf2f59d2a0607: [NFC] Extract function which registers 
sanitizer passes (authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96481

Files:
  clang/lib/CodeGen/BackendUtil.cpp

Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1058,6 +1058,70 @@
   }
 }
 
+static void addSanitizers(const Triple ,
+  const CodeGenOptions ,
+  const LangOptions , PassBuilder ) {
+  PB.registerOptimizerLastEPCallback([&](ModulePassManager ,
+ PassBuilder::OptimizationLevel Level) {
+if (CodeGenOpts.SanitizeCoverageType ||
+CodeGenOpts.SanitizeCoverageIndirectCalls ||
+CodeGenOpts.SanitizeCoverageTraceCmp) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
+  CodeGenOpts.SanitizeCoverageBlocklistFiles));
+}
+
+auto MSanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+  if (LangOpts.Sanitize.has(Mask)) {
+int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
+bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+
+MPM.addPass(
+MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+MemorySanitizerPass({TrackOrigins, Recover, CompileKernel})));
+  }
+};
+MSanPass(SanitizerKind::Memory, false);
+MSanPass(SanitizerKind::KernelMemory, true);
+
+if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+  MPM.addPass(ThreadSanitizerPass());
+  MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
+}
+
+auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+  if (LangOpts.Sanitize.has(Mask)) {
+bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
+bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
+bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
+MPM.addPass(RequireAnalysisPass());
+MPM.addPass(ModuleAddressSanitizerPass(
+CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+AddressSanitizerPass(CompileKernel, Recover, UseAfterScope)));
+  }
+};
+ASanPass(SanitizerKind::Address, false);
+ASanPass(SanitizerKind::KernelAddress, true);
+
+auto HWASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
+  if (LangOpts.Sanitize.has(Mask)) {
+bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+MPM.addPass(HWAddressSanitizerPass(CompileKernel, Recover));
+  }
+};
+HWASanPass(SanitizerKind::HWAddress, false);
+HWASanPass(SanitizerKind::KernelHWAddress, true);
+
+if (LangOpts.Sanitize.has(SanitizerKind::DataFlow)) {
+  MPM.addPass(DataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
+}
+  });
+}
+
 /// A clean version of `EmitAssembly` that uses the new pass manager.
 ///
 /// Not all features are currently supported in this system, but where
@@ -1249,87 +1313,7 @@
 FPM.addPass(BoundsCheckingPass());
   });
 
-if (CodeGenOpts.SanitizeCoverageType ||
-CodeGenOpts.SanitizeCoverageIndirectCalls ||
-CodeGenOpts.SanitizeCoverageTraceCmp) {
-  PB.registerOptimizerLastEPCallback(
-  [this](ModulePassManager , PassBuilder::OptimizationLevel Level) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
-CodeGenOpts.SanitizeCoverageBlocklistFiles));
-  });
-}
-
-auto MSanPass = [&](SanitizerMask Mask, bool CompileKernel) {
-  if (LangOpts.Sanitize.has(Mask)) {
-int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
-bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
-PB.registerOptimizerLastEPCallback(
-[CompileKernel, TrackOrigins, Recover](
-ModulePassManager , PassBuilder::OptimizationLevel Level) {
-  MPM.addPass(
-  MemorySanitizerPass({TrackOrigins, Recover, CompileKernel}));
-  MPM.addPass(createModuleToFunctionPassAdaptor(
-  MemorySanitizerPass({TrackOrigins, Recover, CompileKernel})));
-});
-  }
-};
-MSanPass(SanitizerKind::Memory, false);
-

[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-02-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

FYI, https://reviews.llvm.org/D17444 captures some of the history here.




Comment at: clang/lib/Parse/ParseDeclCXX.cpp:874-876
+if (!getLangOpts().CPlusPlus)
+  Diag(Tok, diag::warn_cxx_static_assert_in_c)
+  << FixItHint::CreateReplacement(Tok.getLocation(), "_Static_assert");

aaron.ballman wrote:
> aaron.ballman wrote:
> > rsmith wrote:
> > > I don't think this diagnostic is useful as-is: on Windows, including 
> > > `` doesn't help because it doesn't `#define static_assert`. And 
> > > people hitting this also can't switch to using `_Static_assert`, because 
> > > MSVC doesn't provide it, only `static_assert`.
> > > 
> > > If we want to warn here, we could perhaps check whether `` has 
> > > been included, but getting that check correct across PCH / modules is not 
> > > straightforward. (If we knew what include guard the CRT's `assert.h` used 
> > > (if any), I guess we could check whether that's defined, but that'd be a 
> > > bit of a hack.) But I'm somewhat inclined to think we don't have a good 
> > > way to distinguish between the good cases and the bad ones, so we 
> > > shouldn't warn. Hopefully MS will fix their CRT at some point and we can 
> > > stop providing this compatibility hack entirely (or start warning on it 
> > > by default).
> > Are you sure they don't support `_Static_assert` yet? I seem to be able to 
> > use it fine: https://godbolt.org/z/vG47he
> > 
> > That said, this does appear to be only available in newer versions of MSVC, 
> > so perhaps you're correct about the diagnostic being a bit unhelpful. My 
> > primary concern is that use of `static_assert` in C is a nonconforming 
> > extension and we default to `-fms-compatibility` on Windows when Clang is 
> > built by MSVC. So it's not difficult to accidentally run into this, but the 
> > only warning we give on it with `-Weverything -pedantic` is how it's not 
> > compatible with C++98.
> > 
> > WDYT?
> I suppose one option would be to look at what version of MSVC we're trying to 
> be compatible with to see if that's a version that supports `/std:c11` and 
> only emit this diagnostic in that case, but tbh, that feels like it'll lead 
> to confusing diagnostic behavior (esp given that we default to ms 
> compatibility mode silently when you build Clang with MSVC on Windows).
> 
> Given that MSVC does support `_Static_assert` when you enable C11 or later 
> language mode, I'm inclined to warn on this construct by default.
> 
> WDYT?
Well, it's good to see that they've made progress, but it [looks 
like](https://godbolt.org/z/YfEhGW) their `` still doesn't `#define 
static_assert`, so I think we still don't have an actionable warning we can 
produce here. We can't reasonably tell people to include `` (as this 
patch does) because that doesn't work. And it doesn't seem reasonable to tell 
people to use `_Static_assert` instead, if they actually have included 
``. (I don't think we want to encourage people to use 
`_Static_assert` instead of `` + `static_assert`.)

So I don't think MSVC adding support for `_Static_assert` really changes 
anything here -- until their `` works, or we find some good way to 
detect whether it was properly included, this warning will fire on both correct 
code and incorrect code, which doesn't seem all that useful.


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

https://reviews.llvm.org/D95396

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


[PATCH] D89274: [WebAssembly] Use the new crt1-command.o if present.

2021-02-11 Thread Dan Gohman 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 rGf9c05fc39145: [WebAssembly] Use the new crt1-command.o if 
present. (authored by sunfish).

Changed prior to commit:
  https://reviews.llvm.org/D89274?vs=297698=323164#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89274

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -77,6 +77,16 @@
 
   const char *Crt1 = "crt1.o";
   const char *Entry = NULL;
+
+  // If crt1-command.o exists, it supports new-style commands, so use it.
+  // Otherwise, use the old crt1.o. This is a temporary transition measure.
+  // Once WASI libc no longer needs to support LLVM versions which lack
+  // support for new-style command, it can make crt1.o the same as
+  // crt1-command.o. And once LLVM no longer needs to support WASI libc
+  // versions before that, it can switch to using crt1-command.o.
+  if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
+Crt1 = "crt1-command.o";
+
   if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "command") {


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -77,6 +77,16 @@
 
   const char *Crt1 = "crt1.o";
   const char *Entry = NULL;
+
+  // If crt1-command.o exists, it supports new-style commands, so use it.
+  // Otherwise, use the old crt1.o. This is a temporary transition measure.
+  // Once WASI libc no longer needs to support LLVM versions which lack
+  // support for new-style command, it can make crt1.o the same as
+  // crt1-command.o. And once LLVM no longer needs to support WASI libc
+  // versions before that, it can switch to using crt1-command.o.
+  if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
+Crt1 = "crt1-command.o";
+
   if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "command") {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f9c05fc - [WebAssembly] Use the new crt1-command.o if present.

2021-02-11 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2021-02-11T14:44:37-08:00
New Revision: f9c05fc391458e455e8e4d4108a7f270f2f7bedc

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

LOG: [WebAssembly] Use the new crt1-command.o if present.

If crt1-command.o exists in the sysroot, the libc has new-style command
support, so use it.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 6b654886e774..83a895b47142 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -77,6 +77,16 @@ void wasm::Linker::ConstructJob(Compilation , const 
JobAction ,
 
   const char *Crt1 = "crt1.o";
   const char *Entry = NULL;
+
+  // If crt1-command.o exists, it supports new-style commands, so use it.
+  // Otherwise, use the old crt1.o. This is a temporary transition measure.
+  // Once WASI libc no longer needs to support LLVM versions which lack
+  // support for new-style command, it can make crt1.o the same as
+  // crt1-command.o. And once LLVM no longer needs to support WASI libc
+  // versions before that, it can switch to using crt1-command.o.
+  if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
+Crt1 = "crt1-command.o";
+
   if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "command") {



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


[PATCH] D96244: [clangd] Introduce Modules

2021-02-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm a little bit nervous about adding this with *no* usage, but it keeps the 
patch size down :-)




Comment at: clang-tools-extra/clangd/Module.cpp:1
+//===--- Module.cpp - Main clangd server code *- 
C++-*-===//
+//

please add if/when it's actually needed



Comment at: clang-tools-extra/clangd/Module.h:13
+/// of only a public interface to access the functionality from C++ embedders,
+///ClangdServer::getModule()->foo(...)
+///

This isn't implemented - i'm not sure if i should be reviewing the comment or 
the impl :-)

we'll need it at some point (if we're going to move features which have public 
APIs in clangdserver into modules) but not in this patch



Comment at: clang-tools-extra/clangd/Module.h:15
+///
+/// FIXME: Extend this with LSP bindings to support updating capabilities and
+/// implementing LSP endpoints.

nit: not just updating but also reading client caps



Comment at: clang-tools-extra/clangd/Module.h:24
+///available to those modules after ClangdServer is initalized.
+///  - module hooks can be called afterwards.
+///  - modules can be destroyed before/after ClangdServer and ClangdLSPServer

need some guarantee that module *usage* ends before clangdserver is destroyed, 
for some sensible definition of usage



Comment at: clang-tools-extra/clangd/Module.h:25
+///  - module hooks can be called afterwards.
+///  - modules can be destroyed before/after ClangdServer and ClangdLSPServer
+///FIXME: Once we make server facilities available to modules, we'll need 
to

this doesn't make sense to me - neither of these own the modules (right?), so 
who would be destroying them while the server is still alive (and how would we 
ensure this is safe)?



Comment at: clang-tools-extra/clangd/Module.h:36
+  /// Identifier for the plugin, should be unique.
+  virtual llvm::StringLiteral id() = 0;
+

what is this for? is it needed?



Comment at: clang-tools-extra/clangd/Module.h:39
+  /// Some modules might own background tasks. They should override this method
+  /// to indicate status of these tasks.
+  virtual void blockUntilIdle() {}

Some indication that this is for testing.



Comment at: clang-tools-extra/clangd/Module.h:40
+  /// to indicate status of these tasks.
+  virtual void blockUntilIdle() {}
+};

this isn't called - call it or leave it out?



Comment at: clang-tools-extra/clangd/Module.h:43
+
+/// Wrapper around a set of modules to provide type based grouping.
+// Ideas for implementing this:

As discussed offline, I don't think sub-interfaces are a great way to express 
the various ways to express clangd, at least initially.
You end up either having to deal with multiple inheritance or multiple module 
instances.
The former is a hassle we only need consider if the interface gets wide, the 
latter loses some of the simplicity of the model (if a feature contains 3 hooks 
that share state, where does that state go?)

For now, I think it's enough to be able to iterate over Module (Given the 
ModuleSet name, I think defining begin()/end() etc make sense)



Comment at: clang-tools-extra/clangd/Module.h:53
+public:
+  explicit ModuleSet(std::vector> Modules);
+  // Returns all the modules of type T.

this interface isn't compatible with modules eventually having public 
interfaces, because it loses the type information. but we can change this later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96244

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:261
+   diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+ "Use of `-fdefault-double-8` requires `-fdefault-real-8`");
+   diags.Report(diagID);

awarzynski wrote:
> Is this requirement document anywhere?
Just found out through running `gfortran`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96344

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


[PATCH] D68590: [clangd] Improve hover scopes for Objective-C code

2021-02-11 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 323156.
dgoldman marked an inline comment as done.
dgoldman added a comment.

- Support protocols


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68590

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2167,7 +2167,8 @@
 HI.Name = "data";
 HI.Type = "char";
 HI.Kind = index::SymbolKind::Field;
-HI.NamespaceScope = "ObjC::"; // FIXME: fix it
+HI.LocalScope = "ObjC::";
+HI.NamespaceScope = "";
 HI.Definition = "char data";
   }},
   {
@@ -2260,6 +2261,86 @@
 HI.Name = "this";
 HI.Definition = "const Foo *";
   }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface MYObject (Private)
+  @property(nonatomic, assign) int privateField;
+  @end
+
+  int someFunction() {
+MYObject *obj = [MYObject sharedInstance];
+return obj.[[private^Field]];
+  }
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "privateField";
+HI.Kind = index::SymbolKind::InstanceProperty;
+HI.LocalScope = "MYObject(Private)::";
+HI.NamespaceScope = "";
+HI.Definition = "@property(nonatomic, assign, unsafe_unretained, "
+"readwrite) int privateField;";
+  }},
+  {
+  R"cpp(
+  @protocol MYProtocol
+  @property(nonatomic, assign) int prop1;
+  @end
+
+  int someFunction() {
+id obj = 0;
+return obj.[[pro^p1]];
+  }
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "prop1";
+HI.Kind = index::SymbolKind::InstanceProperty;
+HI.LocalScope = "MYProtocol::";
+HI.NamespaceScope = "";
+HI.Definition = "@property(nonatomic, assign, unsafe_unretained, "
+"readwrite) int prop1;";
+  }},
+  {R"objc(
+@interface Foo
+@end
+
+@implementation Foo(Private)
++ (int)somePrivateMethod {
+  int [[res^ult]] = 2;
+  return result;
+}
+@end
+)objc",
+   [](HoverInfo ) {
+ HI.Name = "result";
+ HI.Definition = "int result = 2";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.Type = "int";
+ HI.LocalScope = "+[Foo(Private) somePrivateMethod]::";
+ HI.NamespaceScope = "";
+ HI.Value = "2";
+   }},
+  {R"objc(
+@interface Foo
+@end
+
+@implementation Foo
+- (int)variadicArgMethod:(id)first, ... {
+  int [[res^ult]] = 0;
+  return result;
+}
+@end
+)objc",
+   [](HoverInfo ) {
+ HI.Name = "result";
+ HI.Definition = "int result = 0";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.Type = "int";
+ HI.LocalScope = "-[Foo variadicArgMethod:, ...]::";
+ HI.NamespaceScope = "";
+ HI.Value = "0";
+   }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -64,6 +65,15 @@
 std::string getLocalScope(const Decl *D) {
   std::vector Scopes;
   const DeclContext *DC = D->getDeclContext();
+
+  // ObjC scopes won't have multiple components for us to join, instead:
+  // - Methods: "-[Class methodParam1:methodParam2]"
+  // - Classes, categories, and protocols: "MyClass(Category)"
+  if (const ObjCMethodDecl *MD = dyn_cast(DC))
+return printObjCMethod(*MD);
+  else if (const ObjCContainerDecl *CD = dyn_cast(DC))
+return printObjCContainer(*CD);
+
   auto GetName = [](const TypeDecl *D) {
 if (!D->getDeclName().isEmpty()) {
   PrintingPolicy Policy = D->getASTContext().getPrintingPolicy();
@@ -90,6 +100,11 @@
 std::string getNamespaceScope(const Decl *D) {
   const DeclContext *DC = D->getDeclContext();
 
+  // ObjC does not have the concept of namespaces, so instead we support
+  // local scopes.
+  if (isa(DC))
+return "";
+
   if (const TagDecl *TD = 

[clang] 60bed4a - Replace deprecated %T in 2 tests.

2021-02-11 Thread Hafiz Abid Qadeer via cfe-commits

Author: Hafiz Abid Qadeer
Date: 2021-02-11T22:21:21Z
New Revision: 60bed4ab57d562d5770cc9c24a8fcb243208f5e5

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

LOG: Replace deprecated %T in 2 tests.

In D91442, @MaskRay commented about a failure. This commit does the following to
address his comments:

1. Replace %T with %t as former is deprecated.
2. Add an explicit --sysroot argument in a test.

Some tests were failing when gcc-10-riscv64-linux-gnu is installed on test 
machine.
This was happening because the test was checking a case when --gcc-toolchain is 
not
provided. But if --sysroot was also not provided then code could pick a 
toolchain
installed in /usr. So to make the test more robust, I have provided an explicit 
--sysroot
argument. Its value has been chosen to match the existing patterns.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv64-toolchain-extra.c

Removed: 




diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c 
b/clang/test/Driver/riscv32-toolchain-extra.c
index 59e2560b09c7..5df09029fc6f 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv32-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld 
%T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
-// RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv32-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/riscv32-nogcc/bin
+// RUN: ln -s %clang %t/riscv32-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld 
%t/riscv32-nogcc/bin/riscv32-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%t/riscv32-nogcc/riscv32-unknown-elf
+// RUN: %t/riscv32-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--gcc-toolchain=%t/riscv32-nogcc/invalid \
 // RUN:-target riscv32-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
-// RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN: %t/riscv32-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--sysroot=%t/riscv32-nogcc/bin/../riscv32-unknown-elf \
 // RUN:-target riscv32-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv32.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" 
"{{.*}}/riscv32-nogcc/bin/../riscv32-unknown-elf/include"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}/riscv32-nogcc/bin/riscv32-unknown-elf-ld"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}/riscv32-nogcc/bin/../riscv32-unknown-elf/lib/crt0.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}/riscv32-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}/riscv32-nogcc/bin/../riscv32-unknown-elf/lib"
 // C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv32.a"
-// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}/riscv32-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv32.a"
+// C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}/riscv32-nogcc/{{.*}}/lib/clang_rt.crtend-riscv32.o"

diff  --git a/clang/test/Driver/riscv64-toolchain-extra.c 
b/clang/test/Driver/riscv64-toolchain-extra.c
index 4412a90713d4..e6cae72ed2a2 100644
--- 

[PATCH] D93023: Replace deprecated %T in 2 tests.

2021-02-11 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG60bed4ab57d5: Replace deprecated %T in 2 tests. (authored by 
abidh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93023

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv64-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/riscv64-nogcc/bin
+// RUN: ln -s %clang %t/riscv64-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%t/riscv64-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%t/riscv64-nogcc/riscv64-unknown-elf
+// RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--gcc-toolchain=%t/riscv64-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--sysroot=%t/riscv64-nogcc/bin/../riscv64-unknown-elf \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv32-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld 
%T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
-// RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv32-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/riscv32-nogcc/bin
+// RUN: ln -s %clang %t/riscv32-nogcc/bin/clang

[PATCH] D95655: [AArch64] Adding Neon Sm3 & Sm4 Intrinsics

2021-02-11 Thread Pengxuan Zheng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61cca0f2e5bb: [AArch64] Adding Neon Sm3  Sm4 Intrinsics 
(authored by pzheng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95655

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll

Index: llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc %s -mtriple=aarch64 -mattr=+v8.3a,+sm4 -o - | FileCheck %s
+
+define <4 x i32> @test_vsm3partw1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3partw1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3partw1 v0.4s, v1.4s, v2.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm3partw1.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3partw1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+  ret <4 x i32> %vsm3partw1.i
+}
+
+define <4 x i32> @test_vsm3partw2(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3partw2:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3partw2 v0.4s, v1.4s, v2.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm3partw2.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3partw2(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+  ret <4 x i32> %vsm3partw2.i
+}
+
+define <4 x i32> @test_vsm3ss1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3ss1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3ss1 v0.4s, v0.4s, v1.4s, v2.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm3ss1.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3ss1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+  ret <4 x i32> %vsm3ss1.i
+}
+
+define <4 x i32> @test_vsm3tt1a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt1a:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt1a v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt1a.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt1a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt1a.i
+}
+
+define <4 x i32> @test_vsm3tt1b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt1b:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt1b v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt1b.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt1b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt1b.i
+}
+
+define <4 x i32> @test_vsm3tt2a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt2a:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt2a v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt2a.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt2a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt2a.i
+}
+
+define <4 x i32> @test_vsm3tt2b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt2b:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt2b v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt2b.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt2b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt2b.i
+}
+
+define <4 x i32> @test_vsm4e(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vsm4e:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm4e v0.4s, v1.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm4e.i = tail call <4 x i32> @llvm.aarch64.crypto.sm4e(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %vsm4e.i
+}
+
+define <4 x i32> @test_vsm4ekey(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vsm4ekey:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm4ekey v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm4ekey.i = tail call <4 x i32> @llvm.aarch64.crypto.sm4ekey(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %vsm4ekey.i
+}
+
+declare <4 x i32> @llvm.aarch64.crypto.sm3partw1(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm3partw2(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm3ss1(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt1a(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt2b(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt2a(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt1b(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm4e(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm4ekey(<4 x i32>, 

[clang] 61cca0f - [AArch64] Adding Neon Sm3 & Sm4 Intrinsics

2021-02-11 Thread Pengxuan Zheng via cfe-commits

Author: Pengxuan Zheng
Date: 2021-02-11T14:20:20-08:00
New Revision: 61cca0f2e5bbb6045bb27b822e34cd39c9c1acb1

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

LOG: [AArch64] Adding Neon Sm3 & Sm4 Intrinsics

This adds SM3 and SM4 Intrinsics support for AArch64, specifically:
vsm3ss1q_u32
vsm3tt1aq_u32
vsm3tt1bq_u32
vsm3tt2aq_u32
vsm3tt2bq_u32
vsm3partw1q_u32
vsm3partw2q_u32
vsm4eq_u32
vsm4ekeyq_u32

Reviewed By: labrinea

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

Added: 
clang/test/CodeGen/aarch64-neon-range-checks.c
clang/test/CodeGen/aarch64-neon-sm4-sm3.c
llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 3b2a578f796e..9835c13c0dcd 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1134,6 +1134,17 @@ def SHA1SU0 : SInst<"vsha1su0", "", "QUi">;
 def SHA256H : SInst<"vsha256h", "", "QUi">;
 def SHA256H2 : SInst<"vsha256h2", "", "QUi">;
 def SHA256SU1 : SInst<"vsha256su1", "", "QUi">;
+
+def SM3SS1 : SInst<"vsm3ss1", "", "QUi">;
+def SM3TT1A : SInst<"vsm3tt1a", "I", "QUi">;
+def SM3TT1B : SInst<"vsm3tt1b", "I", "QUi">;
+def SM3TT2A : SInst<"vsm3tt2a", "I", "QUi">;
+def SM3TT2B : SInst<"vsm3tt2b", "I", "QUi">;
+def SM3PARTW1 : SInst<"vsm3partw1", "", "QUi">;
+def SM3PARTW2 : SInst<"vsm3partw2", "", "QUi">;
+
+def SM4E : SInst<"vsm4e", "...", "QUi">;
+def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
 }
 
 


diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f7a4295b11c5..a1d518697e60 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5832,6 +5832,15 @@ static const ARMVectorIntrinsicInfo 
AArch64SIMDIntrinsicMap[] = {
   NEONMAP0(vshr_n_v),
   NEONMAP0(vshrn_n_v),
   NEONMAP0(vshrq_n_v),
+  NEONMAP1(vsm3partw1q_v, aarch64_crypto_sm3partw1, 0),
+  NEONMAP1(vsm3partw2q_v, aarch64_crypto_sm3partw2, 0),
+  NEONMAP1(vsm3ss1q_v, aarch64_crypto_sm3ss1, 0),
+  NEONMAP1(vsm3tt1aq_v, aarch64_crypto_sm3tt1a, 0),
+  NEONMAP1(vsm3tt1bq_v, aarch64_crypto_sm3tt1b, 0),
+  NEONMAP1(vsm3tt2aq_v, aarch64_crypto_sm3tt2a, 0),
+  NEONMAP1(vsm3tt2bq_v, aarch64_crypto_sm3tt2b, 0),
+  NEONMAP1(vsm4ekeyq_v, aarch64_crypto_sm4ekey, 0),
+  NEONMAP1(vsm4eq_v, aarch64_crypto_sm4e, 0),
   NEONMAP1(vst1_x2_v, aarch64_neon_st1x2, 0),
   NEONMAP1(vst1_x3_v, aarch64_neon_st1x3, 0),
   NEONMAP1(vst1_x4_v, aarch64_neon_st1x4, 0),
@@ -6710,6 +6719,22 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 Ops.push_back(getAlignmentValue32(PtrOp0));
 return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, "");
   }
+  case NEON::BI__builtin_neon_vsm3partw1q_v:
+  case NEON::BI__builtin_neon_vsm3partw2q_v:
+  case NEON::BI__builtin_neon_vsm3ss1q_v:
+  case NEON::BI__builtin_neon_vsm4ekeyq_v:
+  case NEON::BI__builtin_neon_vsm4eq_v: {
+Function *F = CGM.getIntrinsic(Int);
+return EmitNeonCall(F, Ops, "");
+  }
+  case NEON::BI__builtin_neon_vsm3tt1aq_v:
+  case NEON::BI__builtin_neon_vsm3tt1bq_v:
+  case NEON::BI__builtin_neon_vsm3tt2aq_v:
+  case NEON::BI__builtin_neon_vsm3tt2bq_v: {
+Function *F = CGM.getIntrinsic(Int);
+Ops[3] = Builder.CreateZExt(Ops[3], Int64Ty);
+return EmitNeonCall(F, Ops, "");
+  }
   case NEON::BI__builtin_neon_vst1_x2_v:
   case NEON::BI__builtin_neon_vst1q_x2_v:
   case NEON::BI__builtin_neon_vst1_x3_v:

diff  --git a/clang/test/CodeGen/aarch64-neon-range-checks.c 
b/clang/test/CodeGen/aarch64-neon-range-checks.c
new file mode 100644
index ..fa5454b955e6
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-neon-range-checks.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon 
-target-feature +crypto -verify %s
+
+#include 
+
+void test_range_check_vsm3tt1a(uint32x4_t a, uint32x4_t b, uint32x4_t c) {
+  vsm3tt1aq_u32(a, b, c, 4); // expected-error {{argument value 4 is outside 
the valid range [0, 3]}}
+  vsm3tt1aq_u32(a, b, c, -1); // expected-error {{argument value -1 is outside 
the valid range [0, 3]}}
+  vsm3tt1aq_u32(a, b, c, 3);
+  vsm3tt1aq_u32(a, b, c, 0);
+}
+
+void test_range_check_vsm3tt1b(uint32x4_t a, uint32x4_t b, uint32x4_t c) {
+  vsm3tt1bq_u32(a, b, c, 4);// expected-error {{argument value 4 is outside 
the valid range [0, 3]}}
+  vsm3tt1bq_u32(a, b, 

[PATCH] D68590: [clangd] Improve hover scopes for Objective-C code

2021-02-11 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 323151.
dgoldman added a comment.

- Move over to AST.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68590

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2167,7 +2167,8 @@
 HI.Name = "data";
 HI.Type = "char";
 HI.Kind = index::SymbolKind::Field;
-HI.NamespaceScope = "ObjC::"; // FIXME: fix it
+HI.LocalScope = "ObjC::";
+HI.NamespaceScope = "";
 HI.Definition = "char data";
   }},
   {
@@ -2260,6 +2261,86 @@
 HI.Name = "this";
 HI.Definition = "const Foo *";
   }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface MYObject (Private)
+  @property(nonatomic, assign) int privateField;
+  @end
+
+  int someFunction() {
+MYObject *obj = [MYObject sharedInstance];
+return obj.[[private^Field]];
+  }
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "privateField";
+HI.Kind = index::SymbolKind::InstanceProperty;
+HI.LocalScope = "MYObject(Private)::";
+HI.NamespaceScope = "";
+HI.Definition = "@property(nonatomic, assign, unsafe_unretained, "
+"readwrite) int privateField;";
+  }},
+  {
+  R"cpp(
+  @protocol MYProtocol
+  @property(nonatomic, assign) int prop1;
+  @end
+
+  int someFunction() {
+id obj = 0;
+return obj.[[pro^p1]];
+  }
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "prop1";
+HI.Kind = index::SymbolKind::InstanceProperty;
+HI.LocalScope = "MYProtocol::";
+HI.NamespaceScope = "";
+HI.Definition = "@property(nonatomic, assign, unsafe_unretained, "
+"readwrite) int prop1;";
+  }},
+  {R"objc(
+@interface Foo
+@end
+
+@implementation Foo(Private)
++ (int)somePrivateMethod {
+  int [[res^ult]] = 2;
+  return result;
+}
+@end
+)objc",
+   [](HoverInfo ) {
+ HI.Name = "result";
+ HI.Definition = "int result = 2";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.Type = "int";
+ HI.LocalScope = "+[Foo(Private) somePrivateMethod]::";
+ HI.NamespaceScope = "";
+ HI.Value = "2";
+   }},
+  {R"objc(
+@interface Foo
+@end
+
+@implementation Foo
+- (int)variadicArgMethod:(id)first, ... {
+  int [[res^ult]] = 0;
+  return result;
+}
+@end
+)objc",
+   [](HoverInfo ) {
+ HI.Name = "result";
+ HI.Definition = "int result = 0";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.Type = "int";
+ HI.LocalScope = "-[Foo variadicArgMethod:, ...]::";
+ HI.NamespaceScope = "";
+ HI.Value = "0";
+   }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -64,6 +65,15 @@
 std::string getLocalScope(const Decl *D) {
   std::vector Scopes;
   const DeclContext *DC = D->getDeclContext();
+
+  // ObjC scopes won't have multiple components for us to join, instead:
+  // - Methods: "-[Class methodParam1:methodParam2]"
+  // - Classes, categories, and protocols: "MyClass(Category)"
+  if (const ObjCMethodDecl *MD = dyn_cast(DC))
+return printObjCMethod(*MD);
+  else if (const ObjCContainerDecl *CD = dyn_cast(DC))
+return printObjCContainer(*CD);
+
   auto GetName = [](const TypeDecl *D) {
 if (!D->getDeclName().isEmpty()) {
   PrintingPolicy Policy = D->getASTContext().getPrintingPolicy();
@@ -90,6 +100,11 @@
 std::string getNamespaceScope(const Decl *D) {
   const DeclContext *DC = D->getDeclContext();
 
+  // ObjC does not have the concept of namespaces, so instead we support
+  // local scopes.
+  if (isa(DC))
+return "";
+
   if (const TagDecl *TD = dyn_cast(DC))
 return getNamespaceScope(TD);
   

[PATCH] D68590: [clangd] Improve hover scopes for Objective-C code

2021-02-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:64
 
+static llvm::StringRef getNameForObjCInterface(const ObjCInterfaceDecl *ID) {
+  return ID ? ID->getName() : "<>";

dgoldman wrote:
> sammccall wrote:
> > this function's name doesn't really describe what it's for
> > 
> > it has 3 callsites and is only needed in 2, just inline it?
> Worth keeping, see below, Open to naming suggestions =)
nameOrError?



Comment at: clang-tools-extra/clangd/Hover.cpp:71
+  llvm::raw_string_ostream OS(Name);
+  const ObjCInterfaceDecl *Class = Method->getClassInterface();
+

dgoldman wrote:
> sammccall wrote:
> > looking at the implementation, this is null iff the method is part of a 
> > protocol.
> > <> doesn't seem appropriatefor that case
> It can also be NULL for invalid code (in category).
> 
> Since we only call this for Decls in this decl context protocols can't ever 
> appear as protocols can't have method definitions. Do you think it's still 
> worth handling?
ah, I see...

yes I think the protocol case is worth handling in order to give this a simple 
signature in AST.h (prettyprint an ObjC method, without any surprising caveats)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68590

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


[PATCH] D68590: [clangd] Improve hover scopes for Objective-C code

2021-02-11 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:64
 
+static llvm::StringRef getNameForObjCInterface(const ObjCInterfaceDecl *ID) {
+  return ID ? ID->getName() : "<>";

sammccall wrote:
> this function's name doesn't really describe what it's for
> 
> it has 3 callsites and is only needed in 2, just inline it?
Worth keeping, see below, Open to naming suggestions =)



Comment at: clang-tools-extra/clangd/Hover.cpp:71
+  llvm::raw_string_ostream OS(Name);
+  const ObjCInterfaceDecl *Class = Method->getClassInterface();
+

sammccall wrote:
> looking at the implementation, this is null iff the method is part of a 
> protocol.
> <> doesn't seem appropriatefor that case
It can also be NULL for invalid code (in category).

Since we only call this for Decls in this decl context protocols can't ever 
appear as protocols can't have method definitions. Do you think it's still 
worth handling?



Comment at: clang-tools-extra/clangd/Hover.cpp:96
+  }
+  if (const ObjCCategoryImplDecl *CI = dyn_cast(C)) {
+std::string Name;

sammccall wrote:
> can't you return objcContainerLocalScope(CI->getCategoryDecl()) ?
As noted in getCategoryDecl() the class interface can be NULL when working with 
invalid code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68590

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


[PATCH] D68590: [clangd] Improve hover scopes for Objective-C code

2021-02-11 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 323141.
dgoldman marked 7 inline comments as done.
dgoldman added a comment.

- Address review comments

Will move over to AST.cpp in next update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68590

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2167,7 +2167,8 @@
 HI.Name = "data";
 HI.Type = "char";
 HI.Kind = index::SymbolKind::Field;
-HI.NamespaceScope = "ObjC::"; // FIXME: fix it
+HI.LocalScope = "ObjC::";
+HI.NamespaceScope = "";
 HI.Definition = "char data";
   }},
   {
@@ -2260,6 +2261,86 @@
 HI.Name = "this";
 HI.Definition = "const Foo *";
   }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface MYObject (Private)
+  @property(nonatomic, assign) int privateField;
+  @end
+
+  int someFunction() {
+MYObject *obj = [MYObject sharedInstance];
+return obj.[[private^Field]];
+  }
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "privateField";
+HI.Kind = index::SymbolKind::InstanceProperty;
+HI.LocalScope = "MYObject(Private)::";
+HI.NamespaceScope = "";
+HI.Definition = "@property(nonatomic, assign, unsafe_unretained, "
+"readwrite) int privateField;";
+  }},
+  {
+  R"cpp(
+  @protocol MYProtocol
+  @property(nonatomic, assign) int prop1;
+  @end
+
+  int someFunction() {
+id obj = 0;
+return obj.[[pro^p1]];
+  }
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "prop1";
+HI.Kind = index::SymbolKind::InstanceProperty;
+HI.LocalScope = "MYProtocol::";
+HI.NamespaceScope = "";
+HI.Definition = "@property(nonatomic, assign, unsafe_unretained, "
+"readwrite) int prop1;";
+  }},
+  {R"objc(
+@interface Foo
+@end
+
+@implementation Foo(Private)
++ (int)somePrivateMethod {
+  int [[res^ult]] = 2;
+  return result;
+}
+@end
+)objc",
+   [](HoverInfo ) {
+ HI.Name = "result";
+ HI.Definition = "int result = 2";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.Type = "int";
+ HI.LocalScope = "+[Foo(Private) somePrivateMethod]::";
+ HI.NamespaceScope = "";
+ HI.Value = "2";
+   }},
+  {R"objc(
+@interface Foo
+@end
+
+@implementation Foo
+- (int)variadicArgMethod:(id)first, ... {
+  int [[res^ult]] = 0;
+  return result;
+}
+@end
+)objc",
+   [](HoverInfo ) {
+ HI.Name = "result";
+ HI.Definition = "int result = 0";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.Type = "int";
+ HI.LocalScope = "-[Foo variadicArgMethod:, ...]::";
+ HI.NamespaceScope = "";
+ HI.Value = "0";
+   }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -58,12 +59,66 @@
   return Base;
 }
 
+static llvm::StringRef getNameForObjCInterface(const ObjCInterfaceDecl *ID) {
+  return ID ? ID->getName() : "<>";
+}
+
+static std::string objcMethodLocalScope(const ObjCMethodDecl *Method) {
+  std::string Name;
+  llvm::raw_string_ostream OS(Name);
+  const ObjCInterfaceDecl *Class = Method->getClassInterface();
+
+  OS << (Method->isInstanceMethod() ? '-' : '+') << '['
+ << getNameForObjCInterface(Class);
+
+  if (const ObjCCategoryImplDecl *CID =
+  dyn_cast(Method->getDeclContext()))
+OS << '(' << CID->getName() << ')';
+
+  Method->getSelector().print(OS << ' ');
+  if (Method->isVariadic())
+OS << ", ...";
+
+  OS << ']';
+  OS.flush();
+  return Name;
+}
+
+static std::string objcContainerLocalScope(const ObjCContainerDecl *C) {
+  if (const ObjCCategoryDecl *Category = dyn_cast(C)) {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+const ObjCInterfaceDecl 

[PATCH] D96544: [clangd] Extract binding of typed->untyped LSP handlers to LSPBinder. NFC

2021-02-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, mgorny.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

The goal is to allow the LSP bindings of features to be defined outside
the ClangdLSPServer class, turning it into less of a monolith.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96544

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/LSPBinder.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/LSPBinderTests.cpp

Index: clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
@@ -0,0 +1,85 @@
+//===-- LSPBinderTests.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "LSPBinder.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::_;
+using testing::HasSubstr;
+using testing::Pair;
+using testing::UnorderedElementsAre;
+
+// JSON-serializable type for testing.
+struct Foo {
+  int x;
+};
+bool fromJSON(const llvm::json::Value , Foo , llvm::json::Path P) {
+  return fromJSON(V, F.x, P);
+}
+llvm::json::Value toJSON(const Foo ) { return F.x; }
+
+// Creates a Callback that writes its received value into an Optional.
+template 
+llvm::unique_function)>
+capture(llvm::Optional> ) {
+  Out.reset();
+  return [](llvm::Expected V) { Out.emplace(std::move(V)); };
+}
+
+TEST(LSPBinderTest, IncomingCalls) {
+  LSPBinder::RawHandlers RawHandlers;
+  LSPBinder Binder{RawHandlers};
+  struct Handler {
+void plusOne(const Foo , Callback Reply) {
+  Reply(Foo{Params.x + 1});
+}
+void fail(const Foo , Callback Reply) {
+  Reply(error("x={0}", Params.x));
+}
+void notify(const Foo ) { lastNotify = Params.x; }
+int lastNotify = -1;
+  };
+
+  Handler H;
+  Binder.method("plusOne", , ::plusOne);
+  Binder.method("fail", , ::fail);
+  Binder.notification("notify", , ::notify);
+  ASSERT_THAT(RawHandlers.MethodHandlers.keys(),
+  UnorderedElementsAre("plusOne", "fail"));
+  ASSERT_THAT(RawHandlers.NotificationHandlers.keys(),
+  UnorderedElementsAre("notify"));
+  llvm::Optional> Reply;
+
+  auto  = RawHandlers.MethodHandlers["plusOne"];
+  RawPlusOne(1, capture(Reply));
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
+  RawPlusOne("foo", capture(Reply));
+  EXPECT_THAT_EXPECTED(
+  Reply.getValue(),
+  llvm::FailedWithMessage(
+  HasSubstr("failed to decode plusOne request: expected integer")));
+
+  auto  = RawHandlers.MethodHandlers["fail"];
+  RawFail(2, capture(Reply));
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("x=2"));
+
+  auto  = RawHandlers.NotificationHandlers["notify"];
+  RawNotify(42);
+  EXPECT_EQ(H.lastNotify, 42);
+  RawNotify("hi"); // invalid, will be logged
+  EXPECT_EQ(H.lastNotify, 42);
+}
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -70,6 +70,7 @@
   IndexTests.cpp
   JSONTransportTests.cpp
   LoggerTests.cpp
+  LSPBinderTests.cpp
   LSPClient.cpp
   ModulesTests.cpp
   ParsedASTTests.cpp
Index: clang-tools-extra/clangd/LSPBinder.h
===
--- /dev/null
+++ clang-tools-extra/clangd/LSPBinder.h
@@ -0,0 +1,119 @@
+//===--- LSPBinder.h - Tables of LSP handlers *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_LSPBINDER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_LSPBINDER_H
+
+#include "Protocol.h"
+#include "support/Function.h"
+#include "support/Logger.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/JSON.h"
+
+namespace clang {
+namespace clangd {
+
+/// LSPBinder collects a table of functions that handle LSP calls.
+///
+/// It translates a handler method's signature, e.g.
+///   

[PATCH] D95753: Store compilation dir separately in coverage mapping

2021-02-11 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Two minor missing items:

- Please include a binary test that verifies llvm-cov can prepare a report for 
a binary containing a Version6 coverage blob (for compatibility testing).
- Please also include a short blurb in docs/CoverageMappingFormat.rst 
explaining the format change.

Everything else looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

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


[PATCH] D96406: [Msan, NewPM] Reduce size of msan binaries

2021-02-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM, please add a TODO for more passes




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1291
+  // general purpose optimization passes.
+  FPM.addPass(EarlyCSEPass());
+}

I did not know that MSan does not add the extra optimization passes in the new 
pass manager (see addGeneralOptsForMemorySanitizer). If I remember correctly, 
it used to give ~10% or more speedup on spec2006.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96406

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


[PATCH] D96542: [clang-tidy] Fix `TransformerClangTidyCheck`'s handling of include insertions.

2021-02-11 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: alexfh.
Herald added a subscriber: xazax.hun.
ymandel requested review of this revision.
Herald added a project: clang.

Currently, all include insertions are directed to the main file. However,
Transformer rules can specify alternative destinations for include
insertions. This patch fixes the code to associate the include with the correct
file.

This patch was tested manually. The clang tidy unit test framework does not
support testing changes to header files. Given that this is a bug fix for a live
bug, the patch relies on manual testing rather than blocking on upgrading the
unit test framework.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96542

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp


Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -104,7 +104,8 @@
   Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   break;
 case transformer::EditKind::AddInclude:
-  Diag << Inserter.createMainFileIncludeInsertion(T.Replacement);
+  Diag << Inserter.createIncludeInsertion(
+  Result.SourceManager->getFileID(T.Range.getBegin()), T.Replacement);
   break;
 }
 }


Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -104,7 +104,8 @@
   Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   break;
 case transformer::EditKind::AddInclude:
-  Diag << Inserter.createMainFileIncludeInsertion(T.Replacement);
+  Diag << Inserter.createIncludeInsertion(
+  Result.SourceManager->getFileID(T.Range.getBegin()), T.Replacement);
   break;
 }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7b48326 - NFCI. With the move to the new pass manager by default, sanitize-coverage.c is now passing on ARM.

2021-02-11 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2021-02-11T13:18:18-08:00
New Revision: 7b4832648a6339c798f1f72bbc88b1ee41e9a338

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

LOG: NFCI. With the move to the new pass manager by default, 
sanitize-coverage.c is now passing on ARM.

This change removes the XFAIL from the original test and duplicates the test 
into sanitize-coverage-old-pm.c
which uses the old pass manager and has the corresponding XFAIL.

This should fix the XPASS from this and similar runs:
http://lab.llvm.org:8011/#/builders/60/builds/1875

Added: 
clang/test/CodeGen/sanitize-coverage-old-pm.c

Modified: 
clang/test/CodeGen/sanitize-coverage.c

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-coverage-old-pm.c 
b/clang/test/CodeGen/sanitize-coverage-old-pm.c
new file mode 100644
index ..a6ded8a0fb98
--- /dev/null
+++ b/clang/test/CodeGen/sanitize-coverage-old-pm.c
@@ -0,0 +1,25 @@
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S   
-fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | 
FileCheck %s --check-prefixes=CHECK
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=address-fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,ASAN
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=bounds -fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,BOUNDS
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=memory -fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,MSAN
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=thread -fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,TSAN
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=undefined  -fsanitize-coverage=trace-pc,trace-cmp -o - 
-flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,UBSAN
+//
+// Host armv7 is currently unsupported: 
https://bugs.llvm.org/show_bug.cgi?id=46117
+// XFAIL: armv7, thumbv7
+
+int x[10];
+
+// CHECK-LABEL: define dso_local void @foo(
+void foo(int n) {
+  // CHECK-DAG: call void @__sanitizer_cov_trace_pc
+  // CHECK-DAG: call void @__sanitizer_cov_trace_const_cmp
+  // ASAN-DAG: call void @__asan_report_store
+  // MSAN-DAG: call void @__msan_warning
+  // BOUNDS-DAG: call void @__ubsan_handle_out_of_bounds
+  // TSAN-DAG: call void @__tsan_func_entry
+  // UBSAN-DAG: call void @__ubsan_handle
+  if (n)
+x[n] = 42;
+}
+// CHECK-LABEL: declare void

diff  --git a/clang/test/CodeGen/sanitize-coverage.c 
b/clang/test/CodeGen/sanitize-coverage.c
index ea4ac9296b48..6fc8e39354d4 100644
--- a/clang/test/CodeGen/sanitize-coverage.c
+++ b/clang/test/CodeGen/sanitize-coverage.c
@@ -4,9 +4,6 @@
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=memory -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,MSAN
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=thread -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,TSAN
 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=undefined  -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,UBSAN
-//
-// Host armv7 is currently unsupported: 
https://bugs.llvm.org/show_bug.cgi?id=46117
-// XFAIL: armv7, thumbv7
 
 int x[10];
 



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


[PATCH] D96538: [SYCL] Ignore file-scope asm during device-side SYCL compilation.

2021-02-11 Thread Artur Gainullin via Phabricator via cfe-commits
ArturGainullin created this revision.
ArturGainullin added reviewers: bader, elizabethandrews.
Herald added subscribers: Anastasia, ebevhan, yaxunl.
ArturGainullin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96538

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenSYCL/filescope_asm.c


Index: clang/test/CodeGenSYCL/filescope_asm.c
===
--- /dev/null
+++ clang/test/CodeGenSYCL/filescope_asm.c
@@ -0,0 +1,6 @@
+// RUN:  %clang_cc1 -fsycl -fsycl-is-device -triple 
spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
+//
+// Check that file-scope asm is ignored during device-side SYCL compilation.
+//
+// CHECK-NOT: module asm "foo"
+__asm__("foo");
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5672,6 +5672,9 @@
 // File-scope asm is ignored during device-side OpenMP compilation.
 if (LangOpts.OpenMPIsDevice)
   break;
+// File-scope asm is ignored during device-side SYCL compilation.
+if (LangOpts.SYCLIsDevice)
+  break;
 auto *AD = cast(D);
 getModule().appendModuleInlineAsm(AD->getAsmString()->getString());
 break;


Index: clang/test/CodeGenSYCL/filescope_asm.c
===
--- /dev/null
+++ clang/test/CodeGenSYCL/filescope_asm.c
@@ -0,0 +1,6 @@
+// RUN:  %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
+//
+// Check that file-scope asm is ignored during device-side SYCL compilation.
+//
+// CHECK-NOT: module asm "foo"
+__asm__("foo");
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5672,6 +5672,9 @@
 // File-scope asm is ignored during device-side OpenMP compilation.
 if (LangOpts.OpenMPIsDevice)
   break;
+// File-scope asm is ignored during device-side SYCL compilation.
+if (LangOpts.SYCLIsDevice)
+  break;
 auto *AD = cast(D);
 getModule().appendModuleInlineAsm(AD->getAsmString()->getString());
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM as initial step, but it would be good to adjust the name as Duncan 
suggested before landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D92808#2557132 , @fhahn wrote:

> Another thing I noticed that there's verifier support missing. I think we 
> should at least check that only a single `clang.arc.rv` bundle is specified 
> (https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Verifier.cpp#L3191).
>  We should probably also enforce that the bundle is only provided for 
> functions with an `i8*` return type. That can also be done after the main 
> patch lands.

I added the checks to the verifier. Note that the verifier accepts calls 
returning any pointer type since the return type isn't always `i8*` (e.g., 
`NSObject *foo(void)`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 323107.
ahatanak added a comment.

Address all review comments except for the ones about the bundle name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenObjC/arc-rv-attr.m
  clang/test/CodeGenObjC/arc-unsafeclaim.m
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/ObjCARCUtil.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.h
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
  llvm/test/CodeGen/AArch64/call-rv-marker.ll
  llvm/test/Transforms/DeadArgElim/deadretval.ll
  llvm/test/Transforms/Inline/inline-retainRV-call.ll
  llvm/test/Transforms/ObjCARC/contract-marker-funclet.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Transforms/ObjCARC/contract.ll
  llvm/test/Transforms/ObjCARC/intrinsic-use.ll
  llvm/test/Transforms/ObjCARC/rv.ll
  llvm/test/Transforms/SCCP/clang-arc-rv.ll
  llvm/test/Transforms/TailCallElim/deopt-bundle.ll
  llvm/test/Verifier/operand-bundles.ll

Index: llvm/test/Verifier/operand-bundles.ll
===
--- llvm/test/Verifier/operand-bundles.ll
+++ llvm/test/Verifier/operand-bundles.ll
@@ -1,10 +1,13 @@
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
+%0 = type opaque
+declare void @g()
+declare %0* @foo0()
+declare i8 @foo1()
+
 ; Operand bundles uses are like regular uses, and need to be dominated
 ; by their defs.
 
-declare void @g()
-
 define void @f0(i32* %ptr) {
 ; CHECK: Instruction does not dominate all uses!
 ; CHECK-NEXT:  %x = add i32 42, 1
@@ -60,3 +63,15 @@
   %x = add i32 42, 1
   ret void
 }
+
+define void @f_clang_arc_rv() {
+; CHECK: Multiple "clang.arc.rv" operand bundles
+; CHECK-NEXT: call %0* @foo0() [ "clang.arc.rv"(i64 0), "clang.arc.rv"(i64 0) ]
+; CHECK-NEXT: must call a function returning a pointer
+; CHECK-NEXT: call i8 @foo1() [ "clang.arc.rv"(i64 0) ]
+
+  call %0* @foo0() [ "clang.arc.rv"(i64 0) ]
+  call %0* @foo0() [ "clang.arc.rv"(i64 0), "clang.arc.rv"(i64 0) ]
+  call i8 @foo1() [ "clang.arc.rv"(i64 0) ]
+  ret void
+}
Index: llvm/test/Transforms/TailCallElim/deopt-bundle.ll
===
--- llvm/test/Transforms/TailCallElim/deopt-bundle.ll
+++ llvm/test/Transforms/TailCallElim/deopt-bundle.ll
@@ -55,3 +55,13 @@
 exit:
   ret void
 }
+
+; CHECK-LABEL: @test_clang_arc_rv(
+; CHECK: tail call i8* @getObj(
+
+declare i8* @getObj()
+
+define i8* @test_clang_arc_rv() {
+  %r = call i8* @getObj() [ "clang.arc.rv"(i64 0) ]
+  ret i8* %r
+}
Index: llvm/test/Transforms/SCCP/clang-arc-rv.ll
===
--- /dev/null
+++ llvm/test/Transforms/SCCP/clang-arc-rv.ll
@@ -0,0 +1,24 @@
+; RUN: opt < %s -ipsccp -S | FileCheck %s
+; Return value can't be zapped if there is a call that has operand bundle
+; "clang.arc.rv".
+
+@g0 = global i8 zeroinitializer, align 1
+
+; CHECK-LABEL: @foo(
+; CHECK: ret i8* @g0
+
+define internal i8* @foo() {
+  ret i8* @g0
+}
+
+; CHECK-LABEL: @test(
+; CHECK: %[[R:.*]] = call i8* @foo()
+; CHECK call void (...) @llvm.objc.clang.arc.noop.use(i8* %[[R]])
+
+define void @test() {
+  %r = call i8* @foo() [ "clang.arc.rv"(i64 1) ]
+  call void (...) @llvm.objc.clang.arc.noop.use(i8* %r)
+  ret void
+}
+
+declare void @llvm.objc.clang.arc.noop.use(...)
Index: llvm/test/Transforms/ObjCARC/rv.ll
===
--- llvm/test/Transforms/ObjCARC/rv.ll
+++ llvm/test/Transforms/ObjCARC/rv.ll
@@ -452,6 +452,29 @@
   ret i8* %v3
 }
 
+; Remove operand bundle "clang.arc.rv" and the autoreleaseRV call if the call
+; is a tail call.
+
+; CHECK-LABEL: define i8* @test31(
+; CHECK: %[[CALL:.*]] = tail call i8* @returner()
+; CHECK: ret i8* %[[CALL]]
+
+define i8* @test31() {
+  %call = tail call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
+; CHECK-LABEL: define i8* 

[PATCH] D95753: Store compilation dir separately in coverage mapping

2021-02-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 323106.
phosek marked 2 inline comments as done.
phosek added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

I have addressed all the comments and fixed all tests. I'm happy to slice this 
into multiple patches if you prefer landing the refactoring separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CoverageMapping/abspath.cpp
  clang/test/Profile/profile-prefix-map.c
  compiler-rt/include/profile/InstrProfData.inc
  llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/unittests/ProfileData/CoverageMappingTest.cpp

Index: llvm/unittests/ProfileData/CoverageMappingTest.cpp
===
--- llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -129,6 +129,7 @@
 struct CoverageMappingTest : ::testing::TestWithParam> {
   bool UseMultipleReaders;
   StringMap Files;
+  std::vector Filenames;
   std::vector InputFunctions;
   std::vector OutputFunctions;
 
@@ -146,7 +147,7 @@
 auto R = Files.find(Name);
 if (R != Files.end())
   return R->second;
-unsigned Index = Files.size();
+unsigned Index = Files.size() + 1;
 Files.try_emplace(Name, Index);
 return Index;
   }
@@ -200,11 +201,12 @@
 
   void readCoverageRegions(const std::string ,
OutputFunctionCoverageData ) {
-SmallVector Filenames(Files.size());
+Filenames.resize(Files.size() + 1);
 for (const auto  : Files)
-  Filenames[E.getValue()] = E.getKey();
+  Filenames[E.getValue()] = E.getKey().str();
 std::vector Expressions;
-RawCoverageMappingReader Reader(Coverage, Filenames, Data.Filenames,
+ArrayRef FilenameRefs = llvm::makeArrayRef(Filenames);
+RawCoverageMappingReader Reader(Coverage, FilenameRefs, Data.Filenames,
 Expressions, Data.Regions);
 EXPECT_THAT_ERROR(Reader.read(), Succeeded());
   }
@@ -896,7 +898,7 @@
   std::pair({true, true})),);
 
 TEST(CoverageMappingTest, filename_roundtrip) {
-  std::vector Paths({"a", "b", "c", "d", "e"});
+  std::vector Paths({"", "a", "b", "c", "d", "e"});
 
   for (bool Compress : {false, true}) {
 std::string EncodedFilenames;
@@ -906,16 +908,12 @@
   Writer.write(OS, Compress);
 }
 
-std::vector ReadFilenames;
+std::vector ReadFilenames;
 RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
-BinaryCoverageReader::DecompressedData Decompressed;
-EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion, Decompressed),
-  Succeeded());
-if (!Compress)
-  ASSERT_EQ(Decompressed.size(), 0U);
+EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion), Succeeded());
 
 ASSERT_EQ(ReadFilenames.size(), Paths.size());
-for (unsigned I = 0; I < Paths.size(); ++I)
+for (unsigned I = 1; I < Paths.size(); ++I)
   ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
   }
 }
Index: llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -27,7 +27,7 @@
 using namespace coverage;
 
 CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter(
-ArrayRef Filenames)
+ArrayRef Filenames)
 : Filenames(Filenames) {
 #ifndef NDEBUG
   StringSet<> NameSet;
Index: llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -97,9 +97,7 @@
   return Error::success();
 }
 
-Error RawCoverageFilenamesReader::read(
-CovMapVersion Version,
-BinaryCoverageReader::DecompressedData ) {
+Error RawCoverageFilenamesReader::read(CovMapVersion Version) {
   uint64_t NumFilenames;
   if (auto Err = readSize(NumFilenames))
 return Err;
@@ -107,7 +105,7 @@
 return make_error(coveragemap_error::malformed);
 
   if (Version < CovMapVersion::Version4)
-return readUncompressed(NumFilenames);
+return readUncompressed(Version, NumFilenames);
 
   // The uncompressed length may exceed 

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

In D92808#2557634 , @dexonsmith wrote:

> In D92808#2555868 , @ahatanak wrote:
>
>> For example, if SCCP just does a normal RAUW on the following call, which is 
>> taken from the example I posted,
>>
>>   %r = call i8* @foo() [ "clang.arc.rv"(i64 1, i8* %r) ]
>>
>> will become
>>
>>   %r = call i8* @foo() [ "clang.arc.rv"(i64 1, i8* @g0) ]
>>
>> `%r` doesn't have an explicit use in the IR anymore, so passes like 
>> deadargelim can change the return type of the function to `void`.
>
> Is that a problem? It seems like this keeps all the information ARC needs. 
> This could be lowered to:
>
>   call void @foo()
>   call @unsafeClaimAutoreleasedReturnValue(i8* @g0)
>
> The ARC optimizer and ARC lowering both need to know about this case, but I 
> don't see why deadargelim needs to know anything special.

I see, you are right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D96495: [clangd] Retire the cross-file-rename command-line flag.

2021-02-11 Thread Haojian Wu 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 rG573348ab9b28: [clangd] Retire the cross-file-rename 
command-line flag. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96495

Files:
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -832,8 +832,12 @@
 TU.ExtraArgs.push_back("-xobjective-c++");
 auto AST = TU.build();
 for (const auto  : Code.points()) {
-  auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  auto RenameResult = rename({RenamePos,
+  NewName,
+  AST,
+  testPath(TU.Filename),
+  /*Index*/ nullptr,
+  {/*CrossFile*/ false}});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1133,8 +1137,12 @@
 }
 auto AST = TU.build();
 llvm::StringRef NewName = Case.NewName;
-auto Results =
-rename({T.point(), NewName, AST, testPath(TU.Filename), Case.Index});
+auto Results = rename({T.point(),
+   NewName,
+   AST,
+   testPath(TU.Filename),
+   Case.Index,
+   {/*CrossFile=*/false}});
 bool WantRename = true;
 if (T.ranges().empty())
   WantRename = false;
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -286,6 +286,7 @@
 RetiredFlag RecoveryASTType("recovery-ast-type");
 RetiredFlag AsyncPreamble("async-preamble");
 RetiredFlag CollectMainFileRefs("collect-main-file-refs");
+RetiredFlag CrossFileRename("cross-file-rename");
 
 opt LimitResults{
 "limit-results",
@@ -295,7 +296,6 @@
 init(100),
 };
 
-
 list TweakList{
 "tweaks",
 cat(Features),
@@ -304,13 +304,6 @@
 CommaSeparated,
 };
 
-opt CrossFileRename{
-"cross-file-rename",
-cat(Features),
-desc("Enable cross-file rename feature."),
-init(true),
-};
-
 opt FoldingRanges{
 "folding-ranges",
 cat(Features),
@@ -852,9 +845,6 @@
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
 Opts.Encoding = ForceOffsetEncoding;
 
-  // Shall we allow to customize the file limit?
-  Opts.Rename.AllowCrossFile = CrossFileRename;
-
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -29,7 +29,7 @@
 struct RenameOptions {
   /// If true, enable cross-file rename; otherwise, only allows to rename a
   /// symbol that's only used in the current file.
-  bool AllowCrossFile = false;
+  bool AllowCrossFile = true;
   /// The maximum number of affected files (0 means no limit), only meaningful
   /// when AllowCrossFile = true.
   /// If the actual number exceeds the limit, rename is forbidden.


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -832,8 +832,12 @@
 TU.ExtraArgs.push_back("-xobjective-c++");
 auto AST = TU.build();
 for (const auto  : Code.points()) {
-  auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  auto RenameResult = rename({RenamePos,
+  NewName,
+  AST,
+  testPath(TU.Filename),
+  /*Index*/ nullptr,
+  {/*CrossFile*/ false}});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1133,8 +1137,12 @@
 }
 auto AST = TU.build();
 llvm::StringRef NewName = Case.NewName;
-auto Results =
-rename({T.point(), NewName, AST, testPath(TU.Filename), Case.Index});
+auto Results = rename({T.point(),
+  

[clang-tools-extra] 573348a - [clangd] Retire the cross-file-rename command-line flag.

2021-02-11 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-02-11T20:28:50+01:00
New Revision: 573348ab9b281221e0e78376c233d1898ed0bf68

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

LOG: [clangd] Retire the cross-file-rename command-line flag.

This patch only focuses on the flag. Removing actual single-file mode
(and the flag in RenameOption) will come in a follow-up.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.h 
b/clang-tools-extra/clangd/refactor/Rename.h
index ff23a67cfc46..dbaf9dd2e284 100644
--- a/clang-tools-extra/clangd/refactor/Rename.h
+++ b/clang-tools-extra/clangd/refactor/Rename.h
@@ -29,7 +29,7 @@ using DirtyBufferGetter =
 struct RenameOptions {
   /// If true, enable cross-file rename; otherwise, only allows to rename a
   /// symbol that's only used in the current file.
-  bool AllowCrossFile = false;
+  bool AllowCrossFile = true;
   /// The maximum number of affected files (0 means no limit), only meaningful
   /// when AllowCrossFile = true.
   /// If the actual number exceeds the limit, rename is forbidden.

diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 6a61f0db5294..595cbcf80d51 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -286,6 +286,7 @@ RetiredFlag RecoveryAST("recovery-ast");
 RetiredFlag RecoveryASTType("recovery-ast-type");
 RetiredFlag AsyncPreamble("async-preamble");
 RetiredFlag CollectMainFileRefs("collect-main-file-refs");
+RetiredFlag CrossFileRename("cross-file-rename");
 
 opt LimitResults{
 "limit-results",
@@ -295,7 +296,6 @@ opt LimitResults{
 init(100),
 };
 
-
 list TweakList{
 "tweaks",
 cat(Features),
@@ -304,13 +304,6 @@ list TweakList{
 CommaSeparated,
 };
 
-opt CrossFileRename{
-"cross-file-rename",
-cat(Features),
-desc("Enable cross-file rename feature."),
-init(true),
-};
-
 opt FoldingRanges{
 "folding-ranges",
 cat(Features),
@@ -852,9 +845,6 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
 Opts.Encoding = ForceOffsetEncoding;
 
-  // Shall we allow to customize the file limit?
-  Opts.Rename.AllowCrossFile = CrossFileRename;
-
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index b1cd8bc3dc49..2a746a06b286 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -832,8 +832,12 @@ TEST(RenameTest, WithinFileRename) {
 TU.ExtraArgs.push_back("-xobjective-c++");
 auto AST = TU.build();
 for (const auto  : Code.points()) {
-  auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  auto RenameResult = rename({RenamePos,
+  NewName,
+  AST,
+  testPath(TU.Filename),
+  /*Index*/ nullptr,
+  {/*CrossFile*/ false}});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1133,8 +1137,12 @@ TEST(RenameTest, Renameable) {
 }
 auto AST = TU.build();
 llvm::StringRef NewName = Case.NewName;
-auto Results =
-rename({T.point(), NewName, AST, testPath(TU.Filename), Case.Index});
+auto Results = rename({T.point(),
+   NewName,
+   AST,
+   testPath(TU.Filename),
+   Case.Index,
+   {/*CrossFile=*/false}});
 bool WantRename = true;
 if (T.ranges().empty())
   WantRename = false;



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


[PATCH] D93023: Replace deprecated %T in 2 tests.

2021-02-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D93023

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


[PATCH] D96363: Mark output as text if it is really text

2021-02-11 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Thanks. LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

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


[PATCH] D96363: Mark output as text if it is really text

2021-02-11 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 323093.
abhina.sreeskantharajan added a comment.

Thanks for reviewing! Addressing inline comments by adding /*Binary*/ comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " << Script << " " << EC.message();


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -252,7 +252,10 @@
   }
 
   std::error_code EC;
-  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC, sys::fs::OF_None);
+  raw_fd_ostream OS(Options.NoOutput ? "-" : Path.str(), EC,
+Options.RemarksFormat == remarks::Format::Bitstream
+? sys::fs::OF_None
+: sys::fs::OF_Text);
   if (EC)
 return errorCodeToError(EC);
 
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -185,7 +185,7 @@
 void RewriteMacrosAction::ExecuteAction() {
   CompilerInstance  = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance ) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1434,7 +1434,9 @@
   llvm::SmallString<128> Script(CrashInfo.Filename);
   llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
+llvm::sys::fs::FA_Write,
+llvm::sys::fs::OF_Text);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run 

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

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

In D92808#2556542 , @fhahn wrote:

> @dexonsmith  @rjmccall What do you think? Would you be happy with iterating 
> on the suggestions in tree?

I don't feel strongly either way; happy for it to land as-is (bugs fixed) and 
iterated on there. One thought is that if the name is going to change it'd be 
nice to have it right for git-blame (today I would vote for 
"clang.arc.attachedcall" but anything a bit more clear would be fine), but of 
course that can change later too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D94779: [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.

2021-02-11 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.

Thank you for the clarification. It would be great if that could be 
communicated in the summary/commit message. It's sounds like emitting 
`llvm.loop.vectorize.predicate.enable` when vectorization is disabled is the 
motivation behind the patch.

It's not great that `vectorize_predicate` also influences `interleave(enable)`, 
but due to both being done be the LoopVectorize pass, seems hard to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D96495: [clangd] Retire the cross-file-rename command-line flag.

2021-02-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 323084.
hokein added a comment.

fix failure tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96495

Files:
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -832,8 +832,12 @@
 TU.ExtraArgs.push_back("-xobjective-c++");
 auto AST = TU.build();
 for (const auto  : Code.points()) {
-  auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  auto RenameResult = rename({RenamePos,
+  NewName,
+  AST,
+  testPath(TU.Filename),
+  /*Index*/ nullptr,
+  {/*CrossFile*/ false}});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1133,8 +1137,12 @@
 }
 auto AST = TU.build();
 llvm::StringRef NewName = Case.NewName;
-auto Results =
-rename({T.point(), NewName, AST, testPath(TU.Filename), Case.Index});
+auto Results = rename({T.point(),
+   NewName,
+   AST,
+   testPath(TU.Filename),
+   Case.Index,
+   {/*CrossFile=*/false}});
 bool WantRename = true;
 if (T.ranges().empty())
   WantRename = false;
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -286,6 +286,7 @@
 RetiredFlag RecoveryASTType("recovery-ast-type");
 RetiredFlag AsyncPreamble("async-preamble");
 RetiredFlag CollectMainFileRefs("collect-main-file-refs");
+RetiredFlag CrossFileRename("cross-file-rename");
 
 opt LimitResults{
 "limit-results",
@@ -295,7 +296,6 @@
 init(100),
 };
 
-
 list TweakList{
 "tweaks",
 cat(Features),
@@ -304,13 +304,6 @@
 CommaSeparated,
 };
 
-opt CrossFileRename{
-"cross-file-rename",
-cat(Features),
-desc("Enable cross-file rename feature."),
-init(true),
-};
-
 opt FoldingRanges{
 "folding-ranges",
 cat(Features),
@@ -852,9 +845,6 @@
   if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
 Opts.Encoding = ForceOffsetEncoding;
 
-  // Shall we allow to customize the file limit?
-  Opts.Rename.AllowCrossFile = CrossFileRename;
-
   if (CheckFile.getNumOccurrences()) {
 llvm::SmallString<256> Path;
 llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -29,7 +29,7 @@
 struct RenameOptions {
   /// If true, enable cross-file rename; otherwise, only allows to rename a
   /// symbol that's only used in the current file.
-  bool AllowCrossFile = false;
+  bool AllowCrossFile = true;
   /// The maximum number of affected files (0 means no limit), only meaningful
   /// when AllowCrossFile = true.
   /// If the actual number exceeds the limit, rename is forbidden.


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -832,8 +832,12 @@
 TU.ExtraArgs.push_back("-xobjective-c++");
 auto AST = TU.build();
 for (const auto  : Code.points()) {
-  auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  auto RenameResult = rename({RenamePos,
+  NewName,
+  AST,
+  testPath(TU.Filename),
+  /*Index*/ nullptr,
+  {/*CrossFile*/ false}});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1133,8 +1137,12 @@
 }
 auto AST = TU.build();
 llvm::StringRef NewName = Case.NewName;
-auto Results =
-rename({T.point(), NewName, AST, testPath(TU.Filename), Case.Index});
+auto Results = rename({T.point(),
+   NewName,
+   AST,
+   testPath(TU.Filename),
+   

[PATCH] D96495: [clangd] Retire the cross-file-rename command-line flag.

2021-02-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D96495#2556897 , @njames93 wrote:

> Those test failures look related.

oh, right. the failure tests rely on the default cross-file flag, fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96495

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


[PATCH] D96248: [OpenMP][AMDGPU] Add support for linking libomptarget bitcode

2021-02-11 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96248

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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

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

In D92808#2555868 , @ahatanak wrote:

> For example, if SCCP just does a normal RAUW on the following call, which is 
> taken from the example I posted,
>
>   %r = call i8* @foo() [ "clang.arc.rv"(i64 1, i8* %r) ]
>
> will become
>
>   %r = call i8* @foo() [ "clang.arc.rv"(i64 1, i8* @g0) ]
>
> `%r` doesn't have an explicit use in the IR anymore, so passes like 
> deadargelim can change the return type of the function to `void`.

Is that a problem? It seems like this keeps all the information ARC needs. This 
could be lowered to:

  call void @foo()
  call @unsafeClaimAutoreleasedReturnValue(i8* @g0)

The ARC optimizer and ARC lowering both need to know about this case, but I 
don't see why deadargelim needs to know anything special.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D96427: Support multi-configuration generators correctly in several config files

2021-02-11 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D96427#2555251 , @JDevlieghere 
wrote:

> LGTM. I'm surprised the `dsymutil` one slipped through the cracks, we have a 
> bot that should (?) be testing this configuration: 
> http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/

Maybe it used the system dsymutil or something? (or maybe it worked by accident 
in the Xcode setup)

Anyway, I wonder if we could have some (low frequency) bot that could test this 
configuration? There is the LLDB+Xcode one and I have my own standalone build 
bot, but I guess we would need a Visual studio one too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96427

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


[PATCH] D95928: [OpenMP] Delay more diagnostics of potentially non-emitted code

2021-02-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95928

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


[PATCH] D89274: [WebAssembly] Use the new crt1-command.o if present.

2021-02-11 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.
This revision is now accepted and ready to land.

Ok so we can see this as an interm thing.  I think I'm OK with that.  Could you 
add a comment about that, or at least say why we want to support both the old 
crt1 and the new crt1-command at the same time (i.e. so that wasi-libc can 
easily suppot both old and new llvm right?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89274

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


[PATCH] D96285: [clang][Arm] Fix handling of -Wa,-implicit-it=

2021-02-11 Thread Nick Desaulniers 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 rGa680bc3a31d3: [clang][Arm] Fix handling of -Wa,-implicit-it= 
(authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96285

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-target-as-mimplicit-it.s


Index: clang/test/Driver/arm-target-as-mimplicit-it.s
===
--- /dev/null
+++ clang/test/Driver/arm-target-as-mimplicit-it.s
@@ -0,0 +1,44 @@
+/// Simple tests for valid input.
+/// -Wa,-implicit-it=
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always %s 2>&1 
| FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never %s 2>&1 
| FileCheck %s --check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=arm %s 2>&1 | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=thumb %s 2>&1 
| FileCheck %s --check-prefix=THUMB
+/// -Xassembler -mimplicit-it=
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=always 
%s 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=never 
%s 2>&1 | FileCheck %s --check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=arm %s 
2>&1 | FileCheck %s --check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=thumb 
%s 2>&1 | FileCheck %s --check-prefix=THUMB
+/// Test space separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never 
-Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
+/// Test comma separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=never,-mimplicit-it=always %s 2>&1 | FileCheck %s 
--check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=always,-mimplicit-it=never %s 2>&1 | FileCheck %s 
--check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=always,-mimplicit-it=arm %s 2>&1 | FileCheck %s 
--check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=always,-mimplicit-it=thumb %s 2>&1 | FileCheck %s 
--check-prefix=THUMB
+
+/// Mix -implicit-it= (compiler) with -Wa,-mimplicit-it= (assembler), assembler
+/// takes priority. -mllvm -arm-implicit-it= will be repeated, with the
+/// assembler flag appearing last (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=never 
-Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s 
--check-prefix=NEVER_ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=always 
-Wa,-mimplicit-it=never %S/Inputs/wildcard1.c 2>&1 | FileCheck %s 
--check-prefix=ALWAYS_NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never 
-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s 
--check-prefix=ALWAYS_NEVER
+
+/// Test invalid input.
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | 
FileCheck %s --check-prefix=INVALID
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 
2>&1 | FileCheck %s --check-prefix=XINVALID
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
+// RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=always,-mimplicit-it=foo %s 2>&1 | FileCheck %s 
--check-prefix=INVALID
+
+
+// ALWAYS: "-mllvm" "-arm-implicit-it=always"
+// NEVER: "-mllvm" "-arm-implicit-it=never"
+// ARM: "-mllvm" "-arm-implicit-it=arm"
+// THUMB: "-mllvm" "-arm-implicit-it=thumb"
+// NEVER_ALWAYS: "-mllvm" "-arm-implicit-it=never" "-mllvm" 
"-arm-implicit-it=always"
+// ALWAYS_NEVER: "-mllvm" "-arm-implicit-it=always" "-mllvm" 
"-arm-implicit-it=never"
+// INVALID: error: unsupported argument '-mimplicit-it=foo' to option 'Wa,'
+// XINVALID: error: unsupported argument '-mimplicit-it=foo' to option 
'Xassembler'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2304,6 +2304,17 @@
   DumpCompilationDatabase(C, "", Target, Output, Input, 

[clang] a680bc3 - [clang][Arm] Fix handling of -Wa,-implicit-it=

2021-02-11 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2021-02-11T10:51:25-08:00
New Revision: a680bc3a31d36d321ccf3801bdcff74d58842bfa

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

LOG: [clang][Arm] Fix handling of -Wa,-implicit-it=

Similiar to D95872, this flag can be set for the assembler directly.
Move validation code into a reusable helper function.

Link: https://bugs.llvm.org/show_bug.cgi?id=49023
Link: https://github.com/ClangBuiltLinux/linux/issues/1270
Reported-by: Arnd Bergmann 
Signed-off-by: Nick Desaulniers 

Reviewed By: DavidSpickett

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

Added: 
clang/test/Driver/arm-target-as-mimplicit-it.s

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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d2a9ea3c9ef8..c2b195a8088f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2304,6 +2304,17 @@ void Clang::DumpCompilationDatabaseFragmentToDir(
   DumpCompilationDatabase(C, "", Target, Output, Input, Args);
 }
 
+static bool AddARMImplicitITArgs(const ArgList , ArgStringList ,
+ StringRef Value) {
+  if (Value == "always" || Value == "never" || Value == "arm" ||
+  Value == "thumb") {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value));
+return true;
+  }
+  return false;
+}
+
 static void CollectArgsForIntegratedAssembler(Compilation ,
   const ArgList ,
   ArgStringList ,
@@ -2327,14 +2338,9 @@ static void 
CollectArgsForIntegratedAssembler(Compilation ,
   case llvm::Triple::thumbeb:
 if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) {
   StringRef Value = A->getValue();
-  if (Value == "always" || Value == "never" || Value == "arm" ||
-  Value == "thumb") {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value));
-  } else {
+  if (!AddARMImplicitITArgs(Args, CmdArgs, Value))
 D.Diag(diag::err_drv_unsupported_option_argument)
 << A->getOption().getName() << Value;
-  }
 }
 break;
   default:
@@ -2376,6 +2382,9 @@ static void CollectArgsForIntegratedAssembler(Compilation 
,
   case llvm::Triple::thumbeb:
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
+if (Value.startswith("-mimplicit-it=") &&
+AddARMImplicitITArgs(Args, CmdArgs, Value.split("=").second))
+  continue;
 if (Value == "-mthumb")
   // -mthumb has already been processed in ComputeLLVMTriple()
   // recognize but skip over here.

diff  --git a/clang/test/Driver/arm-target-as-mimplicit-it.s 
b/clang/test/Driver/arm-target-as-mimplicit-it.s
new file mode 100644
index ..b13b4918780c
--- /dev/null
+++ b/clang/test/Driver/arm-target-as-mimplicit-it.s
@@ -0,0 +1,44 @@
+/// Simple tests for valid input.
+/// -Wa,-implicit-it=
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always %s 2>&1 
| FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never %s 2>&1 
| FileCheck %s --check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=arm %s 2>&1 | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=thumb %s 2>&1 
| FileCheck %s --check-prefix=THUMB
+/// -Xassembler -mimplicit-it=
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=always 
%s 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=never 
%s 2>&1 | FileCheck %s --check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=arm %s 
2>&1 | FileCheck %s --check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=thumb 
%s 2>&1 | FileCheck %s --check-prefix=THUMB
+/// Test space separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never 
-Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always 
-Wa,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
+/// Test comma separated -Wa,- arguments (latter wins).
+// RUN: %clang -target 

[PATCH] D96487: Restore diagnostic handler after CodeGenAction::ExecuteAction

2021-02-11 Thread Rong Xu via Phabricator via cfe-commits
xur accepted this revision.
xur added a comment.
This revision is now accepted and ready to land.

This looks fine to me. Thanks for fixing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96487

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


[PATCH] D95772: [DebugInfo] Normalize paths by removing unnecessary dots

2021-02-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D95772#2534103 , @dblaikie wrote:

> Does this address @rnk's feedback about symlinks? ( 
> https://reviews.llvm.org/D87657#2296028 )

It doesn't, I think if we want to handle that case, we'd need to use 
`sys::fs::real_path` rather than `sys::path::remove_dots`. That should produce 
correct result but it's more expensive.

While working on coverage mapping, I've noticed that we already use 

 `sys::path::remove_dots` with `remove_dots_dots=true` to normalize filenames 
there. Whichever way we decide on, I think it'd be useful to unify the two.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95772

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


[PATCH] D94779: [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.

2021-02-11 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Thanks for your comments. This patch is not intended to have no consequence - 
it's just not being communicated well in the commit message.

The problem at the moment, with mainline clang, is that specifying:

  #pragma clang loop vectorize_width(4) vectorize_predicate(enable)

(or under MVE, as predication is often done by default):

  #pragma clang loop vectorize_width(4) vectorize_predicate(disable)

The predication is ignored because the width is set. As in:
https://godbolt.org/z/ex8jvW
So there is no way at the moment to control predication and width at the same 
time.

That is what this patch is aiming to fix, and that fix alone is quite simple. 
Unfortunately in order to fix that we also need to deal with (like you say) the 
awkward edge case where vectorize_width(1) is set and predication is enabled. 
But that's really just an edge case. This patch makes it work similar to 
interleaving, as far as I understand. If the user specifies

  #pragma clang loop vectorize_width(1) interleave_count(4) 
vectorize_predicate(enable)

They get no vectorization, but interleaving which is predicated. I.e what they 
asked for. (There's a chance that is then SLP vectorizes, but that's a 
different problem :-) ) The predicated interleaving will likely be horrible for 
performance, but if the user asked for it I don't see a reason not to give it 
to them in this case. And the more interesting case of when a vector width is 
specified should start working. The only thing that is really changing is when 
llvm.loop.vectorize.predicate.enable is emitted, and I only meant to imply for 
the predicate pragma specifically, that the user should get what they ask for 
so long as the vectorizer can provide it.

I agree with you in general that pragmas/metadata are difficult and should not 
be changed without good reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D96363: Mark output as text if it is really text

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

LGTM with two inline nits.




Comment at: clang/lib/Frontend/Rewrite/FrontendActions.cpp:188
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
   if (!OS) return;





Comment at: clang/lib/Frontend/Rewrite/FrontendActions.cpp:273
 OutputStream =
-CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
 if (!OutputStream)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96363

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


[PATCH] D96507: [clangd] Move command handlers into a map in ClangdLSPServer. NFC

2021-02-11 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, lgtm!




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:587
+  std::vector Commands;
+  llvm::copy(CommandHandlers.keys(), std::back_inserter(Commands));
+  llvm::sort(Commands);

nit: `llvm::append_range(Commands, CommandHandlers.keys())`



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:649
 {"executeCommandProvider",
- llvm::json::Object{
- {"commands",
-  {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND,
-   ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
- }},
+ llvm::json::Object{{"commands", Commands}}},
 {"typeHierarchyProvider", true},

nit: `std::move(Commands)`



Comment at: clang-tools-extra/clangd/Protocol.h:918
   // Command to apply fix-its. Uses WorkspaceEdit as argument.
   const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND;
   // Command to apply the code action. Uses TweakArgs as argument.

can we also move these into ClangdLSPServer now ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96507

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


[PATCH] D94621: [clang-tidy] add concurrency-async-fs

2021-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D94621#2554228 , @segoon wrote:

> alexfh, aaron.ballman, hi! Any comments on the patch?

Have you run this check over large real-world code bases beyond Yandex.Taxi?

I think this is likely to be a maintenance burden because the list of blocking 
functions will likely never be complete (e.g., it's missing all the Win32 
functions and `wchar_t` variants from C and POSIX) and I'm concerned that the 
output will be too chatty to be useful except in projects that are laid out in 
a very particular way. I would anticipate that these functions get used within 
a concurrent thread with some frequency specifically *because* they're blocking 
operations (so they are performed in a thread to keep the main thread 
unblocked).


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

https://reviews.llvm.org/D94621

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


[PATCH] D96049: [Timer] On macOS count number of executed instructions

2021-02-11 Thread Alex Hoppen via Phabricator via cfe-commits
ahoppen added inline comments.



Comment at: llvm/CMakeLists.txt:656
+  list(APPEND CMAKE_REQUIRED_LIBRARIES proc)
+endif()
+

thakis wrote:
> also, any reason to not do this in `llvm/cmake/config-ix.cmake` where all the 
> other checks like this are?
No, I just didn't know about `llvm/cmake/config-ix.cmake`. I’ll move it there. 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96049

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


[PATCH] D96281: [clang-tidy] Add options to flag individual core increments and to ignore macros to readability-function-cognitive-complexity check.

2021-02-11 Thread Jens Massberg via Phabricator via cfe-commits
massberg added a comment.



In D96281#2556586 , @njames93 wrote:

> How does this handle a macro where the argument has complex code.
>
>   MACRO(if (...) {});

I agree that macro arguments should account to the complexity.

However, with this change macro arguments are ignored.
Unfortunately, I do not see an easy way how to ignore the macro code, but 
consider the arguments during analysis.

Optimally, macro calls should be considered like function calls in code. 
Consider the following example:

  #define noop
  
  #define SomeMacro(x)  \
if (1) {\
  x \
}
  
  void f() {
SomeMacro(if (1) { noop; })
  }

With IgnoreMacros='false' the check gives the function `f()` a complexity of 3, 
while with IgnoreMacro='true' the check gives it at complexity of 0.
IMO the complexity should be 1 (and maybe the macro definition itself should be 
flagged to have a complexity of 1).

So there is still room for improvements. However, from the code that I have 
seen it is more likely that there is complexity in the macros itself and not in 
their arguments when being used.
So I would tend to use the option IgnoreMacros='true'. However, as this isn't 
perfect and others might not agree with it I decided to add the option and also 
default it to
the old implementation.

I have added test cases that show this problem of ignoring macro arguments and 
added a comment to the documentation of the option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[PATCH] D94622: [clang-tidy] add concurrency-async-no-new-threads

2021-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/concurrency/AsyncNoNewThreadsCheck.cpp:41
+/* WinAPI */
+"CreateThread", //
+"CreateRemoteThread",   //

Missing the `::` in front of all of these identifiers.



Comment at: 
clang-tools-extra/clang-tidy/concurrency/AsyncNoNewThreadsCheck.cpp:22
+/* C++ std */
+"::std::async", //
+

segoon wrote:
> aaron.ballman wrote:
> > segoon wrote:
> > > aaron.ballman wrote:
> > > > The trailing comment markers don't really add much.
> > > it's a hack for clang-format, otherwise it contatenates the lines, 
> > > creating unmaintainable mess of strings. "One line - one name" is much 
> > > more suitable.
> > Ah, I didn't know that'd change the behavior of clang-format, that's neat!
> > 
> > FWIW, we usually don't do a whole lot of markup to avoid clang-format 
> > issues (such as the clang-format: on/off markers). Instead, we usually just 
> > ignore the LINT warnings in code review and check the code in as-is. This 
> > helps reduce clutter in the code base. In this case, the comments aren't 
> > adding a ton of clutter so maybe they're fine. But they definitely look odd 
> > as a reader of the code, which is a bit distracting.
> IMO having an ability to run clang-format for sources is very handy. It makes 
> me sad if running clang-format against the source forces me to set some 
> markers or reverting a part of clang-format changes in the source parts I 
> have never touched. An ability to simply rerun checks/linters is very 
> powerful.
I empathize, but clang-format is a moving target that hasn't existed as long as 
the rest of the project, so the project has a mismatch of formats. This is why 
the usual rule of thumb is: clang-format a full file and accept what it 
produces (on new files, like this one) or clang-format your diff (on existing 
files). If you don't like what clang-format produces in either situation, we 
typically format it by hand and then don't worry about it until the next time 
someone touches that code. Of course, I notice that we don't mention 
clang-format anywhere in the style guide at all. :-(

I won't insist on a change here, but I also would not be surprised if the 
useless comment markers were removed by someone during a "cleanup" either.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/concurrency-async-no-new-threads.rst:8-10
+functions and types. E.g. if the code uses C++ coroutines, it is expected
+that only new coroutines or coroutine-based primitives are created
+instead of heavy system threads.

segoon wrote:
> aaron.ballman wrote:
> > segoon wrote:
> > > aaron.ballman wrote:
> > > > FWIW, this suggests to me that what you really want is a way for APIs 
> > > > to opt into this behavior. There's no reason why you wouldn't have a 
> > > > complex system that has both threads and coroutines in it, but it does 
> > > > stand to reason that you may want to say "this function, and everything 
> > > > called within this function, should not create any system threads" in 
> > > > some situations.
> > > > 
> > > > The note below helps call out the expectations from the check, but it 
> > > > requires the developer to restructure the way they write code pretty 
> > > > drastically in order to make the checking behavior more reasonable, 
> > > > which does not seem ideal.
> > > I think it is a complex problem, so it should be separated into smaller 
> > > tasks.
> > > 
> > > Step one - checks with hardcoded functions/types with user-guided 
> > > enabling on a per-file basis. A semi-automated check.
> > > 
> > > Step two - try to solve other parts of the puzzle. Maybe try to add 
> > > [clang:coroutine_safe] tag and teach clang static analyzer to deduce 
> > > coroutine safety property and use it for enabling/disabling the cheks. 
> > > Maybe reuse other (not yet implemented) heuristics from static analyzer 
> > > (or other tools) to identify coroutine functions and check only these 
> > > functions. I'm not an expert in static analyzer, so other LLVM developers 
> > > might find a clever heuristics when to enable/disable these checks or 
> > > maybe how to deduce blacklisted/whitelisted functions/types lists (e.g. 
> > > for concurrency-async-{fs,blocking}).
> > > 
> > > Indeed, the current approach has its own limitations. But it may be a 
> > > first step in the right direction.
> > My fear with the current approach is that I don't think projects usually 
> > split their code in the way this check requires, and so the check will not 
> > be very useful in practice because it will be too chatty. Have you tried 
> > running this check over some large projects that use coroutines to see what 
> > the diagnostic results look like?
> I haven't conducted a survey, but I can say for Yandex.Taxi where the patch 
> has originated. The codebase is ~350KLOC. The main parts are:
> 1) a 

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

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

In D96090#2551664 , @ASDenysPetrov 
wrote:

> Updated. Unlinked parent revision D95799  
> from the stack. Made corresponding changes in this patch.
> @steakhal I did it. The changes should be safer now.

In the upcoming days, I'm gonna schedule this on our CI. We will see the 
results.


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

https://reviews.llvm.org/D96090

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


[PATCH] D96483: [flang][driver] Add options for unparsing

2021-02-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/tools/f18/f18.cpp:541
   driver.debugNoSemantics = true;
-} else if (arg == "-funparse") {
+} else if (arg == "-funparse" || arg == "-fdebug_unparse") {
   driver.dumpUnparse = true;

tskeith wrote:
> This should be "-fdebug-unparse" (with a hyphen). That may be why all those 
> tests are failing.
Fixed, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96483

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


[PATCH] D96427: Support multi-configuration generators correctly in several config files

2021-02-11 Thread Stella Stamenova 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 rGed98676fa483: Support multi-configuration generators 
correctly in several config files (authored by stella.stamenova).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96427

Files:
  clang/test/Unit/lit.site.cfg.py.in
  lld/test/CMakeLists.txt
  lld/test/Unit/lit.site.cfg.py.in
  lld/test/lit.site.cfg.py.in
  lldb/test/API/lit.site.cfg.py.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/Unit/lit.site.cfg.py.in
  llvm/test/lit.site.cfg.py.in
  mlir/examples/standalone/test/lit.site.cfg.py.in
  mlir/integration_test/lit.site.cfg.py.in
  mlir/test/Unit/lit.site.cfg.py.in
  mlir/test/lit.site.cfg.py.in

Index: mlir/test/lit.site.cfg.py.in
===
--- mlir/test/lit.site.cfg.py.in
+++ mlir/test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
 config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -51,6 +51,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: mlir/test/Unit/lit.site.cfg.py.in
===
--- mlir/test/Unit/lit.site.cfg.py.in
+++ mlir/test/Unit/lit.site.cfg.py.in
@@ -17,6 +17,7 @@
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+config.shlibdir = config.shlibdir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
 key, = e.args
Index: mlir/integration_test/lit.site.cfg.py.in
===
--- mlir/integration_test/lit.site.cfg.py.in
+++ mlir/integration_test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
 config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -40,6 +40,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: mlir/examples/standalone/test/lit.site.cfg.py.in
===
--- mlir/examples/standalone/test/lit.site.cfg.py.in
+++ mlir/examples/standalone/test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
 config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -35,6 +35,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
 config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
 config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
-config.llvm_lib_dir = path(r"@LLVM_LIBRARY_DIR@")
+config.llvm_lib_dir = path(r"@LLVM_LIBS_DIR@")
 config.llvm_shlib_dir = path(r"@SHLIBDIR@")
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -56,6 +56,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: llvm/test/Unit/lit.site.cfg.py.in

[clang] ed98676 - Support multi-configuration generators correctly in several config files

2021-02-11 Thread Stella Stamenova via cfe-commits

Author: Stella Stamenova
Date: 2021-02-11T09:32:20-08:00
New Revision: ed98676fa4833bb80632fc7c9db10c3328d78485

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

LOG: Support multi-configuration generators correctly in several config files

Multi-configuration generators (such as Visual Studio and Xcode) allow the 
specification of a build flavor at build time instead of config time, so the 
lit configuration files need to support that - and they do for the most part. 
There are several places that had one of two issues (or both!):

1) Paths had %(build_mode)s set up, but then not configured, resulting in 
values that would not work correctly e.g. 
D:/llvm-build/%(build_mode)s/bin/dsymutil.exe
2) Paths did not have %(build_mode)s set up, but instead contained 
$(Configuration) (which is the value for Visual Studio at configuration time, 
for Xcode they would have had the equivalent) e.g. 
"D:/llvm-build/$(Configuration)/lib".

This seems to indicate that we still have a lot of fragility in the 
configurations, but also that a number of these paths are never used (at least 
on Windows) since the errors appear to have been there a while.

This patch fixes the configurations and it has been tested with Ninja and 
Visual Studio to generate the correct paths. We should consider removing some 
of these settings altogether.

Reviewed By: JDevlieghere, mehdi_amini

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

Added: 


Modified: 
clang/test/Unit/lit.site.cfg.py.in
lld/test/CMakeLists.txt
lld/test/Unit/lit.site.cfg.py.in
lld/test/lit.site.cfg.py.in
lldb/test/API/lit.site.cfg.py.in
llvm/cmake/modules/AddLLVM.cmake
llvm/test/CMakeLists.txt
llvm/test/Unit/lit.site.cfg.py.in
llvm/test/lit.site.cfg.py.in
mlir/examples/standalone/test/lit.site.cfg.py.in
mlir/integration_test/lit.site.cfg.py.in
mlir/test/Unit/lit.site.cfg.py.in
mlir/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/test/Unit/lit.site.cfg.py.in 
b/clang/test/Unit/lit.site.cfg.py.in
index ad5e6d0c8b2a..3edab4473dc4 100644
--- a/clang/test/Unit/lit.site.cfg.py.in
+++ b/clang/test/Unit/lit.site.cfg.py.in
@@ -19,6 +19,7 @@ try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+config.shlibdir = config.shlibdir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
 key, = e.args

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index ce0bcaa9203d..b2543901b757 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -1,8 +1,11 @@
-set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}")
-set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
-set(LLVM_BUILD_MODE "%(build_mode)s")
-set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
-set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
+if (CMAKE_CFG_INTDIR STREQUAL ".")
+  set(LLVM_BUILD_MODE ".")
+else ()
+  set(LLVM_BUILD_MODE "%(build_mode)s")
+endif ()
+
+string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLD_LIBS_DIR 
"${LLVM_LIBRARY_OUTPUT_INTDIR}")
+string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLD_TOOLS_DIR 
"${LLVM_RUNTIME_OUTPUT_INTDIR}")
 
 llvm_canonicalize_cmake_booleans(
   LLVM_ENABLE_ZLIB

diff  --git a/lld/test/Unit/lit.site.cfg.py.in 
b/lld/test/Unit/lit.site.cfg.py.in
index d96e20f11d0a..65d9f9d85935 100644
--- a/lld/test/Unit/lit.site.cfg.py.in
+++ b/lld/test/Unit/lit.site.cfg.py.in
@@ -8,8 +8,8 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lld_obj_root = "@LLD_BINARY_DIR@"
 config.lld_src_root = "@LLD_SOURCE_DIR@"
-config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
-config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
+config.lld_libs_dir = "@LLD_LIBS_DIR@"
+config.lld_tools_dir = "@LLD_TOOLS_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 
@@ -19,6 +19,8 @@ try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+config.lld_libs_dir = config.lld_libs_dir % lit_config.params
+config.lld_tools_dir = config.lld_tools_dir % lit_config.params
 except KeyError as e:
 key, = e.args
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index a4e00b9dac93..a140284e0ded 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -9,8 +9,8 @@ 

[PATCH] D96483: [flang][driver] Add options for unparsing

2021-02-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 323054.
awarzynski added a comment.

Fix typo in f18.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96483

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/FrontendOptions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/lib/Parser/CMakeLists.txt
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Parser/continuation-in-if.f
  flang/test/Parser/pp-dir-comments.f90
  flang/test/Semantics/canondo01.f90
  flang/test/Semantics/canondo02.f90
  flang/test/Semantics/canondo03.f90
  flang/test/Semantics/canondo04.f90
  flang/test/Semantics/canondo05.f90
  flang/test/Semantics/critical04.f90
  flang/test/Semantics/defined-ops.f90
  flang/test/Semantics/doconcurrent02.f90
  flang/test/Semantics/doconcurrent03.f90
  flang/test/Semantics/doconcurrent04.f90
  flang/test/Semantics/doconcurrent07.f90
  flang/test/Semantics/label02.f90
  flang/test/Semantics/label03.f90
  flang/test/Semantics/label04.f90
  flang/test/Semantics/label05.f90
  flang/test/Semantics/label06.f90
  flang/test/Semantics/label07.f90
  flang/test/Semantics/label08.f90
  flang/test/Semantics/label09.f90
  flang/test/Semantics/label10.f90
  flang/test/Semantics/label12.f90
  flang/test/Semantics/label13.f90
  flang/test/Semantics/label15.f90
  flang/test/lit.cfg.py
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -538,9 +538,10 @@
   options.instrumentedParse = true;
 } else if (arg == "-fdebug-no-semantics") {
   driver.debugNoSemantics = true;
-} else if (arg == "-funparse") {
+} else if (arg == "-funparse" || arg == "-fdebug-unparse") {
   driver.dumpUnparse = true;
-} else if (arg == "-funparse-with-symbols") {
+} else if (arg == "-funparse-with-symbols" ||
+arg == "-fdebug-unparse-with-symbols") {
   driver.dumpUnparseWithSymbols = true;
 } else if (arg == "-funparse-typed-exprs-to-f18-fc") {
   driver.unparseTypedExprsToF18_FC = true;
Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -79,6 +79,14 @@
 extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
 unresolved='fatal'))
 
+if config.include_flang_new_driver_test:
+   tools.append(ToolSubst('%flang_fc1', command=FindTool('flang-new'),
+   extra_args=['-fc1'], unresolved='fatal'))
+else:
+   tools.append(ToolSubst('%flang_fc1', command=FindTool('f18'),
+extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
+unresolved='fatal'))
+
 if config.flang_standalone_build:
 llvm_config.add_tool_substitutions(tools, [config.flang_llvm_tools_dir])
 else:
Index: flang/test/Semantics/label15.f90
===
--- flang/test/Semantics/label15.f90
+++ flang/test/Semantics/label15.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
 
 !CHECK-NOT: error:
 module mm
Index: flang/test/Semantics/label13.f90
===
--- flang/test/Semantics/label13.f90
+++ flang/test/Semantics/label13.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
 ! CHECK: branch into loop body from outside
 ! CHECK: the loop branched into
 
Index: flang/test/Semantics/label12.f90
===
--- flang/test/Semantics/label12.f90
+++ flang/test/Semantics/label12.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
 ! CHECK: expected end of statement
 
 subroutine s
Index: flang/test/Semantics/label10.f90
===
--- flang/test/Semantics/label10.f90
+++ flang/test/Semantics/label10.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
 ! CHECK: '60' not a FORMAT
 ! CHECK: data transfer use of '60'
 
Index: flang/test/Semantics/label09.f90
===
--- flang/test/Semantics/label09.f90
+++ flang/test/Semantics/label09.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols 

[PATCH] D96427: Support multi-configuration generators correctly in several config files

2021-02-11 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova updated this revision to Diff 323053.
stella.stamenova edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96427

Files:
  clang/test/Unit/lit.site.cfg.py.in
  lld/test/CMakeLists.txt
  lld/test/Unit/lit.site.cfg.py.in
  lld/test/lit.site.cfg.py.in
  lldb/test/API/lit.site.cfg.py.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/Unit/lit.site.cfg.py.in
  llvm/test/lit.site.cfg.py.in
  mlir/examples/standalone/test/lit.site.cfg.py.in
  mlir/integration_test/lit.site.cfg.py.in
  mlir/test/Unit/lit.site.cfg.py.in
  mlir/test/lit.site.cfg.py.in

Index: mlir/test/lit.site.cfg.py.in
===
--- mlir/test/lit.site.cfg.py.in
+++ mlir/test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
 config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -51,6 +51,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: mlir/test/Unit/lit.site.cfg.py.in
===
--- mlir/test/Unit/lit.site.cfg.py.in
+++ mlir/test/Unit/lit.site.cfg.py.in
@@ -17,6 +17,7 @@
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
+config.shlibdir = config.shlibdir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
 key, = e.args
Index: mlir/integration_test/lit.site.cfg.py.in
===
--- mlir/integration_test/lit.site.cfg.py.in
+++ mlir/integration_test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
 config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -40,6 +40,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: mlir/examples/standalone/test/lit.site.cfg.py.in
===
--- mlir/examples/standalone/test/lit.site.cfg.py.in
+++ mlir/examples/standalone/test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
 config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -35,6 +35,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -7,7 +7,7 @@
 config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
 config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
 config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
-config.llvm_lib_dir = path(r"@LLVM_LIBRARY_DIR@")
+config.llvm_lib_dir = path(r"@LLVM_LIBS_DIR@")
 config.llvm_shlib_dir = path(r"@SHLIBDIR@")
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
@@ -56,6 +56,7 @@
 # used when we can't determine the tool dir at configuration time.
 try:
 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
 except KeyError:
 e = sys.exc_info()[1]
Index: llvm/test/Unit/lit.site.cfg.py.in
===
--- llvm/test/Unit/lit.site.cfg.py.in
+++ llvm/test/Unit/lit.site.cfg.py.in
@@ -14,6 +14,7 @@
 try:
 config.llvm_tools_dir = 

[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-02-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Hi, guys!
Does anyone can review this item, except @steakhal (thanks him)? Please, look.


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

https://reviews.llvm.org/D90157

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


[PATCH] D96281: [clang-tidy] Add options to flag individual core increments and to ignore macros to readability-function-cognitive-complexity check.

2021-02-11 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 323052.
massberg marked 2 inline comments as done.
massberg added a comment.

Add test cases showing that when IgnoreMacros is set to 'true', also macro 
arguments are ignored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.FlagBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=THRESHOLD5 %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 5}, \
+// RUN:  {key: readability-function-cognitive-complexity.FlagBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.FlagBasicIncrements, \
+// RUN:   value: "false"} ]}'
+
+void func_of_complexity_4() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  if (1) {
+if (1) {
+}
+  }
+  if (1) {
+  }
+}
+
+#define MacroOfComplexity10 \
+  if (1) {  \
+if (1) {\
+  if (1) {  \
+if (1) {\
+}   \
+  } \
+}   \
+  }
+
+void function_with_macro() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'function_with_macro' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+
+  MacroOfComplexity10
+
+  if (1) {
+  }
+}
+
+#define uglyfunctionmacro(name) \
+  void name() { \
+if (true) { \
+  try { \
+  } catch (...) {   \
+  } \
+}   \
+  }
+
+uglyfunctionmacro(MacroFunction)
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: function 'MacroFunction' has cognitive complexity of 3 (threshold 0) [readability-function-cognitive-complexity]
+
+#define noop
+
+#define SomeMacro(x) \
+  if (1) {   \
+x\
+  }
+
+void func_macro_1() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_1' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  SomeMacro(noop;)
+}
+
+void func_macro_2() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_2' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  // Note that if the IgnoreMacro option is set to 'true', currently also macro
+  // arguments 

[PATCH] D50106: [libc++] Fix tuple assignment from types derived from a tuple-like

2021-02-11 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 323047.
ldionne added a comment.

Fix segfault on GCC and a few incorrect checks in the type traits.

I reduced the GCC segfault and it appears to have been fixed on GCC trunk, so
I won't be filing a bug report.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50106

Files:
  libcxx/include/tuple
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/const_array.pass.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/rvalue_array.pass.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
  
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/laziness.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
  
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
  libcxx/test/support/propagate_value_category.hpp

Index: libcxx/test/support/propagate_value_category.hpp
===
--- /dev/null
+++ libcxx/test/support/propagate_value_category.hpp
@@ -0,0 +1,153 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+#define TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+
+#include "test_macros.h"
+#include 
+
+#if TEST_STD_VER < 11
+#error this header may only be used in C++11
+#endif
+
+using UnderlyingVCType = unsigned;
+enum ValueCategory : UnderlyingVCType {
+  VC_None = 0,
+  VC_LVal = 1 << 0,
+  VC_RVal = 1 << 1,
+  VC_Const = 1 << 2,
+  VC_Volatile = 1 << 3,
+  VC_ConstVolatile = VC_Const | VC_Volatile
+};
+
+inline constexpr ValueCategory operator&(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS & (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator|(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS | (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator^(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS ^ (UnderlyingVCType)RHS);
+}
+
+inline constexpr bool isValidValueCategory(ValueCategory VC) {
+  return (VC & (VC_LVal | VC_RVal)) != (VC_LVal | VC_RVal);
+}
+
+inline constexpr bool hasValueCategory(ValueCategory Arg, ValueCategory Key) {
+  return Arg == Key || ((Arg & Key) == Key);
+}
+
+template 
+using UnCVRef =
+typename std::remove_cv::type>::type;
+
+template 
+constexpr ValueCategory getReferenceQuals() {
+  return std::is_lvalue_reference::value
+ ? VC_LVal
+ : (std::is_rvalue_reference::value ? VC_RVal : VC_None);
+}
+static_assert(getReferenceQuals() == VC_None, "");
+static_assert(getReferenceQuals() == VC_LVal, "");
+static_assert(getReferenceQuals() == VC_RVal, "");
+
+template 
+constexpr ValueCategory getCVQuals() {
+  using Vp = typename std::remove_reference::type;
+  return std::is_const::value && std::is_volatile::value
+ ? VC_ConstVolatile
+ : (std::is_const::value
+? VC_Const
+: (std::is_volatile::value ? VC_Volatile : VC_None));
+}
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+static_assert(getCVQuals() == VC_Volatile, "");
+static_assert(getCVQuals() == VC_ConstVolatile, "");
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+
+template 
+inline constexpr ValueCategory getValueCategory() {
+  return getReferenceQuals() | getCVQuals();
+}
+static_assert(getValueCategory() == VC_None, "");
+static_assert(getValueCategory() == (VC_LVal | VC_Const), "");
+static_assert(getValueCategory() ==
+  (VC_RVal | VC_ConstVolatile),
+  "");
+
+template 
+struct ApplyValueCategory {
+private:
+  static_assert(isValidValueCategory(VC), "");
+
+  template 
+  using CondT = typename std::conditional::type;
+
+public:
+  template >
+  using ApplyCVQuals = CondT<
+  hasValueCategory(VC, VC_ConstVolatile), typename std::add_cv::type,
+  CondT::type,
+CondT::type, Tp>>>;
+
+  template ::type>
+  using ApplyReferenceQuals =
+  

[PATCH] D96519: [Clang][OpenMP] Fixed an issue that `target team` is emitted incorrectly

2021-02-11 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, JonChesterfield, ABataev, grokos.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch is trying to fix the bug 47039 
(https://bugs.llvm.org/show_bug.cgi?id=47039).
The root cause is, in clang, if `NumTeams` is not `nullptr`, it will emit call
to `target teams`, even if the value of `NumTeams` is 0. This is wrong, but at
least the team number is 0, so if the runtime can handle this correct, it should
still be fine. However, in the runtime, we only check the boolean variable
`IsTeamConstruct`, and don't check the team number. The last straw is, in CUDA
plugin, if the team number is 0, and the loop count is also 0, then it will set
the team number to a default value, which is 128 now.

In this patch, instead of emitting `TeamNum` of value 0, we emit `nullptr`
instead, which is spec conformant at least, aside from the discussion on the
weekly meeting that no team can also mean one team with one thread.

Failed tests will be fixed accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96519

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6574,24 +6574,20 @@
 CGOpenMPRuntime::getSingleCompoundChild(CGF.getContext(), Body);
 if (const auto *NestedDir =
 dyn_cast_or_null(ChildStmt)) {
-  if (isOpenMPTeamsDirective(NestedDir->getDirectiveKind())) {
-if (NestedDir->hasClausesOfKind()) {
-  CGOpenMPInnerExprInfo CGInfo(CGF, *CS);
-  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
-  const Expr *NumTeams =
-  NestedDir->getSingleClause()->getNumTeams();
-  llvm::Value *NumTeamsVal =
-  CGF.EmitScalarExpr(NumTeams,
- /*IgnoreResultAssign*/ true);
-  return Bld.CreateIntCast(NumTeamsVal, CGF.Int32Ty,
-   /*isSigned=*/true);
-}
-return Bld.getInt32(0);
-  }
-  if (isOpenMPParallelDirective(NestedDir->getDirectiveKind()) ||
-  isOpenMPSimdDirective(NestedDir->getDirectiveKind()))
+  if (isOpenMPTeamsDirective(NestedDir->getDirectiveKind()) &&
+  NestedDir->hasClausesOfKind()) {
+CGOpenMPInnerExprInfo CGInfo(CGF, *CS);
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
+const Expr *NumTeams =
+NestedDir->getSingleClause()->getNumTeams();
+llvm::Value *NumTeamsVal =
+CGF.EmitScalarExpr(NumTeams,
+   /*IgnoreResultAssign*/ true);
+return Bld.CreateIntCast(NumTeamsVal, CGF.Int32Ty,
+ /*isSigned=*/true);
+  } else if (isOpenMPParallelDirective(NestedDir->getDirectiveKind()) ||
+ isOpenMPSimdDirective(NestedDir->getDirectiveKind()))
 return Bld.getInt32(1);
-  return Bld.getInt32(0);
 }
 return nullptr;
   }


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6574,24 +6574,20 @@
 CGOpenMPRuntime::getSingleCompoundChild(CGF.getContext(), Body);
 if (const auto *NestedDir =
 dyn_cast_or_null(ChildStmt)) {
-  if (isOpenMPTeamsDirective(NestedDir->getDirectiveKind())) {
-if (NestedDir->hasClausesOfKind()) {
-  CGOpenMPInnerExprInfo CGInfo(CGF, *CS);
-  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
-  const Expr *NumTeams =
-  NestedDir->getSingleClause()->getNumTeams();
-  llvm::Value *NumTeamsVal =
-  CGF.EmitScalarExpr(NumTeams,
- /*IgnoreResultAssign*/ true);
-  return Bld.CreateIntCast(NumTeamsVal, CGF.Int32Ty,
-   /*isSigned=*/true);
-}
-return Bld.getInt32(0);
-  }
-  if (isOpenMPParallelDirective(NestedDir->getDirectiveKind()) ||
-  isOpenMPSimdDirective(NestedDir->getDirectiveKind()))
+  if (isOpenMPTeamsDirective(NestedDir->getDirectiveKind()) &&
+  NestedDir->hasClausesOfKind()) {
+CGOpenMPInnerExprInfo CGInfo(CGF, *CS);
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
+const Expr *NumTeams =
+NestedDir->getSingleClause()->getNumTeams();
+llvm::Value *NumTeamsVal =
+CGF.EmitScalarExpr(NumTeams,
+   /*IgnoreResultAssign*/ true);
+return Bld.CreateIntCast(NumTeamsVal, CGF.Int32Ty,
+ /*isSigned=*/true);
+  } else 

[PATCH] D94779: [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.

2021-02-11 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

To illustrate how complicated interpreting the vectorize pragma has become in 
the mid-end:

  TransformationMode llvm::hasVectorizeTransformation(Loop *L) {
Optional Enable =
getOptionalBoolLoopAttribute(L, "llvm.loop.vectorize.enable");
  
if (Enable == false)
  return TM_SuppressedByUser;
  
Optional VectorizeWidth =
getOptionalElementCountLoopAttribute(L);
Optional InterleaveCount =
getOptionalIntLoopAttribute(L, "llvm.loop.interleave.count");
  
// 'Forcing' vector width and interleave count to one effectively disables
// this transformation.
if (Enable == true && VectorizeWidth && VectorizeWidth->isScalar() &&
InterleaveCount == 1)
  return TM_SuppressedByUser;
  
if (getBooleanLoopAttribute(L, "llvm.loop.isvectorized"))
  return TM_Disable;
  
if (Enable == true)
  return TM_ForcedByUser;
  
if ((VectorizeWidth && VectorizeWidth->isScalar()) && InterleaveCount == 1)
  return TM_Disable;
  
if ((VectorizeWidth && VectorizeWidth->isVector()) || InterleaveCount > 1)
  return TM_Enable;
  
if (hasDisableAllTransformsHint(L))
  return TM_Disable;
  
return TM_Unspecified;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D94779: [Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.

2021-02-11 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D94779#2556274 , @dmgreen wrote:

> This makes sense to me. If the user specifies the pragma then we send that 
> through to the vectorizer, whatever it is. As much as `vectorize_width(1) 
> interleave_count(4) vectorize_predicate(enable)` doesn't make a lot of sense, 
> it's still something that should work. And if the user asks for it, that's 
> what should be done.

Unfortunately, it is not that simple. How vectorize metadata is emitted, how it 
is interpreted by the LoopVectorize pass, and when the 
WarnMissedTransformations pass emits a warning is non-trivial and I would not 
mess with it with no reason or if we generally wanted to clean this up. For 
instance, is implicitly enabling the vectorizer when the width is set  the 
front-end's jobs or the LoopVectorizers? The function 
`hasVectorizeTransformation` in LoopUtils.h tries to abstract from that. That 
is, there is no 1-to-1 relationship between loop hint pragmas and loop metadata 
as you seem to assume.

The summary motivates this as "This ensures better feedback for the 
user/programmer." However, the user will not see any difference since the 
LoopVectorize will just ignore it. Worse, the IR contains contradicting 
information. IMHO, it's the font-end's job to resolve semantic inconsistencies 
and potentially warn users about it.

I don't intend to block this patch because it seems to have no consequence, but 
the motivation is insufficient. If the author uses the predicate in an upstream 
pass they should mention it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94779

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


[PATCH] D96285: [clang][Arm] Fix handling of -Wa,-implicit-it=

2021-02-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked 2 inline comments as done.
nickdesaulniers added a comment.

Thanks for the review (here and D96304 )!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96285

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


[PATCH] D96049: [Timer] On macOS count number of executed instructions

2021-02-11 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: llvm/include/llvm/Config/config.h.cmake:356
 
+#cmakedefine HAVE_PROC_PID_RUSAGE 1
+

thakis wrote:
> Any reason to use `#cmakedefine` instead of `cmakedefine01` here? This type 
> of check usually uses `#cmakedefine01` in this file.
Please ignore this, `#cmakedefine` is what most other `HAVE_` things use. I 
misremembered this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96049

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


[PATCH] D96051: [OpenCL] Support enum and typedef args in TableGen BIFs

2021-02-11 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 323040.
svenvh added a comment.

Add test for new diagnostic.


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

https://reviews.llvm.org/D96051

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/OpenCLBuiltins.td
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -48,7 +48,7 @@
 //Find out whether a string matches an existing OpenCL builtin function
 //name and return an index into BuiltinTable and the number of overloads.
 //
-//  * void OCL2Qual(ASTContext&, OpenCLTypeStruct, std::vector&)
+//  * void OCL2Qual(Sema&, OpenCLTypeStruct, std::vector&)
 //Convert an OpenCLTypeStruct type to a list of QualType instances.
 //One OpenCLTypeStruct can represent multiple types, primarily when using
 //GenTypes.
@@ -726,6 +726,9 @@
 void BuiltinNameEmitter::EmitQualTypeFinder() {
   OS << R"(
 
+static QualType getOpenCLEnumType(Sema , llvm::StringRef Name);
+static QualType getOpenCLTypedefType(Sema , llvm::StringRef Name);
+
 // Convert an OpenCLTypeStruct type to a list of QualTypes.
 // Generic types represent multiple types and vector sizes, thus a vector
 // is returned. The conversion is done in two steps:
@@ -734,8 +737,9 @@
 // or a single scalar type for non generic types.
 // Step 2: Qualifiers and other type properties such as vector size are
 // applied.
-static void OCL2Qual(ASTContext , const OpenCLTypeStruct ,
+static void OCL2Qual(Sema , const OpenCLTypeStruct ,
  llvm::SmallVectorImpl ) {
+  ASTContext  = S.Context;
   // Number of scalar types in the GenType.
   unsigned GenTypeNumTypes;
   // Pointer to the list of vector sizes for the GenType.
Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -17,6 +17,17 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #endif
 
+// First, test that Clang gracefully handles missing types.
+#ifdef NO_HEADER
+void test_without_header() {
+  barrier(0);
+  // expected-note@-1 0+{{candidate function not viable}}
+  // expected-error@-2 0+{{argument type 'void' is incomplete}}
+  // expected-error@-3 0+{{no matching function for call to 'barrier'}}
+  // expected-error@* {{typedef type cl_mem_fence_flags not found; include the base header with -finclude-default-header}}
+}
+#endif
+
 // Provide typedefs when invoking clang without -finclude-default-header.
 #ifdef NO_HEADER
 typedef unsigned char uchar;
@@ -34,6 +45,9 @@
 typedef uint uint4 __attribute__((ext_vector_type(4)));
 typedef long long2 __attribute__((ext_vector_type(2)));
 
+typedef uint cl_mem_fence_flags;
+#define CLK_GLOBAL_MEM_FENCE 0x02
+
 // Enable extensions that are enabled in opencl-c-base.h.
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #define cl_khr_subgroup_extended_types 1
@@ -53,6 +67,18 @@
   atom_cmpxchg((volatile __global unsigned int *)global_p, ui, ui);
 }
 
+// Only test enum arguments when the base header is included, because we need
+// the enum declarations.
+#if !defined(NO_HEADER) && (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+kernel void test_enum_args(volatile global atomic_int *global_p, global int *expected) {
+  int desired;
+  atomic_compare_exchange_strong_explicit(global_p, expected, desired,
+  memory_order_acq_rel,
+  memory_order_relaxed,
+  memory_scope_work_group);
+}
+#endif
+
 kernel void basic_conversion() {
   double d;
   float f;
@@ -184,6 +210,8 @@
 kernel void basic_work_item() {
   uint ui;
 
+  barrier(CLK_GLOBAL_MEM_FENCE);
+
   get_enqueued_local_size(ui);
 #if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_enqueued_local_size' is invalid in OpenCL}}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -677,9 +677,43 @@
 D->dump();
 }
 
+/// Diagnose a missing builtin type.
+static QualType diagOpenCLBuiltinTypeError(Sema , llvm::StringRef TypeClass,
+   llvm::StringRef Name) {
+  S.Diag(SourceLocation(), diag::err_opencl_type_not_found)
+  << TypeClass << Name;
+  return S.Context.VoidTy;
+}
+
+/// Lookup an OpenCL enum type.
+static QualType getOpenCLEnumType(Sema , llvm::StringRef Name) {
+  

[PATCH] D96049: [Timer] On macOS count number of executed instructions

2021-02-11 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: llvm/CMakeLists.txt:656
+  list(APPEND CMAKE_REQUIRED_LIBRARIES proc)
+endif()
+

also, any reason to not do this in `llvm/cmake/config-ix.cmake` where all the 
other checks like this are?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96049

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


[PATCH] D96049: [Timer] On macOS count number of executed instructions

2021-02-11 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: llvm/include/llvm/Config/config.h.cmake:356
 
+#cmakedefine HAVE_PROC_PID_RUSAGE 1
+

Any reason to use `#cmakedefine` instead of `cmakedefine01` here? This type of 
check usually uses `#cmakedefine01` in this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96049

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


[PATCH] D96049: [Timer] On macOS count number of executed instructions

2021-02-11 Thread Raphael Isemann 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 rG7e3b9aba609f: [Timer] On macOS count number of executed 
instructions (authored by ahoppen, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96049

Files:
  
clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
  llvm/CMakeLists.txt
  llvm/include/llvm/Config/config.h.cmake
  llvm/include/llvm/Support/Timer.h
  llvm/lib/Support/Timer.cpp

Index: llvm/lib/Support/Timer.cpp
===
--- llvm/lib/Support/Timer.cpp
+++ llvm/lib/Support/Timer.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Timer.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Config/config.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
@@ -24,6 +25,14 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 
+#if HAVE_UNISTD_H
+#include 
+#endif
+
+#ifdef HAVE_PROC_PID_RUSAGE
+#include 
+#endif
+
 using namespace llvm;
 
 // This ugly hack is brought to you courtesy of constructor/destructor ordering
@@ -120,6 +129,17 @@
   return sys::Process::GetMallocUsage();
 }
 
+static uint64_t getCurInstructionsExecuted() {
+#if defined(HAVE_UNISTD_H) && defined(HAVE_PROC_PID_RUSAGE) && \
+defined(RUSAGE_INFO_V4)
+  struct rusage_info_v4 ru;
+  if (proc_pid_rusage(getpid(), RUSAGE_INFO_V4, (rusage_info_t *)) == 0) {
+return ru.ri_instructions;
+  }
+#endif
+  return 0;
+}
+
 TimeRecord TimeRecord::getCurrentTime(bool Start) {
   using Seconds = std::chrono::duration>;
   TimeRecord Result;
@@ -128,9 +148,11 @@
 
   if (Start) {
 Result.MemUsed = getMemUsage();
+Result.InstructionsExecuted = getCurInstructionsExecuted();
 sys::Process::GetTimeUsage(now, user, sys);
   } else {
 sys::Process::GetTimeUsage(now, user, sys);
+Result.InstructionsExecuted = getCurInstructionsExecuted();
 Result.MemUsed = getMemUsage();
   }
 
@@ -180,6 +202,8 @@
 
   if (Total.getMemUsed())
 OS << format("%9" PRId64 "  ", (int64_t)getMemUsed());
+  if (Total.getInstructionsExecuted())
+OS << format("%9" PRId64 "  ", (int64_t)getInstructionsExecuted());
 }
 
 
@@ -339,6 +363,8 @@
   OS << "   ---Wall Time---";
   if (Total.getMemUsed())
 OS << "  ---Mem---";
+  if (Total.getInstructionsExecuted())
+OS << "  ---Instr---";
   OS << "  --- Name ---\n";
 
   // Loop through all of the timing data, printing it out.
@@ -433,6 +459,10 @@
   OS << delim;
   printJSONValue(OS, R, ".mem", T.getMemUsed());
 }
+if (T.getInstructionsExecuted()) {
+  OS << delim;
+  printJSONValue(OS, R, ".instr", T.getInstructionsExecuted());
+}
   }
   TimersToPrint.clear();
   return delim;
Index: llvm/include/llvm/Support/Timer.h
===
--- llvm/include/llvm/Support/Timer.h
+++ llvm/include/llvm/Support/Timer.h
@@ -24,12 +24,15 @@
 class raw_ostream;
 
 class TimeRecord {
-  double WallTime;   ///< Wall clock time elapsed in seconds.
-  double UserTime;   ///< User time elapsed.
-  double SystemTime; ///< System time elapsed.
-  ssize_t MemUsed;   ///< Memory allocated (in bytes).
+  double WallTime;   ///< Wall clock time elapsed in seconds.
+  double UserTime;   ///< User time elapsed.
+  double SystemTime; ///< System time elapsed.
+  ssize_t MemUsed;   ///< Memory allocated (in bytes).
+  uint64_t InstructionsExecuted; ///< Number of instructions executed
 public:
-  TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {}
+  TimeRecord()
+  : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0),
+InstructionsExecuted(0) {}
 
   /// Get the current time and memory usage.  If Start is true we get the memory
   /// usage before the time, otherwise we get time before memory usage.  This
@@ -42,6 +45,7 @@
   double getSystemTime() const { return SystemTime; }
   double getWallTime() const { return WallTime; }
   ssize_t getMemUsed() const { return MemUsed; }
+  uint64_t getInstructionsExecuted() const { return InstructionsExecuted; }
 
   bool operator<(const TimeRecord ) const {
 // Sort by Wall Time elapsed, as it is the only thing really accurate
@@ -49,16 +53,18 @@
   }
 
   void operator+=(const TimeRecord ) {
-WallTime   += RHS.WallTime;
-UserTime   += RHS.UserTime;
+WallTime += RHS.WallTime;
+UserTime += RHS.UserTime;
 SystemTime += RHS.SystemTime;
-MemUsed+= RHS.MemUsed;
+MemUsed += RHS.MemUsed;
+InstructionsExecuted += RHS.InstructionsExecuted;
   }
   void operator-=(const TimeRecord ) {
-WallTime   -= RHS.WallTime;
-UserTime   -= RHS.UserTime;
+WallTime -= 

[clang-tools-extra] 7e3b9ab - [Timer] On macOS count number of executed instructions

2021-02-11 Thread Raphael Isemann via cfe-commits

Author: Alex Hoppen
Date: 2021-02-11T17:26:37+01:00
New Revision: 7e3b9aba609f7f6c944baa319f0a61041ccdc707

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

LOG: [Timer] On macOS count number of executed instructions

In addition to wall time etc. this should allow us to get less noisy
values for time measurements.

Reviewed By: JDevlieghere

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

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
llvm/CMakeLists.txt
llvm/include/llvm/Config/config.h.cmake
llvm/include/llvm/Support/Timer.h
llvm/lib/Support/Timer.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
 
b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
index 832723ba4ab5..f0939f71edc0 100644
--- 
a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
@@ -17,8 +17,9 @@
 // CHECK-FILE-NEXT:"profile": {
 // CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.wall": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
 // CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.user": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
-// CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.sys": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}
-// CHECK-FILE-NEXT: }
+// CHECK-FILE-NEXT:"time.clang-tidy.readability-function-size.sys": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}{{,?}}
+// If available on the platform, we also have a 
"time.clang-tidy.readability-function-size.instr" entry
+// CHECK-FILE: }
 // CHECK-FILE-NEXT: }
 
 // CHECK-FILE-NOT: {
@@ -27,7 +28,7 @@
 // CHECK-FILE-NOT: "profile": {
 // CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.wall": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
 // CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.user": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
-// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.sys": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}
+// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.sys": 
{{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}{{,?}}
 // CHECK-FILE-NOT: }
 // CHECK-FILE-NOT: }
 

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index f5298de9f7ca..5d705b17f6f1 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -649,6 +649,12 @@ if (LLVM_BUILD_STATIC)
   endforeach()
 endif()
 
+include(CheckSymbolExists)
+check_symbol_exists(proc_pid_rusage "libproc.h" HAVE_PROC_PID_RUSAGE)
+if(HAVE_PROC_PID_RUSAGE)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES proc)
+endif()
+
 # Use libtool instead of ar if you are both on an Apple host, and targeting 
Apple.
 if(CMAKE_HOST_APPLE AND APPLE)
   include(UseLibtool)

diff  --git a/llvm/include/llvm/Config/config.h.cmake 
b/llvm/include/llvm/Config/config.h.cmake
index 0783fbcfe4d4..10d16d3f1f8e 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -353,4 +353,6 @@
 /* Whether Timers signpost passes in Xcode Instruments */
 #cmakedefine01 LLVM_SUPPORT_XCODE_SIGNPOSTS
 
+#cmakedefine HAVE_PROC_PID_RUSAGE 1
+
 #endif

diff  --git a/llvm/include/llvm/Support/Timer.h 
b/llvm/include/llvm/Support/Timer.h
index 045ac448bdb4..c5874ed35698 100644
--- a/llvm/include/llvm/Support/Timer.h
+++ b/llvm/include/llvm/Support/Timer.h
@@ -24,12 +24,15 @@ class TimerGroup;
 class raw_ostream;
 
 class TimeRecord {
-  double WallTime;   ///< Wall clock time elapsed in seconds.
-  double UserTime;   ///< User time elapsed.
-  double SystemTime; ///< System time elapsed.
-  ssize_t MemUsed;   ///< Memory allocated (in bytes).
+  double WallTime;   ///< Wall clock time elapsed in seconds.
+  double UserTime;   ///< User time elapsed.
+  double SystemTime; ///< System time elapsed.
+  ssize_t MemUsed;   ///< Memory allocated (in bytes).
+  uint64_t InstructionsExecuted; ///< Number of instructions executed
 public:
-  TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {}
+  TimeRecord()
+  : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0),
+InstructionsExecuted(0) {}
 
   /// Get the current time and memory usage.  If Start is true we get the 
memory
   /// usage before the time, otherwise we get time before memory usage.  This
@@ -42,6 +45,7 @@ class TimeRecord {
   double getSystemTime() const { return SystemTime; }
   double getWallTime() const { 

[PATCH] D95536: [clang][sema] Note decl location on missing member

2021-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D95536#2553325 , @tbaeder wrote:

> In D95536#2552258 , @aaron.ballman 
> wrote:
>
>> In D95536#2551332 , @tbaeder wrote:
>>
>>> Any update on this?
>>
>> Thank you for the patch! Do you have some motivating examples of when this 
>> would really add clarity to the diagnostic? I'm not opposed to the patch per 
>> se, but I'm a bit wary about adding an additional note because that makes 
>> the diagnostic output seem that much longer, which makes the salient 
>> diagnostics a bit harder to find (colorization in the terminal helps with 
>> this, though).
>
> I run into this a lot when looking into a larger, new code base. When adding 
> new code, I often look at surrounding code and infer how e.g. an enum member 
> is called. Take https://godbolt.org/z/Tcoxf5 for example, I could've seen 
> code using `OsType::Unix` and inferred that the OsType for Windows will be 
> called `OsType::Windows`, but it's `Win32`. The next step for me as a human 
> is of course to grep the source code for the declaration of `OsType` and 
> check the members. (On the other hand, a "Foo is not a member of enum 
> FooEnum, existing members are: Bar1, Bar2, Bar3, ..." diagnostic would 
> probably be more useful. But that has its own drawbacks).

Hmm... I feel like the diagnostic should already be sufficient to locate the 
originating location of the class or namespace and the note is adding a bit 
more (almost, but not quite) noise, but at the same time, I don't feel so 
strongly that I'd block the patch. I'd like to hear from other reviewers though.

As for some interesting test cases -- I don't think we should issue the note 
when the diagnostic already appears within the class declaration itself. e.g.,

  struct S {
void func();
  
void other(S s) {
  s.foo(); // error, but no need to point to where S is declared
}
  };

Another similar case but involving an anonymous class:

  struct S {
struct {
  void func();
} t;
  
void foo() {
  t.blech(); // Should we do anything about this?
}
  };

A pathological case for C code, which shows another case where I think the note 
is more noise than anything (not that I expect anyone to ever write this code, 
so not worth special handling for unless it's fallout from other special 
handling code that's more useful):

  int func(struct S { int a; } s) {
return s.b;
  }

Anonymous namespaces:

  namespace foo {
  namespace {
void func();
  }
  }
  
  void bar() {
foo::blarg(); // Should point to 'foo'?
  }


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

https://reviews.llvm.org/D95536

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


[PATCH] D96456: [ThinLTO, NewPM] Add Config::OptPassBuilderHook

2021-02-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1066
  PassBuilder::OptimizationLevel Level) 
{
+if (CodeGenOpts.OptimizationLevel == 0) {
+  if (!CodeGenOpts.ThinLTOIndexFile.empty())

Some comments around the cases being checked in this if-then-else would be 
helpful.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1328
+CodeGenOpts.ThinLTOIndexFile.empty()) {
+  // This is testing distributed ThinLTO PostLink. O0 called optimized in
+  // PreLink.

I don't understand what you mean by "O0 called optimized"?
Also maybe make it clear that the first sentence goes with the second check?

Also, it isn't clear to me how this is preventing the sanitizers from being 
added in the ThinLTO pre-link compiles for optimized compiles, as shown in your 
tests. Unlike regular LTO pre-link optimized builds, which are still getting 
the sanitizers.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1541
+  Triple TargetTriple(M->getTargetTriple());
+  Conf.OptimizerLastPassBuilderHook = [&](PassBuilder ) {
+addSanitizers(TargetTriple, CGOpts, LOpts, PB);

This will add sanitizers for the ThinLTO post-link compiles in a distributed 
build environment. Does something need to set these up for ThinLTO post-link 
compiles in the in-process ThinLTO case? In that case thinBackend() is invoked 
via LTO.cpp through the linker.



Comment at: llvm/include/llvm/LTO/Config.h:51
   std::vector PassPlugins;
-  /// For adding passes that run right before codegen.
+  /// For adding passes that run by optimizer.
+  std::function OptimizerLastPassBuilderHook;

This one should say NewPM only.



Comment at: llvm/include/llvm/LTO/Config.h:53
+  std::function OptimizerLastPassBuilderHook;
+  /// For adding passes that run right before codegen (NewPM only).
   std::function PreCodeGenPassesHook;

This one should say legacy PM only



Comment at: llvm/include/llvm/LTO/Config.h:54
+  /// For adding passes that run by opt.
+  std::function OptPassBuilderHook;
   Optional RelocModel = Reloc::PIC_;

vitalybuka wrote:
> aeubanks wrote:
> > vitalybuka wrote:
> > > tejohnson wrote:
> > > > Is this essentially the new PM equivalent to PreCodeGenPassesHook above 
> > > > (since this new hook runs at the end of opt)?
> > > > Also, might be good to name this like OptimizerLastPassBuilderHook or 
> > > > something like that to indicate its position within the opt pipeline.
> > > Kind of. PreCodeGenPassesHook is codegen and it's Legacy PM only.
> > I think the idea is that this callback adds PassBuilder callbacks in 
> > various parts of the the pipeline. Perhaps just `PassBuilderHook`? It's 
> > weird that we only allow one, but I guess we can make it a vector in the 
> > future if necessary.
> I guess the point of OptimizerLastPassBuilderHook name is to show that this 
> is not any PassBuilder, but the one used in ::opt()
My point was just that they are effectively at the same place (the end of opt 
is pretty much the beginning of codegen), so I was wondering if it was worth 
making the legacy and new PM hooks be at the same place. But it probably 
doesn't matter much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

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


[PATCH] D78979: OpenCL: Include builtin header by default

2021-02-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

The new review: https://reviews.llvm.org/D96515


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

https://reviews.llvm.org/D78979

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


[PATCH] D96483: [flang][driver] Add options for unparsing

2021-02-11 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/tools/f18/f18.cpp:541
   driver.debugNoSemantics = true;
-} else if (arg == "-funparse") {
+} else if (arg == "-funparse" || arg == "-fdebug_unparse") {
   driver.dumpUnparse = true;

This should be "-fdebug-unparse" (with a hyphen). That may be why all those 
tests are failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96483

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


[PATCH] D96515: [OpenCL] Add builtin declarations by default.

2021-02-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, arsenm.
Herald added subscribers: dang, ebevhan, yaxunl.
Herald added a reviewer: jansvoboda11.
Anastasia requested review of this revision.
Herald added a subscriber: wdng.

See original RFC: 
https://lists.llvm.org/pipermail/cfe-dev/2021-February/067610.html

This patch enabled the Tablegen based declarations by default along with 
`opencl-c-base.h` containing complete list of OpenCL types. It also adds a new 
flag `-cl-no-stdinc` that disables extra header includes and declarations.

The next step would be to either add missing declarations into Tablegen header 
or opencl-c-base.h.


https://reviews.llvm.org/D96515

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/Types.cpp
  clang/test/Driver/default-includes.cl
  clang/unittests/AST/MatchVerifier.h

Index: clang/unittests/AST/MatchVerifier.h
===
--- clang/unittests/AST/MatchVerifier.h
+++ clang/unittests/AST/MatchVerifier.h
@@ -117,6 +117,7 @@
 FileName = "input.cc";
 break;
   case Lang_OpenCL:
+Args.push_back("-cl-no-stdinc");
 FileName = "input.cl";
 break;
   case Lang_OBJCXX:
Index: clang/test/Driver/default-includes.cl
===
--- /dev/null
+++ clang/test/Driver/default-includes.cl
@@ -0,0 +1,13 @@
+// RUN: %clang %s -Xclang -verify -fsyntax-only
+// RUN: %clang %s -cl-no-stdinc -Xclang -verify -DNOINC -fsyntax-only
+
+#ifndef NOINC
+//expected-no-diagnostics
+#endif
+
+void test() {
+int i = get_global_id(0);
+#ifdef NOINC
+//expected-error@-2{{implicit declaration of function 'get_global_id' is invalid in OpenCL}}
+#endif
+}
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -160,6 +160,8 @@
   }
 }
 
+bool types::isOpenCL(ID Id) { return Id == TY_CL; }
+
 bool types::isCXX(ID Id) {
   switch (Id) {
   default:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3158,7 +3158,8 @@
   }
 }
 
-static void RenderOpenCLOptions(const ArgList , ArgStringList ) {
+static void RenderOpenCLOptions(const ArgList , ArgStringList ,
+types::ID InputType) {
   // cl-denorms-are-zero is not forwarded. It is translated into a generic flag
   // for denormal flushing handling based on the target.
   const unsigned ForwardedArguments[] = {
@@ -3183,6 +3184,13 @@
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
   CmdArgs.push_back(Args.MakeArgString(A->getOption().getPrefixedName()));
+
+  // Only add the default headers if we are compiling OpenCL sources.
+  if ((types::isOpenCL(InputType) || Args.hasArg(options::OPT_cl_std_EQ)) &&
+  !Args.hasArg(options::OPT_cl_no_stdinc)) {
+CmdArgs.push_back("-finclude-default-header");
+CmdArgs.push_back("-fdeclare-opencl-builtins");
+  }
 }
 
 static void RenderARCMigrateToolOptions(const Driver , const ArgList ,
@@ -5680,7 +5688,7 @@
   }
 
   // Forward -cl options to -cc1
-  RenderOpenCLOptions(Args, CmdArgs);
+  RenderOpenCLOptions(Args, CmdArgs, InputType);
 
   if (IsHIP) {
 if (Args.hasFlag(options::OPT_fhip_new_launch_api,
Index: clang/include/clang/Driver/Types.h
===
--- clang/include/clang/Driver/Types.h
+++ clang/include/clang/Driver/Types.h
@@ -81,6 +81,9 @@
   /// isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
   bool isObjC(ID Id);
 
+  /// isOpenCL - Is this an "OpenCL" input.
+  bool isOpenCL(ID Id);
+
   /// isFortran - Is this a Fortran input.
   bool isFortran(ID Id);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -818,6 +818,8 @@
 def cl_uniform_work_group_size : Flag<["-"], "cl-uniform-work-group-size">, Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Defines that the global work-size be a multiple of the work-group size specified to clEnqueueNDRangeKernel">,
   MarshallingInfoFlag>;
+def cl_no_stdinc : Flag<["-"], "cl-no-stdinc">, Group,
+  HelpText<"OpenCL only. Disables all standard includes containing non-native to compiler types and functions from OpenCL C.">;
 def client__name : JoinedOrSeparate<["-"], "client_name">;
 def combine : Flag<["-", "--"], "combine">, Flags<[NoXarchOption, Unsupported]>;
 def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Another thing I noticed that there's verifier support missing. I think we 
should at least check that only a single `clang.arc.rv` bundle is specified 
(https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Verifier.cpp#L3191).
 We should probably also enforce that the bundle is only provided for functions 
with an `i8*` return type. That can also be done after the main patch lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

2021-02-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 323025.
steakhal added a comment.

Actually, somehow I messed up something previously. Now, the diff contains the 
latest version.
Sorry for the inconvenience!

Rebased on top of 2407eb08a5748bc2613e95fa449fc1cae6f4ff8f 
.


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

https://reviews.llvm.org/D94673

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/test/Analysis/plist-macros-with-expansion-ctu.c
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -91,26 +91,6 @@
   *Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
 
   if (NewFD) {
-// Check GetImportedFromSourceLocation.
-llvm::Optional> SLocResult =
-CTU.getImportedFromSourceLocation(NewFD->getLocation());
-EXPECT_TRUE(SLocResult);
-if (SLocResult) {
-  SourceLocation OrigSLoc = (*SLocResult).first;
-  ASTUnit *OrigUnit = (*SLocResult).second;
-  // OrigUnit is created internally by CTU (is not the
-  // ASTWithDefinition).
-  TranslationUnitDecl *OrigTU =
-  OrigUnit->getASTContext().getTranslationUnitDecl();
-  const FunctionDecl *FDWithDefinition = FindFInTU(OrigTU);
-  EXPECT_TRUE(FDWithDefinition);
-  if (FDWithDefinition) {
-EXPECT_EQ(FDWithDefinition->getName(), "f");
-EXPECT_TRUE(FDWithDefinition->isThisDeclarationADefinition());
-EXPECT_EQ(OrigSLoc, FDWithDefinition->getLocation());
-  }
-}
-
 // Check parent map.
 const DynTypedNodeList ParentsAfterImport =
 Ctx.getParentMapContext().getParents(*FD);
Index: clang/test/Analysis/plist-macros-with-expansion-ctu.c
===
--- clang/test/Analysis/plist-macros-with-expansion-ctu.c
+++ clang/test/Analysis/plist-macros-with-expansion-ctu.c
@@ -2,13 +2,13 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -emit-pch -o %t/ctudir/plist-macros-ctu.c.ast %S/Inputs/plist-macros-ctu.c
 // RUN: cp %S/Inputs/plist-macros-with-expansion-ctu.c.externalDefMap.txt %t/ctudir/externalDefMap.txt
-
+//
 // RUN: %clang_analyze_cc1 -analyzer-checker=core \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=%t/ctudir \
 // RUN:   -analyzer-config expand-macros=true \
 // RUN:   -analyzer-output=plist-multi-file -o %t.plist -verify %s
-// XFAIL: *
+//
 // Check the macro expansions from the plist output here, to make the test more
 // understandable.
 //   RUN: FileCheck --input-file=%t.plist %s
@@ -23,25 +23,30 @@
   F3();
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM1
-// CHECK-NEXT: expansion*Z = (int *)0
-
+// FIXME: Macro expansion for other TUs should also work.
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 
 void test1() {
   int *X;
   F1();
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM
-// CHECK-NEXT: expansion*X = (int *)0
+
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 
 void test2() {
   int *X;
   F2();
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM
-// CHECK-NEXT: expansion*Y = (int *)0
+
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 
 #define M F1()
 
@@ -50,10 +55,20 @@
   M;
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
-// CHECK: nameM
-// CHECK-NEXT: expansionF1(X)
-// CHECK: nameM
-// CHECK-NEXT: expansion*X = (int *)0
+// Macro expansions for the main TU still works, even in CTU mode.
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   location
+// CHECK-NEXT:   
+// CHECK-NEXT:line55
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   nameM
+// CHECK-NEXT:   expansionF1 (X )
+// CHECK-NEXT:  
+// CHECK-NEXT: 
 
 #undef M
 #define M F2()
@@ -64,10 +79,19 @@
   *X = 1; // expected-warning{{Dereference of null pointer}}
 }
 
-// CHECK: nameM
-// CHECK-NEXT: expansionF2(X)
-// CHECK: nameM
-// CHECK-NEXT: expansion*Y = (int *)0
+// CHECK:  macro_expansions
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   location
+// CHECK-NEXT:   
+// CHECK-NEXT:line78
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   nameM
+// CHECK-NEXT:   expansionF2 (X )
+// CHECK-NEXT:  
+// CHECK-NEXT: 
 
 void test_h() {
   int *X;
@@ -75,5 

[PATCH] D93223: [analyzer] Create MacroExpansionContext member in AnalysisConsumer

2021-02-11 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 323024.
steakhal added a comment.

Nothing changed.
Rebased on top of 2407eb08a5748bc2613e95fa449fc1cae6f4ff8f 
.


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

https://reviews.llvm.org/D93223

Files:
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -20,6 +20,7 @@
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/CallGraph.h"
 #include "clang/Analysis/CodeInjector.h"
+#include "clang/Analysis/MacroExpansionContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
@@ -98,6 +99,8 @@
   /// working with a PCH file.
   SetOfDecls LocalTUDecls;
 
+  MacroExpansionContext MacroExpansions;
+
   // Set of PathDiagnosticConsumers.  Owned by AnalysisManager.
   PathDiagnosticConsumers PathConsumers;
 
@@ -122,7 +125,8 @@
CodeInjector *injector)
   : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr),
 PP(CI.getPreprocessor()), OutDir(outdir), Opts(std::move(opts)),
-Plugins(plugins), Injector(injector), CTU(CI) {
+Plugins(plugins), Injector(injector), CTU(CI),
+MacroExpansions(CI.getLangOpts()) {
 DigestAnalyzerOptions();
 if (Opts->PrintStats || Opts->ShouldSerializeStats) {
   AnalyzerTimers = std::make_unique(
@@ -136,6 +140,9 @@
   *AnalyzerTimers);
   llvm::EnableStatistics(/* PrintOnExit= */ false);
 }
+
+if (Opts->ShouldDisplayMacroExpansions)
+  MacroExpansions.registerForPreprocessor(PP);
   }
 
   ~AnalysisConsumer() override {
@@ -150,7 +157,8 @@
   break;
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)\
   case PD_##NAME:  \
-CREATEFN(Opts->getDiagOpts(), PathConsumers, OutDir, PP, CTU); \
+CREATEFN(Opts->getDiagOpts(), PathConsumers, OutDir, PP, CTU,  \
+ MacroExpansions); \
 break;
 #include "clang/StaticAnalyzer/Core/Analyses.def"
 default:
Index: clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Analysis/MacroExpansionContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
@@ -138,8 +139,9 @@
 
 void ento::createTextPathDiagnosticConsumer(
 PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
+const std::string , const Preprocessor ,
+const cross_tu::CrossTranslationUnitContext ,
+const MacroExpansionContext ) {
   C.emplace_back(new TextDiagnostics(std::move(DiagOpts), PP.getDiagnostics(),
  PP.getLangOpts(),
  /*ShouldDisplayPathNotes=*/true));
@@ -147,8 +149,9 @@
 
 void ento::createTextMinimalPathDiagnosticConsumer(
 PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
+const std::string , const Preprocessor ,
+const cross_tu::CrossTranslationUnitContext ,
+const MacroExpansionContext ) {
   C.emplace_back(new TextDiagnostics(std::move(DiagOpts), PP.getDiagnostics(),
  PP.getLangOpts(),
  /*ShouldDisplayPathNotes=*/false));
Index: clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/Analysis/MacroExpansionContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/Version.h"
@@ -48,7 +49,8 @@
 void ento::createSarifDiagnosticConsumer(
 

[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as not done.
aaron.ballman added a comment.

Ping.


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

https://reviews.llvm.org/D95396

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


  1   2   >