[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80543 (PR #80544)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:

@cjacek What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/80544
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80543 (PR #80544)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80544
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80543 (PR #80544)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80544

resolves llvm/llvm-project#80543

>From 08044778c48c6ed29b6ac6ad6b377b71c73a505a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Sat, 3 Feb 2024 14:52:49 +0100
Subject: [PATCH] [compiler-rt] Remove duplicate MS names for chkstk symbols
 (#80450)

Prior to 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2, the builtins library
contained two chkstk implementations for each of i386 and x86_64, one
that was used in mingw environments, and one unused (with a symbol name
not matching anything that is used anywhere). Some of the functions
additionally had other, also unused, aliases.

After cleaning this up in 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2, the
unused symbol names were removed.

At the same time, symbol aliases were added for the names as they are
used by MSVC; the functions are functionally equivalent, but have
different names between mingw and MSVC style environments.

By adding a symbol alias (so that one object file contains two different
symbols for the same function), users can run into problems with
duplicate definitions, if they themselves define one of the symbols (for
various reasons), but need to link in the other one.

This happens for Wine, which provides their own definition of
"__chkstk", but when built in mingw mode does need compiler-rt to
provide the mingw specific symbol names; see
https://github.com/mstorsjo/llvm-mingw/issues/397.

To avoid the issue, remove the extra MS style names. They weren't
entirely usable as such for MSVC style environments anyway, as
compiler-rt builtins don't build these object files at all, when built
in MSVC mode; thus, the effort to provide them for MSVC style
environments in 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2 was a
half-hearted step towards that.

If we really do want to provide those functions (as an alternative to
the ones provided by MSVC itself), we should do it in a separate object
file (even if the function implementation is the same), so that users
who have a definition of one of them but need a definition of the other,
won't have conflicts.

Additionally, if we do want to provide them for MSVC, those files
actually should be built when building the builtins in MSVC mode as well
(see compiler-rt/lib/builtins/CMakeLists.txt).

If we do that, there's a risk that an MSVC style build ends up linking
in and preferring our implementation over the one provided by MSVC,
which would be suboptimal. Our implementation always probes the
requested amount of stack, while the MSVC one checks the amount of
allocated stack and only probes as much as really is needed.

In short - this reverts the situation to what it was in the 17.x release
series (except for unused functions that have been removed).

(cherry picked from commit 248aeac1ad2cf4f583490dd1312a5b448d2bb8cc)
---
 compiler-rt/lib/builtins/i386/chkstk.S   | 2 --
 compiler-rt/lib/builtins/x86_64/chkstk.S | 2 --
 2 files changed, 4 deletions(-)

diff --git a/compiler-rt/lib/builtins/i386/chkstk.S 
b/compiler-rt/lib/builtins/i386/chkstk.S
index a84bb0ee30070..cdd9a4c2a5752 100644
--- a/compiler-rt/lib/builtins/i386/chkstk.S
+++ b/compiler-rt/lib/builtins/i386/chkstk.S
@@ -14,7 +14,6 @@
 .text
 .balign 4
 DEFINE_COMPILERRT_FUNCTION(_alloca) // _chkstk and _alloca are the same 
function
-DEFINE_COMPILERRT_FUNCTION(_chkstk)
 push   %ecx
 cmp$0x1000,%eax
 lea8(%esp),%ecx // esp before calling this routine -> ecx
@@ -35,7 +34,6 @@ DEFINE_COMPILERRT_FUNCTION(_chkstk)
 push   (%eax)   // push return address onto the stack
 sub%esp,%eax// restore the original value in eax
 ret
-END_COMPILERRT_FUNCTION(_chkstk)
 END_COMPILERRT_FUNCTION(_alloca)
 
 #endif // __i386__
diff --git a/compiler-rt/lib/builtins/x86_64/chkstk.S 
b/compiler-rt/lib/builtins/x86_64/chkstk.S
index 494ee261193bc..ad7953a116ac7 100644
--- a/compiler-rt/lib/builtins/x86_64/chkstk.S
+++ b/compiler-rt/lib/builtins/x86_64/chkstk.S
@@ -18,7 +18,6 @@
 .text
 .balign 4
 DEFINE_COMPILERRT_FUNCTION(___chkstk_ms)
-DEFINE_COMPILERRT_FUNCTION(__chkstk)
 push   %rcx
 push   %rax
 cmp$0x1000,%rax
@@ -36,7 +35,6 @@ DEFINE_COMPILERRT_FUNCTION(__chkstk)
 pop%rax
 pop%rcx
 ret
-END_COMPILERRT_FUNCTION(__chkstk)
 END_COMPILERRT_FUNCTION(___chkstk_ms)
 
 #endif // __x86_64__

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


[llvm-branch-commits] [libcxx] 5f40ce9 - [libc++][modules] Support using the module std with -fno-char8_t. (#79155)

2024-02-03 Thread via llvm-branch-commits

Author: Po-yao Chang
Date: 2024-02-02T19:53:27Z
New Revision: 5f40ce9e310808c6326371475c0e2f840c946de1

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

LOG: [libc++][modules] Support using the module std with -fno-char8_t. (#79155)

Exclude some using-declarations in the module purview when compiling
with `-fno-char8_t`.

(cherry picked from commit dc4483659fc51890fdc732acc66a4dcda6e68047)

Added: 


Modified: 
libcxx/modules/std/atomic.inc
libcxx/modules/std/iosfwd.inc
libcxx/modules/std/string.inc
libcxx/modules/std/string_view.inc

Removed: 




diff  --git a/libcxx/modules/std/atomic.inc b/libcxx/modules/std/atomic.inc
index 5139b7531093d..88b31ccdb2084 100644
--- a/libcxx/modules/std/atomic.inc
+++ b/libcxx/modules/std/atomic.inc
@@ -60,7 +60,9 @@ export namespace std {
   using std::atomic_char;
   using std::atomic_char16_t;
   using std::atomic_char32_t;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
   using std::atomic_char8_t;
+#endif
   using std::atomic_int;
   using std::atomic_llong;
   using std::atomic_long;

diff  --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc
index ec8b434ca0c51..410fb6aefed80 100644
--- a/libcxx/modules/std/iosfwd.inc
+++ b/libcxx/modules/std/iosfwd.inc
@@ -14,7 +14,9 @@ export namespace std {
 #endif
   using std::u16streampos;
   using std::u32streampos;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
   using std::u8streampos;
+#endif
 
   using std::basic_osyncstream;
   using std::basic_syncbuf;

diff  --git a/libcxx/modules/std/string.inc b/libcxx/modules/std/string.inc
index c83ee7643f87e..9808a96215a18 100644
--- a/libcxx/modules/std/string.inc
+++ b/libcxx/modules/std/string.inc
@@ -34,7 +34,9 @@ export namespace std {
   using std::string;
   using std::u16string;
   using std::u32string;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
   using std::u8string;
+#endif
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
   using std::wstring;
 #endif
@@ -58,7 +60,9 @@ export namespace std {
 using std::pmr::string;
 using std::pmr::u16string;
 using std::pmr::u32string;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
 using std::pmr::u8string;
+#endif
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
 using std::pmr::wstring;
 #endif

diff  --git a/libcxx/modules/std/string_view.inc 
b/libcxx/modules/std/string_view.inc
index 1fa63a7739535..f4f9d80ddb83d 100644
--- a/libcxx/modules/std/string_view.inc
+++ b/libcxx/modules/std/string_view.inc
@@ -27,7 +27,9 @@ export namespace std {
   using std::string_view;
   using std::u16string_view;
   using std::u32string_view;
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
   using std::u8string_view;
+#endif
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
   using std::wstring_view;
 #endif



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


[llvm-branch-commits] [libcxx] PR for llvm/llvm-project#79155 (PR #80484)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80484
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80441 (PR #80444)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80444

>From d9f8cd8028db85204724f4efc1eec9b567dac05c Mon Sep 17 00:00:00 2001
From: Sander de Smalen 
Date: Fri, 2 Feb 2024 09:29:47 +
Subject: [PATCH] [Clang][AArch64] Add missing SME macros (#80293)

__ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse
the "za" and "zt0" strings in the SME attributes.

__ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler can
generate code for attributes with "za" and "zt0" state, respectively.

__ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports the
__arm_locally_streaming attribute.

(cherry picked from commit 9e649518e6038a5b9ea38cfa424468657d3be59e)
---
 clang/lib/Basic/Targets/AArch64.cpp   | 23 +++
 clang/lib/Basic/Targets/AArch64.h |  1 +
 .../Preprocessor/aarch64-target-features.c| 13 +++
 clang/test/Preprocessor/init-aarch64.c|  2 ++
 4 files changed, 39 insertions(+)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index d47181bfca4fc..336b7a5e3d727 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -387,6 +387,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
 
+  // These macros are set when Clang can parse declarations with these
+  // attributes.
+  Builder.defineMacro("__ARM_STATE_ZA", "1");
+  Builder.defineMacro("__ARM_STATE_ZT0", "1");
+
   // 0xe implies support for half, single and double precision operations.
   if (FPU & FPUMode)
 Builder.defineMacro("__ARM_FP", "0xE");
@@ -431,6 +436,17 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSME) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
+  if (HasSME2) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_SME2");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -686,6 +702,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
+  .Case("sme2", HasSME2)
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
@@ -806,6 +823,12 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
   HasFullFP16 = true;
 }
+if (Feature == "+sme2") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+}
 if (Feature == "+sme-f64f64") {
   HasSME = true;
   HasSMEF64F64 = true;
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index f0e0782e7abe9..9699222b0bf77 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
+  bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
   bool HasSB = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 15879da04fcf0..9914775097e57 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -60,6 +60,10 @@
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
+// CHECK: __ARM_STATE_ZA 1
+// CHECK: __ARM_STATE_ZT0 1
+// CHECK-NOT: __ARM_FEATURE_SME
+// CHECK-NOT: __ARM_FEATURE_SME2
 
 // RUN: %clang -target aarch64-none-elf -march=armv8-r -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-R-PROFILE
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-R-PROFILE
@@ -634,3 +638,12 @@
 
 // RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-RCPC3 %s
 // CHECK-RCPC3: __ARM_FEATURE_RCPC 3
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sme -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME %s
+// CHECK-SME: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME: __ARM_FEATURE_SME 1
+//
+// RUN: %clang --target=aarch64 -march=armv9-a+sme2 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME2 %s
+// CHECK-SME2: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME2: __ARM_FEATURE_SME 1
+// CHECK-SME2: __ARM_FEATURE_SME2 1
diff --git a/clang/test/Preprocessor/init-aarch64.c 
b/clang/test/Preprocessor/init-a

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80441 (PR #80444)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80444
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] d9f8cd8 - [Clang][AArch64] Add missing SME macros (#80293)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

Author: Sander de Smalen
Date: 2024-02-03T10:17:11-08:00
New Revision: d9f8cd8028db85204724f4efc1eec9b567dac05c

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

LOG: [Clang][AArch64] Add missing SME macros (#80293)

__ARM_STATE_ZA and __ARM_STATE_ZT0 are set when the compiler can parse
the "za" and "zt0" strings in the SME attributes.

__ARM_FEATURE_SME and __ARM_FEATURE_SME2 are set when the compiler can
generate code for attributes with "za" and "zt0" state, respectively.

__ARM_FEATURE_LOCALLY_STREAMING is set when the compiler supports the
__arm_locally_streaming attribute.

(cherry picked from commit 9e649518e6038a5b9ea38cfa424468657d3be59e)

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/test/Preprocessor/aarch64-target-features.c
clang/test/Preprocessor/init-aarch64.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index d47181bfca4fc..336b7a5e3d727 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -387,6 +387,11 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
 
+  // These macros are set when Clang can parse declarations with these
+  // attributes.
+  Builder.defineMacro("__ARM_STATE_ZA", "1");
+  Builder.defineMacro("__ARM_STATE_ZT0", "1");
+
   // 0xe implies support for half, single and double precision operations.
   if (FPU & FPUMode)
 Builder.defineMacro("__ARM_FP", "0xE");
@@ -431,6 +436,17 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSME) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
+  if (HasSME2) {
+Builder.defineMacro("__ARM_FEATURE_SME");
+Builder.defineMacro("__ARM_FEATURE_SME2");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -686,6 +702,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
+  .Case("sme2", HasSME2)
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
@@ -806,6 +823,12 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
   HasFullFP16 = true;
 }
+if (Feature == "+sme2") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+}
 if (Feature == "+sme-f64f64") {
   HasSME = true;
   HasSMEF64F64 = true;

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index f0e0782e7abe9..9699222b0bf77 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
+  bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
   bool HasSB = false;

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 15879da04fcf0..9914775097e57 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -60,6 +60,10 @@
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
 // CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
+// CHECK: __ARM_STATE_ZA 1
+// CHECK: __ARM_STATE_ZT0 1
+// CHECK-NOT: __ARM_FEATURE_SME
+// CHECK-NOT: __ARM_FEATURE_SME2
 
 // RUN: %clang -target aarch64-none-elf -march=armv8-r -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-R-PROFILE
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-r -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-R-PROFILE
@@ -634,3 +638,12 @@
 
 // RUN: %clang --target=aarch64 -march=armv8.2-a+rcpc3 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-RCPC3 %s
 // CHECK-RCPC3: __ARM_FEATURE_RCPC 3
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sme -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME %s
+// CHECK-SME: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME: __ARM_FEATURE_SME 1
+//
+// RUN: %clang --target=aarch64 -march=armv9-a+sme2 -x c -E -dM %s -o - | 
FileCheck --check-prefix=CHECK-SME2 %s
+// CHECK-SME2: __ARM_FEATURE_LOCALLY_STREAMING 1
+// CHECK-SME2: __ARM_FEATURE_SME 1
+// CHECK-SME2: __ARM_FEATURE_

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79137 (PR #79561)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/79561

>From b7dd1e099f2c3335ba2636cd1d4cfcc4db7a243d Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 24 Jan 2024 10:45:20 +0100
Subject: [PATCH 1/2] [PhaseOrdering] Add additional test for #79161 (NFC)

(cherry picked from commit 543cf08636f3a3bb55dddba2e8cad787601647ba)
---
 .../X86/loop-vectorizer-noalias.ll| 147 ++
 1 file changed, 147 insertions(+)
 create mode 100644 
llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll

diff --git a/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll 
b/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll
new file mode 100644
index 0..846787f721ba7
--- /dev/null
+++ b/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll
@@ -0,0 +1,147 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -S -O3 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+define internal void @acc(ptr noalias noundef %val, ptr noalias noundef %prev) 
{
+entry:
+  %0 = load i8, ptr %prev, align 1
+  %conv = zext i8 %0 to i32
+  %1 = load i8, ptr %val, align 1
+  %conv1 = zext i8 %1 to i32
+  %add = add nsw i32 %conv1, %conv
+  %conv2 = trunc i32 %add to i8
+  store i8 %conv2, ptr %val, align 1
+  ret void
+}
+
+; This loop should not get vectorized.
+; FIXME: This is a miscompile.
+define void @accsum(ptr noundef %vals, i64 noundef %num) #0 {
+; CHECK-LABEL: define void @accsum(
+; CHECK-SAME: ptr nocapture noundef [[VALS:%.*]], i64 noundef [[NUM:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP1:%.*]] = icmp ugt i64 [[NUM]], 1
+; CHECK-NEXT:br i1 [[CMP1]], label [[ITER_CHECK:%.*]], label 
[[FOR_END:%.*]]
+; CHECK:   iter.check:
+; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[NUM]], -1
+; CHECK-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[NUM]], 9
+; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY_PREHEADER:%.*]], 
label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
+; CHECK:   vector.main.loop.iter.check:
+; CHECK-NEXT:[[MIN_ITERS_CHECK3:%.*]] = icmp ult i64 [[NUM]], 33
+; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK3]], label [[VEC_EPILOG_PH:%.*]], 
label [[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:[[N_VEC:%.*]] = and i64 [[TMP0]], -32
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[OFFSET_IDX:%.*]] = or disjoint i64 [[INDEX]], 1
+; CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds i8, ptr [[VALS]], i64 
[[OFFSET_IDX]]
+; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i8, ptr [[TMP1]], i64 -1
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl(metadata 
[[META0:![0-9]+]])
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl(metadata 
[[META3:![0-9]+]])
+; CHECK-NEXT:[[TMP3:%.*]] = getelementptr i8, ptr [[TMP1]], i64 15
+; CHECK-NEXT:[[WIDE_LOAD:%.*]] = load <16 x i8>, ptr [[TMP2]], align 1, 
!alias.scope [[META3]], !noalias [[META0]]
+; CHECK-NEXT:[[WIDE_LOAD4:%.*]] = load <16 x i8>, ptr [[TMP3]], align 1, 
!alias.scope [[META3]], !noalias [[META0]]
+; CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 16
+; CHECK-NEXT:[[WIDE_LOAD5:%.*]] = load <16 x i8>, ptr [[TMP1]], align 1, 
!alias.scope [[META0]], !noalias [[META3]]
+; CHECK-NEXT:[[WIDE_LOAD6:%.*]] = load <16 x i8>, ptr [[TMP4]], align 1, 
!alias.scope [[META0]], !noalias [[META3]]
+; CHECK-NEXT:[[TMP5:%.*]] = add <16 x i8> [[WIDE_LOAD5]], [[WIDE_LOAD]]
+; CHECK-NEXT:[[TMP6:%.*]] = add <16 x i8> [[WIDE_LOAD6]], [[WIDE_LOAD4]]
+; CHECK-NEXT:store <16 x i8> [[TMP5]], ptr [[TMP1]], align 1, !alias.scope 
[[META0]], !noalias [[META3]]
+; CHECK-NEXT:store <16 x i8> [[TMP6]], ptr [[TMP4]], align 1, !alias.scope 
[[META0]], !noalias [[META3]]
+; CHECK-NEXT:[[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32
+; CHECK-NEXT:[[TMP7:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[TMP7]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
+; CHECK:   middle.block:
+; CHECK-NEXT:[[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[CMP_N]], label [[FOR_END]], label 
[[VEC_EPILOG_ITER_CHECK:%.*]]
+; CHECK:   vec.epilog.iter.check:
+; CHECK-NEXT:[[IND_END9:%.*]] = or disjoint i64 [[N_VEC]], 1
+; CHECK-NEXT:[[N_VEC_REMAINING:%.*]] = and i64 [[TMP0]], 24
+; CHECK-NEXT:[[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp eq i64 
[[N_VEC_REMAINING]], 0
+; CHECK-NEXT:br i1 [[MIN_EPILOG_ITERS_CHECK]], label 
[[FOR_BODY_PREHEADER]], label [[VEC_EPILOG_PH]]
+; CHECK:   vec.epilog.ph:
+; CHECK-NEXT:[[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], 
[[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHE

[llvm-branch-commits] [llvm] b7dd1e0 - [PhaseOrdering] Add additional test for #79161 (NFC)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2024-02-03T10:22:03-08:00
New Revision: b7dd1e099f2c3335ba2636cd1d4cfcc4db7a243d

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

LOG: [PhaseOrdering] Add additional test for #79161 (NFC)

(cherry picked from commit 543cf08636f3a3bb55dddba2e8cad787601647ba)

Added: 
llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll 
b/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll
new file mode 100644
index 0..846787f721ba7
--- /dev/null
+++ b/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll
@@ -0,0 +1,147 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -S -O3 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+define internal void @acc(ptr noalias noundef %val, ptr noalias noundef %prev) 
{
+entry:
+  %0 = load i8, ptr %prev, align 1
+  %conv = zext i8 %0 to i32
+  %1 = load i8, ptr %val, align 1
+  %conv1 = zext i8 %1 to i32
+  %add = add nsw i32 %conv1, %conv
+  %conv2 = trunc i32 %add to i8
+  store i8 %conv2, ptr %val, align 1
+  ret void
+}
+
+; This loop should not get vectorized.
+; FIXME: This is a miscompile.
+define void @accsum(ptr noundef %vals, i64 noundef %num) #0 {
+; CHECK-LABEL: define void @accsum(
+; CHECK-SAME: ptr nocapture noundef [[VALS:%.*]], i64 noundef [[NUM:%.*]]) 
local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP1:%.*]] = icmp ugt i64 [[NUM]], 1
+; CHECK-NEXT:br i1 [[CMP1]], label [[ITER_CHECK:%.*]], label 
[[FOR_END:%.*]]
+; CHECK:   iter.check:
+; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[NUM]], -1
+; CHECK-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[NUM]], 9
+; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK]], label [[FOR_BODY_PREHEADER:%.*]], 
label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
+; CHECK:   vector.main.loop.iter.check:
+; CHECK-NEXT:[[MIN_ITERS_CHECK3:%.*]] = icmp ult i64 [[NUM]], 33
+; CHECK-NEXT:br i1 [[MIN_ITERS_CHECK3]], label [[VEC_EPILOG_PH:%.*]], 
label [[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:[[N_VEC:%.*]] = and i64 [[TMP0]], -32
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[OFFSET_IDX:%.*]] = or disjoint i64 [[INDEX]], 1
+; CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds i8, ptr [[VALS]], i64 
[[OFFSET_IDX]]
+; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i8, ptr [[TMP1]], i64 -1
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl(metadata 
[[META0:![0-9]+]])
+; CHECK-NEXT:tail call void @llvm.experimental.noalias.scope.decl(metadata 
[[META3:![0-9]+]])
+; CHECK-NEXT:[[TMP3:%.*]] = getelementptr i8, ptr [[TMP1]], i64 15
+; CHECK-NEXT:[[WIDE_LOAD:%.*]] = load <16 x i8>, ptr [[TMP2]], align 1, 
!alias.scope [[META3]], !noalias [[META0]]
+; CHECK-NEXT:[[WIDE_LOAD4:%.*]] = load <16 x i8>, ptr [[TMP3]], align 1, 
!alias.scope [[META3]], !noalias [[META0]]
+; CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i64 16
+; CHECK-NEXT:[[WIDE_LOAD5:%.*]] = load <16 x i8>, ptr [[TMP1]], align 1, 
!alias.scope [[META0]], !noalias [[META3]]
+; CHECK-NEXT:[[WIDE_LOAD6:%.*]] = load <16 x i8>, ptr [[TMP4]], align 1, 
!alias.scope [[META0]], !noalias [[META3]]
+; CHECK-NEXT:[[TMP5:%.*]] = add <16 x i8> [[WIDE_LOAD5]], [[WIDE_LOAD]]
+; CHECK-NEXT:[[TMP6:%.*]] = add <16 x i8> [[WIDE_LOAD6]], [[WIDE_LOAD4]]
+; CHECK-NEXT:store <16 x i8> [[TMP5]], ptr [[TMP1]], align 1, !alias.scope 
[[META0]], !noalias [[META3]]
+; CHECK-NEXT:store <16 x i8> [[TMP6]], ptr [[TMP4]], align 1, !alias.scope 
[[META0]], !noalias [[META3]]
+; CHECK-NEXT:[[INDEX_NEXT]] = add nuw i64 [[INDEX]], 32
+; CHECK-NEXT:[[TMP7:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[TMP7]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
+; CHECK:   middle.block:
+; CHECK-NEXT:[[CMP_N:%.*]] = icmp eq i64 [[TMP0]], [[N_VEC]]
+; CHECK-NEXT:br i1 [[CMP_N]], label [[FOR_END]], label 
[[VEC_EPILOG_ITER_CHECK:%.*]]
+; CHECK:   vec.epilog.iter.check:
+; CHECK-NEXT:[[IND_END9:%.*]] = or disjoint i64 [[N_VEC]], 1
+; CHECK-NEXT:[[N_VEC_REMAINING:%.*]] = and i64 [[TMP0]], 24
+; CHECK-NEXT:[[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp eq i64 
[[N_VEC_REMAINING]], 0
+; CHECK-NEXT:br i1 [[MIN_EPILOG_ITERS_CHECK]], label 
[[FOR_BODY_PREHEADER]], label [[VEC_EPILOG_PH]]
+; CHECK:   vec.epilog.ph:
+; CHECK-NEXT:[[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]]

[llvm-branch-commits] [llvm] 42b7061 - [LAA] Drop alias scope metadata that is not valid across iterations (#79161)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

Author: Nikita Popov
Date: 2024-02-03T10:22:03-08:00
New Revision: 42b7061f1f0a2c52c8302a25ec656f990236b933

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

LOG: [LAA] Drop alias scope metadata that is not valid across iterations 
(#79161)

LAA currently adds memory locations with their original AATags to AST.
However, scoped alias AATags may be valid only within one loop
iteration, while LAA reasons across iterations.

Fix this by determining which alias scopes are defined inside the loop,
and drop AATags that reference these scopes.

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

(cherry picked from commit cd7ea4ea657ea41b42fcbd0e6b33faa46608d18e)

Added: 


Modified: 
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/test/Analysis/LoopAccessAnalysis/noalias-scope-decl.ll
llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll

Removed: 




diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 7e67c90152829..dd6b88fee415a 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -657,16 +657,18 @@ class AccessAnalysis {
 
   AccessAnalysis(Loop *TheLoop, AAResults *AA, LoopInfo *LI,
  MemoryDepChecker::DepCandidates &DA,
- PredicatedScalarEvolution &PSE)
-  : TheLoop(TheLoop), BAA(*AA), AST(BAA), LI(LI), DepCands(DA), PSE(PSE) {
+ PredicatedScalarEvolution &PSE,
+ SmallPtrSetImpl &LoopAliasScopes)
+  : TheLoop(TheLoop), BAA(*AA), AST(BAA), LI(LI), DepCands(DA), PSE(PSE),
+LoopAliasScopes(LoopAliasScopes) {
 // We're analyzing dependences across loop iterations.
 BAA.enableCrossIterationMode();
   }
 
   /// Register a load  and whether it is only read from.
   void addLoad(MemoryLocation &Loc, Type *AccessTy, bool IsReadOnly) {
-Value *Ptr = const_cast(Loc.Ptr);
-AST.add(Loc.getWithNewSize(LocationSize::beforeOrAfterPointer()));
+Value *Ptr = const_cast(Loc.Ptr);
+AST.add(adjustLoc(Loc));
 Accesses[MemAccessInfo(Ptr, false)].insert(AccessTy);
 if (IsReadOnly)
   ReadOnlyPtr.insert(Ptr);
@@ -674,8 +676,8 @@ class AccessAnalysis {
 
   /// Register a store.
   void addStore(MemoryLocation &Loc, Type *AccessTy) {
-Value *Ptr = const_cast(Loc.Ptr);
-AST.add(Loc.getWithNewSize(LocationSize::beforeOrAfterPointer()));
+Value *Ptr = const_cast(Loc.Ptr);
+AST.add(adjustLoc(Loc));
 Accesses[MemAccessInfo(Ptr, true)].insert(AccessTy);
   }
 
@@ -731,6 +733,32 @@ class AccessAnalysis {
 private:
   typedef MapVector> PtrAccessMap;
 
+  /// Adjust the MemoryLocation so that it represents accesses to this
+  /// location across all iterations, rather than a single one.
+  MemoryLocation adjustLoc(MemoryLocation Loc) const {
+// The accessed location varies within the loop, but remains within the
+// underlying object.
+Loc.Size = LocationSize::beforeOrAfterPointer();
+Loc.AATags.Scope = adjustAliasScopeList(Loc.AATags.Scope);
+Loc.AATags.NoAlias = adjustAliasScopeList(Loc.AATags.NoAlias);
+return Loc;
+  }
+
+  /// Drop alias scopes that are only valid within a single loop iteration.
+  MDNode *adjustAliasScopeList(MDNode *ScopeList) const {
+if (!ScopeList)
+  return nullptr;
+
+// For the sake of simplicity, drop the whole scope list if any scope is
+// iteration-local.
+if (any_of(ScopeList->operands(), [&](Metadata *Scope) {
+  return LoopAliasScopes.contains(cast(Scope));
+}))
+  return nullptr;
+
+return ScopeList;
+  }
+
   /// Go over all memory access and check whether runtime pointer checks
   /// are needed and build sets of dependency check candidates.
   void processMemAccesses();
@@ -775,6 +803,10 @@ class AccessAnalysis {
   PredicatedScalarEvolution &PSE;
 
   DenseMap> UnderlyingObjects;
+
+  /// Alias scopes that are declared inside the loop, and as such not valid
+  /// across iterations.
+  SmallPtrSetImpl &LoopAliasScopes;
 };
 
 } // end anonymous namespace
@@ -2283,6 +2315,7 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo 
*LI,
   // Holds the Load and Store instructions.
   SmallVector Loads;
   SmallVector Stores;
+  SmallPtrSet LoopAliasScopes;
 
   // Holds all the 
diff erent accesses in the loop.
   unsigned NumReads = 0;
@@ -2326,6 +2359,11 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo 
*LI,
   if (HasComplexMemInst)
 continue;
 
+  // Record alias scopes defined inside the loop.
+  if (auto *Decl = dyn_cast(&I))
+for (Metadata *Op : Decl->getScopeList()->operands())
+  LoopAliasScopes.insert(cast(Op));
+
   // Many math library functions read the rounding mode. We will onl

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79137 (PR #79561)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79561
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [libcxx] [clang] [openmp] [lld] [clang-tools-extra] Backport '[clang] static operators should evaluate object argument (reland)' to release/18.x (PR #80109)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80109
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80391

>From 278f80ce95401f7920845d1281aa99804a139b6c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 1 Feb 2024 21:20:27 -0800
Subject: [PATCH] [ELF] Fix compareSections assertion failure when OutputDescs
 in sectionCommands are non-contiguous

In a `--defsym y0=0 -T a.lds` link where a.lds contains only INSERT
commands, the `script->sectionCommands` layout may be:
```
orphan sections
SymbolAssignment due to --defsym
sections created by INSERT commands
```

The `OutputDesc` objects are not contiguous in sortInputSections, and
`compareSections` will be called with a SymbolAssignment argument,
leading to an assertion failure.

(cherry picked from commit dee8786f70a3d62b639113343fa36ef55bdbad63)
---
 lld/ELF/Writer.cpp   | 12 ++--
 lld/test/ELF/linkerscript/insert-before.test | 11 ---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f66f3615fa4a..501c10f358497 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1518,12 +1518,12 @@ template  void Writer::sortSections() 
{
 if (auto *osd = dyn_cast(cmd))
   osd->osec.sortRank = getSectionRank(osd->osec);
   if (!script->hasSectionsCommand) {
-// We know that all the OutputSections are contiguous in this case.
-auto isSection = [](SectionCommand *cmd) { return isa(cmd); };
-std::stable_sort(
-llvm::find_if(script->sectionCommands, isSection),
-llvm::find_if(llvm::reverse(script->sectionCommands), 
isSection).base(),
-compareSections);
+// OutputDescs are mostly contiguous, but may be interleaved with
+// SymbolAssignments in the presence of INSERT commands.
+auto mid = std::stable_partition(
+script->sectionCommands.begin(), script->sectionCommands.end(),
+[](SectionCommand *cmd) { return isa(cmd); });
+std::stable_sort(script->sectionCommands.begin(), mid, compareSections);
   }
 
   // Process INSERT commands and update output section attributes. From this
diff --git a/lld/test/ELF/linkerscript/insert-before.test 
b/lld/test/ELF/linkerscript/insert-before.test
index e6ed413639827..a72834988007c 100644
--- a/lld/test/ELF/linkerscript/insert-before.test
+++ b/lld/test/ELF/linkerscript/insert-before.test
@@ -24,8 +24,9 @@
 ## without making more layout changes. Address/offset assignments are different
 ## with a main linker script.
 
-# RUN: ld.lld --script %s %t1.o -o %t2
-# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s
+## Test non-contiguous OutputDescs in script->sectionCommands.
+# RUN: ld.lld --defsym y0=1 %s --defsym y1=1 %t1.o -o %t2
+# RUN: llvm-readelf -S -l -sX %t2 | FileCheck --check-prefix=CHECK2 %s
 # CHECK2:  Name  Type AddressOff  Size   ES Flg
 # CHECK2-NEXT:   NULL
 # CHECK2-NEXT: .foo.text PROGBITS 0020{{.*}} [[#%x,]] 08 00  AX
@@ -40,9 +41,13 @@
 # CHECK2-NEXT: LOAD  {{.*}} RW  0x1000
 # CHECK2-NEXT: GNU_STACK {{.*}} RW  0
 
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  [[#]] (.foo.text) x0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y1
+
 SECTIONS { .byte : { BYTE(0) } } INSERT BEFORE .data;
 
 SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data;
 
 ## The input section .foo.text is an orphan. It will be placed in .foo.text
-SECTIONS { .foo.text : {} } INSERT BEFORE .text;
+SECTIONS { .foo.text : { x0 = .; } } INSERT BEFORE .text;

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


[llvm-branch-commits] [lld] 278f80c - [ELF] Fix compareSections assertion failure when OutputDescs in sectionCommands are non-contiguous

2024-02-03 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2024-02-03T10:37:52-08:00
New Revision: 278f80ce95401f7920845d1281aa99804a139b6c

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

LOG: [ELF] Fix compareSections assertion failure when OutputDescs in 
sectionCommands are non-contiguous

In a `--defsym y0=0 -T a.lds` link where a.lds contains only INSERT
commands, the `script->sectionCommands` layout may be:
```
orphan sections
SymbolAssignment due to --defsym
sections created by INSERT commands
```

The `OutputDesc` objects are not contiguous in sortInputSections, and
`compareSections` will be called with a SymbolAssignment argument,
leading to an assertion failure.

(cherry picked from commit dee8786f70a3d62b639113343fa36ef55bdbad63)

Added: 


Modified: 
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/insert-before.test

Removed: 




diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f66f3615fa4a..501c10f358497 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1518,12 +1518,12 @@ template  void Writer::sortSections() 
{
 if (auto *osd = dyn_cast(cmd))
   osd->osec.sortRank = getSectionRank(osd->osec);
   if (!script->hasSectionsCommand) {
-// We know that all the OutputSections are contiguous in this case.
-auto isSection = [](SectionCommand *cmd) { return isa(cmd); };
-std::stable_sort(
-llvm::find_if(script->sectionCommands, isSection),
-llvm::find_if(llvm::reverse(script->sectionCommands), 
isSection).base(),
-compareSections);
+// OutputDescs are mostly contiguous, but may be interleaved with
+// SymbolAssignments in the presence of INSERT commands.
+auto mid = std::stable_partition(
+script->sectionCommands.begin(), script->sectionCommands.end(),
+[](SectionCommand *cmd) { return isa(cmd); });
+std::stable_sort(script->sectionCommands.begin(), mid, compareSections);
   }
 
   // Process INSERT commands and update output section attributes. From this

diff  --git a/lld/test/ELF/linkerscript/insert-before.test 
b/lld/test/ELF/linkerscript/insert-before.test
index e6ed413639827..a72834988007c 100644
--- a/lld/test/ELF/linkerscript/insert-before.test
+++ b/lld/test/ELF/linkerscript/insert-before.test
@@ -24,8 +24,9 @@
 ## without making more layout changes. Address/offset assignments are 
diff erent
 ## with a main linker script.
 
-# RUN: ld.lld --script %s %t1.o -o %t2
-# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s
+## Test non-contiguous OutputDescs in script->sectionCommands.
+# RUN: ld.lld --defsym y0=1 %s --defsym y1=1 %t1.o -o %t2
+# RUN: llvm-readelf -S -l -sX %t2 | FileCheck --check-prefix=CHECK2 %s
 # CHECK2:  Name  Type AddressOff  Size   ES Flg
 # CHECK2-NEXT:   NULL
 # CHECK2-NEXT: .foo.text PROGBITS 0020{{.*}} [[#%x,]] 08 00  AX
@@ -40,9 +41,13 @@
 # CHECK2-NEXT: LOAD  {{.*}} RW  0x1000
 # CHECK2-NEXT: GNU_STACK {{.*}} RW  0
 
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  [[#]] (.foo.text) x0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y1
+
 SECTIONS { .byte : { BYTE(0) } } INSERT BEFORE .data;
 
 SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data;
 
 ## The input section .foo.text is an orphan. It will be placed in .foo.text
-SECTIONS { .foo.text : {} } INSERT BEFORE .text;
+SECTIONS { .foo.text : { x0 = .; } } INSERT BEFORE .text;



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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80391
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 140ad18 - ReleaseNotes: add lld/ELF notes (#80393)

2024-02-03 Thread via llvm-branch-commits

Author: Fangrui Song
Date: 2024-02-03T10:48:15-08:00
New Revision: 140ad18e1ea2cfd59ffcbfc22809ae7986a71742

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

LOG: ReleaseNotes: add lld/ELF notes (#80393)

Added: 


Modified: 
lld/docs/ReleaseNotes.rst

Removed: 




diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 01669543cd50c..21a075ad8c4ef 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -29,8 +29,50 @@ ELF Improvements
 * ``--fat-lto-objects`` option is added to support LLVM FatLTO.
   Without ``--fat-lto-objects``, LLD will link LLVM FatLTO objects using the
   relocatable object file. (`D146778 `_)
+* ``-Bsymbolic-non-weak`` is added to directly bind non-weak definitions.
+  (`D158322 `_)
+* ``--lto-validate-all-vtables-have-type-infos``, which complements
+  ``--lto-whole-program-visibility``, is added to disable unsafe whole-program
+  devirtualization. ``--lto-known-safe-vtables=`` can be used
+  to mark known-safe vtable symbols.
+  (`D155659 `_)
+* ``--save-temps --lto-emit-asm`` now derives ELF/asm file names from bitcode 
file names.
+  ``ld.lld --save-temps a.o d/b.o -o out`` will create ELF relocatable files
+  ``out.lto.a.o``/``d/out.lto.b.o`` instead of ``out1.lto.o``/``out2.lto.o``.
+  (`#78835 `_)
+* ``--no-allow-shlib-undefined`` now reports errors for DSO referencing
+  non-exported definitions.
+  (`#70769 `_)
 * common-page-size can now be larger than the system page-size.
   (`#57618 `_)
+* When call graph profile information is available due to instrumentation or
+  sample PGO, input sections are now sorted using the new ``cdsort`` algorithm,
+  better than the previous ``hfsort`` algorithm.
+  (`D152840 `_)
+* Symbol assignments like ``a = DEFINED(a) ? a : 0;`` are now handled.
+  (`#65866 `_)
+* ``OVERLAY`` now supports optional start address and LMA
+  (`#77272 `_)
+* Relocations referencing a symbol defined in ``/DISCARD/`` section now lead to
+  an error.
+  (`#69295 `_)
+* For AArch64 MTE, global variable descriptors have been implemented.
+  (`D152921 `_)
+* ``R_AARCH64_GOTPCREL32`` is now supported.
+  (`#72584 `_)
+* ``R_LARCH_PCREL20_S2``/``R_LARCH_ADD6``/``R_LARCH_CALL36`` and extreme code
+  model relocations are now supported.
+* ``--emit-relocs`` is now supported for RISC-V linker relaxation.
+  (`D159082 `_)
+* Call relaxation respects RVC when mixing +c and -c relocatable files.
+  (`#73977 `_)
+* ``R_RISCV_GOT32_PCREL`` is now supported.
+  (`#72587 `_)
+* ``R_RISCV_SET_ULEB128``/``R_RISCV_SUB_ULEB128`` relocations are now 
supported.
+  (`#72610 `_)
+  (`#77261 `_)
+* RISC-V TLSDESC is now supported.
+  (`#79239 `_)
 
 Breaking changes
 



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


[llvm-branch-commits] [lld] [llvm] ReleaseNotes: add lld/ELF notes (PR #80393)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80393
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80150 (PR #80151)

2024-02-03 Thread via llvm-branch-commits

https://github.com/cor3ntin approved this pull request.

This affects downstream projects already, we should backport.
(It's mostly a partial revert of a recent patch)

https://github.com/llvm/llvm-project/pull/80151
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [VPlan] Explicitly handle scalar pointer inductions. (PR #80273)

2024-02-03 Thread Sumit Lahiri via llvm-branch-commits

https://github.com/lahiri-phdworks approved this pull request.

#1 The instruction vector does not take the size of the operands for the PHI 
instructions. 
- since the phi instruction is not known so the the instruction head is not 
defined. 

https://github.com/llvm/llvm-project/pull/80273
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80566
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [clang] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80566

resolves llvm/llvm-project#80565

>From 5cf1f96dba0e37315f059c90dca809d6a14f7658 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 2 Feb 2024 11:35:08 -0800
Subject: [PATCH] [CMake][PGO] Add option for using an external project to
 generate profile data (#78879)

The new CLANG_PGO_TRAINING_DATA_SOURCE_DIR allows users to specify a
CMake project to use for generating the profile data. For example, to
use the llvm-test-suite to generate profile data you would do:

$ cmake -G Ninja -B build -S llvm -C /clang/cmake/caches/PGO.cmake \
-DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=
\
-DBOOTSTRAP_CLANG_PGO_TRAINING_DEPS=runtimes

Note that the CLANG_PERF_TRAINING_DEPS has been renamed to
CLANG_PGO_TRAINING_DEPS.

-

Co-authored-by: Petr Hosek 
(cherry picked from commit dd0356d741aefa25ece973d6cc4b55dcb73b84b4)
---
 clang/utils/perf-training/CMakeLists.txt | 15 ++---
 clang/utils/perf-training/perf-helper.py | 16 --
 llvm/docs/AdvancedBuilds.rst | 27 ++--
 3 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index c6d51863fb1b5..93744f4606023 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -1,6 +1,10 @@
+include(LLVMExternalProjectUtils)
+
 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
   "The path to a lit testsuite containing samples for PGO and order file 
generation"
   )
+set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source 
directory containing cmake project with source files to use for generating pgo 
data")
+set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to 
build the PGO training data.")
 
 if(LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
@@ -11,11 +15,11 @@ if(LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-profraw "Generating clang PGO data"
 ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang clear-profraw ${CLANG_PERF_TRAINING_DEPS}
+DEPENDS clang clear-profraw ${CLANG_PGO_TRAINING_DEPS}
 )
 
   add_custom_target(clear-profraw
-COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} profraw
+COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ profraw
 COMMENT "Clearing old profraw data")
 
   if(NOT LLVM_PROFDATA)
@@ -26,9 +30,14 @@ if(LLVM_BUILD_INSTRUMENTED)
 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to 
llvm-profdata")
   else()
 add_custom_target(generate-profdata
-  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR}/profiles/
   COMMENT "Merging profdata"
   DEPENDS generate-profraw)
+if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR)
+  llvm_ExternalProject_Add(generate-profraw-external 
${CLANG_PGO_TRAINING_DATA_SOURCE_DIR}
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS 
generate-profraw)
+  add_dependencies(generate-profdata generate-profraw-external)
+endif()
   endif()
 endif()
 
diff --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 99d6ab6ef..3e92cd38a7145 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension):
 
 
 def clean(args):
-if len(args) != 2:
+if len(args) < 2:
 print(
-"Usage: %s clean  \n" % __file__
+"Usage: %s clean  \n" % __file__
 + "\tRemoves all files with extension from ."
 )
 return 1
-for filename in findFilesWithExtension(args[0], args[1]):
-os.remove(filename)
+for path in args[1:-1]:
+for filename in findFilesWithExtension(path, args[-1]):
+os.remove(filename)
 return 0
 
 
 def merge(args):
-if len(args) != 3:
+if len(args) < 3:
 print(
-"Usage: %s merge   \n" % __file__
+"Usage: %s merge   \n" % __file__
 + "\tMerges all profraw files from path into output."
 )
 return 1
 cmd = [args[0], "merge", "-o", args[1]]
-cmd.extend(findFilesWithExtension(args[2], "profraw"))
+for path in args[2:]:
+cmd.extend(findFilesWithExtension(path, "profraw"))
 subprocess.check_call(cmd)
 return 0
 
diff --git a/llvm/docs/AdvancedBuilds.rst b/llvm/docs/Advanced

[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:

@aaupov What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/80566
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80565

---
Full diff: https://github.com/llvm/llvm-project/pull/80566.diff


3 Files Affected:

- (modified) clang/utils/perf-training/CMakeLists.txt (+12-3) 
- (modified) clang/utils/perf-training/perf-helper.py (+9-7) 
- (modified) llvm/docs/AdvancedBuilds.rst (+25-2) 


``diff
diff --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index c6d51863fb1b5..93744f4606023 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -1,6 +1,10 @@
+include(LLVMExternalProjectUtils)
+
 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
   "The path to a lit testsuite containing samples for PGO and order file 
generation"
   )
+set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source 
directory containing cmake project with source files to use for generating pgo 
data")
+set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to 
build the PGO training data.")
 
 if(LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
@@ -11,11 +15,11 @@ if(LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-profraw "Generating clang PGO data"
 ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang clear-profraw ${CLANG_PERF_TRAINING_DEPS}
+DEPENDS clang clear-profraw ${CLANG_PGO_TRAINING_DEPS}
 )
 
   add_custom_target(clear-profraw
-COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} profraw
+COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ profraw
 COMMENT "Clearing old profraw data")
 
   if(NOT LLVM_PROFDATA)
@@ -26,9 +30,14 @@ if(LLVM_BUILD_INSTRUMENTED)
 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to 
llvm-profdata")
   else()
 add_custom_target(generate-profdata
-  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR}/profiles/
   COMMENT "Merging profdata"
   DEPENDS generate-profraw)
+if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR)
+  llvm_ExternalProject_Add(generate-profraw-external 
${CLANG_PGO_TRAINING_DATA_SOURCE_DIR}
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS 
generate-profraw)
+  add_dependencies(generate-profdata generate-profraw-external)
+endif()
   endif()
 endif()
 
diff --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 99d6ab6ef..3e92cd38a7145 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension):
 
 
 def clean(args):
-if len(args) != 2:
+if len(args) < 2:
 print(
-"Usage: %s clean  \n" % __file__
+"Usage: %s clean  \n" % __file__
 + "\tRemoves all files with extension from ."
 )
 return 1
-for filename in findFilesWithExtension(args[0], args[1]):
-os.remove(filename)
+for path in args[1:-1]:
+for filename in findFilesWithExtension(path, args[-1]):
+os.remove(filename)
 return 0
 
 
 def merge(args):
-if len(args) != 3:
+if len(args) < 3:
 print(
-"Usage: %s merge   \n" % __file__
+"Usage: %s merge   \n" % __file__
 + "\tMerges all profraw files from path into output."
 )
 return 1
 cmd = [args[0], "merge", "-o", args[1]]
-cmd.extend(findFilesWithExtension(args[2], "profraw"))
+for path in args[2:]:
+cmd.extend(findFilesWithExtension(path, "profraw"))
 subprocess.check_call(cmd)
 return 0
 
diff --git a/llvm/docs/AdvancedBuilds.rst b/llvm/docs/AdvancedBuilds.rst
index 960b19fa5317f..ee178dd3772c4 100644
--- a/llvm/docs/AdvancedBuilds.rst
+++ b/llvm/docs/AdvancedBuilds.rst
@@ -145,6 +145,29 @@ that also enables ThinTLO, use the following command:
   -DPGO_INSTRUMENT_LTO=Thin \
   /llvm
 
+By default, clang will generate profile data by compiling a simple
+hello world program.  You can also tell clang use an external
+project for generating profile data that may be a better fit for your
+use case.  The project you specify must either be a lit test suite
+(use the CLANG_PGO_TRAINING_DATA option) or a CMake project (use the
+CLANG_PERF_TRAINING_DATA_SOURCE_DIR option).
+
+For example, If you wanted to use the
+`LLVM Test Suite `_ to generate
+profile data you would use t

[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-03 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov approved this pull request.


https://github.com/llvm/llvm-project/pull/80566
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [clang] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-03 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 approved this pull request.

LGTM! Will be nice to have this available in the release branch for the release 
builds and the CI container.

https://github.com/llvm/llvm-project/pull/80566
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80577 (PR #80578)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80578
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80577 (PR #80578)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80578

resolves llvm/llvm-project#80577

>From bb71add47cd69b184b0fe1b72bd44e8a36a74367 Mon Sep 17 00:00:00 2001
From: wanglei 
Date: Fri, 26 Jan 2024 10:24:07 +0800
Subject: [PATCH] [LoongArch] Fixing the incorrect return value of
 LoongArchTTIImpl::getRegisterBitWidth (#79441)

When we do not enable vector features, we should return the default
value (`TargetTransformInfoImplBase::getRegisterBitWidth`) instead of
zero.

This should fix the LoongArch [buildbot
breakage](https://lab.llvm.org/staging/#/builders/5/builds/486) from
#78943.

(cherry picked from commit 1e9924c1f248bbddcb95d82a59708d617297dad3)
---
 .../Target/LoongArch/LoongArchTargetTransformInfo.cpp | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp 
b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
index 04349aa52b540..d47dded9ea6ec 100644
--- a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
@@ -21,17 +21,20 @@ using namespace llvm;
 
 TypeSize LoongArchTTIImpl::getRegisterBitWidth(
 TargetTransformInfo::RegisterKind K) const {
+  TypeSize DefSize = TargetTransformInfoImplBase::getRegisterBitWidth(K);
   switch (K) {
   case TargetTransformInfo::RGK_Scalar:
 return TypeSize::getFixed(ST->is64Bit() ? 64 : 32);
   case TargetTransformInfo::RGK_FixedWidthVector:
-if (ST->hasExtLASX() && ST->hasExpAutoVec())
+if (!ST->hasExpAutoVec())
+  return DefSize;
+if (ST->hasExtLASX())
   return TypeSize::getFixed(256);
-if (ST->hasExtLSX() && ST->hasExpAutoVec())
+if (ST->hasExtLSX())
   return TypeSize::getFixed(128);
-return TypeSize::getFixed(0);
+[[fallthrough]];
   case TargetTransformInfo::RGK_ScalableVector:
-return TypeSize::getScalable(0);
+return DefSize;
   }
 
   llvm_unreachable("Unsupported register kind");

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80577 (PR #80578)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-loongarch

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80577

---
Full diff: https://github.com/llvm/llvm-project/pull/80578.diff


1 Files Affected:

- (modified) llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp (+7-4) 


``diff
diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp 
b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
index 04349aa52b540..d47dded9ea6ec 100644
--- a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
@@ -21,17 +21,20 @@ using namespace llvm;
 
 TypeSize LoongArchTTIImpl::getRegisterBitWidth(
 TargetTransformInfo::RegisterKind K) const {
+  TypeSize DefSize = TargetTransformInfoImplBase::getRegisterBitWidth(K);
   switch (K) {
   case TargetTransformInfo::RGK_Scalar:
 return TypeSize::getFixed(ST->is64Bit() ? 64 : 32);
   case TargetTransformInfo::RGK_FixedWidthVector:
-if (ST->hasExtLASX() && ST->hasExpAutoVec())
+if (!ST->hasExpAutoVec())
+  return DefSize;
+if (ST->hasExtLASX())
   return TypeSize::getFixed(256);
-if (ST->hasExtLSX() && ST->hasExpAutoVec())
+if (ST->hasExtLSX())
   return TypeSize::getFixed(128);
-return TypeSize::getFixed(0);
+[[fallthrough]];
   case TargetTransformInfo::RGK_ScalableVector:
-return TypeSize::getScalable(0);
+return DefSize;
   }
 
   llvm_unreachable("Unsupported register kind");

``




https://github.com/llvm/llvm-project/pull/80578
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80150 (PR #80151)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80151

>From ae04671e43c44f64ed8627d856a3c67e25ce01a6 Mon Sep 17 00:00:00 2001
From: Andrey Ali Khan Bolshakov
 <32954549+bolshako...@users.noreply.github.com>
Date: Wed, 31 Jan 2024 17:28:37 +0300
Subject: [PATCH] [clang] Represent array refs as
 `TemplateArgument::Declaration` (#80050)

This returns (probably temporarily) array-referring NTTP behavior to
which was prior to #78041 because ~~I'm fed up~~ have no time to fix
regressions.

(cherry picked from commit 9bf4e54ef42d907ae7550f36fa518f14fa97af6f)
---
 clang/lib/Sema/SemaTemplate.cpp  | 44 +---
 clang/test/CoverageMapping/templates.cpp | 13 +++
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9bfa71dc8bcf1..a381d876a54c6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -7412,9 +7412,9 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 if (ArgResult.isInvalid())
   return ExprError();
 
-// Prior to C++20, enforce restrictions on possible template argument
-// values.
-if (!getLangOpts().CPlusPlus20 && Value.isLValue()) {
+if (Value.isLValue()) {
+  APValue::LValueBase Base = Value.getLValueBase();
+  auto *VD = const_cast(Base.dyn_cast());
   //   For a non-type template-parameter of pointer or reference type,
   //   the value of the constant expression shall not refer to
   assert(ParamType->isPointerType() || ParamType->isReferenceType() ||
@@ -7423,8 +7423,6 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
   // -- a string literal
   // -- the result of a typeid expression, or
   // -- a predefined __func__ variable
-  APValue::LValueBase Base = Value.getLValueBase();
-  auto *VD = const_cast(Base.dyn_cast());
   if (Base &&
   (!VD ||
isa(VD))) 
{
@@ -7432,24 +7430,30 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 << Arg->getSourceRange();
 return ExprError();
   }
-  // -- a subobject [until C++20]
-  if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 &&
-  VD && VD->getType()->isArrayType() &&
+
+  if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 && VD &&
+  VD->getType()->isArrayType() &&
   Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
   !Value.isLValueOnePastTheEnd() && ParamType->isPointerType()) {
-// Per defect report (no number yet):
-//   ... other than a pointer to the first element of a complete array
-//   object.
-  } else if (!Value.hasLValuePath() || Value.getLValuePath().size() ||
- Value.isLValueOnePastTheEnd()) {
-Diag(StartLoc, diag::err_non_type_template_arg_subobject)
-  << Value.getAsString(Context, ParamType);
-return ExprError();
+SugaredConverted = TemplateArgument(VD, ParamType);
+CanonicalConverted = TemplateArgument(
+cast(VD->getCanonicalDecl()), CanonParamType);
+return ArgResult.get();
+  }
+
+  // -- a subobject [until C++20]
+  if (!getLangOpts().CPlusPlus20) {
+if (!Value.hasLValuePath() || Value.getLValuePath().size() ||
+Value.isLValueOnePastTheEnd()) {
+  Diag(StartLoc, diag::err_non_type_template_arg_subobject)
+  << Value.getAsString(Context, ParamType);
+  return ExprError();
+}
+assert((VD || !ParamType->isReferenceType()) &&
+   "null reference should not be a constant expression");
+assert((!VD || !ParamType->isNullPtrType()) &&
+   "non-null value of type nullptr_t?");
   }
-  assert((VD || !ParamType->isReferenceType()) &&
- "null reference should not be a constant expression");
-  assert((!VD || !ParamType->isNullPtrType()) &&
- "non-null value of type nullptr_t?");
 }
 
 if (Value.isAddrLabelDiff())
diff --git a/clang/test/CoverageMapping/templates.cpp 
b/clang/test/CoverageMapping/templates.cpp
index 7010edbc32c34..143e566a33cb8 100644
--- a/clang/test/CoverageMapping/templates.cpp
+++ b/clang/test/CoverageMapping/templates.cpp
@@ -19,3 +19,16 @@ int main() {
   func(true);
   return 0;
 }
+
+namespace structural_value_crash {
+  template 
+  void tpl_fn() {
+(void)p;
+  }
+
+  int arr[] = {1, 2, 3};
+
+  void test() {
+tpl_fn();
+  }
+}

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


[llvm-branch-commits] [clang] ae04671 - [clang] Represent array refs as `TemplateArgument::Declaration` (#80050)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

Author: Andrey Ali Khan Bolshakov
Date: 2024-02-03T21:09:06-08:00
New Revision: ae04671e43c44f64ed8627d856a3c67e25ce01a6

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

LOG: [clang] Represent array refs as `TemplateArgument::Declaration` (#80050)

This returns (probably temporarily) array-referring NTTP behavior to
which was prior to #78041 because ~~I'm fed up~~ have no time to fix
regressions.

(cherry picked from commit 9bf4e54ef42d907ae7550f36fa518f14fa97af6f)

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/test/CoverageMapping/templates.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9bfa71dc8bcf1..a381d876a54c6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -7412,9 +7412,9 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 if (ArgResult.isInvalid())
   return ExprError();
 
-// Prior to C++20, enforce restrictions on possible template argument
-// values.
-if (!getLangOpts().CPlusPlus20 && Value.isLValue()) {
+if (Value.isLValue()) {
+  APValue::LValueBase Base = Value.getLValueBase();
+  auto *VD = const_cast(Base.dyn_cast());
   //   For a non-type template-parameter of pointer or reference type,
   //   the value of the constant expression shall not refer to
   assert(ParamType->isPointerType() || ParamType->isReferenceType() ||
@@ -7423,8 +7423,6 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
   // -- a string literal
   // -- the result of a typeid expression, or
   // -- a predefined __func__ variable
-  APValue::LValueBase Base = Value.getLValueBase();
-  auto *VD = const_cast(Base.dyn_cast());
   if (Base &&
   (!VD ||
isa(VD))) 
{
@@ -7432,24 +7430,30 @@ ExprResult 
Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 << Arg->getSourceRange();
 return ExprError();
   }
-  // -- a subobject [until C++20]
-  if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 &&
-  VD && VD->getType()->isArrayType() &&
+
+  if (Value.hasLValuePath() && Value.getLValuePath().size() == 1 && VD &&
+  VD->getType()->isArrayType() &&
   Value.getLValuePath()[0].getAsArrayIndex() == 0 &&
   !Value.isLValueOnePastTheEnd() && ParamType->isPointerType()) {
-// Per defect report (no number yet):
-//   ... other than a pointer to the first element of a complete array
-//   object.
-  } else if (!Value.hasLValuePath() || Value.getLValuePath().size() ||
- Value.isLValueOnePastTheEnd()) {
-Diag(StartLoc, diag::err_non_type_template_arg_subobject)
-  << Value.getAsString(Context, ParamType);
-return ExprError();
+SugaredConverted = TemplateArgument(VD, ParamType);
+CanonicalConverted = TemplateArgument(
+cast(VD->getCanonicalDecl()), CanonParamType);
+return ArgResult.get();
+  }
+
+  // -- a subobject [until C++20]
+  if (!getLangOpts().CPlusPlus20) {
+if (!Value.hasLValuePath() || Value.getLValuePath().size() ||
+Value.isLValueOnePastTheEnd()) {
+  Diag(StartLoc, diag::err_non_type_template_arg_subobject)
+  << Value.getAsString(Context, ParamType);
+  return ExprError();
+}
+assert((VD || !ParamType->isReferenceType()) &&
+   "null reference should not be a constant expression");
+assert((!VD || !ParamType->isNullPtrType()) &&
+   "non-null value of type nullptr_t?");
   }
-  assert((VD || !ParamType->isReferenceType()) &&
- "null reference should not be a constant expression");
-  assert((!VD || !ParamType->isNullPtrType()) &&
- "non-null value of type nullptr_t?");
 }
 
 if (Value.isAddrLabelDiff())

diff  --git a/clang/test/CoverageMapping/templates.cpp 
b/clang/test/CoverageMapping/templates.cpp
index 7010edbc32c34..143e566a33cb8 100644
--- a/clang/test/CoverageMapping/templates.cpp
+++ b/clang/test/CoverageMapping/templates.cpp
@@ -19,3 +19,16 @@ int main() {
   func(true);
   return 0;
 }
+
+namespace structural_value_crash {
+  template 
+  void tpl_fn() {
+(void)p;
+  }
+
+  int arr[] = {1, 2, 3};
+
+  void test() {
+tpl_fn();
+  }
+}



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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80150 (PR #80151)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80151
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80577 (PR #80578)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80578

>From 900e7cbfdee09c94d022e4dae923b3c7827f95e3 Mon Sep 17 00:00:00 2001
From: wanglei 
Date: Fri, 26 Jan 2024 10:24:07 +0800
Subject: [PATCH] [LoongArch] Fixing the incorrect return value of
 LoongArchTTIImpl::getRegisterBitWidth (#79441)

When we do not enable vector features, we should return the default
value (`TargetTransformInfoImplBase::getRegisterBitWidth`) instead of
zero.

This should fix the LoongArch [buildbot
breakage](https://lab.llvm.org/staging/#/builders/5/builds/486) from
#78943.

(cherry picked from commit 1e9924c1f248bbddcb95d82a59708d617297dad3)
---
 .../Target/LoongArch/LoongArchTargetTransformInfo.cpp | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp 
b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
index 04349aa52b540..d47dded9ea6ec 100644
--- a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
@@ -21,17 +21,20 @@ using namespace llvm;
 
 TypeSize LoongArchTTIImpl::getRegisterBitWidth(
 TargetTransformInfo::RegisterKind K) const {
+  TypeSize DefSize = TargetTransformInfoImplBase::getRegisterBitWidth(K);
   switch (K) {
   case TargetTransformInfo::RGK_Scalar:
 return TypeSize::getFixed(ST->is64Bit() ? 64 : 32);
   case TargetTransformInfo::RGK_FixedWidthVector:
-if (ST->hasExtLASX() && ST->hasExpAutoVec())
+if (!ST->hasExpAutoVec())
+  return DefSize;
+if (ST->hasExtLASX())
   return TypeSize::getFixed(256);
-if (ST->hasExtLSX() && ST->hasExpAutoVec())
+if (ST->hasExtLSX())
   return TypeSize::getFixed(128);
-return TypeSize::getFixed(0);
+[[fallthrough]];
   case TargetTransformInfo::RGK_ScalableVector:
-return TypeSize::getScalable(0);
+return DefSize;
   }
 
   llvm_unreachable("Unsupported register kind");

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


[llvm-branch-commits] [llvm] 900e7cb - [LoongArch] Fixing the incorrect return value of LoongArchTTIImpl::getRegisterBitWidth (#79441)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

Author: wanglei
Date: 2024-02-03T21:28:38-08:00
New Revision: 900e7cbfdee09c94d022e4dae923b3c7827f95e3

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

LOG: [LoongArch] Fixing the incorrect return value of 
LoongArchTTIImpl::getRegisterBitWidth (#79441)

When we do not enable vector features, we should return the default
value (`TargetTransformInfoImplBase::getRegisterBitWidth`) instead of
zero.

This should fix the LoongArch [buildbot
breakage](https://lab.llvm.org/staging/#/builders/5/builds/486) from
#78943.

(cherry picked from commit 1e9924c1f248bbddcb95d82a59708d617297dad3)

Added: 


Modified: 
llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp

Removed: 




diff  --git a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp 
b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
index 04349aa52b540..d47dded9ea6ec 100644
--- a/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.cpp
@@ -21,17 +21,20 @@ using namespace llvm;
 
 TypeSize LoongArchTTIImpl::getRegisterBitWidth(
 TargetTransformInfo::RegisterKind K) const {
+  TypeSize DefSize = TargetTransformInfoImplBase::getRegisterBitWidth(K);
   switch (K) {
   case TargetTransformInfo::RGK_Scalar:
 return TypeSize::getFixed(ST->is64Bit() ? 64 : 32);
   case TargetTransformInfo::RGK_FixedWidthVector:
-if (ST->hasExtLASX() && ST->hasExpAutoVec())
+if (!ST->hasExpAutoVec())
+  return DefSize;
+if (ST->hasExtLASX())
   return TypeSize::getFixed(256);
-if (ST->hasExtLSX() && ST->hasExpAutoVec())
+if (ST->hasExtLSX())
   return TypeSize::getFixed(128);
-return TypeSize::getFixed(0);
+[[fallthrough]];
   case TargetTransformInfo::RGK_ScalableVector:
-return TypeSize::getScalable(0);
+return DefSize;
   }
 
   llvm_unreachable("Unsupported register kind");



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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80577 (PR #80578)

2024-02-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80578
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80584
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:

@boomanaiden154 What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/80584
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80584

resolves llvm/llvm-project#80580

>From 20fa7b5b2ced924ccc48e1cd523553b899ca828b Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 3 Feb 2024 21:37:46 -0800
Subject: [PATCH] [workflows] Stop using the build-test-llvm-project action
 (#80580)

This action is really just a wrapper around cmake and ninja. It doesn't
add any value to the builds, and I don't think we need it now that there
are reusable workflows.

(cherry picked from commit d25022bb689b9bf48a24c0ae6c29c1d3c2f32823)
---
 .github/workflows/llvm-project-tests.yml | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/llvm-project-tests.yml 
b/.github/workflows/llvm-project-tests.yml
index 91d0b258394ef..79a382bfa4f9a 100644
--- a/.github/workflows/llvm-project-tests.yml
+++ b/.github/workflows/llvm-project-tests.yml
@@ -98,14 +98,23 @@ jobs:
   key: ${{ matrix.os }}
   variant: sccache
   - name: Build and Test
-uses: llvm/actions/build-test-llvm-project@main
 env:
   # Workaround for 
https://github.com/actions/virtual-environments/issues/5900.
   # This should be a no-op for non-mac OSes
   PKG_CONFIG_PATH: 
/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
-with:
-  cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" 
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLDB_INCLUDE_TESTS=OFF 
-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ 
inputs.extra_cmake_args }}'
-  build_target: '${{ inputs.build_target }}'
+shell: bash
+run: |
+  cmake -G Ninja \
+-B build \
+-S llvm \
+-DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" \
+-DCMAKE_BUILD_TYPE=Release \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DLLDB_INCLUDE_TESTS=OFF \
+-DCMAKE_C_COMPILER_LAUNCHER=sccache \
+-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
+${{ inputs.extra_cmake_args }}
+  ninja -C build '${{ inputs.build_target }}'
 
   - name: Build and Test libclc
 if: "!startsWith(matrix.os, 'windows') && contains(inputs.projects, 
'libclc')"

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-github-workflow

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80580

---
Full diff: https://github.com/llvm/llvm-project/pull/80584.diff


1 Files Affected:

- (modified) .github/workflows/llvm-project-tests.yml (+13-4) 


``diff
diff --git a/.github/workflows/llvm-project-tests.yml 
b/.github/workflows/llvm-project-tests.yml
index 91d0b258394ef..79a382bfa4f9a 100644
--- a/.github/workflows/llvm-project-tests.yml
+++ b/.github/workflows/llvm-project-tests.yml
@@ -98,14 +98,23 @@ jobs:
   key: ${{ matrix.os }}
   variant: sccache
   - name: Build and Test
-uses: llvm/actions/build-test-llvm-project@main
 env:
   # Workaround for 
https://github.com/actions/virtual-environments/issues/5900.
   # This should be a no-op for non-mac OSes
   PKG_CONFIG_PATH: 
/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
-with:
-  cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" 
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLDB_INCLUDE_TESTS=OFF 
-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ 
inputs.extra_cmake_args }}'
-  build_target: '${{ inputs.build_target }}'
+shell: bash
+run: |
+  cmake -G Ninja \
+-B build \
+-S llvm \
+-DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" \
+-DCMAKE_BUILD_TYPE=Release \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DLLDB_INCLUDE_TESTS=OFF \
+-DCMAKE_C_COMPILER_LAUNCHER=sccache \
+-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
+${{ inputs.extra_cmake_args }}
+  ninja -C build '${{ inputs.build_target }}'
 
   - name: Build and Test libclc
 if: "!startsWith(matrix.os, 'windows') && contains(inputs.projects, 
'libclc')"

``




https://github.com/llvm/llvm-project/pull/80584
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80580 (PR #80584)

2024-02-03 Thread Aiden Grossman via llvm-branch-commits

https://github.com/boomanaiden154 approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/80584
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80348 (PR #80585)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80585

resolves llvm/llvm-project#80348

>From 705f5fb1af07ac52acb9c13375c9cea3a201440c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 3 Feb 2024 21:42:40 -0800
Subject: [PATCH] [workflows] Only run code formatter on the main branch
 (#80348)

Modifying a cherry-picked patch to fix code formatting issues can be
risky, so we don't typically do this. Therefore, it's not necessary to
run this job on the release branches.

(cherry picked from commit 2193c95e2459887e7e6e4f9f4aacf9252e99858f)
---
 .github/workflows/pr-code-format.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.github/workflows/pr-code-format.yml 
b/.github/workflows/pr-code-format.yml
index 5223089ee8a93..c8fd541fd34db 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -1,5 +1,8 @@
 name: "Check code formatting"
 on: pull_request_target
+  branches:
+- main
+
 permissions:
   pull-requests: write
 

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80348 (PR #80585)

2024-02-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80585
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80348 (PR #80585)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:

@tru What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/80585
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80348 (PR #80585)

2024-02-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-github-workflow

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80348

---
Full diff: https://github.com/llvm/llvm-project/pull/80585.diff


1 Files Affected:

- (modified) .github/workflows/pr-code-format.yml (+3) 


``diff
diff --git a/.github/workflows/pr-code-format.yml 
b/.github/workflows/pr-code-format.yml
index 5223089ee8a93..c8fd541fd34db 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -1,5 +1,8 @@
 name: "Check code formatting"
 on: pull_request_target
+  branches:
+- main
+
 permissions:
   pull-requests: write
 

``




https://github.com/llvm/llvm-project/pull/80585
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [libcxx] [flang] [llvm] [libc] [compiler-rt] [RISCV] Support select optimization (PR #80124)

2024-02-03 Thread Wang Pengcheng via llvm-branch-commits

wangpc-pp wrote:

> JFYI, I don't find the AArch64 data particularly convincing for RISCV. The 
> magnitude of the change even on AArch64 is small, and could easily be swung 
> one direction or the other by differences in implementation between the 
> backends.

Yeah! The result will differ for different targets/CPUs. One RISCV data for 
SPEC 2006 (which is not universal I think) on an OoO RISCV CPU, options: 
`-march=rv64gc_zba_zbb_zicond -O3`:
```
400.perlbench0.538%
401.bzip20.018%
403.gcc  0.105%
429.mcf  1.028%
445.gobmk-0.221%
456.hmmer1.582%
458.sjeng-0.026%
462.libquantum   -0.090%
464.h264ref  0.905%
471.omnetpp  -0.776%
473.astar0.205%
```
The geomean is: 0.295%.
The result can be better with PGO I think (haven't tried it). Some related 
discussions: https://discourse.llvm.org/t/rfc-cmov-vs-branch-optimization.
So I think we can be just like AArch64, make it a tune feature and processors 
can add it if needed.

https://github.com/llvm/llvm-project/pull/80124
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits