[llvm-branch-commits] [clang] 20ea9e3 - In change https://reviews.llvm.org/D115456 on-demand TLS initialization for Microsoft CXX ABI was added.

2022-02-07 Thread Hans Wennborg via llvm-branch-commits

Author: Maurice Heumann
Date: 2022-02-07T11:02:35+01:00
New Revision: 20ea9e379984f240d7135843baae6999abf3bf2b

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

LOG: In change https://reviews.llvm.org/D115456 on-demand TLS initialization 
for Microsoft CXX ABI was added.

This mentions the change in the release notes.

Differential revision: https://reviews.llvm.org/D117500

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5cc53e9ec27b2..a58e3fcd4f42c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -158,6 +158,8 @@ Windows Support
   along with tools such as Live++ or Recode. Microsoft Edit and Continue isn't
   currently supported.
 
+- Support for on-demand initialization of TLS variables was added.
+
 C Language Changes in Clang
 ---
 



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 02d5b11 - [HIPSPV] Fix literals are mapped to Generic address space

2022-02-07 Thread Yaxun Liu via llvm-branch-commits

Author: Yaxun (Sam) Liu
Date: 2022-02-07T10:00:54-05:00
New Revision: 02d5b112138e7e9f30dec685afb380c1b9593a84

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

LOG: [HIPSPV] Fix literals are mapped to Generic address space

This issue is an oversight in D108621.

Literals in HIP are emitted as global constant variables with default
address space which maps to Generic address space for HIPSPV. In
SPIR-V such variables translate to OpVariable instructions with
Generic storage class which are not legal. Fix by mapping literals
to CrossWorkGroup address space.

The literals are not mapped to UniformConstant because the “flat”
pointers in HIP may reference them and “flat” pointers are modeled
as Generic pointers in SPIR-V. In SPIR-V/OpenCL UniformConstant
pointers may not be casted to Generic.

Patch by: Henry Linjamäki

Reviewed by: Yaxun Liu

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenHIP/hipspv-addr-spaces.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 2346176a15628..29806b65e984e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4381,6 +4381,14 @@ LangAS CodeGenModule::GetGlobalConstantAddressSpace() 
const {
 return LangAS::opencl_constant;
   if (LangOpts.SYCLIsDevice)
 return LangAS::sycl_global;
+  if (LangOpts.HIP && LangOpts.CUDAIsDevice && getTriple().isSPIRV())
+// For HIPSPV map literals to cuda_device (maps to CrossWorkGroup in 
SPIR-V)
+// instead of default AS (maps to Generic in SPIR-V). Otherwise, we end up
+// with OpVariable instructions with Generic storage class which is not
+// allowed (SPIR-V V1.6 s3.42.8). Also, mapping literals to SPIR-V
+// UniformConstant storage class is not viable as pointers to it may not be
+// casted to Generic pointers which are used to model HIP's "flat" 
pointers.
+return LangAS::cuda_device;
   if (auto AS = getTarget().getConstantAddressSpace())
 return AS.getValue();
   return LangAS::Default;

diff  --git a/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp 
b/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
index 8f56f2104ecbd..bde360eec8cd9 100644
--- a/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
+++ b/clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
@@ -22,6 +22,9 @@ __device__ struct foo_t {
   int* pi;
 } foo;
 
+// Check literals are placed in address space 1 (CrossWorkGroup/__global).
+// CHECK: @.str ={{.*}} unnamed_addr addrspace(1) constant
+
 // CHECK: define{{.*}} spir_func noundef i32 addrspace(4)* @_Z3barPi(i32 
addrspace(4)*
 __device__ int* bar(int *x) {
   return x;
@@ -44,3 +47,8 @@ __device__ int* baz_s() {
   // CHECK: ret i32 addrspace(4)* addrspacecast (i32 addrspace(3)* @s to i32 
addrspace(4)*
   return &s;
 }
+
+// CHECK: define{{.*}} spir_func noundef i8 addrspace(4)* @_Z3quzv()
+__device__ const char* quz() {
+  return "abc";
+}



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 923b67e - Fix lld standalone build

2022-02-07 Thread Fangrui Song via llvm-branch-commits

Author: Mariusz Ceier
Date: 2022-02-07T09:21:32-08:00
New Revision: 923b67e36917352c1ca1fb1e339dbe5acdc97ddf

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

LOG: Fix lld standalone build

lld/ELF/OutputSections.cpp includes llvm/Config/config.h for
LLVM_ENABLE_ZLIB definition, but llvm/Config/config.h doesn't exist in
standalone build.

To fix this, this patch moves LLVM_ENABLE_ZLIB from config.h to
llvm-config.h and updates OutputSections.cpp to include llvm-config.h
instead of config.h

Reviewed By: MaskRay, mgorny

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

(cherry picked from commit e8bff9ae54a55b4dbfeb6ba55f723abbd81bf494)

Added: 


Modified: 
lld/ELF/OutputSections.cpp
llvm/include/llvm/Config/config.h.cmake
llvm/include/llvm/Config/llvm-config.h.cmake

Removed: 




diff  --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 241b3ea3b4188..53cdcee1bfe86 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -16,7 +16,7 @@
 #include "lld/Common/Memory.h"
 #include "lld/Common/Strings.h"
 #include "llvm/BinaryFormat/Dwarf.h"
-#include "llvm/Config/config.h" // LLVM_ENABLE_ZLIB
+#include "llvm/Config/llvm-config.h" // LLVM_ENABLE_ZLIB
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Parallel.h"

diff  --git a/llvm/include/llvm/Config/config.h.cmake 
b/llvm/include/llvm/Config/config.h.cmake
index 064d2f27dc18b..2098c249e20db 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -300,9 +300,6 @@
 /* Doesn't use `cmakedefine` because it is allowed to be empty. */
 #define LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}"
 
-/* Define if zlib compression is available */
-#cmakedefine01 LLVM_ENABLE_ZLIB
-
 /* Define if overriding target triple is enabled */
 #cmakedefine LLVM_TARGET_TRIPLE_ENV "${LLVM_TARGET_TRIPLE_ENV}"
 

diff  --git a/llvm/include/llvm/Config/llvm-config.h.cmake 
b/llvm/include/llvm/Config/llvm-config.h.cmake
index ec18b40fe04d9..839a1c7c1984f 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -88,6 +88,9 @@
 /* Define if we have curl and want to use it */
 #cmakedefine LLVM_ENABLE_CURL ${LLVM_ENABLE_CURL}
 
+/* Define if zlib compression is available */
+#cmakedefine01 LLVM_ENABLE_ZLIB
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic 
library */
 #cmakedefine LLVM_HAVE_TF_API
 



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 1e7adac - [libc++] Mention in the release notes

2022-02-07 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2022-02-07T12:30:40-05:00
New Revision: 1e7adacd10a465af4e4856e23b7bfb9e0b5c4d76

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

LOG: [libc++] Mention  in the release notes

Added: 


Modified: 
libcxx/docs/ReleaseNotes.rst

Removed: 




diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index a33c6621d448d..dd8d2648ca019 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -47,6 +47,12 @@ New Features
   header by using ``-DLIBCXX_ENABLE_INCOMPLETE_FEATURES=ON`` when
   configuring their build.
 
+- More parts of  have been implemented. Since we still expect to 
make
+  some API and ABI breaking changes, those are disabled by default. However,
+  vendors that wish to enable  in their distribution may do so
+  by defining ``-DLIBCXX_ENABLE_INCOMPLETE_FEATURES=ON`` when configuring
+  their build.
+
 - There's a new CMake option ``LIBCXX_ENABLE_UNICODE`` to disable Unicode
   support in the  header. This only affects the estimation of the
   output width of the format functions.



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libunwind] c0fde75 - [libunwind] Define _Unwind_Backtrace for powerpc, sparc

2022-02-07 Thread Fangrui Song via llvm-branch-commits

Author: Sam James
Date: 2022-02-07T09:38:08-08:00
New Revision: c0fde7580aac12143d63291af452e261808dc4ec

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

LOG: [libunwind] Define _Unwind_Backtrace for powerpc, sparc

Add SPARC to the list of platforms for which we provide a full
unwind implementation which leads to _Unwind_Backtrace being defined within
libunwind.so.

Likewise for PPC (see D118320 for background).

Reviewed By: #libunwind, MaskRay, Arfrever

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

(cherry picked from commit 022011078054c133777e1c3f8ea927bdef97f1fc)

Added: 


Modified: 
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/config.h b/libunwind/src/config.h
index 560edda04eaa9..5ae1604f657dd 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -109,13 +109,10 @@
 #define _LIBUNWIND_SUPPORT_FRAME_APIS
 #endif
 
-#if defined(__i386__) || defined(__x86_64__) ||
\
-defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) ||
\
-(!defined(__APPLE__) && defined(__arm__)) ||   
\
-defined(__aarch64__) ||
\
-defined(__mips__) ||   
\
-defined(__riscv) ||
\
-defined(__hexagon__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) ||
\
+(!defined(__APPLE__) && defined(__arm__)) || defined(__aarch64__) ||   
\
+defined(__mips__) || defined(__riscv) || defined(__hexagon__) ||   
\
+defined(__sparc__)
 #if !defined(_LIBUNWIND_BUILD_SJLJ_APIS)
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
 #endif



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 2150816 - [Driver][OpenBSD] -r: imply -nostdlib like GCC

2022-02-07 Thread Fangrui Song via llvm-branch-commits

Author: Brad Smith
Date: 2022-02-07T10:54:39-08:00
New Revision: 2150816e666ac0e7f9545f016457e82af83bcad2

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

LOG: [Driver][OpenBSD] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

(cherry picked from commit 1831cbd9d4174a93d4017e510ecf0f840af5f7d6)

Added: 


Modified: 
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 96abac57764f7..bcd54bedfa897 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -160,7 +160,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 const char *crt0 = nullptr;
 const char *crtbegin = nullptr;
 if (!Args.hasArg(options::OPT_shared)) {
@@ -191,7 +192,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 // Use the static OpenMP runtime with -static-openmp
 bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
 !Args.hasArg(options::OPT_static);
@@ -234,7 +236,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-lcompiler_rt");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 const char *crtend = nullptr;
 if (!Args.hasArg(options::OPT_shared))
   crtend = "crtend.o";

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index c2ffe2a0397cd..d6d5ae994e67e 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -40,8 +40,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64-LD %s
 // RUN: %clang -no-canonical-prefixes -target mips64el-unknown-openbsd %s -### 
2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
-// CHECK-LD-R: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-LD-R: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" 
"-L{{.*}}" "-r" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" 
"{{.*}}crtend.o"
+// CHECK-LD-R: "-r"
+// CHECK-LD-R-NOT: "-l
+// CHECK-LD-R-NOT: crt{{[^.]+}}.o
 // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" 
"-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" 
"{{.*}}crtend.o"
 // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libunwind] ec05ccb - [libunwind] [sparc] Add SPARCv9 support

2022-02-07 Thread Fangrui Song via llvm-branch-commits

Author: Koakuma
Date: 2022-02-07T11:13:22-08:00
New Revision: ec05ccbc47156314217916b963d8bd9f664c37f8

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

LOG: [libunwind] [sparc] Add SPARCv9 support

Adds libunwind support for SPARCv9 (aka sparc64). This is a rebase of 
@kettenis' patch D32450, which I created (with his permission) because the 
original review has become inactive.
The changes are of a cosmetic nature to make it fit better with the new code 
style, and to reuse the existing SPARCv8 code, whenever possible.

Please let me know if I posted this on the wrong place. Also, the summary of 
the original review is reproduced below:

> This adds unwinder support for 64-bit SPARC (aka SPARCv9). The implementation 
> was done on OpenBSD/sparc64, so it takes StackGhost into account:
>
> https://www.usenix.org/legacy/publications/library/proceedings/sec01/full_papers/frantzen/frantzen_html/index.html
>
> Since StackGhost xor's return addresses with a random cookie before storing 
> them on the stack, the unwinder has to do some extra work to recover those. 
> This is done by introducing a new kRegisterInCFADecrypt "location" type that 
> is used to implement the DW_CFA_GNU_window_save opcode. That implementation 
> is SPARC-specific, but should work for 32-bit SPARC as well. 
> DW_CFA_GNU_window_save is only ever generated on SPARC as far as I know.

Co-authored-by: Mark Kettenis
Reviewed By: #libunwind, thesamesam, MaskRay, Arfrever

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

(cherry picked from commit 2b9554b8850192bdd86c02eb671de1d866df8d87)

Added: 


Modified: 
libunwind/include/__libunwind_config.h
libunwind/src/DwarfInstructions.hpp
libunwind/src/DwarfParser.hpp
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 67527d9da4042..e87bcf40034f3 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -23,6 +23,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64   31
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_HEXAGON   34
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV 64
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_VE143
@@ -125,6 +126,12 @@
 #error "Unsupported MIPS ABI and/or environment"
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
+#elif defined(__sparc__) && defined(__arch64__)
+#define _LIBUNWIND_TARGET_SPARC64 1
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER  
\
+  _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64
+#define _LIBUNWIND_CONTEXT_SIZE 33
+#define _LIBUNWIND_CURSOR_SIZE 45
 # elif defined(__sparc__)
   #define _LIBUNWIND_TARGET_SPARC 1
   #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
@@ -165,6 +172,7 @@
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
 # define _LIBUNWIND_TARGET_SPARC 1
+# define _LIBUNWIND_TARGET_SPARC64 1
 # define _LIBUNWIND_TARGET_HEXAGON 1
 # define _LIBUNWIND_TARGET_RISCV 1
 # define _LIBUNWIND_TARGET_VE 1

diff  --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index 1c50941680b33..c1a241c55ce66 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -74,6 +74,13 @@ class DwarfInstructions {
   }
 };
 
+template 
+auto getSparcWCookie(const R &r, int) -> decltype(r.getWCookie()) {
+  return r.getWCookie();
+}
+template  uint64_t getSparcWCookie(const R &, long) {
+  return 0;
+}
 
 template 
 typename A::pint_t DwarfInstructions::getSavedRegister(
@@ -83,6 +90,10 @@ typename A::pint_t DwarfInstructions::getSavedRegister(
   case CFI_Parser::kRegisterInCFA:
 return (pint_t)addressSpace.getRegister(cfa + (pint_t)savedReg.value);
 
+  case CFI_Parser::kRegisterInCFADecrypt: // sparc64 specific
+return addressSpace.getP(cfa + (pint_t)savedReg.value) ^
+   getSparcWCookie(registers, 0);
+
   case CFI_Parser::kRegisterAtExpression:
 return (pint_t)addressSpace.getRegister(evaluateExpression(
 (pint_t)savedReg.value, addressSpace, registers, cfa));
@@ -124,6 +135,7 @@ double DwarfInstructions::getSavedFloatRegister(
   case CFI_Parser::kRegisterIsExpression:
   case CFI_Parser::kRegisterUnused:
   case CFI_Parser::kRegisterOffsetFromCFA:
+  case CFI_Parser::kRegisterInCFADecrypt:
 // FIX ME
 break;
   }

[llvm-branch-commits] [clang] 592367a - [clang-format] regression from clang-format v13

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: mydeveloperday
Date: 2022-02-07T13:20:56-08:00
New Revision: 592367ab7ea8c70eb26f2a6a7ddeb05b50322545

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

LOG: [clang-format] regression from clang-format v13

https://github.com/llvm/llvm-project/issues/53567

The following source

```
namespace A {

template  struct Foo {
  void foo() { std::cout << "Bar"; }
}; // namespace A
```

is incorrectly formatted as:

```
namespace A {

template  struct Foo{void foo(){std::cout << "Bar";
}
}
; // namespace A
```

This looks to be caused by 
https://github.com/llvm/llvm-project/commit/5c2e7c9ca043d92bed75b08e653fb47c384edd13

Reviewed By: curdeius

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

(cherry picked from commit 23fc20e06c088acff81a06ad546a848bee083051)

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 6426791284090..2e2293c6d58bd 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -3102,7 +3102,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   }
   if (FormatTok->is(tok::l_square)) {
 FormatToken *Previous = FormatTok->Previous;
-if (!Previous || Previous->isNot(tok::r_paren)) {
+if (!Previous ||
+!(Previous->is(tok::r_paren) || Previous->isTypeOrIdentifier())) {
   // Don't try parsing a lambda if we had a closing parenthesis before,
   // it was probably a pointer to an array: int (*)[].
   if (!tryToParseLambda())

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 005e2d6a7b559..136a25fa89468 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -23638,6 +23638,7 @@ TEST_F(FormatTest, ShortTemplatedArgumentLists) {
   verifyFormat("struct Y<[] { return 0; }> {};", Style);
 
   verifyFormat("struct Z : X {};", Style);
+  verifyFormat("template  struct Foo {};", Style);
 }
 
 TEST_F(FormatTest, RemoveBraces) {



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] b391c02 - Re-apply 3fab2d138e30, now with a triple added

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:38-08:00
New Revision: b391c02561bc14e7b2c761dcfff08ea621158acc

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

LOG: Re-apply 3fab2d138e30, now with a triple  added

Was reverted in 1c1b670a73a9 as it broke all non-x86 bots. Original commit
message:

[DebugInfo][InstrRef] Add a max-stack-slots-to-track cut-out

In certain circumstances with things like autogenerated code and asan, you
can end up with thousands of Values live at the same time, causing a large
working set and a lot of information spilled to the stack. Unfortunately
InstrRefBasedLDV doesn't cope well with this and consumes a lot of memory
when there are many many stack slots. See the reproducer in D116821.

It seems very unlikely that a developer would be able to reason about
hundreds of live named local variables at the same time, so a huge working
set and many stack slots is an indicator that we're likely analysing
autogenerated or instrumented code. In those cases: gracefully degrade by
setting an upper bound on the amount of stack slots to track. This limits
peak memory consumption, at the cost of dropping some variable locations,
but in a rare scenario where it's unlikely someone is actually going to
use them.

In terms of the patch, this adds a cl::opt for max number of stack slots to
track, and has the stack-slot-numbering code optionally return None. That
then filters through a number of code paths, which can then chose to not
track a spill / restore if it touches an untracked spill slot. The added
test checks that we drop variable locations that are on the stack, if we
set the limit to zero.

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

(cherry picked from commit 1412366f7d1328b5ec81c71c63de9d878e75)

Added: 
llvm/test/DebugInfo/MIR/InstrRef/spill-slot-limits.mir

Modified: 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
llvm/unittests/CodeGen/InstrRefLDVTest.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 0eb6100230bd1..2e69a5e437e76 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -148,6 +148,20 @@ static cl::opt 
EmulateOldLDV("emulate-old-livedebugvalues", cl::Hidden,
cl::desc("Act like old LiveDebugValues 
did"),
cl::init(false));
 
+// Limit for the maximum number of stack slots we should track, past which we
+// will ignore any spills. InstrRefBasedLDV gathers detailed information on all
+// stack slots which leads to high memory consumption, and in some scenarios
+// (such as asan with very many locals) the working set of the function can be
+// very large, causing many spills. In these scenarios, it is very unlikely 
that
+// the developer has hundreds of variables live at the same time that they're
+// carefully thinking about -- instead, they probably autogenerated the code.
+// When this happens, gracefully stop tracking excess spill slots, rather than
+// consuming all the developer's memory.
+static cl::opt
+StackWorkingSetLimit("livedebugvalues-max-stack-slots", cl::Hidden,
+ cl::desc("livedebugvalues-stack-ws-limit"),
+ cl::init(250));
+
 /// Tracker for converting machine value locations and variable values into
 /// variable locations (the output of LiveDebugValues), recorded as DBG_VALUEs
 /// specifying block live-in locations and transfers within blocks.
@@ -757,9 +771,15 @@ void MLocTracker::writeRegMask(const MachineOperand *MO, 
unsigned CurBB,
   Masks.push_back(std::make_pair(MO, InstID));
 }
 
-SpillLocationNo MLocTracker::getOrTrackSpillLoc(SpillLoc L) {
+Optional MLocTracker::getOrTrackSpillLoc(SpillLoc L) {
   SpillLocationNo SpillID(SpillLocs.idFor(L));
+
   if (SpillID.id() == 0) {
+// If there is no location, and we have reached the limit of how many stack
+// slots to track, then don't track this one.
+if (SpillLocs.size() >= StackWorkingSetLimit)
+  return None;
+
 // Spill location is untracked: create record for this one, and all
 // subregister slots too.
 SpillID = SpillLocationNo(SpillLocs.insert(L));
@@ -898,7 +918,7 @@ bool InstrRefBasedLDV::isCalleeSaved(LocIdx L) const {
 // void InstrRefBasedLDV::printVarLocInMBB(..)
 #endif
 
-SpillLocationNo
+Optional
 InstrRefBasedLDV::extractSpillBaseRegAndOffset(const MachineInstr &MI) {
   assert(MI.hasOneMemOperand() &&
  "Spill instruction does not have exactly one memory operand?");
@@ -913,8 +933,11 @@ InstrRefBasedLDV::extractSpillBaseRegAndOffset(

[llvm-branch-commits] [llvm] 87f0dd3 - Follow up to 9fd9d56dc6b, avoid a memory leak

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:39-08:00
New Revision: 87f0dd330eaa089ca4034dffc105a7f2eef6b90c

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

LOG: Follow up to 9fd9d56dc6b, avoid a memory leak

Gaps in the basic block number range (from blocks being deleted or folded)
get block-value-tables allocated but never ejected, leading to a memory
leak, currently tripping up the asan buildbots. Fix this up by manually
freeing that memory.

As suggested elsewhere, if these things were owned by a unique_ptr then
cleanup would happen automagically. D118774 should eliminate the need for
this dance.

(cherry picked from commit 206cafb680cea0741f8c7b276351db516ff27f81)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 268095e0943a0..cc800736a2dc1 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -3027,6 +3027,16 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
 if (MOutLocs[MBB->getNumber()])
   EjectBlock(*MBB);
 
+  // Finally, there might have been gaps in the block numbering, from dead
+  // blocks being deleted or folded. In those scenarios, we might allocate a
+  // block-table that's never ejected, meaning we have to free it at the end.
+  for (unsigned int I = 0; I < MaxNumBlocks; ++I) {
+if (MInLocs[I]) {
+  delete[] MInLocs[I];
+  delete[] MOutLocs[I];
+}
+  }
+
   return emitTransfers(AllVarsNumbering);
 }
 



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] a03ffad - [DebugInfo] Re-enable instruction referencing for x86_64

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:39-08:00
New Revision: a03ffad5d34c6d1df14e25df17f18ea2fa437c0c

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

LOG: [DebugInfo] Re-enable instruction referencing for x86_64

After discussion in D116821 this was turned off in 74db5c8c95e,
1412366f7 applied to limit the maximum memory consumption in rare
conditions, plus some performance patches.

(cherry picked from commit 6e03a68b776dc06826dacbdab26d24a90bb2173b)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
llvm/test/DebugInfo/X86/instr-ref-flag.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index 8f697611a82c0..40770b15aa35b 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -123,6 +123,11 @@ bool LiveDebugValues::runOnMachineFunction(MachineFunction 
&MF) {
 }
 
 bool llvm::debuginfoShouldUseDebugInstrRef(const Triple &T) {
+  // Enable by default on x86_64, disable if explicitly turned off on cmdline.
+  if (T.getArch() == llvm::Triple::x86_64 &&
+  ValueTrackingVariableLocations != cl::boolOrDefault::BOU_FALSE)
+return true;
+
   // Enable if explicitly requested on command line.
   return ValueTrackingVariableLocations == cl::boolOrDefault::BOU_TRUE;
 }

diff  --git a/llvm/test/DebugInfo/X86/instr-ref-flag.ll 
b/llvm/test/DebugInfo/X86/instr-ref-flag.ll
index 56d34aedabd02..f9d5f99edf77f 100644
--- a/llvm/test/DebugInfo/X86/instr-ref-flag.ll
+++ b/llvm/test/DebugInfo/X86/instr-ref-flag.ll
@@ -13,10 +13,6 @@
 ;; by llc by default, and that it can be turned explicitly on or off as
 ;; desired.
 
-;; Xfail due to faults found in the discussion on
-;; https://reviews.llvm.org/D116821
-; XFAIL: *
-
 ; INSTRREFON: DBG_INSTR_REF
 ; INSTRREFOFF: DBG_VALUE
 



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 762c17b - [DebugInfo][InstrRef][NFC] Free resources at an earlier stage

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:38-08:00
New Revision: 762c17b7b6f24a55b4071382f822114128bb3af1

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

LOG: [DebugInfo][InstrRef][NFC] Free resources at an earlier stage

This patch releases some memory from InstrRefBasedLDV earlier that it would
otherwise. The underlying problem is:
 * We store a big table of "live in values for each block",
 * We translate that into DBG_VALUE instructions in each block,

And both exist in memory at the same time, which needlessly doubles that
information. The most of what this patch does is: as we progressively
translate live-in information into DBG_VALUEs, we free the variable-value /
machine-value tracking information as we go, which significantly reduces
peak memory.

While I'm here, also add a clear method to wipe variable assignments that
have been accumulated into VLocTracker objects, and turn a DenseMap into
a SmallDenseMap to avoid an initial allocation.

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

(cherry picked from commit a80181a81ea44215e49e5da1457614ec0bd44111)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 25d764dee2ed8..7b06bc9b0c39c 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -1029,7 +1029,7 @@ bool InstrRefBasedLDV::transferDebugInstrRef(MachineInstr 
&MI,
 
   // Only handle this instruction when we are building the variable value
   // transfer function.
-  if (!VTracker)
+  if (!VTracker && !TTracker)
 return false;
 
   unsigned InstNo = MI.getOperand(0).getImm();
@@ -1185,7 +1185,8 @@ bool InstrRefBasedLDV::transferDebugInstrRef(MachineInstr 
&MI,
   // for DBG_INSTR_REFs as DBG_VALUEs (just, the former can refer to values 
that
   // aren't immediately available).
   DbgValueProperties Properties(Expr, false);
-  VTracker->defVar(MI, Properties, NewID);
+  if (VTracker)
+VTracker->defVar(MI, Properties, NewID);
 
   // If we're on the final pass through the function, decompose this INSTR_REF
   // into a plain DBG_VALUE.
@@ -2826,6 +2827,7 @@ void InstrRefBasedLDV::emitLocations(
 const TargetPassConfig &TPC) {
   TTracker = new TransferTracker(TII, MTracker, MF, *TRI, CalleeSavedRegs, 
TPC);
   unsigned NumLocs = MTracker->getNumLocs();
+  VTracker = nullptr;
 
   // For each block, load in the machine value locations and variable value
   // live-ins, then step through each instruction in the block. New DBG_VALUEs
@@ -2844,6 +2846,15 @@ void InstrRefBasedLDV::emitLocations(
   TTracker->checkInstForNewValues(CurInst, MI.getIterator());
   ++CurInst;
 }
+
+// Our block information has now been converted into DBG_VALUEs, to be
+// inserted below. Free the memory we allocated to track variable / 
register
+// values. If we don't, we needlessy record the same info in memory twice.
+delete[] MInLocs[bbnum];
+delete[] MOutLocs[bbnum];
+MInLocs[bbnum] = nullptr;
+MOutLocs[bbnum] = nullptr;
+SavedLiveIns[bbnum].clear();
   }
 
emitTransfers(AllVarsNumbering);
@@ -3080,6 +3091,12 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
   << " has " << MaxNumBlocks << " basic blocks and "
   << VarAssignCount
   << " variable assignments, exceeding limits.\n");
+
+// Perform memory cleanup that emitLocations would do otherwise.
+for (int Idx = 0; Idx < MaxNumBlocks; ++Idx) {
+  delete[] MOutLocs[Idx];
+  delete[] MInLocs[Idx];
+}
   } else {
 // Compute the extended ranges, iterating over scopes. There might be
 // something to be said for ordering them by size/locality, but that's for
@@ -3091,6 +3108,9 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
vlocs);
 }
 
+// Now that we've analysed variable assignments, free any tracking data.
+vlocs.clear();
+
 // Using the computed value locations and variable values for each block,
 // create the DBG_VALUE instructions representing the extended variable
 // locations.
@@ -3100,11 +3120,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
 Changed = TTracker->Transfers.size() != 0;
   }
 
-  // Common clean-up of memory.
-  for (int Idx = 0; Idx < MaxNumBlocks; ++Idx) {
-delete[] MOutLocs[Idx];
-delete[] MInLocs[Idx];
-  }
+  // Elements of these arrays will be deleted by emitLocations.
   delete[] MOutLocs;
   delete[] MInLocs;
 

diff  --git a/llvm/lib/CodeGen/LiveDebugVal

[llvm-branch-commits] [llvm] e870e07 - [DebugInfo][InstrRef][NFC] Cache some PHI resolutions

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:38-08:00
New Revision: e870e07019abf9c05660f30c49458b7699f9c5bd

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

LOG: [DebugInfo][InstrRef][NFC] Cache some PHI resolutions

Install a cache of DBG_INSTR_REF -> ValueIDNum resolutions, for scenarios
where the value has to be reconstructed from several DBG_PHIs. Whenever
this happens, it's because branch folding + tail duplication has messed
with the SSA form of the program, and we have to solve a mini SSA problem
to find the variable value. This is always called twice, so it makes sense
to cache the value.

This gives a ~0.5% geomean compile-time-performance improvement on CTMark.

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

(cherry picked from commit d556eb7e27c25ae20befb0811bc8a3423241431d)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 2e69a5e437e76..25d764dee2ed8 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -3122,6 +3122,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
   DebugPHINumToValue.clear();
   OverlapFragments.clear();
   SeenFragments.clear();
+  SeenDbgPHIs.clear();
 
   return Changed;
 }
@@ -3387,6 +3388,21 @@ Optional 
InstrRefBasedLDV::resolveDbgPHIs(MachineFunction &MF,
   ValueIDNum **MLiveIns,
   MachineInstr &Here,
   uint64_t InstrNum) {
+  // This function will be called twice per DBG_INSTR_REF, and might end up
+  // computing lots of SSA information: memoize it.
+  auto SeenDbgPHIIt = SeenDbgPHIs.find(&Here);
+  if (SeenDbgPHIIt != SeenDbgPHIs.end())
+return SeenDbgPHIIt->second;
+
+  Optional Result =
+  resolveDbgPHIsImpl(MF, MLiveOuts, MLiveIns, Here, InstrNum);
+  SeenDbgPHIs.insert({&Here, Result});
+  return Result;
+}
+
+Optional InstrRefBasedLDV::resolveDbgPHIsImpl(
+MachineFunction &MF, ValueIDNum **MLiveOuts, ValueIDNum **MLiveIns,
+MachineInstr &Here, uint64_t InstrNum) {
   // Pick out records of DBG_PHI instructions that have been observed. If there
   // are none, then we cannot compute a value number.
   auto RangePair = std::equal_range(DebugPHINumToValue.begin(),

diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
index fe1d29260e4da..1e1bb758d3d44 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
@@ -864,6 +864,12 @@ class InstrRefBasedLDV : public LDVImpl {
   OverlapMap OverlapFragments;
   VarToFragments SeenFragments;
 
+  /// Mapping of DBG_INSTR_REF instructions to their values, for those
+  /// DBG_INSTR_REFs that call resolveDbgPHIs. These variable references solve
+  /// a mini SSA problem caused by DBG_PHIs being cloned, this collection 
caches
+  /// the result.
+  DenseMap> SeenDbgPHIs;
+
   /// True if we need to examine call instructions for stack clobbers. We
   /// normally assume that they don't clobber SP, but stack probes on Windows
   /// do.
@@ -944,6 +950,12 @@ class InstrRefBasedLDV : public LDVImpl {
   ValueIDNum **MLiveIns, MachineInstr 
&Here,
   uint64_t InstrNum);
 
+  Optional resolveDbgPHIsImpl(MachineFunction &MF,
+  ValueIDNum **MLiveOuts,
+  ValueIDNum **MLiveIns,
+  MachineInstr &Here,
+  uint64_t InstrNum);
+
   /// Step through the function, recording register definitions and movements
   /// in an MLocTracker. Convert the observations into a per-block transfer
   /// function in \p MLocTransfer, suitable for using with the machine value



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 89d7063 - [DebugInfo][InstrRef][NFC] Use depth-first scope search for variable locs

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:38-08:00
New Revision: 89d7063d7ece761901f3d4c8313d29b21a846d85

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

LOG: [DebugInfo][InstrRef][NFC] Use depth-first scope search for variable locs

This patch aims to reduce max-rss from instruction referencing, by avoiding
keeping variable value information in memory for too long. Instead of
computing all the variable values then emitting them to DBG_VALUE
instructions, this patch tries to stream the information out through a
depth first search:
 * Make use of the fact LexicalScopes gives a depth-number to each lexical
   scope,
 * Produce a map that identifies the last lexical scope to make use of a
   block,
 * Enumerate each scope in LexicalScopes' DFS order, solving the variable
   value problem,
 * After each scope is processed, look for any blocks that won't be used by
   any other scope, and emit all the variable information to DBG_VALUE
   instructions.

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

(cherry picked from commit 9fd9d56dc6bdeeddf8cf2af834c6c39d00cd7244)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 7b06bc9b0c39c..268095e0943a0 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -2821,45 +2821,6 @@ void InstrRefBasedLDV::dump_mloc_transfer(
 }
 #endif
 
-void InstrRefBasedLDV::emitLocations(
-MachineFunction &MF, LiveInsT SavedLiveIns, ValueIDNum **MOutLocs,
-ValueIDNum **MInLocs, DenseMap &AllVarsNumbering,
-const TargetPassConfig &TPC) {
-  TTracker = new TransferTracker(TII, MTracker, MF, *TRI, CalleeSavedRegs, 
TPC);
-  unsigned NumLocs = MTracker->getNumLocs();
-  VTracker = nullptr;
-
-  // For each block, load in the machine value locations and variable value
-  // live-ins, then step through each instruction in the block. New DBG_VALUEs
-  // to be inserted will be created along the way.
-  for (MachineBasicBlock &MBB : MF) {
-unsigned bbnum = MBB.getNumber();
-MTracker->reset();
-MTracker->loadFromArray(MInLocs[bbnum], bbnum);
-TTracker->loadInlocs(MBB, MInLocs[bbnum], SavedLiveIns[MBB.getNumber()],
- NumLocs);
-
-CurBB = bbnum;
-CurInst = 1;
-for (auto &MI : MBB) {
-  process(MI, MOutLocs, MInLocs);
-  TTracker->checkInstForNewValues(CurInst, MI.getIterator());
-  ++CurInst;
-}
-
-// Our block information has now been converted into DBG_VALUEs, to be
-// inserted below. Free the memory we allocated to track variable / 
register
-// values. If we don't, we needlessy record the same info in memory twice.
-delete[] MInLocs[bbnum];
-delete[] MOutLocs[bbnum];
-MInLocs[bbnum] = nullptr;
-MOutLocs[bbnum] = nullptr;
-SavedLiveIns[bbnum].clear();
-  }
-
-   emitTransfers(AllVarsNumbering);
-}
-
 void InstrRefBasedLDV::initialSetup(MachineFunction &MF) {
   // Build some useful data structures.
 
@@ -2902,8 +2863,175 @@ void InstrRefBasedLDV::initialSetup(MachineFunction 
&MF) {
 #endif
 }
 
+// Produce an "ejection map" for blocks, i.e., what's the highest-numbered
+// lexical scope it's used in. When exploring in DFS order and we pass that
+// scope, the block can be processed and any tracking information freed.
+void InstrRefBasedLDV::makeDepthFirstEjectionMap(
+SmallVectorImpl &EjectionMap,
+const ScopeToDILocT &ScopeToDILocation,
+ScopeToAssignBlocksT &ScopeToAssignBlocks) {
+  SmallPtrSet BlocksToExplore;
+  SmallVector, 4> WorkStack;
+  auto *TopScope = LS.getCurrentFunctionScope();
+
+  // Unlike lexical scope explorers, we explore in reverse order, to find the
+  // "last" lexical scope used for each block early.
+  WorkStack.push_back({TopScope, TopScope->getChildren().size() - 1});
+
+  while (!WorkStack.empty()) {
+auto &ScopePosition = WorkStack.back();
+LexicalScope *WS = ScopePosition.first;
+ssize_t ChildNum = ScopePosition.second--;
+
+const SmallVectorImpl &Children = WS->getChildren();
+if (ChildNum >= 0) {
+  // If ChildNum is positive, there are remaining children to explore.
+  // Push the child and its children-count onto the stack.
+  auto &ChildScope = Children[ChildNum];
+  WorkStack.push_back(
+  std::make_pair(ChildScope, ChildScope->getChildren().size() - 1));
+} else {
+  WorkStack.pop_back();
+
+  // We've explored all children and any later blocks: examine all blocks
+  // in our scope. If they haven't yet had an ejection number set, t

[llvm-branch-commits] [llvm] 64adff8 - [DebugInfo][InstrRef] Fix a tombstone-in-DenseMap crash from D117877

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2022-02-07T13:26:39-08:00
New Revision: 64adff8ec0c14d2184a4a7cfae4bc503ed41bcea

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

LOG: [DebugInfo][InstrRef] Fix a tombstone-in-DenseMap crash from D117877

This is a follow-up to D117877: variable assignments of DBG_VALUE $noreg,
or DBG_INSTR_REFs where no value can be found, are represented by a
DbgValue object with Kind "Undef", explicitly meaning "there is no value".
In D117877 I added a special-case to some assignment accounting faster,
without considering this scenario. It causes variables to be given the
value ValueIDNum::EmptyValue, which then ends up being a DenseMap key. The
DenseMap asserts, because EmptyValue is the tombstone key.

Fix this by handling the assign-undef scenario in the special case, to
match what happens in the general case: the variable has no value if it's
only ever assigned $noreg / undef.

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

(cherry picked from commit 43de305704a50983bf134d8fb916f752a02eb076)

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/test/DebugInfo/MIR/InstrRef/single-assign-propagation.mir

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index cc800736a2dc1..3b4d717c9ab4a 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -2796,6 +2796,11 @@ void InstrRefBasedLDV::placePHIsForSingleVarDefinition(
   auto ValueIt = VLocs.Vars.find(Var);
   const DbgValue &Value = ValueIt->second;
 
+  // If it's an explicit assignment of "undef", that means there is no location
+  // anyway, anywhere.
+  if (Value.Kind == DbgValue::Undef)
+return;
+
   // Assign the variable value to entry to each dominated block that's in 
scope.
   // Skip the definition block -- it's assigned the variable value in the 
middle
   // of the block somewhere.

diff  --git a/llvm/test/DebugInfo/MIR/InstrRef/single-assign-propagation.mir 
b/llvm/test/DebugInfo/MIR/InstrRef/single-assign-propagation.mir
index 19408b2ec4291..c247004368837 100644
--- a/llvm/test/DebugInfo/MIR/InstrRef/single-assign-propagation.mir
+++ b/llvm/test/DebugInfo/MIR/InstrRef/single-assign-propagation.mir
@@ -1,9 +1,11 @@
 # RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - \
 # RUN:   -experimental-debug-variable-locations=true \
-# RUN: | FileCheck %s -implicit-check-not=DBG_VALUE
+# RUN: | FileCheck %s -implicit-check-not=DBG_VALUE \
+# RUN:--check-prefixes=CHECK,COMMON
 # RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - \
 # RUN:   -experimental-debug-variable-locations=false \
-# RUN: | FileCheck %s --check-prefixes=VARLOC -implicit-check-not=DBG_VALUE
+# RUN: | FileCheck %s -implicit-check-not=DBG_VALUE \
+# RUN:--check-prefixes=VARLOC,COMMON
 #
 # This test is designed to stimulate a simplification of variable-value
 # propagation in InstrRefBasedLDV. When we only have a single assignment of
@@ -63,12 +65,23 @@
 # VARLOC-LABEL: bb.3:
 # VARLOC:   DBG_VALUE
 #
+## Common tail for 'test2' -- this is checking that the assignment of undef or
+## $noreg in single-assignment mode doesn't lead to trouble further down the
+## line, specifically assertion failures.
+#
+# COMMON-LABEL: name: test2
+# COMMON: DBG_VALUE $noreg
 --- |
   define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
   entry:
 ret i32 0, !dbg !17
   }
 
+  define i32 @test2() local_unnamed_addr !dbg !112 {
+  entry:
+ret i32 0, !dbg !117
+  }
+
   !llvm.dbg.cu = !{!0}
   !llvm.module.flags = !{!7, !8, !9, !10}
   !llvm.ident = !{!11}
@@ -94,6 +107,13 @@
   !18 = distinct !DILexicalBlock(scope: !12, file: !1, line: 1, column: 1)
   !19 = distinct !DILexicalBlock(scope: !12, file: !1, line: 1, column: 1)
   !20 = !DILocation(line: 10, scope: !19)
+  !112 = distinct !DISubprogram(name: "test2", linkageName: "102", scope: !1, 
file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: 
DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !115)
+  !115 = !{!116}
+  !116 = !DILocalVariable(name: "myVar", scope: !118, file: !1, line: 7, type: 
!6)
+  !117 = !DILocation(line: 10, scope: !118)
+  !118 = distinct !DILexicalBlock(scope: !112, file: !1, line: 1, column: 1)
+  !119 = distinct !DILexicalBlock(scope: !112, file: !1, line: 1, column: 1)
+  !120 = !DILocation(line: 10, scope: !119)
 
 ...
 ---
@@ -136,3 +156,44 @@ body:  |
 
   bb.6:
 RET 0, debug-location !17
+...
+---
+name: test2
+debugValueSubstitutions:
+  - { srcinst: 4, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }
+body:  |
+  bb.0.entry:
+successors: %bb.1, %bb.5, 

[llvm-branch-commits] [clang-tools-extra] 52557b9 - [clang-tidy] Fix LLVM include order check policy

2022-02-07 Thread Tom Stellard via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2022-02-07T13:31:54-08:00
New Revision: 52557b918b1dbb50f5ba52644db3be87b7934d9a

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

LOG: [clang-tidy] Fix LLVM include order check policy

Clang-format LLVM style has a custom include category for gtest/ and
gmock/ headers between regular includes and angled includes. Do the same here.

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

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

(cherry picked from commit 0447ec2fb050eb37ed1f5991a1562dea6e228f9e)

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp 
b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index c962fb3bc25b2..ab75e3100d85d 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -66,11 +66,15 @@ static int getPriority(StringRef Filename, bool IsAngled, 
bool IsMainModule) {
   Filename.startswith("clang/") || Filename.startswith("clang-c/"))
 return 2;
 
-  // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/") ||
-  Filename.startswith("gmock/"))
+  // Put these between system and llvm headers to be consistent with LLVM
+  // clang-format style.
+  if (Filename.startswith("gtest/") || Filename.startswith("gmock/"))
 return 3;
 
+  // System headers are sorted to the end.
+  if (IsAngled)
+return 4;
+
   // Other headers are inserted between the main module header and LLVM 
headers.
   return 1;
 }

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
index 6dd3d6ace4581..d4da826ced386 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -6,6 +6,7 @@
 #include "gmock/foo.h"
 #include "i.h"
 #include 
+#include 
 #include "llvm/a.h"
 #include "clang/b.h"
 #include "clang-c/c.h" // hi
@@ -19,6 +20,7 @@
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
 // CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
+// CHECK-FIXES-NEXT: #include 
 // CHECK-FIXES-NEXT: #include 
 
 #include "b.h"

diff  --git a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
index 2a3fae05f585f..46a1600e2bd6d 100644
--- a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
@@ -1,4 +1,7 @@
+#include "ClangTidyOptions.h"
 #include "ClangTidyTest.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/HeaderGuardCheck.h"
 #include "llvm/IncludeOrderCheck.h"
 #include "gtest/gtest.h"
@@ -9,11 +12,15 @@ namespace clang {
 namespace tidy {
 namespace test {
 
-static std::string runHeaderGuardCheck(StringRef Code, const Twine &Filename,
-   Optional ExpectedWarning) {
+template 
+static std::string runCheck(StringRef Code, const Twine &Filename,
+Optional ExpectedWarning,
+std::map PathsToContent =
+std::map()) {
   std::vector Errors;
-  std::string Result = test::runCheckOnCode(
-  Code, &Errors, Filename, std::string("-xc++-header"));
+  std::string Result = test::runCheckOnCode(
+  Code, &Errors, Filename, std::string("-xc++-header"), ClangTidyOptions{},
+  std::move(PathsToContent));
   if (Errors.size() != (size_t)ExpectedWarning.hasValue())
 return "invalid error count";
   if (ExpectedWarning && *ExpectedWarning != Errors.back().Message.Message)
@@ -22,27 +29,36 @@ static std::string runHeaderGuardCheck(StringRef Code, 
const Twine &Filename,
   return Result;
 }
 
+static std::string runHeaderGuardCheck(StringRef Code, const Twine &Filename,
+   Optional ExpectedWarning) {
+  return runCheck(Code, Filename,
+std::move(ExpectedWarning));
+}
+
+static std::string
+runIncludeOrderCheck(StringRef Code, const Twine &Filename,
+ Optional ExpectedWarning,
+ llvm::ArrayRef Includes) {
+  std::map PathsToContent;
+  for (auto Include : Includes)
+PathsToContent.emplace(Include, "");
+  return runCheck(Code, Filename, 
std::move(ExpectedWarning),
+ PathsToContent);
+}
+
 namespace {
 struct WithEndifComment 

[llvm-branch-commits] [compiler-rt] 3a8f3b3 - [TSan] Handle FreeBSD specific indirection of libpthread functions

2022-02-07 Thread via llvm-branch-commits

Author: Dimitry Andric
Date: 2022-02-08T01:28:41+03:00
New Revision: 3a8f3b38760277fe1c32ac2d016185d7f5a96974

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

LOG: [TSan] Handle FreeBSD specific indirection of libpthread functions

Similar to 60cc1d3218fc for NetBSD, add aliases and interceptors for the
following pthread related functions:

- pthread_cond_init(3)
- pthread_cond_destroy(3)
- pthread_cond_signal(3)
- pthread_cond_broadcast(3)
- pthread_cond_wait(3)
- pthread_mutex_init(3)
- pthread_mutex_destroy(3)
- pthread_mutex_lock(3)
- pthread_mutex_trylock(3)
- pthread_mutex_unlock(3)
- pthread_rwlock_init(3)
- pthread_rwlock_destroy(3)
- pthread_rwlock_rdlock(3)
- pthread_rwlock_tryrdlock(3)
- pthread_rwlock_wrlock(3)
- pthread_rwlock_trywrlock(3)
- pthread_rwlock_unlock(3)
- pthread_once(3)
- pthread_sigmask(3)

In FreeBSD's libc, a number of internal aliases of the pthread functions
are invoked, typically with an additional prefixed underscore, e.g.
_pthread_cond_init() and so on.

ThreadSanitizer needs to intercept these aliases too, otherwise some
false positive reports about data races might be produced.

Reviewed By: dvyukov

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

(cherry picked from commit 28fb22c90fe73877c529ddae74b9fe30a3a09234)

Added: 


Modified: 
compiler-rt/lib/tsan/rtl/tsan_interceptors.h
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

Removed: 




diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.h 
b/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
index 88a54b5544216..3091ad809c40f 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
@@ -78,6 +78,14 @@ inline bool MustIgnoreInterceptor(ThreadState *thr) {
 
 #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
 
+#if SANITIZER_FREEBSD
+#  define TSAN_INTERCEPTOR_FREEBSD_ALIAS(ret, func, ...) \
+TSAN_INTERCEPTOR(ret, _pthread_##func, __VA_ARGS__)  \
+ALIAS(WRAPPER_NAME(pthread_##func));
+#else
+#  define TSAN_INTERCEPTOR_FREEBSD_ALIAS(ret, func, ...)
+#endif
+
 #if SANITIZER_NETBSD
 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...) \
   TSAN_INTERCEPTOR(ret, __libc_##func, __VA_ARGS__) \

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp 
b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 733ae5ee87ef6..999be79c6418b 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -289,20 +289,25 @@ void ScopedInterceptor::DisableIgnoresImpl() {
 }
 
 #define TSAN_INTERCEPT(func) INTERCEPT_FUNCTION(func)
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+#  define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION(func)
+#else
+#  define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION_VER(func, ver)
+#endif
 #if SANITIZER_FREEBSD
-# define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION(func)
-# define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS(func)
-# define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS_THR(func)
-#elif SANITIZER_NETBSD
-# define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION(func)
-# define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS(func) \
- INTERCEPT_FUNCTION(__libc_##func)
-# define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS_THR(func) \
- INTERCEPT_FUNCTION(__libc_thr_##func)
+#  define TSAN_MAYBE_INTERCEPT_FREEBSD_ALIAS(func) \
+INTERCEPT_FUNCTION(_pthread_##func)
 #else
-# define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION_VER(func, ver)
-# define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS(func)
-# define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS_THR(func)
+#  define TSAN_MAYBE_INTERCEPT_FREEBSD_ALIAS(func)
+#endif
+#if SANITIZER_NETBSD
+#  define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS(func) \
+INTERCEPT_FUNCTION(__libc_##func)
+#  define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS_THR(func) \
+INTERCEPT_FUNCTION(__libc_thr_##func)
+#else
+#  define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS(func)
+#  define TSAN_MAYBE_INTERCEPT_NETBSD_ALIAS_THR(func)
 #endif
 
 #define READ_STRING_OF_LEN(thr, pc, s, len, n) \
@@ -2713,6 +2718,26 @@ TSAN_INTERCEPTOR(void, thr_exit, tid_t *state) {
 #define TSAN_MAYBE_INTERCEPT_THR_EXIT
 #endif
 
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, cond_init, void *c, void *a)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, cond_destroy, void *c)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, cond_signal, void *c)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, cond_broadcast, void *c)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, cond_wait, void *c, void *m)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, mutex_init, void *m, void *a)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, mutex_destroy, void *m)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, mutex_lock, void *m)
+TSAN_INTERCEPTOR_FREEBSD_ALIAS(int, mutex_trylock, void *m)
+TSAN_INTERCEPTOR_FREEBSD_A

[llvm-branch-commits] [llvm] e6b508f - [LV] Use VScaleForTuning to allow wider epilogue VFs.

2022-02-07 Thread via llvm-branch-commits

Author: Sander de Smalen
Date: 2022-02-08T01:31:01+03:00
New Revision: e6b508f49ae951b67ed99218003f9c966e59e2ae

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

LOG: [LV] Use VScaleForTuning to allow wider epilogue VFs.

When the main loop is e.g. VF=vscale x 1 and the epilogue VF cannot
be any smaller, the vectorizer should try to estimate how many lanes are
executed at runtime and allow a suitable fixed-width VF to be chosen. It
can use VScaleForTuning to figure out what a suitable fixed-width VF could
be. For the case where the main loop VF is VF=vscale x 1, and VScaleForTuning=8,
it could still choose an epilogue VF upto VF=4.

This was a bit tricky to test, so this patch also introduces a wrapper
function to get 'VScaleForTuning' by also considering vscale_range.
If min and max are equal, then that will be the vscale we compile for.
It makes little sense to tune for a different width if the code
will not be portable for other widths.

Reviewed By: david-arm

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

(cherry picked from commit eaee477edafed691dae206cea7c0a42893eb2821)

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 3290439ecd070..21c16f07e2377 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1701,6 +1701,11 @@ class LoopVectorizationCostModel {
 private:
   unsigned NumPredStores = 0;
 
+  /// Convenience function that returns the value of vscale_range iff
+  /// vscale_range.min == vscale_range.max or otherwise returns the value
+  /// returned by the corresponding TLI method.
+  Optional getVScaleForTuning() const;
+
   /// \return An upper bound for the vectorization factors for both
   /// fixed and scalable vectorization, where the minimum-known number of
   /// elements is a power-of-2 larger than zero. If scalable vectorization is
@@ -5600,6 +5605,18 @@ ElementCount 
LoopVectorizationCostModel::getMaximizedVFForTarget(
   return MaxVF;
 }
 
+Optional LoopVectorizationCostModel::getVScaleForTuning() const {
+  if (TheFunction->hasFnAttribute(Attribute::VScaleRange)) {
+auto Attr = TheFunction->getFnAttribute(Attribute::VScaleRange);
+auto Min = Attr.getVScaleRangeMin();
+auto Max = Attr.getVScaleRangeMax();
+if (Max && Min == Max)
+  return Max;
+  }
+
+  return TTI.getVScaleForTuning();
+}
+
 bool LoopVectorizationCostModel::isMoreProfitable(
 const VectorizationFactor &A, const VectorizationFactor &B) const {
   InstructionCost CostA = A.Cost;
@@ -5624,7 +5641,7 @@ bool LoopVectorizationCostModel::isMoreProfitable(
   // Improve estimate for the vector width if it is scalable.
   unsigned EstimatedWidthA = A.Width.getKnownMinValue();
   unsigned EstimatedWidthB = B.Width.getKnownMinValue();
-  if (Optional VScale = TTI.getVScaleForTuning()) {
+  if (Optional VScale = getVScaleForTuning()) {
 if (A.Width.isScalable())
   EstimatedWidthA *= VScale.getValue();
 if (B.Width.isScalable())
@@ -5673,7 +5690,7 @@ VectorizationFactor 
LoopVectorizationCostModel::selectVectorizationFactor(
 
 #ifndef NDEBUG
 unsigned AssumedMinimumVscale = 1;
-if (Optional VScale = TTI.getVScaleForTuning())
+if (Optional VScale = getVScaleForTuning())
   AssumedMinimumVscale = VScale.getValue();
 unsigned Width =
 Candidate.Width.isScalable()
@@ -5885,8 +5902,20 @@ 
LoopVectorizationCostModel::selectEpilogueVectorizationFactor(
 return Result;
   }
 
+  // If MainLoopVF = vscale x 2, and vscale is expected to be 4, then we know
+  // the main loop handles 8 lanes per iteration. We could still benefit from
+  // vectorizing the epilogue loop with VF=4.
+  ElementCount EstimatedRuntimeVF = MainLoopVF;
+  if (MainLoopVF.isScalable()) {
+EstimatedRuntimeVF = ElementCount::getFixed(MainLoopVF.getKnownMinValue());
+if (Optional VScale = getVScaleForTuning())
+  EstimatedRuntimeVF *= VScale.getValue();
+  }
+
   for (auto &NextVF : ProfitableVFs)
-if (ElementCount::isKnownLT(NextVF.Width, MainLoopVF) &&
+if (((!NextVF.Width.isScalable() && MainLoopVF.isScalable() &&
+  ElementCount::isKnownLT(NextVF.Width, EstimatedRuntimeVF)) ||
+ ElementCount::isKnownLT(NextVF.Width, MainLoopVF)) &&
 (Result.Width.isScalar() || isMoreProfitable(NextVF, Result)) &&
 LVP.hasPlanWithVF(NextVF.Width))
   Result = NextVF;

diff  --git a/llvm/test/Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll
index e68bb7ecb456a..ab3cdebb31e50

[llvm-branch-commits] [llvm] ebe5b44 - [x86] add test coverage for AMD Ryzen fast sqrt codegen; NFC

2022-02-07 Thread via llvm-branch-commits

Author: Sanjay Patel
Date: 2022-02-08T01:31:24+03:00
New Revision: ebe5b447270cc77ca8000d50d4032bc806658086

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

LOG: [x86] add test coverage for AMD Ryzen fast sqrt codegen; NFC

(cherry picked from commit 1eb4f88bfef1ab93b8286fdfd05a8b814507e329)

Added: 


Modified: 
llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll 
b/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll
index df0a6adff100c..ab97dd6f4b33e 100644
--- a/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll
+++ b/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll
@@ -3,6 +3,8 @@
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=sandybridge | FileCheck %s 
--check-prefixes=FAST-SCALAR,SNB
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=broadwell   | FileCheck %s 
--check-prefixes=FAST-SCALAR,BDW
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=skylake | FileCheck %s 
--check-prefixes=FAST-SCALAR,SKL
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver1  | FileCheck %s 
--check-prefixes=SLOW-SCALAR,ZN1
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver3  | FileCheck %s 
--check-prefixes=SLOW-SCALAR,ZN3
 
 define float @f32_no_daz(float %f) #0 {
 ; NHM-LABEL: f32_no_daz:
@@ -24,6 +26,19 @@ define float @f32_no_daz(float %f) #0 {
 ; FAST-SCALAR:   # %bb.0:
 ; FAST-SCALAR-NEXT:vsqrtss %xmm0, %xmm0, %xmm0
 ; FAST-SCALAR-NEXT:retq
+;
+; SLOW-SCALAR-LABEL: f32_no_daz:
+; SLOW-SCALAR:   # %bb.0:
+; SLOW-SCALAR-NEXT:vrsqrtss %xmm0, %xmm0, %xmm1
+; SLOW-SCALAR-NEXT:vbroadcastss {{.*#+}} xmm3 = [NaN,NaN,NaN,NaN]
+; SLOW-SCALAR-NEXT:vmulss %xmm1, %xmm0, %xmm2
+; SLOW-SCALAR-NEXT:vfmadd213ss {{.*#+}} xmm1 = (xmm2 * xmm1) + mem
+; SLOW-SCALAR-NEXT:vmulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2
+; SLOW-SCALAR-NEXT:vandps %xmm3, %xmm0, %xmm0
+; SLOW-SCALAR-NEXT:vcmpltss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
+; SLOW-SCALAR-NEXT:vmulss %xmm1, %xmm2, %xmm1
+; SLOW-SCALAR-NEXT:vandnps %xmm1, %xmm0, %xmm0
+; SLOW-SCALAR-NEXT:retq
   %call = tail call fast float @llvm.sqrt.f32(float %f) #2
   ret float %call
 }
@@ -80,6 +95,38 @@ define <4 x float> @v4f32_no_daz(<4 x float> %f) #0 {
 ; SKL:   # %bb.0:
 ; SKL-NEXT:vsqrtps %xmm0, %xmm0
 ; SKL-NEXT:retq
+;
+; ZN1-LABEL: v4f32_no_daz:
+; ZN1:   # %bb.0:
+; ZN1-NEXT:vrsqrtps %xmm0, %xmm1
+; ZN1-NEXT:vbroadcastss {{.*#+}} xmm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
+; ZN1-NEXT:vbroadcastss {{.*#+}} xmm4 = [NaN,NaN,NaN,NaN]
+; ZN1-NEXT:vmulps %xmm1, %xmm0, %xmm2
+; ZN1-NEXT:vfmadd231ps {{.*#+}} xmm3 = (xmm2 * xmm1) + xmm3
+; ZN1-NEXT:vbroadcastss {{.*#+}} xmm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
+; ZN1-NEXT:vandps %xmm4, %xmm0, %xmm0
+; ZN1-NEXT:vmulps %xmm1, %xmm2, %xmm1
+; ZN1-NEXT:vmulps %xmm3, %xmm1, %xmm1
+; ZN1-NEXT:vbroadcastss {{.*#+}} xmm3 = 
[1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
+; ZN1-NEXT:vcmpleps %xmm0, %xmm3, %xmm0
+; ZN1-NEXT:vandps %xmm1, %xmm0, %xmm0
+; ZN1-NEXT:retq
+;
+; ZN3-LABEL: v4f32_no_daz:
+; ZN3:   # %bb.0:
+; ZN3-NEXT:vbroadcastss {{.*#+}} xmm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
+; ZN3-NEXT:vrsqrtps %xmm0, %xmm1
+; ZN3-NEXT:vbroadcastss {{.*#+}} xmm4 = [NaN,NaN,NaN,NaN]
+; ZN3-NEXT:vmulps %xmm1, %xmm0, %xmm2
+; ZN3-NEXT:vfmadd231ps {{.*#+}} xmm3 = (xmm2 * xmm1) + xmm3
+; ZN3-NEXT:vbroadcastss {{.*#+}} xmm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
+; ZN3-NEXT:vandps %xmm4, %xmm0, %xmm0
+; ZN3-NEXT:vmulps %xmm1, %xmm2, %xmm1
+; ZN3-NEXT:vmulps %xmm3, %xmm1, %xmm1
+; ZN3-NEXT:vbroadcastss {{.*#+}} xmm3 = 
[1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
+; ZN3-NEXT:vcmpleps %xmm0, %xmm3, %xmm0
+; ZN3-NEXT:vandps %xmm1, %xmm0, %xmm0
+; ZN3-NEXT:retq
   %call = tail call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %f) #2
   ret <4 x float> %call
 }
@@ -151,6 +198,38 @@ define <8 x float> @v8f32_no_daz(<8 x float> %f) #0 {
 ; SKL:   # %bb.0:
 ; SKL-NEXT:vsqrtps %ymm0, %ymm0
 ; SKL-NEXT:retq
+;
+; ZN1-LABEL: v8f32_no_daz:
+; ZN1:   # %bb.0:
+; ZN1-NEXT:vrsqrtps %ymm0, %ymm1
+; ZN1-NEXT:vbroadcastss {{.*#+}} ymm3 = 
[-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
+; ZN1-NEXT:vbroadcastss {{.*#+}} ymm4 = [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN]
+; ZN1-NEXT:vmulps %ymm1, %ymm0, %ymm2
+; ZN1-NEXT:vandps %ymm4, %ymm0, %ymm0
+; ZN1-NEXT:vfmadd231ps {{.*#+}} ymm3 = (ymm2 * ymm1) + ymm3
+; ZN1-NEXT:vbroadcastss {{.*#+}} ymm1 = 
[-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
+; ZN1-NEXT:vmulps %ymm1, %ymm2, %ymm1
+; ZN1-NEXT:vmulps %ymm3, %ymm1, %ymm1
+; ZN1-NEXT:vbroadcastss {{.*#+}} ymm3 = 
[1.17549435E-38,1.17

[llvm-branch-commits] [llvm] 0f27bf2 - [x86] enable fast sqrtss/sqrtps tuning for AMD Zen cores

2022-02-07 Thread via llvm-branch-commits

Author: Sanjay Patel
Date: 2022-02-08T01:31:24+03:00
New Revision: 0f27bf28d255e2b227865aa0f5f6d63273eacefd

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

LOG: [x86] enable fast sqrtss/sqrtps tuning for AMD Zen cores

As discussed in D118534, all of the recent AMD CPUs have
relatively fast (<14 cycle latency) "sqrtss" and "sqrtps"
instructions:
https://uops.info/table.html?search=sqrtps&cb_lat=on&cb_tp=on&cb_SNB=on&cb_SKL=on&cb_ZENp=on&cb_ZEN2=on&cb_ZEN3=on&cb_measurements=on&cb_avx=on&cb_sse=on

So we should set this tuning flag to alter codegen of plain
"sqrt(X)" expansion (as opposed to reciprocal-sqrt - there
is other test coverage for that pattern). The expansion is
both slower and less accurate than the hardware instruction.

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

(cherry picked from commit fff3e1dbaa9ee2d91dc15b39defa88346f03a4c2)

Added: 


Modified: 
llvm/lib/Target/X86/X86.td
llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 380507308c3dd..bafba2ee09c37 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -1169,6 +1169,8 @@ def ProcessorFeatures {
  TuningFastBEXTR,
  TuningFast15ByteNOP,
  TuningBranchFusion,
+ TuningFastScalarFSQRT,
+ TuningFastVectorFSQRT,
  TuningFastScalarShiftMasks,
  TuningFastMOVBE,
  TuningSlowSHLD,

diff  --git a/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll 
b/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll
index ab97dd6f4b33e..6d2fbe0364dbd 100644
--- a/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll
+++ b/llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll
@@ -2,9 +2,9 @@
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=nehalem | FileCheck %s 
--check-prefixes=NHM
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=sandybridge | FileCheck %s 
--check-prefixes=FAST-SCALAR,SNB
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=broadwell   | FileCheck %s 
--check-prefixes=FAST-SCALAR,BDW
-; RUN: llc < %s -mtriple=x86_64-- -mcpu=skylake | FileCheck %s 
--check-prefixes=FAST-SCALAR,SKL
-; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver1  | FileCheck %s 
--check-prefixes=SLOW-SCALAR,ZN1
-; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver3  | FileCheck %s 
--check-prefixes=SLOW-SCALAR,ZN3
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=skylake | FileCheck %s 
--check-prefixes=FAST-SCALAR,FAST-VECTOR
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver1  | FileCheck %s 
--check-prefixes=FAST-SCALAR,FAST-VECTOR
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver3  | FileCheck %s 
--check-prefixes=FAST-SCALAR,FAST-VECTOR
 
 define float @f32_no_daz(float %f) #0 {
 ; NHM-LABEL: f32_no_daz:
@@ -26,19 +26,6 @@ define float @f32_no_daz(float %f) #0 {
 ; FAST-SCALAR:   # %bb.0:
 ; FAST-SCALAR-NEXT:vsqrtss %xmm0, %xmm0, %xmm0
 ; FAST-SCALAR-NEXT:retq
-;
-; SLOW-SCALAR-LABEL: f32_no_daz:
-; SLOW-SCALAR:   # %bb.0:
-; SLOW-SCALAR-NEXT:vrsqrtss %xmm0, %xmm0, %xmm1
-; SLOW-SCALAR-NEXT:vbroadcastss {{.*#+}} xmm3 = [NaN,NaN,NaN,NaN]
-; SLOW-SCALAR-NEXT:vmulss %xmm1, %xmm0, %xmm2
-; SLOW-SCALAR-NEXT:vfmadd213ss {{.*#+}} xmm1 = (xmm2 * xmm1) + mem
-; SLOW-SCALAR-NEXT:vmulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2
-; SLOW-SCALAR-NEXT:vandps %xmm3, %xmm0, %xmm0
-; SLOW-SCALAR-NEXT:vcmpltss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
-; SLOW-SCALAR-NEXT:vmulss %xmm1, %xmm2, %xmm1
-; SLOW-SCALAR-NEXT:vandnps %xmm1, %xmm0, %xmm0
-; SLOW-SCALAR-NEXT:retq
   %call = tail call fast float @llvm.sqrt.f32(float %f) #2
   ret float %call
 }
@@ -91,42 +78,10 @@ define <4 x float> @v4f32_no_daz(<4 x float> %f) #0 {
 ; BDW-NEXT:vandps %xmm1, %xmm0, %xmm0
 ; BDW-NEXT:retq
 ;
-; SKL-LABEL: v4f32_no_daz:
-; SKL:   # %bb.0:
-; SKL-NEXT:vsqrtps %xmm0, %xmm0
-; SKL-NEXT:retq
-;
-; ZN1-LABEL: v4f32_no_daz:
-; ZN1:   # %bb.0:
-; ZN1-NEXT:vrsqrtps %xmm0, %xmm1
-; ZN1-NEXT:vbroadcastss {{.*#+}} xmm3 = [-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
-; ZN1-NEXT:vbroadcastss {{.*#+}} xmm4 = [NaN,NaN,NaN,NaN]
-; ZN1-NEXT:vmulps %xmm1, %xmm0, %xmm2
-; ZN1-NEXT:vfmadd231ps {{.*#+}} xmm3 = (xmm2 * xmm1) + xmm3
-; ZN1-NEXT:vbroadcastss {{.*#+}} xmm1 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
-; ZN1-NEXT:vandps %xmm4, %xmm0, %xmm0
-; ZN1-NEXT:vmulps %xmm1, %xmm2, %xmm1
-; ZN1-NEXT:vmulps %xmm3, %xmm1, %xmm1
-; ZN1-NEXT:vbroadcastss {{.*#+}} xmm3 = 
[1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
-; ZN1-NEXT:  

[llvm-branch-commits] [llvm] 2bae96d - [AArch64][SVE] Remove false register dependency for unary FP convert operations

2022-02-07 Thread via llvm-branch-commits

Author: Matt Devereau
Date: 2022-02-08T01:32:10+03:00
New Revision: 2bae96d8a3490b1e5df19f4df56842448cb5caa7

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

LOG: [AArch64][SVE] Remove false register dependency for unary FP convert 
operations

Generate movprfx for floating point convert zeroing pseudo operations

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

(cherry picked from commit 6b73a4cc7db96af1dd02db68c07fe4a807104c53)

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/CodeGen/AArch64/sve-fcvt.ll
llvm/test/CodeGen/AArch64/sve-fpext-load.ll
llvm/test/CodeGen/AArch64/sve-split-fcvt.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index 1d162610de9ca..2397a6d320a22 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1679,60 +1679,61 @@ let Predicates = [HasSVEorStreamingSVE] in {
   defm FCVTZS_ZPmZ_DtoD : sve_fp_2op_p_zd< 0b110, "fcvtzs", ZPR64, ZPR64, 
null_frag, AArch64fcvtzs_mt, nxv2i64, nxv2i1, nxv2f64, 
ElementSizeD>;
   defm FCVTZU_ZPmZ_DtoD : sve_fp_2op_p_zd< 0b111, "fcvtzu", ZPR64, ZPR64, 
null_frag, AArch64fcvtzu_mt, nxv2i64, nxv2i1, nxv2f64, 
ElementSizeD>;
 
-  def : Pat<(nxv2f32 (AArch64fcvte_mt (nxv2i1 PPR:$Pg), (nxv2f16 ZPR:$Zs), 
(nxv2f32 ZPR:$Zd))),
-(FCVT_ZPmZ_HtoS ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+  //These patterns exist to improve the code quality of conversions on 
unpacked types.
+  def : Pat<(nxv2f32 (AArch64fcvte_mt (nxv2i1 (SVEAllActive):$Pg), (nxv2f16 
ZPR:$Zs), (nxv2f32 ZPR:$Zd))),
+(FCVT_ZPmZ_HtoS_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
   // FP_ROUND has an additional 'precise' flag which indicates the type of 
rounding.
   // This is ignored by the pattern below where it is matched by (i64 timm0_1)
-  def : Pat<(nxv2f16 (AArch64fcvtr_mt (nxv2i1 PPR:$Pg), (nxv2f32 ZPR:$Zs), 
(i64 timm0_1), (nxv2f16 ZPR:$Zd))),
-(FCVT_ZPmZ_StoH ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+  def : Pat<(nxv2f16 (AArch64fcvtr_mt (nxv2i1 (SVEAllActive):$Pg), (nxv2f32 
ZPR:$Zs), (i64 timm0_1), (nxv2f16 ZPR:$Zd))),
+(FCVT_ZPmZ_StoH_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  // Floating-point -> signed integer
-  def : Pat<(nxv2f16 (AArch64scvtf_mt (nxv2i1 PPR:$Pg),
+  // Signed integer -> Floating-point 
+  def : Pat<(nxv2f16 (AArch64scvtf_mt (nxv2i1 (SVEAllActive):$Pg),
   (sext_inreg (nxv2i64 ZPR:$Zs), nxv2i16), (nxv2f16 
ZPR:$Zd))),
-(SCVTF_ZPmZ_HtoH ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+(SCVTF_ZPmZ_HtoH_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  def : Pat<(nxv4f16 (AArch64scvtf_mt (nxv4i1 PPR:$Pg),
+  def : Pat<(nxv4f16 (AArch64scvtf_mt (nxv4i1 (SVEAllActive):$Pg),
   (sext_inreg (nxv4i32 ZPR:$Zs), nxv4i16), (nxv4f16 
ZPR:$Zd))),
-(SCVTF_ZPmZ_HtoH ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+(SCVTF_ZPmZ_HtoH_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  def : Pat<(nxv2f16 (AArch64scvtf_mt (nxv2i1 PPR:$Pg),
+  def : Pat<(nxv2f16 (AArch64scvtf_mt (nxv2i1 (SVEAllActive):$Pg),
   (sext_inreg (nxv2i64 ZPR:$Zs), nxv2i32), (nxv2f16 
ZPR:$Zd))),
-(SCVTF_ZPmZ_StoH ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+(SCVTF_ZPmZ_StoH_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  def : Pat<(nxv2f32 (AArch64scvtf_mt (nxv2i1 PPR:$Pg),
+  def : Pat<(nxv2f32 (AArch64scvtf_mt (nxv2i1 (SVEAllActive):$Pg),
   (sext_inreg (nxv2i64 ZPR:$Zs), nxv2i32), (nxv2f32 
ZPR:$Zd))),
-(SCVTF_ZPmZ_StoS ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+(SCVTF_ZPmZ_StoS_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  def : Pat<(nxv2f64 (AArch64scvtf_mt (nxv2i1 PPR:$Pg),
+  def : Pat<(nxv2f64 (AArch64scvtf_mt (nxv2i1 (SVEAllActive):$Pg),
   (sext_inreg (nxv2i64 ZPR:$Zs), nxv2i32), (nxv2f64 
ZPR:$Zd))),
-(SCVTF_ZPmZ_StoD ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+(SCVTF_ZPmZ_StoD_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  // Floating-point -> unsigned integer
-  def : Pat<(nxv2f16 (AArch64ucvtf_mt (nxv2i1 PPR:$Pg),
+  // Unsigned integer -> Floating-point
+  def : Pat<(nxv2f16 (AArch64ucvtf_mt (nxv2i1 (SVEAllActive):$Pg),
   (and (nxv2i64 ZPR:$Zs),
(nxv2i64 (AArch64dup (i64 0x, (nxv2f16 
ZPR:$Zd))),
-(UCVTF_ZPmZ_HtoH ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
+(UCVTF_ZPmZ_HtoH_UNDEF ZPR:$Zd, PPR:$Pg, ZPR:$Zs)>;
 
-  def : Pat<(nxv2f16 (AArch64ucvtf_mt (nxv2i1 PPR:$Pg),
+  def : Pat<(nxv2f16 (AArch64ucvtf_mt (nxv2i1 (SVEAllActive):$Pg),
   (and (nxv2i64 ZPR:$Zs),
(nxv2i64 (

[llvm-branch-commits] [lld] 319f4b2 - [lld][clang][cmake] Clean up a few things

2022-02-07 Thread via llvm-branch-commits

Author: John Ericson
Date: 2022-02-08T01:29:25+03:00
New Revision: 319f4b2d52e31b000db75a0a2484b5f2ab90534a

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

LOG: [lld][clang][cmake] Clean up a few things

- If not using `llvm-config`, `LLVM_MAIN_SRC_DIR` now has a sane default

- `LLVM_CONFIG_PATH` will continue to work for LLD for back compat.

- More quoting of paths in an abundance of caution.

Reviewed By: nikic

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

(cherry picked from commit e0eeae9a447004cc346d9bf36c0d02f45e276a7c)

Added: 


Modified: 
clang/CMakeLists.txt
lld/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2bb395ffece53..1cc9bacf4e5eb 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -71,24 +71,26 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
-set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
-  endif()
-
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
+set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
+  endif()
+
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
+  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 1a53c5bf47a8d..9bcc135665d02 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -15,6 +15,10 @@ if(LLD_BUILT_STANDALONE)
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@ if(LLD_BUILT_STANDALONE)
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
   endif()
 
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] 524758d - [lldb][CMake] Fix linking of gdb-remote when LLVM_ENABLE_ZLIB is ON

2022-02-07 Thread Fangrui Song via llvm-branch-commits

Author: Mariusz Ceier
Date: 2022-02-07T23:26:57-08:00
New Revision: 524758d1a75e21a9133b597ea649237d75a46abb

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

LOG: [lldb][CMake] Fix linking of gdb-remote when LLVM_ENABLE_ZLIB is ON

When LLVM_ENABLE_ZLIB is ON gdb-remote should link against ZLIB::ZLIB.

This fixes
```
/mnt/b/yoe/master/build/tmp/hosttools/ld: 
lib/liblldbPluginProcessGDBRemote.a(GDBRemoteCommunication.cpp.o): in function 
`lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket() 
[clone .localalias]':
GDBRemoteCommunication.cpp:(.text._ZN12lldb_private18process_gdb_remote22GDBRemoteCommunication16DecompressPacketEv+0x59a):
 undefined reference to `inflateInit2_'
/mnt/b/yoe/master/build/tmp/hosttools/ld: 
GDBRemoteCommunication.cpp:(.text._ZN12lldb_private18process_gdb_remote22GDBRemoteCommunication16DecompressPacketEv+0x5af):
 undefined reference to `inflate'
```

Reviewed By: JDevlieghere, MaskRay

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

(cherry picked from commit 385f5c4d33799df25a85ceb54b6232499cb8a78d)

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt 
b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
index 3a1a0e435ad25..e0c798187bd5b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -15,6 +15,10 @@ if(HAVE_LIBCOMPRESSION)
   set(LIBCOMPRESSION compression)
 endif()
 
+if(LLVM_ENABLE_ZLIB)
+  list(APPEND LLDB_SYSTEM_LIBS ZLIB::ZLIB)
+endif()
+
 add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
   GDBRemoteClientBase.cpp
   GDBRemoteCommunication.cpp
@@ -39,6 +43,7 @@ add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
 lldbSymbol
 lldbTarget
 lldbUtility
+${LLDB_SYSTEM_LIBS}
 ${LLDB_PLUGINS}
 ${LIBCOMPRESSION}
   LINK_COMPONENTS



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits