[llvm-branch-commits] [llvm] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

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

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

Backport ec2b7522dbee1cb9d6ade6e1768462247dcf 
f84980570d3f85bdf5c9432647c05bae04a735a0 
cb2ca23345d3d9bde027a18d301949e8bdf606a6

Requested by: @mstorsjo

>From f56a43226c678530b77427e4aaad375528ccfc80 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 15 Mar 2024 08:16:46 -0700
Subject: [PATCH 1/3] llvm-shlib: Fix libLLVM-${MAJOR}.so symlink on MacOS
 (#85163)

This is a partial revert of 10c48a772742b7afe665a815b7eba2047f17dc4b
with a fix for the symlink target name on MacOS

See #84637

(cherry picked from commit ec2b7522dbee1cb9d6ade6e1768462247dcf)
---
 llvm/cmake/modules/AddLLVM.cmake | 6 +++---
 llvm/tools/llvm-shlib/CMakeLists.txt | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 3bc78b0dc9355a..ceec15b611140d 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2074,7 +2074,7 @@ function(add_lit_testsuites project directory)
 endfunction()
 
 function(llvm_install_library_symlink name dest type)
-  cmake_parse_arguments(ARG "" "COMPONENT;SOVERSION" "" ${ARGN})
+  cmake_parse_arguments(ARG "FULL_DEST" "COMPONENT" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})
 if(EXISTS ${path}/LLVMInstallSymlink.cmake)
   set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
@@ -2088,8 +2088,8 @@ function(llvm_install_library_symlink name dest type)
   endif()
 
   set(full_name 
${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
-  if (ARG_SOVERSION)
-set(full_dest 
${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}.${ARG_SOVERSION})
+  if (ARG_FULL_DEST)
+set(full_dest ${dest})
   else()
 set(full_dest 
${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
   endif()
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index eba1672faee7fa..9adce0617ff736 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -35,8 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
   endif()
   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
   # Add symlink for backwards compatibility with old library name
-  get_target_property(LLVM_DYLIB_SOVERSION LLVM SOVERSION)
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
LLVM SHARED COMPONENT LLVM SOVERSION ${LLVM_DYLIB_SOVERSION})
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")

>From a2ef9bb96883bd3dc36fb465b0ecea3e9533395a Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 16 Mar 2024 22:47:27 -0700
Subject: [PATCH 2/3] [llvm-shlib] Fix libLLVM-18 symlink on mingw (#85554)

The TARGET_SONAME_FILE_NAME generator expression is not available on dll
target platforms.

(cherry picked from commit f84980570d3f85bdf5c9432647c05bae04a735a0)
---
 llvm/tools/llvm-shlib/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 9adce0617ff736..0ad350bcbe0d7b 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -35,7 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
   endif()
   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
   # Add symlink for backwards compatibility with old library name
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")

>From c9ac7cc41f2d7f7181713f6652b5fee463381cae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 19 Mar 2024 08:48:57 +0200
Subject: [PATCH 3/3] [llvm-shlib] Fix the version naming style of libLLVM for
 Windows (#85710)

This reverts the changes from 91a384621e5b762d9c173ffd247cfeadd5f436a2
for Windows targets. The changes in that commit don't work as expected
for Windows targets (those parts of llvm_add_library don't quite behave
the same for Windows), while the previous status quo (producing a
library named "libLLVM-.dll") is the defacto standard way of
doing versioned library names there, contrary to on Unix.

After that commit, the library always ended up named "libLLVM.dll",
executables linking against it would reference "libLLVM.dll", and
"libLLVM-.dll" was provided as a symlink.

Thus revert this bit back to as it were, so that executables actually
link against a versioned libLLVM, and no separate symlink is needed.

The only thing

[llvm-branch-commits] [llvm] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

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

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/85746
___
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] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

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

llvmbot wrote:

@nikic @mstorsjo @tstellar What do you think about merging this PR to the 
release branch?

https://github.com/llvm/llvm-project/pull/85746
___
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] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/85750

We add a common class `SingleFusion` that accepts a single instruction
pair to simplify fusion definitions.



___
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] [RISCV] Support select optimization (PR #80124)

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


@@ -101,6 +101,11 @@ static cl::opt EnableMISchedLoadClustering(
 cl::desc("Enable load clustering in the machine scheduler"),
 cl::init(false));
 
+static cl::opt
+EnableSelectOpt("riscv-select-opt", cl::Hidden,

wangpc-pp wrote:

Most of the added passes have been run before, so they may be cached?

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


[llvm-branch-commits] [llvm] [RISCV] Support select optimization (PR #80124)

2024-03-19 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.
> 
> Do we have any data without Zicond? The worst case Zicond sequence is 
> czero.eqz+czero.nez+or which is kind of expensive. Curious if this is 
> pointing to Zicond being used too aggressively.

Sorry, I didn't run it with this configuration.
I was going to run some small benchmarks (the hardware resources were busy) 
like coremark on CA model today, but it seems there is no codegen change with 
selectopt enabled. :-(
Will lacking this data block this PR?


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


[llvm-branch-commits] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

2024-03-19 Thread Matt Arsenault via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/85750
___
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] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

2024-03-19 Thread Nikita Popov via llvm-branch-commits

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

A bit unfortunate to have these changes post-release, but I think we do need to 
make them.

https://github.com/llvm/llvm-project/pull/85746
___
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] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

2024-03-19 Thread Martin Storsjö via llvm-branch-commits

mstorsjo wrote:

> A bit unfortunate to have these changes post-release, but I think we do need 
> to make them.

Yes, in particular as the earlier changes were backported. If the whole series 
would have been left out from 18.x, there wouldn't have been any hurry in 
backporting.

https://github.com/llvm/llvm-project/pull/85746
___
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] [NFC] Refactors argument order. (PR #85781)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/85781

Putting the output reference argument first looks more sensible.

>From 1af98d79952669b1ce05b42aeeae32bd4ea83ee7 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [NFC] Refactors argument order.

Putting the output reference argument first looks more sensible.
---
 libcxx/include/__chrono/formatter.h | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 4ad59382a4148a..b64cae529a294d 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -79,7 +79,7 @@ namespace __formatter {
 // small). Therefore a duration uses its own conversion.
 template 
 _LIBCPP_HIDE_FROM_ABI void
-__format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, 
basic_stringstream<_CharT>& __sstr) {
+__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const 
chrono::duration<_Rep, _Period>& __value) {
   __sstr << std::use_facet>(__sstr.getloc()).decimal_point();
 
   using __duration = chrono::duration<_Rep, _Period>;
@@ -110,13 +110,13 @@ __format_sub_seconds(const chrono::duration<_Rep, 
_Period>& __value, basic_strin
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, 
basic_stringstream<_CharT>& __sstr) {
-  __formatter::__format_sub_seconds(__value.time_since_epoch(), __sstr);
+_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(basic_stringstream<_CharT>& 
__sstr, const _Tp& __value) {
+  __formatter::__format_sub_seconds(__sstr, __value.time_since_epoch());
 }
 
 template 
 _LIBCPP_HIDE_FROM_ABI void
-__format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, 
basic_stringstream<_CharT>& __sstr) {
+__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const 
chrono::hh_mm_ss<_Duration>& __value) {
   __sstr << std::use_facet>(__sstr.getloc()).decimal_point();
   if constexpr (chrono::treat_as_floating_point_v)
 std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
@@ -143,7 +143,7 @@ consteval bool __use_fraction() {
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, 
basic_stringstream<_CharT>& __sstr) {
+_LIBCPP_HIDE_FROM_ABI void __format_year(basic_stringstream<_CharT>& __sstr, 
int __year) {
   if (__year < 0) {
 __sstr << _CharT('-');
 __year = -__year;
@@ -159,7 +159,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, 
basic_stringstream<_CharT>&
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, 
basic_stringstream<_CharT>& __sstr) {
+_LIBCPP_HIDE_FROM_ABI void __format_century(basic_stringstream<_CharT>& 
__sstr, int __year) {
   // TODO FMT Write an issue
   // [tab:time.format.spec]
   //   %C The year divided by 100 using floored division. If the result is a
@@ -172,7 +172,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, 
basic_stringstream<_Char
 
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
-const _Tp& __value, basic_stringstream<_CharT>& __sstr, 
basic_string_view<_CharT> __chrono_specs) {
+basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
@@ -196,7 +196,7 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 // strftime's output is only defined in the range [00, 99].
 int __year = __t.tm_year + 1900;
 if (__year < 1000 || __year > )
-  __formatter::__format_century(__year, __sstr);
+  __formatter::__format_century(__sstr, __year);
 else
   __facet.put(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
@@ -242,7 +242,7 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __facet.put(
 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
 if constexpr (__use_fraction<_Tp>())
-  __formatter::__format_sub_seconds(__value, __sstr);
+  __formatter::__format_sub_seconds(__sstr, __value);
 break;
 
 // Unlike time_put and strftime the formatting library requires %Y
@@ -283,13 +283,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 // Depending on the platform's libc the range of supported years is
 // limited. Intead of of testing all conditions use the internal
 // implementation unconditionally.
-__formatter::__format_year(__t.tm_year + 1900, __sstr);
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
   case _CharT('F'): {
 int __year = __t.tm_year + 1900;
 

[llvm-branch-commits] [libcxx] [NFC] Refactors argument order. (PR #85781)

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

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

Putting the output reference argument first looks more sensible.

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


1 Files Affected:

- (modified) libcxx/include/__chrono/formatter.h (+14-14) 


``diff
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 4ad59382a4148a..b64cae529a294d 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -79,7 +79,7 @@ namespace __formatter {
 // small). Therefore a duration uses its own conversion.
 template 
 _LIBCPP_HIDE_FROM_ABI void
-__format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, 
basic_stringstream<_CharT>& __sstr) {
+__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const 
chrono::duration<_Rep, _Period>& __value) {
   __sstr << std::use_facet>(__sstr.getloc()).decimal_point();
 
   using __duration = chrono::duration<_Rep, _Period>;
@@ -110,13 +110,13 @@ __format_sub_seconds(const chrono::duration<_Rep, 
_Period>& __value, basic_strin
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, 
basic_stringstream<_CharT>& __sstr) {
-  __formatter::__format_sub_seconds(__value.time_since_epoch(), __sstr);
+_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(basic_stringstream<_CharT>& 
__sstr, const _Tp& __value) {
+  __formatter::__format_sub_seconds(__sstr, __value.time_since_epoch());
 }
 
 template 
 _LIBCPP_HIDE_FROM_ABI void
-__format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, 
basic_stringstream<_CharT>& __sstr) {
+__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const 
chrono::hh_mm_ss<_Duration>& __value) {
   __sstr << std::use_facet>(__sstr.getloc()).decimal_point();
   if constexpr (chrono::treat_as_floating_point_v)
 std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
@@ -143,7 +143,7 @@ consteval bool __use_fraction() {
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, 
basic_stringstream<_CharT>& __sstr) {
+_LIBCPP_HIDE_FROM_ABI void __format_year(basic_stringstream<_CharT>& __sstr, 
int __year) {
   if (__year < 0) {
 __sstr << _CharT('-');
 __year = -__year;
@@ -159,7 +159,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, 
basic_stringstream<_CharT>&
 }
 
 template 
-_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, 
basic_stringstream<_CharT>& __sstr) {
+_LIBCPP_HIDE_FROM_ABI void __format_century(basic_stringstream<_CharT>& 
__sstr, int __year) {
   // TODO FMT Write an issue
   // [tab:time.format.spec]
   //   %C The year divided by 100 using floored division. If the result is a
@@ -172,7 +172,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, 
basic_stringstream<_Char
 
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
-const _Tp& __value, basic_stringstream<_CharT>& __sstr, 
basic_string_view<_CharT> __chrono_specs) {
+basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
@@ -196,7 +196,7 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 // strftime's output is only defined in the range [00, 99].
 int __year = __t.tm_year + 1900;
 if (__year < 1000 || __year > )
-  __formatter::__format_century(__year, __sstr);
+  __formatter::__format_century(__sstr, __year);
 else
   __facet.put(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
@@ -242,7 +242,7 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __facet.put(
 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
 if constexpr (__use_fraction<_Tp>())
-  __formatter::__format_sub_seconds(__value, __sstr);
+  __formatter::__format_sub_seconds(__sstr, __value);
 break;
 
 // Unlike time_put and strftime the formatting library requires %Y
@@ -283,13 +283,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 // Depending on the platform's libc the range of supported years is
 // limited. Intead of of testing all conditions use the internal
 // implementation unconditionally.
-__formatter::__format_year(__t.tm_year + 1900, __sstr);
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
   case _CharT('F'): {
 int __year = __t.tm_year + 1900;
 if (__year < 1000) {
-  __formatter::__format_year(__year, __sstr);
+  __formatter::__format_year(__sstr, __year);
   __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_Char

[llvm-branch-commits] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/85750


___
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] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/85750


___
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] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/85750


___
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] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/85750


___
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] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

https://github.com/wangpc-pp closed 
https://github.com/llvm/llvm-project/pull/85750
___
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] [MacroFusion] Add SingleFusion that accepts a single instruction pair (PR #85750)

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

wangpc-pp wrote:

Committed as 4a6bc9fd14bd79f1edf5b651b43bd9bda9b90991.

https://github.com/llvm/llvm-project/pull/85750
___
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] [NFC][libc++][TZDB] Refactors argument order. (PR #85781)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante edited 
https://github.com/llvm/llvm-project/pull/85781
___
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] [flang] bf39f3b - Revert "[Flang][OpenMP][Lower] NFC: Move clause processing helpers into the C…"

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

Author: Sergio Afonso
Date: 2024-03-19T13:24:23Z
New Revision: bf39f3bb45a02431ea54fb9a59a9216641914751

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

LOG: Revert "[Flang][OpenMP][Lower] NFC: Move clause processing helpers into 
the C…"

This reverts commit 2f2f16f32bb2a6c250b19adbc229d9dc3b38640c.

Added: 


Modified: 
flang/lib/Lower/OpenMP/ClauseProcessor.cpp
flang/lib/Lower/OpenMP/ClauseProcessor.h
flang/lib/Lower/OpenMP/OpenMP.cpp
flang/lib/Lower/OpenMP/Utils.cpp
flang/lib/Lower/OpenMP/Utils.h

Removed: 




diff  --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 81919f2a48965b..13347c8cf7b658 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -208,25 +208,6 @@ addUseDeviceClause(Fortran::lower::AbstractConverter 
&converter,
 useDeviceSymbols.push_back(object.id());
 }
 
-static void convertLoopBounds(Fortran::lower::AbstractConverter &converter,
-  mlir::Location loc,
-  llvm::SmallVectorImpl &lowerBound,
-  llvm::SmallVectorImpl &upperBound,
-  llvm::SmallVectorImpl &step,
-  std::size_t loopVarTypeSize) {
-  fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
-  // The types of lower bound, upper bound, and step are converted into the
-  // type of the loop variable if necessary.
-  mlir::Type loopVarType = getLoopVarType(converter, loopVarTypeSize);
-  for (unsigned it = 0; it < (unsigned)lowerBound.size(); it++) {
-lowerBound[it] =
-firOpBuilder.createConvert(loc, loopVarType, lowerBound[it]);
-upperBound[it] =
-firOpBuilder.createConvert(loc, loopVarType, upperBound[it]);
-step[it] = firOpBuilder.createConvert(loc, loopVarType, step[it]);
-  }
-}
-
 
//===--===//
 // ClauseProcessor unique clauses
 
//===--===//
@@ -236,7 +217,8 @@ bool ClauseProcessor::processCollapse(
 llvm::SmallVectorImpl &lowerBound,
 llvm::SmallVectorImpl &upperBound,
 llvm::SmallVectorImpl &step,
-llvm::SmallVectorImpl &iv) const {
+llvm::SmallVectorImpl &iv,
+std::size_t &loopVarTypeSize) const {
   bool found = false;
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
 
@@ -254,7 +236,7 @@ bool ClauseProcessor::processCollapse(
 found = true;
   }
 
-  std::size_t loopVarTypeSize = 0;
+  loopVarTypeSize = 0;
   do {
 Fortran::lower::pft::Evaluation *doLoop =
 &doConstructEval->getFirstNestedEvaluation();
@@ -285,9 +267,6 @@ bool ClauseProcessor::processCollapse(
 &*std::next(doConstructEval->getNestedEvaluations().begin());
   } while (collapseValue > 0);
 
-  convertLoopBounds(converter, currentLocation, lowerBound, upperBound, step,
-loopVarTypeSize);
-
   return found;
 }
 
@@ -928,7 +907,6 @@ bool ClauseProcessor::processMap(
 bool ClauseProcessor::processReduction(
 mlir::Location currentLocation,
 llvm::SmallVectorImpl &reductionVars,
-llvm::SmallVectorImpl &reductionTypes,
 llvm::SmallVectorImpl &reductionDeclSymbols,
 llvm::SmallVectorImpl 
*reductionSymbols)
 const {
@@ -938,9 +916,6 @@ bool ClauseProcessor::processReduction(
 ReductionProcessor rp;
 rp.addReductionDecl(currentLocation, converter, clause, reductionVars,
 reductionDeclSymbols, reductionSymbols);
-reductionTypes.reserve(reductionVars.size());
-llvm::transform(reductionVars, std::back_inserter(reductionTypes),
-[](mlir::Value v) { return v.getType(); });
   });
 }
 

diff  --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 3f50909fe73abd..3f6adcce8ae877 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -56,12 +56,14 @@ class ClauseProcessor {
 clauses(makeList(clauses, semaCtx)) {}
 
   // 'Unique' clauses: They can appear at most once in the clause list.
-  bool processCollapse(
-  mlir::Location currentLocation, Fortran::lower::pft::Evaluation &eval,
-  llvm::SmallVectorImpl &lowerBound,
-  llvm::SmallVectorImpl &upperBound,
-  llvm::SmallVectorImpl &step,
-  llvm::SmallVectorImpl &iv) const;
+  bool
+  processCollapse(mlir::Location currentLocation,
+  Fortran::lower::pft::Evaluation &eval,
+  llvm::SmallVectorImpl &lowerBound,
+  llvm::SmallVectorImpl &upperBound,
+  llvm::SmallVectorImpl &ste

[llvm-branch-commits] [llvm] release/18.x: workflows: Fix baseline version for llvm abi checks (#85166) (PR #85789)

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

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

Backport d93363a0e803a9fb2889ff03237f4e93aacf0108

Requested by: @tstellar

>From ecc22d27e5b81f87f9e3edbf8981c67d6b154843 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Tue, 19 Mar 2024 06:55:10 -0700
Subject: [PATCH] workflows: Fix baseline version for llvm abi checks (#85166)

The baseline version calculations was assuming the minor release would
always be 0.

(cherry picked from commit d93363a0e803a9fb2889ff03237f4e93aacf0108)
---
 .github/workflows/llvm-tests.yml | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/llvm-tests.yml b/.github/workflows/llvm-tests.yml
index 127628d76f1913..64d60bc3da45e1 100644
--- a/.github/workflows/llvm-tests.yml
+++ b/.github/workflows/llvm-tests.yml
@@ -42,6 +42,7 @@ jobs:
   BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
   ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
   BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
+  BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }}
   LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
   LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
   LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
@@ -58,7 +59,14 @@ jobs:
   - name: Setup Variables
 id: vars
 run: |
-  if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 ] || [ 
${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
+  # C++ ABI:
+  # 18.1.0 we aren't doing ABI checks.
+  # 18.1.1 We want to check 18.1.0.
+  # C ABI:
+  # 18.1.0 We want to check 17.0.x
+  # 18.1.1 We want to check 18.1.0
+  echo "BASELINE_VERSION_MINOR=1" >> "$GITHUB_OUTPUT"
+  if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
 {
   echo "BASELINE_VERSION_MAJOR=$(( ${{ 
steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))"
   echo "ABI_HEADERS=llvm-c"
@@ -82,7 +90,7 @@ jobs:
 include:
   - name: build-baseline
 llvm_version_major: ${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
-ref: llvmorg-${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
+ref: llvmorg-${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MINOR }}.0
 repo: llvm/llvm-project
   - name: build-latest
 llvm_version_major: ${{ 
needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}

___
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] release/18.x: workflows: Fix baseline version for llvm abi checks (#85166) (PR #85789)

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

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/85789
___
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] release/18.x: workflows: Fix baseline version for llvm abi checks (#85166) (PR #85789)

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

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/85789
___
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] release/18.x: workflows: Fix baseline version for llvm abi checks (#85166) (PR #85789)

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

llvmbot wrote:




@llvm/pr-subscribers-github-workflow

Author: None (llvmbot)


Changes

Backport d93363a0e803a9fb2889ff03237f4e93aacf0108

Requested by: @tstellar

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


1 Files Affected:

- (modified) .github/workflows/llvm-tests.yml (+10-2) 


``diff
diff --git a/.github/workflows/llvm-tests.yml b/.github/workflows/llvm-tests.yml
index 127628d76f1913..64d60bc3da45e1 100644
--- a/.github/workflows/llvm-tests.yml
+++ b/.github/workflows/llvm-tests.yml
@@ -42,6 +42,7 @@ jobs:
   BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
   ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
   BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
+  BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }}
   LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
   LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
   LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
@@ -58,7 +59,14 @@ jobs:
   - name: Setup Variables
 id: vars
 run: |
-  if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 ] || [ 
${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
+  # C++ ABI:
+  # 18.1.0 we aren't doing ABI checks.
+  # 18.1.1 We want to check 18.1.0.
+  # C ABI:
+  # 18.1.0 We want to check 17.0.x
+  # 18.1.1 We want to check 18.1.0
+  echo "BASELINE_VERSION_MINOR=1" >> "$GITHUB_OUTPUT"
+  if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
 {
   echo "BASELINE_VERSION_MAJOR=$(( ${{ 
steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))"
   echo "ABI_HEADERS=llvm-c"
@@ -82,7 +90,7 @@ jobs:
 include:
   - name: build-baseline
 llvm_version_major: ${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
-ref: llvmorg-${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
+ref: llvmorg-${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.${{ 
needs.abi-dump-setup.outputs.BASELINE_VERSION_MINOR }}.0
 repo: llvm/llvm-project
   - name: build-latest
 llvm_version_major: ${{ 
needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}

``




https://github.com/llvm/llvm-project/pull/85789
___
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] [libc++][TZDB] Improves time zone format specifiers. (PR #85797)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/85797

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone 
information. The function time_put<_CharT>::put() does not have proper time 
zone support, therefore it's a manual implementation.

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

>From 6327aeec1a6adfb1be3dcb95aa1f0ad6204213f4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Improves time zone format specifiers.

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone
information. The function time_put<_CharT>::put() does not have proper
time zone support, therefore it's a manual implementation.

Fixes https://github.com/llvm/llvm-project/issues/78184
---
 libcxx/include/__chrono/formatter.h   | 50 ++-
 .../time.syn/formatter.file_time.pass.cpp | 39 ++-
 .../time/time.syn/formatter.sys_time.pass.cpp | 39 ++-
 3 files changed, 56 insertions(+), 72 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index b64cae529a294d..8b8592041a1fb9 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP___CHRONO_FORMATTER_H
 #define _LIBCPP___CHRONO_FORMATTER_H
 
+#include <__algorithm/ranges_copy.h>
 #include <__chrono/calendar.h>
 #include <__chrono/concepts.h>
 #include <__chrono/convert_to_tm.h>
@@ -170,10 +171,45 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_century(basic_stringstream<_CharT>& __sstr,
   __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
 }
 
+// Implements the %z format specifier according to [tab:time.format.spec], 
where
+// '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same,
+// so there is no need to distinguish between them.)
+template 
+_LIBCPP_HIDE_FROM_ABI void
+__format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds 
__offset, bool __modifier) {
+  if (__offset < 0s) {
+__sstr << _CharT('-');
+__offset = -__offset;
+  } else
+__sstr << _CharT('+');
+
+  chrono::hh_mm_ss __hms{__offset};
+  std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  if (__modifier)
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
+  else
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+}
+
+// Helper to store the time zone information needed for formatting.
+struct _LIBCPP_HIDE_FROM_ABI __time_zone {
+  // Typically these abbreviations as short and fit in the string's internal
+  // buffer.
+  string __abbrev{"UTC"};
+  chrono::seconds __offset{0};
+};
+
+template 
+_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
+  __time_zone __result;
+  return __result;
+}
+
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
 basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
+  __time_zone __z = __formatter::__convert_to_time_zone(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
 if (*__it == _CharT('%')) {
@@ -296,9 +332,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
   } break;
 
+  case _CharT('z'):
+__formatter::__format_zone_offset(__sstr, __z.__offset, false);
+break;
+
   case _CharT('Z'):
-// TODO FMT Add

[llvm-branch-commits] [libcxx] [libc++][TZDB] Improves time zone format specifiers. (PR #85797)

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

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone 
information. The function time_put<_CharT>::put() does not have proper 
time zone support, therefore it's a manual implementation.

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

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


3 Files Affected:

- (modified) libcxx/include/__chrono/formatter.h (+48-2) 
- (modified) libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp (+4-35) 
- (modified) libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp (+4-35) 


``diff
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index b64cae529a294d..8b8592041a1fb9 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP___CHRONO_FORMATTER_H
 #define _LIBCPP___CHRONO_FORMATTER_H
 
+#include <__algorithm/ranges_copy.h>
 #include <__chrono/calendar.h>
 #include <__chrono/concepts.h>
 #include <__chrono/convert_to_tm.h>
@@ -170,10 +171,45 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_century(basic_stringstream<_CharT>& __sstr,
   __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
 }
 
+// Implements the %z format specifier according to [tab:time.format.spec], 
where
+// '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same,
+// so there is no need to distinguish between them.)
+template 
+_LIBCPP_HIDE_FROM_ABI void
+__format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds 
__offset, bool __modifier) {
+  if (__offset < 0s) {
+__sstr << _CharT('-');
+__offset = -__offset;
+  } else
+__sstr << _CharT('+');
+
+  chrono::hh_mm_ss __hms{__offset};
+  std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  if (__modifier)
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
+  else
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+}
+
+// Helper to store the time zone information needed for formatting.
+struct _LIBCPP_HIDE_FROM_ABI __time_zone {
+  // Typically these abbreviations as short and fit in the string's internal
+  // buffer.
+  string __abbrev{"UTC"};
+  chrono::seconds __offset{0};
+};
+
+template 
+_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
+  __time_zone __result;
+  return __result;
+}
+
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
 basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
+  __time_zone __z = __formatter::__convert_to_time_zone(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
 if (*__it == _CharT('%')) {
@@ -296,9 +332,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
   } break;
 
+  case _CharT('z'):
+__formatter::__format_zone_offset(__sstr, __z.__offset, false);
+break;
+
   case _CharT('Z'):
-// TODO FMT Add proper timezone support.
-__sstr << _LIBCPP_STATICALLY_WIDEN(_CharT, "UTC");
+// __abbrev is always a char so the copy may convert.
+ranges::copy(__z.__abbrev, std::ostreambuf_iterator<_CharT>{__sstr});
 break;
 
   case _CharT('O'):
@@ -314,9 +354,15 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 break;
   }
 }
+
+// Oz produces the same output as Ez below.
 [[fallthrough]];
   case _CharT('E'):
 ++__it;
+if (*__it == 'z') {
+  __formatter::__format_zone_offset(__sstr, __z.__offset, true);
+  break;
+}
 [[fallthrough]];
   default:
 __facet.put(
diff --git a/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp 
b/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp
index b07282593d759c..f57841cca86293 100644
--- a/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp
+++ b/libcxx/test/std/time/time.syn/form

[llvm-branch-commits] [llvm] release/18.x: workflows: Fix baseline version for llvm abi checks (#85166) (PR #85789)

2024-03-19 Thread Nikita Popov via llvm-branch-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/85789
___
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] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

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

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

Backport d66121d74a458e098511b9de920d815440acaa1b

Requested by: @sunfishcode

>From b6593858043e3e83101e1e7cc15a850f899a7c9c Mon Sep 17 00:00:00 2001
From: Alex Crichton 
Date: Mon, 18 Mar 2024 19:55:34 -0500
Subject: [PATCH] [WebAssembly] Change the default linker for `wasm32-wasip2`
 (#84569)

This commit changes the default linker in the WebAssembly toolchain for
the `wasm32-wasip2` target. This target is being added to the
WebAssembly/wasi-sdk and WebAssembly/wasi-libc projects to target the
Component Model by default, in contrast with the preexisting
`wasm32-wasi` target (in the process of being renamed to
`wasm32-wasip1`) which outputs a core WebAssembly module by default.

The `wasm-component-ld` project currently lives in my GitHub account at
https://github.com/alexcrichton/wasm-component-ld and isn't necessarily
"official" yet, but it's expected to continue to evolve as the
`wasm32-wasip2` target continues to shape up and evolve.

(cherry picked from commit d66121d74a458e098511b9de920d815440acaa1b)
---
 clang/lib/Driver/ToolChains/WebAssembly.cpp | 27 +++--
 clang/lib/Driver/ToolChains/WebAssembly.h   |  2 +-
 clang/test/Driver/wasm-toolchain.c  | 24 ++
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 57f4600727ec89..0b16b660364f07 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -44,8 +44,15 @@ std::string wasm::Linker::getLinkerPath(const ArgList &Args) 
const {
   llvm::sys::fs::can_execute(UseLinker))
 return std::string(UseLinker);
 
-  // Accept 'lld', and 'ld' as aliases for the default linker
-  if (UseLinker != "lld" && UseLinker != "ld")
+  // Interpret 'lld' as explicitly requesting `wasm-ld`, so look for that
+  // linker. Note that for `wasm32-wasip2` this overrides the default 
linker
+  // of `wasm-component-ld`.
+  if (UseLinker == "lld") {
+return ToolChain.GetProgramPath("wasm-ld");
+  }
+
+  // Allow 'ld' as an alias for the default linker
+  if (UseLinker != "ld")
 ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
 << A->getAsString(Args);
 }
@@ -73,6 +80,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
 
+  // On `wasip2` the default linker is `wasm-component-ld` which wraps the
+  // execution of `wasm-ld`. Find `wasm-ld` and pass it as an argument of where
+  // to find it to avoid it needing to hunt and rediscover or search `PATH` for
+  // where it is.
+  if (llvm::sys::path::stem(Linker).ends_with_insensitive(
+  "wasm-component-ld")) {
+CmdArgs.push_back("--wasm-ld-path");
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetProgramPath("wasm-ld")));
+  }
+
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
@@ -221,6 +238,12 @@ WebAssembly::WebAssembly(const Driver &D, const 
llvm::Triple &Triple,
   }
 }
 
+const char *WebAssembly::getDefaultLinker() const {
+  if (getOS() == "wasip2")
+return "wasm-component-ld";
+  return "wasm-ld";
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.h 
b/clang/lib/Driver/ToolChains/WebAssembly.h
index ae60f464c10818..76e0ca39bd748d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.h
+++ b/clang/lib/Driver/ToolChains/WebAssembly.h
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly final : public 
ToolChain {
llvm::opt::ArgStringList &CmdArgs) const override;
   SanitizerMask getSupportedSanitizers() const override;
 
-  const char *getDefaultLinker() const override { return "wasm-ld"; }
+  const char *getDefaultLinker() const override;
 
   CXXStdlibType GetDefaultCXXStdlibType() const override {
 return ToolChain::CST_Libcxx;
diff --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index f950283ec42aa0..88590a3ba4c453 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -197,3 +197,27 @@
 // RUN: not %clang -### %s --target=wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
 // PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with 
'-mno-mutable-globals'
+
+// Test that `wasm32-wasip2` invokes the `wasm-component-ld` linker by default
+// instead of `wasm-ld`.
+
+// RUN: %clang -### -O2 --target=wasm32-wasip2 %s --sysroot /foo 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_WASIP2 %s
+// LINK_WA

[llvm-branch-commits] [clang] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

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

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/85802
___
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] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

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

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/85802
___
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] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

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

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: None (llvmbot)


Changes

Backport d66121d74a458e098511b9de920d815440acaa1b

Requested by: @sunfishcode

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


3 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (+25-2) 
- (modified) clang/lib/Driver/ToolChains/WebAssembly.h (+1-1) 
- (modified) clang/test/Driver/wasm-toolchain.c (+24) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 57f4600727ec89..0b16b660364f07 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -44,8 +44,15 @@ std::string wasm::Linker::getLinkerPath(const ArgList &Args) 
const {
   llvm::sys::fs::can_execute(UseLinker))
 return std::string(UseLinker);
 
-  // Accept 'lld', and 'ld' as aliases for the default linker
-  if (UseLinker != "lld" && UseLinker != "ld")
+  // Interpret 'lld' as explicitly requesting `wasm-ld`, so look for that
+  // linker. Note that for `wasm32-wasip2` this overrides the default 
linker
+  // of `wasm-component-ld`.
+  if (UseLinker == "lld") {
+return ToolChain.GetProgramPath("wasm-ld");
+  }
+
+  // Allow 'ld' as an alias for the default linker
+  if (UseLinker != "ld")
 ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
 << A->getAsString(Args);
 }
@@ -73,6 +80,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
 
+  // On `wasip2` the default linker is `wasm-component-ld` which wraps the
+  // execution of `wasm-ld`. Find `wasm-ld` and pass it as an argument of where
+  // to find it to avoid it needing to hunt and rediscover or search `PATH` for
+  // where it is.
+  if (llvm::sys::path::stem(Linker).ends_with_insensitive(
+  "wasm-component-ld")) {
+CmdArgs.push_back("--wasm-ld-path");
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetProgramPath("wasm-ld")));
+  }
+
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
@@ -221,6 +238,12 @@ WebAssembly::WebAssembly(const Driver &D, const 
llvm::Triple &Triple,
   }
 }
 
+const char *WebAssembly::getDefaultLinker() const {
+  if (getOS() == "wasip2")
+return "wasm-component-ld";
+  return "wasm-ld";
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.h 
b/clang/lib/Driver/ToolChains/WebAssembly.h
index ae60f464c10818..76e0ca39bd748d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.h
+++ b/clang/lib/Driver/ToolChains/WebAssembly.h
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly final : public 
ToolChain {
llvm::opt::ArgStringList &CmdArgs) const override;
   SanitizerMask getSupportedSanitizers() const override;
 
-  const char *getDefaultLinker() const override { return "wasm-ld"; }
+  const char *getDefaultLinker() const override;
 
   CXXStdlibType GetDefaultCXXStdlibType() const override {
 return ToolChain::CST_Libcxx;
diff --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index f950283ec42aa0..88590a3ba4c453 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -197,3 +197,27 @@
 // RUN: not %clang -### %s --target=wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
 // PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with 
'-mno-mutable-globals'
+
+// Test that `wasm32-wasip2` invokes the `wasm-component-ld` linker by default
+// instead of `wasm-ld`.
+
+// RUN: %clang -### -O2 --target=wasm32-wasip2 %s --sysroot /foo 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_WASIP2 %s
+// LINK_WASIP2: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_WASIP2: wasm-component-ld{{.*}}" "-L/foo/lib/wasm32-wasip2" "crt1.o" 
"[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// Test that on `wasm32-wasip2` the `wasm-component-ld` programs is told where
+// to find `wasm-ld` by default.
+
+// RUN: %clang -### -O2 --target=wasm32-wasip2 %s --sysroot /foo 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_WASIP2_FIND_WASMLD %s
+// LINK_WASIP2_FIND_WASMLD: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_WASIP2_FIND_WASMLD: wasm-component-ld{{.*}}" {{.*}} "--wasm-ld-path" 
"{{.*}}wasm-ld{{.*}}" {{.*}} "[[temp]]" {{.*}}
+
+// If `wasm32-wasip2` is configured with `wasm-ld` as a linker then don't pass
+// the `--wasm-ld-path` flag.
+
+// RUN: %clang -### -O2 --target=wasm32-wasip2 -fuse-ld=lld %s --sysroot /foo 
2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_WASIP2_USE_WASMLD 

[llvm-branch-commits] [clang] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

2024-03-19 Thread Dan Gohman via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/85802
___
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] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Christian Ulmann via llvm-branch-commits

https://github.com/Dinistro created 
https://github.com/llvm/llvm-project/pull/85813

This commit relaxes the assumption of type consistency for LLVM dialect load 
and store operations in SROA. Instead, there is now a check that loads and 
stores are in the bounds specified by the sub-slot they access.

This commit additionally removes the corresponding patterns from the type 
consistency pass, as they are no longer necessary.

Note: It will be necessary to extend Mem2Reg with the logic for differently 
sized accesses as well. This is non-the-less a strict upgrade for productive 
flows, as the type consistency pass can produce invalid IR for some odd cases.

>From 2a1b83dae932b23d7160e0b29f6d3b0ff173bb46 Mon Sep 17 00:00:00 2001
From: Christian Ulmann 
Date: Tue, 19 Mar 2024 15:33:34 +
Subject: [PATCH] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses

This commit relaxes the assumption of type consistency for LLVM dialect
load and store operations in SROA. Instead, there is now a check that
loads and stores are in the bounds specified by the sub-slot they
access.

This commit additionally removes the corresponding patterns from the
type consistency pass, as they are no longer necessary.
---
 mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td   |   6 +-
 .../LLVMIR/Transforms/TypeConsistency.h   |  12 --
 .../mlir/Interfaces/MemorySlotInterfaces.h|   4 +-
 mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp | 111 --
 .../LLVMIR/Transforms/TypeConsistency.cpp | 101 -
 .../Dialect/MemRef/IR/MemRefMemorySlot.cpp|   7 +-
 mlir/test/Dialect/LLVMIR/sroa.mlir|  91 
 .../test/Dialect/LLVMIR/type-consistency.mlir | 140 ++
 8 files changed, 209 insertions(+), 263 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index b523374f6c06b5..f8f9264b3889be 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -323,7 +323,8 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
 }
 
 def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
-[DeclareOpInterfaceMethods,
+[DeclareOpInterfaceMethods,
+ DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods]> {
   dag args = (ins LLVM_AnyPointer:$addr,
@@ -402,7 +403,8 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
 }
 
 def LLVM_StoreOp : LLVM_MemAccessOpBase<"store",
-[DeclareOpInterfaceMethods,
+[DeclareOpInterfaceMethods,
+ DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods]> {
   dag args = (ins LLVM_LoadableType:$value,
diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h 
b/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
index b32ac56d7079c6..cacb241bfd7a10 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
@@ -29,18 +29,6 @@ namespace LLVM {
 /// interpret pointee types as consistently as possible.
 std::unique_ptr createTypeConsistencyPass();
 
-/// Transforms uses of pointers to a whole struct to uses of pointers to the
-/// first element of a struct. This is achieved by inserting a GEP to the first
-/// element when possible.
-template 
-class AddFieldGetterToStructDirectUse : public OpRewritePattern {
-public:
-  using OpRewritePattern::OpRewritePattern;
-
-  LogicalResult matchAndRewrite(User user,
-PatternRewriter &rewriter) const override;
-};
-
 /// Canonicalizes GEPs of which the base type and the pointer's type hint do 
not
 /// match. This is done by replacing the original GEP into a GEP with the type
 /// hint as a base type when an element of the hinted type aligns with the
diff --git a/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h 
b/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
index 56e5e96aecd13c..87db1aaf39dea2 100644
--- a/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
+++ b/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
@@ -26,8 +26,8 @@ struct MemorySlot {
 
 /// Memory slot attached with information about its destructuring procedure.
 struct DestructurableMemorySlot : public MemorySlot {
-  /// Maps an index within the memory slot to the type of the pointer that
-  /// will be generated to access the element directly.
+  /// Maps an index within the memory slot to the element type of the pointer
+  /// that will be generated to access the element directly.
   DenseMap elementPtrs;
 };
 
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
index 00b4559658fd4d..f9662789025764 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
@@ -13,10 +13,8 @@
 
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
-#include "mlir/IR/IRMapping.h"

[llvm-branch-commits] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

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

llvmbot wrote:



@llvm/pr-subscribers-mlir-llvm

@llvm/pr-subscribers-mlir-memref

Author: Christian Ulmann (Dinistro)


Changes

This commit relaxes the assumption of type consistency for LLVM dialect load 
and store operations in SROA. Instead, there is now a check that loads and 
stores are in the bounds specified by the sub-slot they access.

This commit additionally removes the corresponding patterns from the type 
consistency pass, as they are no longer necessary.

Note: It will be necessary to extend Mem2Reg with the logic for differently 
sized accesses as well. This is non-the-less a strict upgrade for productive 
flows, as the type consistency pass can produce invalid IR for some odd cases.

---

Patch is 33.21 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/85813.diff


8 Files Affected:

- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td (+4-2) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h 
(-12) 
- (modified) mlir/include/mlir/Interfaces/MemorySlotInterfaces.h (+2-2) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+98-13) 
- (modified) mlir/lib/Dialect/LLVMIR/Transforms/TypeConsistency.cpp (-101) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefMemorySlot.cpp (+2-5) 
- (modified) mlir/test/Dialect/LLVMIR/sroa.mlir (+91) 
- (modified) mlir/test/Dialect/LLVMIR/type-consistency.mlir (+12-128) 


``diff
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index b523374f6c06b5..f8f9264b3889be 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -323,7 +323,8 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
 }
 
 def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
-[DeclareOpInterfaceMethods,
+[DeclareOpInterfaceMethods,
+ DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods]> {
   dag args = (ins LLVM_AnyPointer:$addr,
@@ -402,7 +403,8 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
 }
 
 def LLVM_StoreOp : LLVM_MemAccessOpBase<"store",
-[DeclareOpInterfaceMethods,
+[DeclareOpInterfaceMethods,
+ DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods]> {
   dag args = (ins LLVM_LoadableType:$value,
diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h 
b/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
index b32ac56d7079c6..cacb241bfd7a10 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h
@@ -29,18 +29,6 @@ namespace LLVM {
 /// interpret pointee types as consistently as possible.
 std::unique_ptr createTypeConsistencyPass();
 
-/// Transforms uses of pointers to a whole struct to uses of pointers to the
-/// first element of a struct. This is achieved by inserting a GEP to the first
-/// element when possible.
-template 
-class AddFieldGetterToStructDirectUse : public OpRewritePattern {
-public:
-  using OpRewritePattern::OpRewritePattern;
-
-  LogicalResult matchAndRewrite(User user,
-PatternRewriter &rewriter) const override;
-};
-
 /// Canonicalizes GEPs of which the base type and the pointer's type hint do 
not
 /// match. This is done by replacing the original GEP into a GEP with the type
 /// hint as a base type when an element of the hinted type aligns with the
diff --git a/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h 
b/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
index 56e5e96aecd13c..87db1aaf39dea2 100644
--- a/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
+++ b/mlir/include/mlir/Interfaces/MemorySlotInterfaces.h
@@ -26,8 +26,8 @@ struct MemorySlot {
 
 /// Memory slot attached with information about its destructuring procedure.
 struct DestructurableMemorySlot : public MemorySlot {
-  /// Maps an index within the memory slot to the type of the pointer that
-  /// will be generated to access the element directly.
+  /// Maps an index within the memory slot to the element type of the pointer
+  /// that will be generated to access the element directly.
   DenseMap elementPtrs;
 };
 
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
index 00b4559658fd4d..f9662789025764 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
@@ -13,10 +13,8 @@
 
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
-#include "mlir/IR/IRMapping.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/PatternMatch.h"
-#include "mlir/IR/ValueRange.h"
 #include "mlir/Interfaces/DataLayoutInterfaces.h"
 #include "mlir/Interfaces/MemorySlotInterfaces.h"
 #include "llvm/ADT/STLExtras.h"
@@ -71,12 +69,8 @@ SmallVector 
LLVM::AllocaOp::getDestructurableSlots() {
   if (!destructuredType)
 retu

[llvm-branch-commits] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi created 
https://github.com/llvm/llvm-project/pull/85817

When adding fixups for RISCV_TLSDESC_ADD_LO and RISCV_TLSDESC_LOAD_LO,
the local label added for RISCV TLSDESC relocations have STT_TLS set,
which is incorrect. Instead, these labels should have `STT_NOTYPE`.

This patch stops adding such fixups and avoid setting the STT_TLS on
these symbols. Failing to do so can cause LLD to emit an error `has an
STT_TLS symbol but doesn't have an SHF_TLS section`. We additionally,
adjust how LLD services these relocations to avoid errors with
incompatible relocation and sybol types.



___
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] Fix handling of RISCV TLSDESC relocations (PR #85817)

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

llvmbot wrote:




@llvm/pr-subscribers-lld-elf

Author: Paul Kirth (ilovepi)


Changes

When adding fixups for RISCV_TLSDESC_ADD_LO and RISCV_TLSDESC_LOAD_LO,
the local label added for RISCV TLSDESC relocations have STT_TLS set,
which is incorrect. Instead, these labels should have `STT_NOTYPE`.

This patch stops adding such fixups and avoid setting the STT_TLS on
these symbols. Failing to do so can cause LLD to emit an error `has an
STT_TLS symbol but doesn't have an SHF_TLS section`. We additionally,
adjust how LLD services these relocations to avoid errors with
incompatible relocation and sybol types.


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


4 Files Affected:

- (modified) lld/ELF/Relocations.cpp (+7-2) 
- (modified) lld/test/ELF/riscv-tlsdesc-relax.s (+8) 
- (modified) lld/test/ELF/riscv-tlsdesc.s (+15-9) 
- (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp (-2) 


``diff
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 619fbaf5dc5452..241a5b82d35f4a 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,7 +1280,6 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
-
   if (oneof(expr) &&
   config->shared) {
@@ -1480,7 +1479,13 @@ template  void 
RelocationScanner::scanOne(RelTy *&i) {
 
   // Process TLS relocations, including TLS optimizations. Note that
   // R_TPREL and R_TPREL_NEG relocations are resolved in processAux.
-  if (sym.isTls()) {
+  if (sym.isTls() ||
+  // These RISCV TLSDESC relocations reference a local symbol that won't be
+  // a TLS symbol, but we need to process them in handleTlsRelocation the
+  // same as other TLS relocations.
+  (config->emachine == EM_RISCV &&
+   (type == R_RISCV_TLSDESC_CALL || type == R_RISCV_TLSDESC_LOAD_LO12 ||
+type == R_RISCV_TLSDESC_ADD_LO12))) {
 if (unsigned processed =
 handleTlsRelocation(type, sym, *sec, offset, addend, expr)) {
   i += processed - 1;
diff --git a/lld/test/ELF/riscv-tlsdesc-relax.s 
b/lld/test/ELF/riscv-tlsdesc-relax.s
index fb24317e6535ca..5718d4175be113 100644
--- a/lld/test/ELF/riscv-tlsdesc-relax.s
+++ b/lld/test/ELF/riscv-tlsdesc-relax.s
@@ -33,12 +33,14 @@
 # GD64-NEXT: c.add   a0, tp
 # GD64-NEXT: jal {{.*}} 
 ## &.got[c]-. = 0x20c0+8 - 0x1020 = 0x10a8
+# GD64-LABEL: <.Ltlsdesc_hi1>:
 # GD64-NEXT:   1020: auipc   a4, 0x1
 # GD64-NEXT: ld  a5, 0xa8(a4)
 # GD64-NEXT: addia0, a4, 0xa8
 # GD64-NEXT: jalrt0, 0x0(a5)
 # GD64-NEXT: c.add   a0, tp
 ## &.got[c]-. = 0x20c0+8 - 0x1032 = 0x1096
+# GD64-LABEL: <.Ltlsdesc_hi2>:
 # GD64-NEXT:   1032: auipc   a6, 0x1
 # GD64-NEXT: ld  a7, 0x96(a6)
 # GD64-NEXT: addia0, a6, 0x96
@@ -64,6 +66,7 @@
 # LE64-NEXT: jal {{.*}} 
 # LE64-NEXT: R_RISCV_JAL foo
 # LE64-NEXT: R_RISCV_RELAX *ABS*
+# LE64-LABEL: <.Ltlsdesc_hi1>:
 # LE64-NEXT: addia0, zero, 0x7ff
 # LE64-NEXT: R_RISCV_TLSDESC_HI20 b
 # LE64-NEXT: R_RISCV_RELAX *ABS*
@@ -71,6 +74,7 @@
 # LE64-NEXT: R_RISCV_TLSDESC_ADD_LO12 .Ltlsdesc_hi1
 # LE64-NEXT: R_RISCV_TLSDESC_CALL .Ltlsdesc_hi1
 # LE64-NEXT: c.add   a0, tp
+# LE64-LABEL: <.Ltlsdesc_hi2>:
 # LE64-NEXT: addizero, zero, 0x0
 # LE64-NEXT: R_RISCV_TLSDESC_HI20 b
 # LE64-NEXT: addizero, zero, 0x0
@@ -93,9 +97,11 @@
 # LE64A-NEXT: addia0, a0, -0x479
 # LE64A-NEXT: c.add   a0, tp
 # LE64A-NEXT: jal {{.*}} 
+# LE64A-LABEL: <.Ltlsdesc_hi1>:
 # LE64A-NEXT: lui a0, 0x2
 # LE64A-NEXT: addia0, a0, -0x479
 # LE64A-NEXT: c.add   a0, tp
+# LE64A-LABEL: <.Ltlsdesc_hi2>:
 # LE64A-NEXT: addizero, zero, 0x0
 # LE64A-NEXT: addizero, zero, 0x0
 # LE64A-NEXT: lui a0, 0x2
@@ -115,10 +121,12 @@
 # IE64-NEXT: c.add   a0, tp
 # IE64-NEXT: jal {{.*}} 
 ## &.got[c]-. = 0x120e0+8 - 0x11018 = 0x10d0
+# IE64-LABEL: <.Ltlsdesc_hi1>:
 # IE64-NEXT:  11018: auipc   a0, 0x1
 # IE64-NEXT: ld  a0, 0xd0(a0)
 # IE64-NEXT: c.add   a0, tp
 ## &.got[c]-. = 0x120e0+8 - 0x1102a = 0x10be
+# IE64-LABEL: <.Ltlsdesc_hi2>:
 # IE64-NEXT: addizero, zero, 0x0
 # IE64-NEXT: addizero, zero, 0x0
 # IE64-NEXT:  1102a: auipc   a0, 0x1
diff --git a/lld/test/ELF/riscv-tlsdesc.s b/lld/test/ELF/riscv-tlsdesc.s
index a893d098344d0a..b181f0e9a17a48 100644
--- a/lld/test/ELF/riscv-tlsdesc.s
+++ b/lld/test/ELF/riscv-tlsdesc.s
@@ -30,10 +30,10 @@
 # RUN: llvm-objdump --no-show-raw-insn -M no-aliases -h -d a.32.ie | FileCheck 
%s --check-prefix=IE32
 
 # RUN: llvm-mc -triple=riscv64 --position-independent -filetype=obj d.s

[llvm-branch-commits] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits


@@ -1280,7 +1280,6 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
-

ilovepi wrote:

will remove whitespace diff.

https://github.com/llvm/llvm-project/pull/85817
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

___
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] 48ebe1b - Revert "[dsymutil] Remove support for obfuscated bitcode (#85713)"

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

Author: Andres Villegas
Date: 2024-03-19T10:15:43-07:00
New Revision: 48ebe1b0a23d5d692db931afa214ac964cf06bfd

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

LOG: Revert "[dsymutil] Remove support for obfuscated bitcode (#85713)"

This reverts commit 43a2ec483fe08064b53a6293682e9bab97df61a0.

Added: 
llvm/test/tools/dsymutil/ARM/obfuscated.test
llvm/test/tools/dsymutil/Inputs/obfuscated.2.arm64
llvm/test/tools/dsymutil/Inputs/obfuscated.2.map
llvm/test/tools/dsymutil/Inputs/obfuscated.arm64
llvm/test/tools/dsymutil/Inputs/obfuscated.map
llvm/tools/dsymutil/SymbolMap.cpp
llvm/tools/dsymutil/SymbolMap.h

Modified: 
llvm/docs/CommandGuide/dsymutil.rst
llvm/include/llvm/CodeGen/NonRelocatableStringpool.h
llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
llvm/lib/CodeGen/NonRelocatableStringpool.cpp
llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp
llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h
llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h
llvm/lib/DWARFLinker/Parallel/OutputSections.h
llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h
llvm/test/tools/dsymutil/cmdline.test
llvm/tools/dsymutil/CMakeLists.txt
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
llvm/tools/dsymutil/LinkUtils.h
llvm/tools/dsymutil/MachOUtils.cpp
llvm/tools/dsymutil/MachOUtils.h
llvm/tools/dsymutil/Options.td
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp

Removed: 




diff  --git a/llvm/docs/CommandGuide/dsymutil.rst 
b/llvm/docs/CommandGuide/dsymutil.rst
index e3f2f33224b015..af9d7f16b36196 100644
--- a/llvm/docs/CommandGuide/dsymutil.rst
+++ b/llvm/docs/CommandGuide/dsymutil.rst
@@ -140,6 +140,10 @@ OPTIONS
  (in bytes) to the linked dSYM. The table is sorted by the output size listing
  the object files with the largest contribution first.
 
+.. option:: --symbol-map 
+
+ Update the existing dSYMs inplace using symbol map specified.
+
 .. option:: -s, --symtab
 
  Dumps the symbol table found in *executable* or object file(s) and exits.

diff  --git a/llvm/include/llvm/CodeGen/NonRelocatableStringpool.h 
b/llvm/include/llvm/CodeGen/NonRelocatableStringpool.h
index 4b8eed7bdb1b53..3dc0731f5a04ee 100644
--- a/llvm/include/llvm/CodeGen/NonRelocatableStringpool.h
+++ b/llvm/include/llvm/CodeGen/NonRelocatableStringpool.h
@@ -27,7 +27,10 @@ class NonRelocatableStringpool {
   /// order.
   using MapTy = StringMap;
 
-  NonRelocatableStringpool(bool PutEmptyString = false) {
+  NonRelocatableStringpool(
+  std::function Translator = nullptr,
+  bool PutEmptyString = false)
+  : Translator(Translator) {
 if (PutEmptyString)
   getEntry("");
   }
@@ -56,6 +59,7 @@ class NonRelocatableStringpool {
   MapTy Strings;
   uint64_t CurrentEndOffset = 0;
   unsigned NumEntries = 0;
+  std::function Translator;
 };
 
 /// Helper for making strong types.

diff  --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h 
b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
index e7a1a3cd838c22..bebdfd5e60257e 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
@@ -45,13 +45,16 @@ class DwarfStreamer : public DwarfEmitter {
 public:
   DwarfStreamer(DWARFLinkerBase::OutputFileType OutFileType,
 raw_pwrite_stream &OutFile,
+DWARFLinkerBase::TranslatorFuncTy Translator,
 DWARFLinkerBase::MessageHandlerTy Warning)
-  : OutFile(OutFile), OutFileType(OutFileType), WarningHandler(Warning) {}
+  : OutFile(OutFile), OutFileType(OutFileType), Translator(Translator),
+WarningHandler(Warning) {}
   virtual ~DwarfStreamer() = default;
 
   static Expected> createStreamer(
   const Triple &TheTriple, DWARFLinkerBase::OutputFileType FileType,
-  raw_pwrite_stream &OutFile, DWARFLinkerBase::MessageHandlerTy Warning);
+  raw_pwrite_stream &OutFile, DWARFLinkerBase::TranslatorFuncTy Translator,
+  DWARFLinkerBase::MessageHandlerTy Warning);
 
   Error init(Triple TheTriple, StringRef Swift5ReflectionSegmentName);
 
@@ -292,6 +295,7 @@ class DwarfStreamer : public DwarfEmitter {
   /// The output file we stream the linked Dwarf to.
   raw_pwrite_stream &OutFile;
   DWARFLinker::OutputFileType OutFileType = 
DWARFLinker::OutputFileType::Object;
+  std::function Translator;
 
   uint64_t RangesSectionSize = 0;
   uint64_t RngListsSectionSize = 0;

diff  --git

[llvm-branch-commits] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Tobias Gysi via llvm-branch-commits

https://github.com/gysit edited https://github.com/llvm/llvm-project/pull/85813
___
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] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Tobias Gysi via llvm-branch-commits


@@ -26,8 +26,8 @@ struct MemorySlot {
 
 /// Memory slot attached with information about its destructuring procedure.
 struct DestructurableMemorySlot : public MemorySlot {
-  /// Maps an index within the memory slot to the type of the pointer that
-  /// will be generated to access the element directly.
+  /// Maps an index within the memory slot to the element type of the pointer
+  /// that will be generated to access the element directly.

gysit wrote:

```suggestion
  /// Maps an index within the memory slot to the corresponding subelement type.
```
Would something like this work as well?

https://github.com/llvm/llvm-project/pull/85813
___
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] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Tobias Gysi via llvm-branch-commits


@@ -215,3 +215,94 @@ llvm.func @no_nested_dynamic_indexing(%arg: i32) -> i32 {
   // CHECK: llvm.return %[[RES]] : i32
   llvm.return %3 : i32
 }
+
+// -
+
+// CHECK-LABEL: llvm.func @store_first_field
+llvm.func @store_first_field(%arg: i32) {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
+  %1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> 
!llvm.ptr
+  // CHECK: llvm.store %{{.*}}, %[[ALLOCA]] : i32
+  llvm.store %arg, %1 : i32, !llvm.ptr
+  llvm.return
+}
+
+// -
+
+// CHECK-LABEL: llvm.func @store_first_field_different_type
+// CHECK-SAME: (%[[ARG:.*]]: f32)
+llvm.func @store_first_field_different_type(%arg: f32) {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
+  %1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> 
!llvm.ptr
+  // CHECK: llvm.store %[[ARG]], %[[ALLOCA]] : f32
+  llvm.store %arg, %1 : f32, !llvm.ptr
+  llvm.return
+}
+
+// -
+
+// CHECK-LABEL: llvm.func @store_sub_field
+// CHECK-SAME: (%[[ARG:.*]]: f32)
+llvm.func @store_sub_field(%arg: f32) {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i64
+  %1 = llvm.alloca %0 x !llvm.struct<"foo", (i64, i32)> : (i32) -> !llvm.ptr
+  // CHECK: llvm.store %[[ARG]], %[[ALLOCA]] : f32
+  llvm.store %arg, %1 : f32, !llvm.ptr
+  llvm.return
+}
+
+// -
+
+// CHECK-LABEL: llvm.func @load_first_field
+llvm.func @load_first_field() -> i32 {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
+  %1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> 
!llvm.ptr
+  // CHECK: %[[RES:.*]] = llvm.load %[[ALLOCA]] : !llvm.ptr -> i32
+  %2 = llvm.load %1 : !llvm.ptr -> i32
+  // CHECK: llvm.return %[[RES]] : i32
+  llvm.return %2 : i32
+}
+
+// -
+
+// CHECK-LABEL: llvm.func @load_first_field_different_type
+llvm.func @load_first_field_different_type() -> f32 {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
+  %1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> 
!llvm.ptr
+  // CHECK: %[[RES:.*]] = llvm.load %[[ALLOCA]] : !llvm.ptr -> f32
+  %2 = llvm.load %1 : !llvm.ptr -> f32
+  // CHECK: llvm.return %[[RES]] : f32
+  llvm.return %2 : f32
+}
+
+// -
+
+// CHECK-LABEL: llvm.func @load_sub_field
+llvm.func @load_sub_field() -> i32 {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i64 : (i32) -> !llvm.ptr
+  // CHECK-NOT: llvm.alloca

gysit wrote:

Would this or CHECK-NEXT on the next check line make sense in all the tests?

https://github.com/llvm/llvm-project/pull/85813
___
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] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Tobias Gysi via llvm-branch-commits

https://github.com/gysit commented:

Nice!

https://github.com/llvm/llvm-project/pull/85813
___
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] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Tobias Gysi via llvm-branch-commits


@@ -182,17 +176,107 @@ DeletionKind LLVM::StoreOp::removeBlockingUses(
   return DeletionKind::Delete;
 }
 
+/// Checks if `slot` can be accessed through the provided access type.
+static bool isValidAccessType(const MemorySlot &slot, Type accessType,
+  const DataLayout &dataLayout) {
+  return dataLayout.getTypeSize(accessType) <=
+ dataLayout.getTypeSize(slot.elemType);
+}
+
 LogicalResult LLVM::LoadOp::ensureOnlySafeAccesses(
 const MemorySlot &slot, SmallVectorImpl &mustBeSafelyUsed,
 const DataLayout &dataLayout) {
-  return success(getAddr() != slot.ptr || getType() == slot.elemType);
+  return success(getAddr() != slot.ptr ||
+ isValidAccessType(slot, getType(), dataLayout));
 }
 
 LogicalResult LLVM::StoreOp::ensureOnlySafeAccesses(
 const MemorySlot &slot, SmallVectorImpl &mustBeSafelyUsed,
 const DataLayout &dataLayout) {
   return success(getAddr() != slot.ptr ||
- getValue().getType() == slot.elemType);
+ isValidAccessType(slot, getValue().getType(), dataLayout));
+}
+
+/// Returns the subslot's type at the requested index.
+static Type getTypeAtIndex(const DestructurableMemorySlot &slot,
+   Attribute index) {
+  auto subelementIndexMap =
+  
slot.elemType.cast().getSubelementIndexMap();
+  if (!subelementIndexMap)
+return {};
+  assert(!subelementIndexMap->empty());
+
+  // Note: Returns a null-type when no entry was found.
+  return subelementIndexMap->lookup(index);
+}
+
+bool LLVM::LoadOp::canRewire(const DestructurableMemorySlot &slot,
+ SmallPtrSetImpl &usedIndices,
+ SmallVectorImpl &mustBeSafelyUsed,
+ const DataLayout &dataLayout) {
+  if (getVolatile_())
+return false;
+
+  // A load always accesses the first element of the destructured slot.
+  auto index = IntegerAttr::get(IntegerType::get(getContext(), 32), 0);
+  Type subslotType = getTypeAtIndex(slot, index);
+  if (!subslotType)
+return false;
+
+  // The access can only be replaced when the subslot is read within its 
bounds.
+  if (dataLayout.getTypeSize(getType()) > dataLayout.getTypeSize(subslotType))
+return false;
+
+  usedIndices.insert(index);
+  return true;
+}
+
+DeletionKind LLVM::LoadOp::rewire(const DestructurableMemorySlot &slot,
+  DenseMap &subslots,
+  RewriterBase &rewriter,
+  const DataLayout &dataLayout) {
+  auto index = IntegerAttr::get(IntegerType::get(getContext(), 32), 0);
+  auto it = subslots.find(index);
+  assert(it != subslots.end());
+
+  rewriter.modifyOpInPlace(
+  *this, [&]() { getAddrMutable().set(it->getSecond().ptr); });
+  return DeletionKind::Keep;
+}
+
+bool LLVM::StoreOp::canRewire(const DestructurableMemorySlot &slot,
+  SmallPtrSetImpl &usedIndices,
+  SmallVectorImpl &mustBeSafelyUsed,
+  const DataLayout &dataLayout) {
+  if (getVolatile_())
+return false;
+
+  // A load always accesses the first element of the destructured slot.

gysit wrote:

```suggestion
  // A store always accesses the first element of the destructured slot.
```

https://github.com/llvm/llvm-project/pull/85813
___
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] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Tobias Gysi via llvm-branch-commits


@@ -384,16 +468,17 @@ bool LLVM::GEPOp::canRewire(const 
DestructurableMemorySlot &slot,
   // dynamic indices can never be properly rewired.
   if (!getDynamicIndices().empty())
 return false;
+   TODO: This is not necessary, I think.
+  // if (slot.elemType != getElemType())
+  //   return false;

gysit wrote:

This seem to be a debug left over and the condition seems to be checked above?

Maybe not in this PR, but should we use the data layout here as well instead of 
checking the element type. I.e. we could compute the offset of the GEP and then 
check if the offset points to the beginning of a subelement (of the slot and 
maybe also of a nested slot).

https://github.com/llvm/llvm-project/pull/85813
___
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] 3a4cb7a - Revert "[Float2Int] Resolve FIXME: Pick the smallest legal type that fits (#7…"

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

Author: alexfh
Date: 2024-03-19T19:30:42+01:00
New Revision: 3a4cb7acfb8a9b346121e54ccc8f6753044b0add

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

LOG: Revert "[Float2Int] Resolve FIXME: Pick the smallest legal type that fits 
(#7…"

This reverts commit 06c06e15f45acd3ea24756978629f1d78724870e.

Added: 


Modified: 
llvm/include/llvm/Transforms/Scalar/Float2Int.h
llvm/lib/Transforms/Scalar/Float2Int.cpp
llvm/test/Transforms/Float2Int/basic.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Scalar/Float2Int.h 
b/llvm/include/llvm/Transforms/Scalar/Float2Int.h
index 337e229efcf379..83be329bed60ba 100644
--- a/llvm/include/llvm/Transforms/Scalar/Float2Int.h
+++ b/llvm/include/llvm/Transforms/Scalar/Float2Int.h
@@ -44,7 +44,7 @@ class Float2IntPass : public PassInfoMixin {
   std::optional calcRange(Instruction *I);
   void walkBackwards();
   void walkForwards();
-  bool validateAndTransform(const DataLayout &DL);
+  bool validateAndTransform();
   Value *convert(Instruction *I, Type *ToTy);
   void cleanup();
 

diff  --git a/llvm/lib/Transforms/Scalar/Float2Int.cpp 
b/llvm/lib/Transforms/Scalar/Float2Int.cpp
index 6ad4be169b589a..ccca8bcc1a56ac 100644
--- a/llvm/lib/Transforms/Scalar/Float2Int.cpp
+++ b/llvm/lib/Transforms/Scalar/Float2Int.cpp
@@ -311,7 +311,7 @@ void Float2IntPass::walkForwards() {
 }
 
 // If there is a valid transform to be done, do it.
-bool Float2IntPass::validateAndTransform(const DataLayout &DL) {
+bool Float2IntPass::validateAndTransform() {
   bool MadeChange = false;
 
   // Iterate over every disjoint partition of the def-use graph.
@@ -376,24 +376,16 @@ bool Float2IntPass::validateAndTransform(const DataLayout 
&DL) {
   LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n");
   continue;
 }
-
-// OK, R is known to be representable.
-// Pick the smallest legal type that will fit.
-Type *Ty = DL.getSmallestLegalIntType(*Ctx, MinBW);
-if (!Ty) {
-  // Every supported target supports 64-bit and 32-bit integers,
-  // so fallback to a 32 or 64-bit integer if the value fits.
-  if (MinBW <= 32) {
-Ty = Type::getInt32Ty(*Ctx);
-  } else if (MinBW <= 64) {
-Ty = Type::getInt64Ty(*Ctx);
-  } else {
-LLVM_DEBUG(dbgs() << "F2I: Value requires more than bits to represent "
- "than the target supports!\n");
-continue;
-  }
+if (MinBW > 64) {
+  LLVM_DEBUG(
+  dbgs() << "F2I: Value requires more than 64 bits to represent!\n");
+  continue;
 }
 
+// OK, R is known to be representable. Now pick a type for it.
+// FIXME: Pick the smallest legal type that will fit.
+Type *Ty = (MinBW > 32) ? Type::getInt64Ty(*Ctx) : Type::getInt32Ty(*Ctx);
+
 for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
  MI != ME; ++MI)
   convert(*MI, Ty);
@@ -499,8 +491,7 @@ bool Float2IntPass::runImpl(Function &F, const 
DominatorTree &DT) {
   walkBackwards();
   walkForwards();
 
-  const DataLayout &DL = F.getParent()->getDataLayout();
-  bool Modified = validateAndTransform(DL);
+  bool Modified = validateAndTransform();
   if (Modified)
 cleanup();
   return Modified;

diff  --git a/llvm/test/Transforms/Float2Int/basic.ll 
b/llvm/test/Transforms/Float2Int/basic.ll
index a454b773f4ebab..2854a83179b7eb 100644
--- a/llvm/test/Transforms/Float2Int/basic.ll
+++ b/llvm/test/Transforms/Float2Int/basic.ll
@@ -1,29 +1,16 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes=float2int -S | FileCheck %s -check-prefixes=CHECK,NONE
-; RUN: opt < %s -passes=float2int -S --data-layout="n64" | FileCheck %s 
-check-prefixes=CHECK,ONLY64
-; RUN: opt < %s -passes=float2int -S --data-layout="n8:16:32:64"| FileCheck %s 
-check-prefixes=CHECK,MULTIPLE
+; RUN: opt < %s -passes='float2int' -S | FileCheck %s
 
 ;
 ; Positive tests
 ;
 
 define i16 @simple1(i8 %a) {
-; NONE-LABEL: @simple1(
-; NONE-NEXT:[[TMP1:%.*]] = zext i8 [[A:%.*]] to i32
-; NONE-NEXT:[[T21:%.*]] = add i32 [[TMP1]], 1
-; NONE-NEXT:[[TMP2:%.*]] = trunc i32 [[T21]] to i16
-; NONE-NEXT:ret i16 [[TMP2]]
-;
-; ONLY64-LABEL: @simple1(
-; ONLY64-NEXT:[[TMP1:%.*]] = zext i8 [[A:%.*]] to i64
-; ONLY64-NEXT:[[T21:%.*]] = add i64 [[TMP1]], 1
-; ONLY64-NEXT:[[TMP2:%.*]] = trunc i64 [[T21]] to i16
-; ONLY64-NEXT:ret i16 [[TMP2]]
-;
-; MULTIPLE-LABEL: @simple1(
-; MULTIPLE-NEXT:[[TMP1:%.*]] = zext i8 [[A:%.*]] to i16
-; MULTIPLE-NEXT:[[T21:%.*]] = add i16 [[TMP1]], 1
-; MULTIPLE-NEXT:ret i16 [[T21]]
+; CHECK-LABEL: @simple1(
+; CHECK-NEXT:[[TMP1:%.*]] = zext i8 [[A:%.*]] to i32
+; CHECK-NEXT:[[T21:%.*]] = add i32 [[TMP1]], 1
+; CHECK-NEXT:  

[llvm-branch-commits] [cmake] Reenable FatLTO for Fuchsia toolchains (PR #85709)

2024-03-19 Thread Petr Hosek via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/85709
___
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] release/18.x: workflows: Fix baseline version for llvm abi checks (#85166) (PR #85789)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/85789
___
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] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

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

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

>From b1f1effacf32150021e1ae93afcd3933a66f8260 Mon Sep 17 00:00:00 2001
From: Alex Crichton 
Date: Mon, 18 Mar 2024 19:55:34 -0500
Subject: [PATCH] [WebAssembly] Change the default linker for `wasm32-wasip2`
 (#84569)

This commit changes the default linker in the WebAssembly toolchain for
the `wasm32-wasip2` target. This target is being added to the
WebAssembly/wasi-sdk and WebAssembly/wasi-libc projects to target the
Component Model by default, in contrast with the preexisting
`wasm32-wasi` target (in the process of being renamed to
`wasm32-wasip1`) which outputs a core WebAssembly module by default.

The `wasm-component-ld` project currently lives in my GitHub account at
https://github.com/alexcrichton/wasm-component-ld and isn't necessarily
"official" yet, but it's expected to continue to evolve as the
`wasm32-wasip2` target continues to shape up and evolve.

(cherry picked from commit d66121d74a458e098511b9de920d815440acaa1b)
---
 clang/lib/Driver/ToolChains/WebAssembly.cpp | 27 +++--
 clang/lib/Driver/ToolChains/WebAssembly.h   |  2 +-
 clang/test/Driver/wasm-toolchain.c  | 24 ++
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 57f4600727ec89..0b16b660364f07 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -44,8 +44,15 @@ std::string wasm::Linker::getLinkerPath(const ArgList &Args) 
const {
   llvm::sys::fs::can_execute(UseLinker))
 return std::string(UseLinker);
 
-  // Accept 'lld', and 'ld' as aliases for the default linker
-  if (UseLinker != "lld" && UseLinker != "ld")
+  // Interpret 'lld' as explicitly requesting `wasm-ld`, so look for that
+  // linker. Note that for `wasm32-wasip2` this overrides the default 
linker
+  // of `wasm-component-ld`.
+  if (UseLinker == "lld") {
+return ToolChain.GetProgramPath("wasm-ld");
+  }
+
+  // Allow 'ld' as an alias for the default linker
+  if (UseLinker != "ld")
 ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
 << A->getAsString(Args);
 }
@@ -73,6 +80,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
 
+  // On `wasip2` the default linker is `wasm-component-ld` which wraps the
+  // execution of `wasm-ld`. Find `wasm-ld` and pass it as an argument of where
+  // to find it to avoid it needing to hunt and rediscover or search `PATH` for
+  // where it is.
+  if (llvm::sys::path::stem(Linker).ends_with_insensitive(
+  "wasm-component-ld")) {
+CmdArgs.push_back("--wasm-ld-path");
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetProgramPath("wasm-ld")));
+  }
+
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
@@ -221,6 +238,12 @@ WebAssembly::WebAssembly(const Driver &D, const 
llvm::Triple &Triple,
   }
 }
 
+const char *WebAssembly::getDefaultLinker() const {
+  if (getOS() == "wasip2")
+return "wasm-component-ld";
+  return "wasm-ld";
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.h 
b/clang/lib/Driver/ToolChains/WebAssembly.h
index ae60f464c10818..76e0ca39bd748d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.h
+++ b/clang/lib/Driver/ToolChains/WebAssembly.h
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly final : public 
ToolChain {
llvm::opt::ArgStringList &CmdArgs) const override;
   SanitizerMask getSupportedSanitizers() const override;
 
-  const char *getDefaultLinker() const override { return "wasm-ld"; }
+  const char *getDefaultLinker() const override;
 
   CXXStdlibType GetDefaultCXXStdlibType() const override {
 return ToolChain::CST_Libcxx;
diff --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index f950283ec42aa0..88590a3ba4c453 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -197,3 +197,27 @@
 // RUN: not %clang -### %s --target=wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
 // PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with 
'-mno-mutable-globals'
+
+// Test that `wasm32-wasip2` invokes the `wasm-component-ld` linker by default
+// instead of `wasm-ld`.
+
+// RUN: %clang -### -O2 --target=wasm32-wasip2 %s --sysroot /foo 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_WASIP2 %s
+// LINK_WASIP2: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_WASIP2: wasm-component-ld{{.

[llvm-branch-commits] [clang] b1f1eff - [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569)

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

Author: Alex Crichton
Date: 2024-03-19T12:42:53-07:00
New Revision: b1f1effacf32150021e1ae93afcd3933a66f8260

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

LOG: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569)

This commit changes the default linker in the WebAssembly toolchain for
the `wasm32-wasip2` target. This target is being added to the
WebAssembly/wasi-sdk and WebAssembly/wasi-libc projects to target the
Component Model by default, in contrast with the preexisting
`wasm32-wasi` target (in the process of being renamed to
`wasm32-wasip1`) which outputs a core WebAssembly module by default.

The `wasm-component-ld` project currently lives in my GitHub account at
https://github.com/alexcrichton/wasm-component-ld and isn't necessarily
"official" yet, but it's expected to continue to evolve as the
`wasm32-wasip2` target continues to shape up and evolve.

(cherry picked from commit d66121d74a458e098511b9de920d815440acaa1b)

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/lib/Driver/ToolChains/WebAssembly.h
clang/test/Driver/wasm-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 57f4600727ec89..0b16b660364f07 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -44,8 +44,15 @@ std::string wasm::Linker::getLinkerPath(const ArgList &Args) 
const {
   llvm::sys::fs::can_execute(UseLinker))
 return std::string(UseLinker);
 
-  // Accept 'lld', and 'ld' as aliases for the default linker
-  if (UseLinker != "lld" && UseLinker != "ld")
+  // Interpret 'lld' as explicitly requesting `wasm-ld`, so look for that
+  // linker. Note that for `wasm32-wasip2` this overrides the default 
linker
+  // of `wasm-component-ld`.
+  if (UseLinker == "lld") {
+return ToolChain.GetProgramPath("wasm-ld");
+  }
+
+  // Allow 'ld' as an alias for the default linker
+  if (UseLinker != "ld")
 ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
 << A->getAsString(Args);
 }
@@ -73,6 +80,16 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
 
+  // On `wasip2` the default linker is `wasm-component-ld` which wraps the
+  // execution of `wasm-ld`. Find `wasm-ld` and pass it as an argument of where
+  // to find it to avoid it needing to hunt and rediscover or search `PATH` for
+  // where it is.
+  if (llvm::sys::path::stem(Linker).ends_with_insensitive(
+  "wasm-component-ld")) {
+CmdArgs.push_back("--wasm-ld-path");
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetProgramPath("wasm-ld")));
+  }
+
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
@@ -221,6 +238,12 @@ WebAssembly::WebAssembly(const Driver &D, const 
llvm::Triple &Triple,
   }
 }
 
+const char *WebAssembly::getDefaultLinker() const {
+  if (getOS() == "wasip2")
+return "wasm-component-ld";
+  return "wasm-ld";
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }

diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.h 
b/clang/lib/Driver/ToolChains/WebAssembly.h
index ae60f464c10818..76e0ca39bd748d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.h
+++ b/clang/lib/Driver/ToolChains/WebAssembly.h
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly final : public 
ToolChain {
llvm::opt::ArgStringList &CmdArgs) const override;
   SanitizerMask getSupportedSanitizers() const override;
 
-  const char *getDefaultLinker() const override { return "wasm-ld"; }
+  const char *getDefaultLinker() const override;
 
   CXXStdlibType GetDefaultCXXStdlibType() const override {
 return ToolChain::CST_Libcxx;

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index f950283ec42aa0..88590a3ba4c453 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -197,3 +197,27 @@
 // RUN: not %clang -### %s --target=wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -fPIC -mno-mutable-globals %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=PIC_NO_MUTABLE_GLOBALS %s
 // PIC_NO_MUTABLE_GLOBALS: error: invalid argument '-fPIC' not allowed with 
'-mno-mutable-globals'
+
+// Test that `wasm32-wasip2` invokes the `wasm-component-ld` linker by default
+// instead of `wasm-ld`.
+
+// RUN: %clang -### -O2 --target=wasm32-wasip2 %s --sysroot /foo 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_WASIP2 %s
+// LIN

[llvm-branch-commits] [clang] release/18.x: [WebAssembly] Change the default linker for `wasm32-wasip2` (#84569) (PR #85802)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/85802
___
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] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

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

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

>From bcf98bd8419997f006811b6f40703e4e791972e6 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 15 Mar 2024 08:16:46 -0700
Subject: [PATCH 1/3] llvm-shlib: Fix libLLVM-${MAJOR}.so symlink on MacOS
 (#85163)

This is a partial revert of 10c48a772742b7afe665a815b7eba2047f17dc4b
with a fix for the symlink target name on MacOS

See #84637

(cherry picked from commit ec2b7522dbee1cb9d6ade6e1768462247dcf)
---
 llvm/cmake/modules/AddLLVM.cmake | 6 +++---
 llvm/tools/llvm-shlib/CMakeLists.txt | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 3bc78b0dc9355a..ceec15b611140d 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2074,7 +2074,7 @@ function(add_lit_testsuites project directory)
 endfunction()
 
 function(llvm_install_library_symlink name dest type)
-  cmake_parse_arguments(ARG "" "COMPONENT;SOVERSION" "" ${ARGN})
+  cmake_parse_arguments(ARG "FULL_DEST" "COMPONENT" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})
 if(EXISTS ${path}/LLVMInstallSymlink.cmake)
   set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
@@ -2088,8 +2088,8 @@ function(llvm_install_library_symlink name dest type)
   endif()
 
   set(full_name 
${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
-  if (ARG_SOVERSION)
-set(full_dest 
${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}.${ARG_SOVERSION})
+  if (ARG_FULL_DEST)
+set(full_dest ${dest})
   else()
 set(full_dest 
${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
   endif()
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index eba1672faee7fa..9adce0617ff736 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -35,8 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
   endif()
   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
   # Add symlink for backwards compatibility with old library name
-  get_target_property(LLVM_DYLIB_SOVERSION LLVM SOVERSION)
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
LLVM SHARED COMPONENT LLVM SOVERSION ${LLVM_DYLIB_SOVERSION})
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")

>From cba6ebf0d0abd226c207a0043dee201ffb805466 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 16 Mar 2024 22:47:27 -0700
Subject: [PATCH 2/3] [llvm-shlib] Fix libLLVM-18 symlink on mingw (#85554)

The TARGET_SONAME_FILE_NAME generator expression is not available on dll
target platforms.

(cherry picked from commit f84980570d3f85bdf5c9432647c05bae04a735a0)
---
 llvm/tools/llvm-shlib/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 9adce0617ff736..0ad350bcbe0d7b 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -35,7 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
   endif()
   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
   # Add symlink for backwards compatibility with old library name
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")

>From c09f6f6f43418b8c67ef8822fbbf5e04296fdf2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 19 Mar 2024 08:48:57 +0200
Subject: [PATCH 3/3] [llvm-shlib] Fix the version naming style of libLLVM for
 Windows (#85710)

This reverts the changes from 91a384621e5b762d9c173ffd247cfeadd5f436a2
for Windows targets. The changes in that commit don't work as expected
for Windows targets (those parts of llvm_add_library don't quite behave
the same for Windows), while the previous status quo (producing a
library named "libLLVM-.dll") is the defacto standard way of
doing versioned library names there, contrary to on Unix.

After that commit, the library always ended up named "libLLVM.dll",
executables linking against it would reference "libLLVM.dll", and
"libLLVM-.dll" was provided as a symlink.

Thus revert this bit back to as it were, so that executables actually
link against a versioned libLLVM, and no separate symlink is needed.

The only thing that might be improved compared to the status quo as it
was before these changes, is that the import library is named
"lib/libLLVM-.dll.a", while the common st

[llvm-branch-commits] [llvm] cba6ebf - [llvm-shlib] Fix libLLVM-18 symlink on mingw (#85554)

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

Author: Tom Stellard
Date: 2024-03-19T12:48:35-07:00
New Revision: cba6ebf0d0abd226c207a0043dee201ffb805466

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

LOG: [llvm-shlib] Fix libLLVM-18 symlink on mingw (#85554)

The TARGET_SONAME_FILE_NAME generator expression is not available on dll
target platforms.

(cherry picked from commit f84980570d3f85bdf5c9432647c05bae04a735a0)

Added: 


Modified: 
llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 




diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 9adce0617ff736..0ad350bcbe0d7b 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -35,7 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
   endif()
   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
   # Add symlink for backwards compatibility with old library name
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")



___
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] bcf98bd - llvm-shlib: Fix libLLVM-${MAJOR}.so symlink on MacOS (#85163)

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

Author: Tom Stellard
Date: 2024-03-19T12:48:35-07:00
New Revision: bcf98bd8419997f006811b6f40703e4e791972e6

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

LOG: llvm-shlib: Fix libLLVM-${MAJOR}.so symlink on MacOS (#85163)

This is a partial revert of 10c48a772742b7afe665a815b7eba2047f17dc4b
with a fix for the symlink target name on MacOS

See #84637

(cherry picked from commit ec2b7522dbee1cb9d6ade6e1768462247dcf)

Added: 


Modified: 
llvm/cmake/modules/AddLLVM.cmake
llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 




diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 3bc78b0dc9355a..ceec15b611140d 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2074,7 +2074,7 @@ function(add_lit_testsuites project directory)
 endfunction()
 
 function(llvm_install_library_symlink name dest type)
-  cmake_parse_arguments(ARG "" "COMPONENT;SOVERSION" "" ${ARGN})
+  cmake_parse_arguments(ARG "FULL_DEST" "COMPONENT" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})
 if(EXISTS ${path}/LLVMInstallSymlink.cmake)
   set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
@@ -2088,8 +2088,8 @@ function(llvm_install_library_symlink name dest type)
   endif()
 
   set(full_name 
${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
-  if (ARG_SOVERSION)
-set(full_dest 
${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}.${ARG_SOVERSION})
+  if (ARG_FULL_DEST)
+set(full_dest ${dest})
   else()
 set(full_dest 
${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
   endif()

diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index eba1672faee7fa..9adce0617ff736 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -35,8 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
   endif()
   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
   # Add symlink for backwards compatibility with old library name
-  get_target_property(LLVM_DYLIB_SOVERSION LLVM SOVERSION)
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
LLVM SHARED COMPONENT LLVM SOVERSION ${LLVM_DYLIB_SOVERSION})
+  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")



___
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] c09f6f6 - [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)

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

Author: Martin Storsjö
Date: 2024-03-19T12:48:35-07:00
New Revision: c09f6f6f43418b8c67ef8822fbbf5e04296fdf2d

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

LOG: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)

This reverts the changes from 91a384621e5b762d9c173ffd247cfeadd5f436a2
for Windows targets. The changes in that commit don't work as expected
for Windows targets (those parts of llvm_add_library don't quite behave
the same for Windows), while the previous status quo (producing a
library named "libLLVM-.dll") is the defacto standard way of
doing versioned library names there, contrary to on Unix.

After that commit, the library always ended up named "libLLVM.dll",
executables linking against it would reference "libLLVM.dll", and
"libLLVM-.dll" was provided as a symlink.

Thus revert this bit back to as it were, so that executables actually
link against a versioned libLLVM, and no separate symlink is needed.

The only thing that might be improved compared to the status quo as it
was before these changes, is that the import library is named
"lib/libLLVM-.dll.a", while the common style would be to name it
plainly "lib/libLLVM.dll.a" (even while it produces references to
"libLLVM-.dll", but none of these had that effect for Windows
targets.

(As a side note, the llvm-shlib library can be built for MinGW, but not
currently in MSVC configurations.)

(cherry picked from commit cb2ca23345d3d9bde027a18d301949e8bdf606a6)

Added: 


Modified: 
llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 




diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt 
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 0ad350bcbe0d7b..b20ac318e768db 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -33,9 +33,13 @@ if(LLVM_BUILD_LLVM_DYLIB)
   if (LLVM_LINK_LLVM_DYLIB)
 set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN)
   endif()
-  add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
-  # Add symlink for backwards compatibility with old library name
-  
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
+  if (WIN32)
+add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
+  else()
+add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB OUTPUT_NAME LLVM 
${INSTALL_WITH_TOOLCHAIN} ${SOURCES})
+# Add symlink for backwards compatibility with old library name
+
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} 
$ SHARED FULL_DEST COMPONENT LLVM)
+  endif()
 
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")



___
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] release/18.x: [llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710) (PR #85746)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/85746
___
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] release/18.x: [PowerPC] Update chain uses when emitting lxsizx (#84892) (PR #85648)

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

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

>From df20f2fc99986e07886efe9ab279ee0846f5e911 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Mon, 18 Mar 2024 22:31:05 +0800
Subject: [PATCH] [PowerPC] Update chain uses when emitting lxsizx (#84892)

(cherry picked from commit e5b20c83e5ba25e6e0650df30352ce54c2f6ea2f)
---
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp   |  1 +
 .../CodeGen/PowerPC/scalar-double-ldst.ll | 58 +++
 .../test/CodeGen/PowerPC/scalar-float-ldst.ll | 58 +++
 3 files changed, 117 insertions(+)

diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index aec58d1c0dcb9f..85f1e670045b92 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -14942,6 +14942,7 @@ SDValue PPCTargetLowering::combineFPToIntToFP(SDNode *N,
 SDValue Ld = DAG.getMemIntrinsicNode(PPCISD::LXSIZX, dl,
  DAG.getVTList(MVT::f64, MVT::Other),
  Ops, MVT::i8, LDN->getMemOperand());
+DAG.makeEquivalentMemoryOrdering(LDN, Ld);
 
 // For signed conversion, we need to sign-extend the value in the VSR
 if (Signed) {
diff --git a/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll 
b/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
index 6f68679325c579..798637b6840f1e 100644
--- a/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
@@ -7281,3 +7281,61 @@ entry:
   store double %str, ptr inttoptr (i64 1 to ptr), align 4096
   ret void
 }
+
+define dso_local void @st_reversed_double_from_i8(ptr %ptr) {
+; CHECK-P10-LABEL: st_reversed_double_from_i8:
+; CHECK-P10:   # %bb.0: # %entry
+; CHECK-P10-NEXT:li r4, 8
+; CHECK-P10-NEXT:lxsibzx f0, 0, r3
+; CHECK-P10-NEXT:xxspltidp vs2, -1023410176
+; CHECK-P10-NEXT:lxsibzx f1, r3, r4
+; CHECK-P10-NEXT:xscvuxddp f0, f0
+; CHECK-P10-NEXT:xscvuxddp f1, f1
+; CHECK-P10-NEXT:xsadddp f0, f0, f2
+; CHECK-P10-NEXT:xsadddp f1, f1, f2
+; CHECK-P10-NEXT:stfd f1, 0(r3)
+; CHECK-P10-NEXT:stfd f0, 8(r3)
+; CHECK-P10-NEXT:blr
+;
+; CHECK-P9-LABEL: st_reversed_double_from_i8:
+; CHECK-P9:   # %bb.0: # %entry
+; CHECK-P9-NEXT:li r4, 8
+; CHECK-P9-NEXT:lxsibzx f0, 0, r3
+; CHECK-P9-NEXT:lxsibzx f1, r3, r4
+; CHECK-P9-NEXT:addis r4, r2, .LCPI300_0@toc@ha
+; CHECK-P9-NEXT:lfs f2, .LCPI300_0@toc@l(r4)
+; CHECK-P9-NEXT:xscvuxddp f0, f0
+; CHECK-P9-NEXT:xscvuxddp f1, f1
+; CHECK-P9-NEXT:xsadddp f0, f0, f2
+; CHECK-P9-NEXT:xsadddp f1, f1, f2
+; CHECK-P9-NEXT:stfd f0, 8(r3)
+; CHECK-P9-NEXT:stfd f1, 0(r3)
+; CHECK-P9-NEXT:blr
+;
+; CHECK-P8-LABEL: st_reversed_double_from_i8:
+; CHECK-P8:   # %bb.0: # %entry
+; CHECK-P8-NEXT:lbz r4, 0(r3)
+; CHECK-P8-NEXT:lbz r5, 8(r3)
+; CHECK-P8-NEXT:mtfprwz f0, r4
+; CHECK-P8-NEXT:mtfprwz f1, r5
+; CHECK-P8-NEXT:addis r4, r2, .LCPI300_0@toc@ha
+; CHECK-P8-NEXT:lfs f2, .LCPI300_0@toc@l(r4)
+; CHECK-P8-NEXT:xscvuxddp f0, f0
+; CHECK-P8-NEXT:xscvuxddp f1, f1
+; CHECK-P8-NEXT:xsadddp f0, f0, f2
+; CHECK-P8-NEXT:xsadddp f1, f1, f2
+; CHECK-P8-NEXT:stfd f1, 0(r3)
+; CHECK-P8-NEXT:stfd f0, 8(r3)
+; CHECK-P8-NEXT:blr
+entry:
+  %idx = getelementptr inbounds i8, ptr %ptr, i64 8
+  %i0 = load i8, ptr %ptr, align 1
+  %i1 = load i8, ptr %idx, align 1
+  %f0 = uitofp i8 %i0 to double
+  %f1 = uitofp i8 %i1 to double
+  %a0 = fadd double %f0, -1.28e+02
+  %a1 = fadd double %f1, -1.28e+02
+  store double %a1, ptr %ptr, align 8
+  store double %a0, ptr %idx, align 8
+  ret void
+}
diff --git a/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll 
b/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
index 824dd4c4db6cb7..f3960573421298 100644
--- a/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
@@ -7271,3 +7271,61 @@ entry:
   store double %conv, ptr inttoptr (i64 1 to ptr), align 4096
   ret void
 }
+
+define dso_local void @st_reversed_float_from_i8(ptr %ptr) {
+; CHECK-P10-LABEL: st_reversed_float_from_i8:
+; CHECK-P10:   # %bb.0: # %entry
+; CHECK-P10-NEXT:li r4, 8
+; CHECK-P10-NEXT:lxsibzx f0, 0, r3
+; CHECK-P10-NEXT:xxspltidp vs2, -1023410176
+; CHECK-P10-NEXT:lxsibzx f1, r3, r4
+; CHECK-P10-NEXT:xscvuxdsp f0, f0
+; CHECK-P10-NEXT:xscvuxdsp f1, f1
+; CHECK-P10-NEXT:xsaddsp f0, f0, f2
+; CHECK-P10-NEXT:xsaddsp f1, f1, f2
+; CHECK-P10-NEXT:stfs f0, 8(r3)
+; CHECK-P10-NEXT:stfs f1, 0(r3)
+; CHECK-P10-NEXT:blr
+;
+; CHECK-P9-LABEL: st_reversed_float_from_i8:
+; CHECK-P9:   # %bb.0: # %entry
+; CHECK-P9-NEXT:li r4, 8
+; CHECK-P9-NEXT:lxsibzx f0, 0, r3
+; CHECK-P9-NEXT:lxsibzx f1, r3, r4
+; CHECK-P9-NEXT:addis r4, r2, .LCPI300_0@toc@ha
+; CHECK-P9-NEXT:lfs f2, .LCPI300_0@toc@l

[llvm-branch-commits] [llvm] df20f2f - [PowerPC] Update chain uses when emitting lxsizx (#84892)

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

Author: Qiu Chaofan
Date: 2024-03-19T12:52:09-07:00
New Revision: df20f2fc99986e07886efe9ab279ee0846f5e911

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

LOG: [PowerPC] Update chain uses when emitting lxsizx (#84892)

(cherry picked from commit e5b20c83e5ba25e6e0650df30352ce54c2f6ea2f)

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index aec58d1c0dcb9f..85f1e670045b92 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -14942,6 +14942,7 @@ SDValue PPCTargetLowering::combineFPToIntToFP(SDNode *N,
 SDValue Ld = DAG.getMemIntrinsicNode(PPCISD::LXSIZX, dl,
  DAG.getVTList(MVT::f64, MVT::Other),
  Ops, MVT::i8, LDN->getMemOperand());
+DAG.makeEquivalentMemoryOrdering(LDN, Ld);
 
 // For signed conversion, we need to sign-extend the value in the VSR
 if (Signed) {

diff  --git a/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll 
b/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
index 6f68679325c579..798637b6840f1e 100644
--- a/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar-double-ldst.ll
@@ -7281,3 +7281,61 @@ entry:
   store double %str, ptr inttoptr (i64 1 to ptr), align 4096
   ret void
 }
+
+define dso_local void @st_reversed_double_from_i8(ptr %ptr) {
+; CHECK-P10-LABEL: st_reversed_double_from_i8:
+; CHECK-P10:   # %bb.0: # %entry
+; CHECK-P10-NEXT:li r4, 8
+; CHECK-P10-NEXT:lxsibzx f0, 0, r3
+; CHECK-P10-NEXT:xxspltidp vs2, -1023410176
+; CHECK-P10-NEXT:lxsibzx f1, r3, r4
+; CHECK-P10-NEXT:xscvuxddp f0, f0
+; CHECK-P10-NEXT:xscvuxddp f1, f1
+; CHECK-P10-NEXT:xsadddp f0, f0, f2
+; CHECK-P10-NEXT:xsadddp f1, f1, f2
+; CHECK-P10-NEXT:stfd f1, 0(r3)
+; CHECK-P10-NEXT:stfd f0, 8(r3)
+; CHECK-P10-NEXT:blr
+;
+; CHECK-P9-LABEL: st_reversed_double_from_i8:
+; CHECK-P9:   # %bb.0: # %entry
+; CHECK-P9-NEXT:li r4, 8
+; CHECK-P9-NEXT:lxsibzx f0, 0, r3
+; CHECK-P9-NEXT:lxsibzx f1, r3, r4
+; CHECK-P9-NEXT:addis r4, r2, .LCPI300_0@toc@ha
+; CHECK-P9-NEXT:lfs f2, .LCPI300_0@toc@l(r4)
+; CHECK-P9-NEXT:xscvuxddp f0, f0
+; CHECK-P9-NEXT:xscvuxddp f1, f1
+; CHECK-P9-NEXT:xsadddp f0, f0, f2
+; CHECK-P9-NEXT:xsadddp f1, f1, f2
+; CHECK-P9-NEXT:stfd f0, 8(r3)
+; CHECK-P9-NEXT:stfd f1, 0(r3)
+; CHECK-P9-NEXT:blr
+;
+; CHECK-P8-LABEL: st_reversed_double_from_i8:
+; CHECK-P8:   # %bb.0: # %entry
+; CHECK-P8-NEXT:lbz r4, 0(r3)
+; CHECK-P8-NEXT:lbz r5, 8(r3)
+; CHECK-P8-NEXT:mtfprwz f0, r4
+; CHECK-P8-NEXT:mtfprwz f1, r5
+; CHECK-P8-NEXT:addis r4, r2, .LCPI300_0@toc@ha
+; CHECK-P8-NEXT:lfs f2, .LCPI300_0@toc@l(r4)
+; CHECK-P8-NEXT:xscvuxddp f0, f0
+; CHECK-P8-NEXT:xscvuxddp f1, f1
+; CHECK-P8-NEXT:xsadddp f0, f0, f2
+; CHECK-P8-NEXT:xsadddp f1, f1, f2
+; CHECK-P8-NEXT:stfd f1, 0(r3)
+; CHECK-P8-NEXT:stfd f0, 8(r3)
+; CHECK-P8-NEXT:blr
+entry:
+  %idx = getelementptr inbounds i8, ptr %ptr, i64 8
+  %i0 = load i8, ptr %ptr, align 1
+  %i1 = load i8, ptr %idx, align 1
+  %f0 = uitofp i8 %i0 to double
+  %f1 = uitofp i8 %i1 to double
+  %a0 = fadd double %f0, -1.28e+02
+  %a1 = fadd double %f1, -1.28e+02
+  store double %a1, ptr %ptr, align 8
+  store double %a0, ptr %idx, align 8
+  ret void
+}

diff  --git a/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll 
b/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
index 824dd4c4db6cb7..f3960573421298 100644
--- a/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
+++ b/llvm/test/CodeGen/PowerPC/scalar-float-ldst.ll
@@ -7271,3 +7271,61 @@ entry:
   store double %conv, ptr inttoptr (i64 1 to ptr), align 4096
   ret void
 }
+
+define dso_local void @st_reversed_float_from_i8(ptr %ptr) {
+; CHECK-P10-LABEL: st_reversed_float_from_i8:
+; CHECK-P10:   # %bb.0: # %entry
+; CHECK-P10-NEXT:li r4, 8
+; CHECK-P10-NEXT:lxsibzx f0, 0, r3
+; CHECK-P10-NEXT:xxspltidp vs2, -1023410176
+; CHECK-P10-NEXT:lxsibzx f1, r3, r4
+; CHECK-P10-NEXT:xscvuxdsp f0, f0
+; CHECK-P10-NEXT:xscvuxdsp f1, f1
+; CHECK-P10-NEXT:xsaddsp f0, f0, f2
+; CHECK-P10-NEXT:xsaddsp f1, f1, f2
+; CHECK-P10-NEXT:stfs f0, 8(r3)
+; CHECK-P10-NEXT:stfs f1, 0(r3)
+; CHECK-P10-NEXT:blr
+;
+; CHECK-P9-LABEL: st_reversed_float_from_i8:
+; CHECK-P9:   # %bb.0: # %entry
+; CHECK-P9-NEXT:li r4, 8
+; CHECK-P9-NEXT:lxsibzx f0, 0, r3
+; CHECK-P9-NEXT:lxsi

[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Update chain uses when emitting lxsizx (#84892) (PR #85648)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/85648
___
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] [cmake] Reenable FatLTO for Fuchsia toolchains (PR #85709)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi closed 
https://github.com/llvm/llvm-project/pull/85709
___
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] release/18.x: [TSan] Fix atomicrmw xchg with pointer and floats (#85228) (PR #85371)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/85371

>From 631dfbf2ad986e4ab006e5fb2565136b2eb4dbaa Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Fri, 15 Mar 2024 09:02:10 +0100
Subject: [PATCH] [TSan] Fix atomicrmw xchg with pointer and floats (#85228)

atomicrmw xchg also accepts pointer and floating-point values. To handle
those, insert necessary casts to and from integer. This is what we do
for cmpxchg as well.

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

(cherry picked from commit ff2fb2a1d78585944dcdb9061c8487fe1476dfa4)
---
 .../Instrumentation/ThreadSanitizer.cpp   |  9 +
 .../Instrumentation/ThreadSanitizer/atomic.ll | 20 +++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index 8ee0bca7e354f0..0f42ff79086994 100644
--- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -752,11 +752,12 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, 
const DataLayout &DL) {
 const unsigned ByteSize = 1U << Idx;
 const unsigned BitSize = ByteSize * 8;
 Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
-Value *Args[] = {Addr,
- IRB.CreateIntCast(RMWI->getValOperand(), Ty, false),
+Value *Val = RMWI->getValOperand();
+Value *Args[] = {Addr, IRB.CreateBitOrPointerCast(Val, Ty),
  createOrdering(&IRB, RMWI->getOrdering())};
-CallInst *C = CallInst::Create(F, Args);
-ReplaceInstWithInst(I, C);
+Value *C = IRB.CreateCall(F, Args);
+I->replaceAllUsesWith(IRB.CreateBitOrPointerCast(C, Val->getType()));
+I->eraseFromParent();
   } else if (AtomicCmpXchgInst *CASI = dyn_cast(I)) {
 Value *Addr = CASI->getPointerOperand();
 Type *OrigOldValTy = CASI->getNewValOperand()->getType();
diff --git a/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll 
b/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
index 76afc4bf007c2d..8b387cd4962979 100644
--- a/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
+++ b/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
@@ -78,6 +78,26 @@ entry:
 ; CHECK-LABEL: atomic8_xchg_monotonic
 ; CHECK: call i8 @__tsan_atomic8_exchange(ptr %a, i8 0, i32 0), !dbg
 
+define void @atomic8_xchg_monotonic_ptr(ptr %a, ptr %b) nounwind uwtable {
+entry:
+  atomicrmw xchg ptr %a, ptr %b monotonic, !dbg !7
+  ret void, !dbg !7
+}
+; CHECK-LABEL: atomic8_xchg_monotonic_ptr
+; CHECK: [[ARG:%.*]] = ptrtoint ptr %b to i64, !dbg
+; CHECK: [[RES:%.*]] = call i64 @__tsan_atomic64_exchange(ptr %a, i64 [[ARG]], 
i32 0), !dbg
+; CHECK: [[CAST:%.*]] = inttoptr i64 [[RES]] to ptr, !dbg
+
+define void @atomic8_xchg_monotonic_float(ptr %a, float %b) nounwind uwtable {
+entry:
+  atomicrmw xchg ptr %a, float %b monotonic, !dbg !7
+  ret void, !dbg !7
+}
+; CHECK-LABEL: atomic8_xchg_monotonic_float
+; CHECK: [[ARG:%.*]] = bitcast float %b to i32, !dbg
+; CHECK: [[RES:%.*]] = call i32 @__tsan_atomic32_exchange(ptr %a, i32 [[ARG]], 
i32 0), !dbg
+; CHECK: [[CAST:%.*]] = bitcast i32 [[RES]] to float, !dbg
+
 define void @atomic8_add_monotonic(ptr %a) nounwind uwtable {
 entry:
   atomicrmw add ptr %a, i8 0 monotonic, !dbg !7

___
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] [openmp] 2d35ba4 - Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#846…"

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

Author: David CARLIER
Date: 2024-03-19T13:04:17-07:00
New Revision: 2d35ba4a85774074bd17186aa44451772d3a9a27

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

LOG: Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. 
(#846…"

This reverts commit 9b3edb592debc00a5c3fbf7a71f63e07d6af44be.

Added: 


Modified: 
openmp/runtime/src/kmp.h

Removed: 




diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index d51ec886cfe556..e3a1e20731bbe0 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1403,19 +1403,9 @@ extern void __kmp_query_cpuid(kmp_cpuinfo_t *p);
 // subleaf is only needed for cache and topology discovery and can be set to
 // zero in most cases
 static inline void __kmp_x86_cpuid(int leaf, int subleaf, struct kmp_cpuid *p) 
{
-#if KMP_ARCH_X86 && (defined(__pic__) || defined(__PIC__))
-  // on i386 arch, the ebx reg. is used by pic, thus we need to preserve from
-  // being trashed beforehand
-  __asm__ __volatile__("mov %%ebx, %%edi\n"
-   "cpuid\n"
-   "xchg %%edi, %%ebx\n"
-   : "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
-   : "a"(leaf), "c"(subleaf));
-#else
   __asm__ __volatile__("cpuid"
: "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
: "a"(leaf), "c"(subleaf));
-#endif
 }
 // Load p into FPU control word
 static inline void __kmp_load_x87_fpu_control_word(const kmp_int16 *p) {



___
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] [openmp] Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#84626)" (PR #85527)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/85527

>From 2d35ba4a85774074bd17186aa44451772d3a9a27 Mon Sep 17 00:00:00 2001
From: David CARLIER 
Date: Sat, 16 Mar 2024 13:41:33 +
Subject: [PATCH] =?UTF-8?q?Revert=20"release/18.x:=20[openmp]=20=5F=5Fkmp?=
 =?UTF-8?q?=5Fx86=5Fcpuid=20fix=20for=20i386/PIC=20builds.=20(#846?=
 =?UTF-8?q?=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 9b3edb592debc00a5c3fbf7a71f63e07d6af44be.
---
 openmp/runtime/src/kmp.h | 10 --
 1 file changed, 10 deletions(-)

diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index d51ec886cfe556..e3a1e20731bbe0 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1403,19 +1403,9 @@ extern void __kmp_query_cpuid(kmp_cpuinfo_t *p);
 // subleaf is only needed for cache and topology discovery and can be set to
 // zero in most cases
 static inline void __kmp_x86_cpuid(int leaf, int subleaf, struct kmp_cpuid *p) 
{
-#if KMP_ARCH_X86 && (defined(__pic__) || defined(__PIC__))
-  // on i386 arch, the ebx reg. is used by pic, thus we need to preserve from
-  // being trashed beforehand
-  __asm__ __volatile__("mov %%ebx, %%edi\n"
-   "cpuid\n"
-   "xchg %%edi, %%ebx\n"
-   : "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
-   : "a"(leaf), "c"(subleaf));
-#else
   __asm__ __volatile__("cpuid"
: "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
: "a"(leaf), "c"(subleaf));
-#endif
 }
 // Load p into FPU control word
 static inline void __kmp_load_x87_fpu_control_word(const kmp_int16 *p) {

___
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] [openmp] 2d35ba4 - Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#846…"

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

Author: David CARLIER
Date: 2024-03-19T13:04:17-07:00
New Revision: 2d35ba4a85774074bd17186aa44451772d3a9a27

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

LOG: Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. 
(#846…"

This reverts commit 9b3edb592debc00a5c3fbf7a71f63e07d6af44be.

Added: 


Modified: 
openmp/runtime/src/kmp.h

Removed: 




diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index d51ec886cfe556..e3a1e20731bbe0 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1403,19 +1403,9 @@ extern void __kmp_query_cpuid(kmp_cpuinfo_t *p);
 // subleaf is only needed for cache and topology discovery and can be set to
 // zero in most cases
 static inline void __kmp_x86_cpuid(int leaf, int subleaf, struct kmp_cpuid *p) 
{
-#if KMP_ARCH_X86 && (defined(__pic__) || defined(__PIC__))
-  // on i386 arch, the ebx reg. is used by pic, thus we need to preserve from
-  // being trashed beforehand
-  __asm__ __volatile__("mov %%ebx, %%edi\n"
-   "cpuid\n"
-   "xchg %%edi, %%ebx\n"
-   : "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
-   : "a"(leaf), "c"(subleaf));
-#else
   __asm__ __volatile__("cpuid"
: "=a"(p->eax), "=b"(p->ebx), "=c"(p->ecx), "=d"(p->edx)
: "a"(leaf), "c"(subleaf));
-#endif
 }
 // Load p into FPU control word
 static inline void __kmp_load_x87_fpu_control_word(const kmp_int16 *p) {



___
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] [openmp] Revert "release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#84626)" (PR #85527)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/85527
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

___
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] Backport #85277 (PR #85422)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/85422

>From fd9f1faf8fcb0308b369f9acec3a56e42381a025 Mon Sep 17 00:00:00 2001
From: Patryk Wychowaniec 
Date: Fri, 15 Mar 2024 12:07:54 +0100
Subject: [PATCH] [AVR] Remove earlyclobber from LDDRdPtrQ (#85277)

LDDRdPtrQ was marked as `earlyclobber`, which doesn't play well with
GreedyRA (which can generate this instruction through `loadRegFromStackSlot()`).

This seems to be the same case as:

https://github.com/llvm/llvm-project/blob/a99b912c9b74f6ef91786b4dfbc25160c27d3b41/llvm/lib/Target/AVR/AVRInstrInfo.td#L1421

Closes https://github.com/llvm/llvm-project/issues/81911.
---
 llvm/lib/Target/AVR/AVRInstrInfo.td |   2 +-
 llvm/test/CodeGen/AVR/bug-81911.ll  | 163 
 2 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AVR/bug-81911.ll

diff --git a/llvm/lib/Target/AVR/AVRInstrInfo.td 
b/llvm/lib/Target/AVR/AVRInstrInfo.td
index efaaec32ee6bb1..0a77c7c1d418a1 100644
--- a/llvm/lib/Target/AVR/AVRInstrInfo.td
+++ b/llvm/lib/Target/AVR/AVRInstrInfo.td
@@ -1398,7 +1398,7 @@ let mayLoad = 1, hasSideEffects = 0,
 
 // Load indirect with displacement operations.
 let canFoldAsLoad = 1, isReMaterializable = 1 in {
-  let Constraints = "@earlyclobber $reg" in def LDDRdPtrQ
+  def LDDRdPtrQ
   : FSTDLDD<0,
 (outs GPR8
  : $reg),
diff --git a/llvm/test/CodeGen/AVR/bug-81911.ll 
b/llvm/test/CodeGen/AVR/bug-81911.ll
new file mode 100644
index 00..2a22666a1ff927
--- /dev/null
+++ b/llvm/test/CodeGen/AVR/bug-81911.ll
@@ -0,0 +1,163 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=avr -mcpu=atmega328 -O1 -verify-machineinstrs | 
FileCheck %s
+
+define internal i8 @main() {
+; CHECK-LABEL: main:
+; CHECK:   ; %bb.0: ; %bb0
+; CHECK-NEXT:push r2
+; CHECK-NEXT:push r3
+; CHECK-NEXT:push r4
+; CHECK-NEXT:push r5
+; CHECK-NEXT:push r6
+; CHECK-NEXT:push r7
+; CHECK-NEXT:push r8
+; CHECK-NEXT:push r9
+; CHECK-NEXT:push r10
+; CHECK-NEXT:push r11
+; CHECK-NEXT:push r12
+; CHECK-NEXT:push r13
+; CHECK-NEXT:push r14
+; CHECK-NEXT:push r15
+; CHECK-NEXT:push r16
+; CHECK-NEXT:push r17
+; CHECK-NEXT:push r28
+; CHECK-NEXT:push r29
+; CHECK-NEXT:in r28, 61
+; CHECK-NEXT:in r29, 62
+; CHECK-NEXT:sbiw r28, 13
+; CHECK-NEXT:in r0, 63
+; CHECK-NEXT:cli
+; CHECK-NEXT:out 62, r29
+; CHECK-NEXT:out 63, r0
+; CHECK-NEXT:out 61, r28
+; CHECK-NEXT:ldi r16, 0
+; CHECK-NEXT:ldi r17, 0
+; CHECK-NEXT:ldi r18, -1
+; CHECK-NEXT:;APP
+; CHECK-NEXT:ldi r24, 123
+; CHECK-NEXT:;NO_APP
+; CHECK-NEXT:std Y+1, r24 ; 1-byte Folded Spill
+; CHECK-NEXT:movw r24, r28
+; CHECK-NEXT:adiw r24, 6
+; CHECK-NEXT:std Y+3, r25 ; 2-byte Folded Spill
+; CHECK-NEXT:std Y+2, r24 ; 2-byte Folded Spill
+; CHECK-NEXT:movw r8, r16
+; CHECK-NEXT:movw r6, r16
+; CHECK-NEXT:movw r4, r16
+; CHECK-NEXT:movw r2, r16
+; CHECK-NEXT:rjmp .LBB0_2
+; CHECK-NEXT:  .LBB0_1: ; %bb1
+; CHECK-NEXT:; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT:andi r30, 1
+; CHECK-NEXT:ldd r31, Y+4 ; 1-byte Folded Reload
+; CHECK-NEXT:dec r31
+; CHECK-NEXT:cpi r30, 0
+; CHECK-NEXT:movw r8, r18
+; CHECK-NEXT:movw r6, r20
+; CHECK-NEXT:movw r4, r22
+; CHECK-NEXT:movw r2, r24
+; CHECK-NEXT:mov r18, r31
+; CHECK-NEXT:brne .LBB0_2
+; CHECK-NEXT:rjmp .LBB0_4
+; CHECK-NEXT:  .LBB0_2: ; %bb1
+; CHECK-NEXT:; =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:std Y+4, r18 ; 1-byte Folded Spill
+; CHECK-NEXT:movw r18, r8
+; CHECK-NEXT:movw r20, r6
+; CHECK-NEXT:movw r22, r4
+; CHECK-NEXT:movw r24, r2
+; CHECK-NEXT:ldi r26, 10
+; CHECK-NEXT:ldi r27, 0
+; CHECK-NEXT:movw r10, r26
+; CHECK-NEXT:movw r12, r16
+; CHECK-NEXT:movw r14, r16
+; CHECK-NEXT:call __udivdi3
+; CHECK-NEXT:std Y+13, r25
+; CHECK-NEXT:std Y+12, r24
+; CHECK-NEXT:std Y+11, r23
+; CHECK-NEXT:std Y+10, r22
+; CHECK-NEXT:std Y+9, r21
+; CHECK-NEXT:std Y+8, r20
+; CHECK-NEXT:std Y+7, r19
+; CHECK-NEXT:std Y+6, r18
+; CHECK-NEXT:ldd r30, Y+2 ; 2-byte Folded Reload
+; CHECK-NEXT:ldd r31, Y+3 ; 2-byte Folded Reload
+; CHECK-NEXT:;APP
+; CHECK-NEXT:;NO_APP
+; CHECK-NEXT:ldi r30, 1
+; CHECK-NEXT:cp r8, r1
+; CHECK-NEXT:cpc r9, r1
+; CHECK-NEXT:cpc r6, r16
+; CHECK-NEXT:cpc r7, r17
+; CHECK-NEXT:cpc r4, r16
+; CHECK-NEXT:cpc r5, r17
+; CHECK-NEXT:cpc r2, r16
+; CHECK-NEXT:cpc r3, r17
+; CHECK-NEXT:breq .LBB0_3
+; CHECK-NEXT:rjmp .LBB0_1
+; CHECK-NEXT:  .LBB0_3: ; %bb1
+; CHECK-NEXT:; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT:mov r30, r1
+; CHECK-NEXT:rjmp .LBB0_1
+; CHECK-NEXT:  .LBB0_4: ; %bb3
+; CHECK-NEXT:ldd r24, Y+1 ; 1-b

[llvm-branch-commits] [llvm] fd9f1fa - [AVR] Remove earlyclobber from LDDRdPtrQ (#85277)

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

Author: Patryk Wychowaniec
Date: 2024-03-19T13:11:29-07:00
New Revision: fd9f1faf8fcb0308b369f9acec3a56e42381a025

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

LOG: [AVR] Remove earlyclobber from LDDRdPtrQ (#85277)

LDDRdPtrQ was marked as `earlyclobber`, which doesn't play well with
GreedyRA (which can generate this instruction through `loadRegFromStackSlot()`).

This seems to be the same case as:

https://github.com/llvm/llvm-project/blob/a99b912c9b74f6ef91786b4dfbc25160c27d3b41/llvm/lib/Target/AVR/AVRInstrInfo.td#L1421

Closes https://github.com/llvm/llvm-project/issues/81911.

Added: 
llvm/test/CodeGen/AVR/bug-81911.ll

Modified: 
llvm/lib/Target/AVR/AVRInstrInfo.td

Removed: 




diff  --git a/llvm/lib/Target/AVR/AVRInstrInfo.td 
b/llvm/lib/Target/AVR/AVRInstrInfo.td
index efaaec32ee6bb1..0a77c7c1d418a1 100644
--- a/llvm/lib/Target/AVR/AVRInstrInfo.td
+++ b/llvm/lib/Target/AVR/AVRInstrInfo.td
@@ -1398,7 +1398,7 @@ let mayLoad = 1, hasSideEffects = 0,
 
 // Load indirect with displacement operations.
 let canFoldAsLoad = 1, isReMaterializable = 1 in {
-  let Constraints = "@earlyclobber $reg" in def LDDRdPtrQ
+  def LDDRdPtrQ
   : FSTDLDD<0,
 (outs GPR8
  : $reg),

diff  --git a/llvm/test/CodeGen/AVR/bug-81911.ll 
b/llvm/test/CodeGen/AVR/bug-81911.ll
new file mode 100644
index 00..2a22666a1ff927
--- /dev/null
+++ b/llvm/test/CodeGen/AVR/bug-81911.ll
@@ -0,0 +1,163 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=avr -mcpu=atmega328 -O1 -verify-machineinstrs | 
FileCheck %s
+
+define internal i8 @main() {
+; CHECK-LABEL: main:
+; CHECK:   ; %bb.0: ; %bb0
+; CHECK-NEXT:push r2
+; CHECK-NEXT:push r3
+; CHECK-NEXT:push r4
+; CHECK-NEXT:push r5
+; CHECK-NEXT:push r6
+; CHECK-NEXT:push r7
+; CHECK-NEXT:push r8
+; CHECK-NEXT:push r9
+; CHECK-NEXT:push r10
+; CHECK-NEXT:push r11
+; CHECK-NEXT:push r12
+; CHECK-NEXT:push r13
+; CHECK-NEXT:push r14
+; CHECK-NEXT:push r15
+; CHECK-NEXT:push r16
+; CHECK-NEXT:push r17
+; CHECK-NEXT:push r28
+; CHECK-NEXT:push r29
+; CHECK-NEXT:in r28, 61
+; CHECK-NEXT:in r29, 62
+; CHECK-NEXT:sbiw r28, 13
+; CHECK-NEXT:in r0, 63
+; CHECK-NEXT:cli
+; CHECK-NEXT:out 62, r29
+; CHECK-NEXT:out 63, r0
+; CHECK-NEXT:out 61, r28
+; CHECK-NEXT:ldi r16, 0
+; CHECK-NEXT:ldi r17, 0
+; CHECK-NEXT:ldi r18, -1
+; CHECK-NEXT:;APP
+; CHECK-NEXT:ldi r24, 123
+; CHECK-NEXT:;NO_APP
+; CHECK-NEXT:std Y+1, r24 ; 1-byte Folded Spill
+; CHECK-NEXT:movw r24, r28
+; CHECK-NEXT:adiw r24, 6
+; CHECK-NEXT:std Y+3, r25 ; 2-byte Folded Spill
+; CHECK-NEXT:std Y+2, r24 ; 2-byte Folded Spill
+; CHECK-NEXT:movw r8, r16
+; CHECK-NEXT:movw r6, r16
+; CHECK-NEXT:movw r4, r16
+; CHECK-NEXT:movw r2, r16
+; CHECK-NEXT:rjmp .LBB0_2
+; CHECK-NEXT:  .LBB0_1: ; %bb1
+; CHECK-NEXT:; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT:andi r30, 1
+; CHECK-NEXT:ldd r31, Y+4 ; 1-byte Folded Reload
+; CHECK-NEXT:dec r31
+; CHECK-NEXT:cpi r30, 0
+; CHECK-NEXT:movw r8, r18
+; CHECK-NEXT:movw r6, r20
+; CHECK-NEXT:movw r4, r22
+; CHECK-NEXT:movw r2, r24
+; CHECK-NEXT:mov r18, r31
+; CHECK-NEXT:brne .LBB0_2
+; CHECK-NEXT:rjmp .LBB0_4
+; CHECK-NEXT:  .LBB0_2: ; %bb1
+; CHECK-NEXT:; =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:std Y+4, r18 ; 1-byte Folded Spill
+; CHECK-NEXT:movw r18, r8
+; CHECK-NEXT:movw r20, r6
+; CHECK-NEXT:movw r22, r4
+; CHECK-NEXT:movw r24, r2
+; CHECK-NEXT:ldi r26, 10
+; CHECK-NEXT:ldi r27, 0
+; CHECK-NEXT:movw r10, r26
+; CHECK-NEXT:movw r12, r16
+; CHECK-NEXT:movw r14, r16
+; CHECK-NEXT:call __udivdi3
+; CHECK-NEXT:std Y+13, r25
+; CHECK-NEXT:std Y+12, r24
+; CHECK-NEXT:std Y+11, r23
+; CHECK-NEXT:std Y+10, r22
+; CHECK-NEXT:std Y+9, r21
+; CHECK-NEXT:std Y+8, r20
+; CHECK-NEXT:std Y+7, r19
+; CHECK-NEXT:std Y+6, r18
+; CHECK-NEXT:ldd r30, Y+2 ; 2-byte Folded Reload
+; CHECK-NEXT:ldd r31, Y+3 ; 2-byte Folded Reload
+; CHECK-NEXT:;APP
+; CHECK-NEXT:;NO_APP
+; CHECK-NEXT:ldi r30, 1
+; CHECK-NEXT:cp r8, r1
+; CHECK-NEXT:cpc r9, r1
+; CHECK-NEXT:cpc r6, r16
+; CHECK-NEXT:cpc r7, r17
+; CHECK-NEXT:cpc r4, r16
+; CHECK-NEXT:cpc r5, r17
+; CHECK-NEXT:cpc r2, r16
+; CHECK-NEXT:cpc r3, r17
+; CHECK-NEXT:breq .LBB0_3
+; CHECK-NEXT:rjmp .LBB0_1
+; CHECK-NEXT:  .LBB0_3: ; %bb1
+; CHECK-NEXT:; in Loop: Header=BB0_2 Depth=1
+; CHECK-NEXT:mov r30, r1
+; CHECK-NEXT:rjmp .LBB0_1
+; CHECK-NEXT:  .LBB0_4: 

[llvm-branch-commits] [llvm] Backport #85277 (PR #85422)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/85422
___
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] release/18.x: [TSan] Fix atomicrmw xchg with pointer and floats (#85228) (PR #85371)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/85371

>From 53ea0de61dcdeed075b81e4986b61054b7336f18 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Fri, 15 Mar 2024 09:02:10 +0100
Subject: [PATCH] [TSan] Fix atomicrmw xchg with pointer and floats (#85228)

atomicrmw xchg also accepts pointer and floating-point values. To handle
those, insert necessary casts to and from integer. This is what we do
for cmpxchg as well.

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

(cherry picked from commit ff2fb2a1d78585944dcdb9061c8487fe1476dfa4)
---
 .../Instrumentation/ThreadSanitizer.cpp   |  9 +
 .../Instrumentation/ThreadSanitizer/atomic.ll | 20 +++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index 8ee0bca7e354f0..0f42ff79086994 100644
--- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -752,11 +752,12 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, 
const DataLayout &DL) {
 const unsigned ByteSize = 1U << Idx;
 const unsigned BitSize = ByteSize * 8;
 Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
-Value *Args[] = {Addr,
- IRB.CreateIntCast(RMWI->getValOperand(), Ty, false),
+Value *Val = RMWI->getValOperand();
+Value *Args[] = {Addr, IRB.CreateBitOrPointerCast(Val, Ty),
  createOrdering(&IRB, RMWI->getOrdering())};
-CallInst *C = CallInst::Create(F, Args);
-ReplaceInstWithInst(I, C);
+Value *C = IRB.CreateCall(F, Args);
+I->replaceAllUsesWith(IRB.CreateBitOrPointerCast(C, Val->getType()));
+I->eraseFromParent();
   } else if (AtomicCmpXchgInst *CASI = dyn_cast(I)) {
 Value *Addr = CASI->getPointerOperand();
 Type *OrigOldValTy = CASI->getNewValOperand()->getType();
diff --git a/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll 
b/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
index 76afc4bf007c2d..8b387cd4962979 100644
--- a/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
+++ b/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
@@ -78,6 +78,26 @@ entry:
 ; CHECK-LABEL: atomic8_xchg_monotonic
 ; CHECK: call i8 @__tsan_atomic8_exchange(ptr %a, i8 0, i32 0), !dbg
 
+define void @atomic8_xchg_monotonic_ptr(ptr %a, ptr %b) nounwind uwtable {
+entry:
+  atomicrmw xchg ptr %a, ptr %b monotonic, !dbg !7
+  ret void, !dbg !7
+}
+; CHECK-LABEL: atomic8_xchg_monotonic_ptr
+; CHECK: [[ARG:%.*]] = ptrtoint ptr %b to i64, !dbg
+; CHECK: [[RES:%.*]] = call i64 @__tsan_atomic64_exchange(ptr %a, i64 [[ARG]], 
i32 0), !dbg
+; CHECK: [[CAST:%.*]] = inttoptr i64 [[RES]] to ptr, !dbg
+
+define void @atomic8_xchg_monotonic_float(ptr %a, float %b) nounwind uwtable {
+entry:
+  atomicrmw xchg ptr %a, float %b monotonic, !dbg !7
+  ret void, !dbg !7
+}
+; CHECK-LABEL: atomic8_xchg_monotonic_float
+; CHECK: [[ARG:%.*]] = bitcast float %b to i32, !dbg
+; CHECK: [[RES:%.*]] = call i32 @__tsan_atomic32_exchange(ptr %a, i32 [[ARG]], 
i32 0), !dbg
+; CHECK: [[CAST:%.*]] = bitcast i32 [[RES]] to float, !dbg
+
 define void @atomic8_add_monotonic(ptr %a) nounwind uwtable {
 entry:
   atomicrmw add ptr %a, i8 0 monotonic, !dbg !7

___
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] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

ilovepi wrote:

Well, since I'm not going to have time to work on this in the near future, and 
it will be quite a while before I can roll out an experimental toolchain to 
partners, I'm going to close this for now. Its easy enough to re-open when we 
have  better feeling for its value, but I do still think its good to have a way 
to opt into a transform irrespective of the optlevel.

https://github.com/llvm/llvm-project/pull/83049
___
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] [llvm][dfa-jump-threading] Allow DFAJumpThreading with optsize (PR #83049)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi closed 
https://github.com/llvm/llvm-project/pull/83049
___
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] release/18.x: [Mips] Fix missing sign extension in expansion of sub-word atomic max (#77072) (PR #84566)

2024-03-19 Thread Craig Topper via llvm-branch-commits


@@ -2001,8 +2225,6 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext 
%val) {
 ; MIPSELR6-NEXT:  $BB6_1: # %entry
 ; MIPSELR6-NEXT:# =>This Inner Loop Header: Depth=1
 ; MIPSELR6-NEXT:ll $2, 0($6)
-; MIPSELR6-NEXT:and $2, $2, $8

topperc wrote:

@brad0 I think I missed this in the previous review. Why is it ok to remove the 
AND from the unsigned tests? My original command about the AND being unnecssary 
was for the signed cases.

https://github.com/llvm/llvm-project/pull/84566
___
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] release/18.x: Reland Print library module manifest path again (#84881) (PR #85637)

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

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

>From 17ad7ca5e18ae5b6d85e38c92f30a642739ce225 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Sun, 17 Mar 2024 21:14:53 +0800
Subject: [PATCH] Reland Print library module manifest path again  (#84881)

Following of https://github.com/llvm/llvm-project/pull/82160

The reason why the above PR fails is that the `--sysroot` has lower
priority than the libc++ built from the same source. On the one hand, it
matches the codes behavior. We will add the built libc++ project paths
in the ToolChain class. But we will only add the path related to sysroot
in Linux class, which is derived from the ToolChain classes. So the
paths of just built libc++ is in the front of the paths relative to
sysroot. On the other hand, the behavior should be good from the higher
level. Since the just built libc++ has the same version number with the
just built clang, so it makes sense that these 2 compilers just matches.

So for patch it self, I hacked it by using resource dir in the test
since the resource dir has the higher priority, which is not strongly
correct since we won't do that in practice.

@kaz7 would you like to test on your environment to avoid this get
reverted again?

On the libc++ side, it shows that it lacks a `modules.json` file for the
just built libc++ directory. If we don't have that, it will be
problematic to use std modules from the just built clang and libc++
pair. Then it is not good. And I feel it may be problematic for future
compiler/standard library developers. So I feel this is somewhat a
libc++ issue that need to be fixed.

Also if we don't like the hacked test in the current patch, we must wait
for libc++ to fix this to proceed. But I feel this is somewhat odd since
the test of clang shouldn't dependent on libc++.

CC: @mordante

-

Co-authored-by: Mark de Wever 
(cherry picked from commit 0e1e1fc8f0eae6ebdce40ef2154aa90e35e5bed7)
---
 clang/include/clang/Driver/Driver.h   | 10 +
 clang/include/clang/Driver/Options.td |  3 ++
 clang/lib/Driver/Driver.cpp   | 44 +++
 ...les-print-library-module-manifest-path.cpp | 36 +++
 4 files changed, 93 insertions(+)
 create mode 100644 
clang/test/Driver/modules-print-library-module-manifest-path.cpp

diff --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 3ee1bcf2a69c9b..595f104e406d37 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -602,6 +602,16 @@ class Driver {
   // FIXME: This should be in CompilationInfo.
   std::string GetProgramPath(StringRef Name, const ToolChain &TC) const;
 
+  /// Lookup the path to the Standard library module manifest.
+  ///
+  /// \param C - The compilation.
+  /// \param TC - The tool chain for additional information on
+  /// directories to search.
+  //
+  // FIXME: This should be in CompilationInfo.
+  std::string GetStdModuleManifestPath(const Compilation &C,
+   const ToolChain &TC) const;
+
   /// HandleAutocompletions - Handle --autocomplete by searching and printing
   /// possible flags, descriptions, and its arguments.
   void HandleAutocompletions(StringRef PassedFlags) const;
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 175bedbfb4d01c..9b1c7cf6b8f35c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5320,6 +5320,9 @@ def print_resource_dir : Flag<["-", "--"], 
"print-resource-dir">,
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">,
   Visibility<[ClangOption, CLOption]>;
+def print_std_module_manifest_path : Flag<["-", "--"], 
"print-library-module-manifest-path">,
+  HelpText<"Print the path for the C++ Standard library module manifest">,
+  Visibility<[ClangOption, CLOption]>;
 def print_targets : Flag<["-", "--"], "print-targets">,
   HelpText<"Print the registered targets">,
   Visibility<[ClangOption, CLOption]>;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 93cddf742d521d..dee5446a50ea59 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2194,6 +2194,12 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_std_module_manifest_path)) {
+llvm::outs() << GetStdModuleManifestPath(C, C.getDefaultToolChain())
+ << '\n';
+return false;
+  }
+
   if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
 if (std::optional RuntimePath = TC.getRuntimePath())
   llvm::outs() << *RuntimePath << '\n';
@@ -6166,6 +6172,44 @@ std::string Driver::GetProgramPath(StringRef Name, const 
ToolChain &TC) const {
   return std::string(Name);
 }
 
+std::string Driver::GetStdModuleManifestPath(const Compilation &C,

[llvm-branch-commits] [llvm] release/18.x: [RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506) (PR #82572)

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

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

>From 42f511c95c6f58a2ed8d6fe35af1cde14c750342 Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Wed, 21 Feb 2024 18:05:04 +0800
Subject: [PATCH 1/3] [RISCV] Add test case for miscompile in gather -> strided
 load combine. NFC

This shows the issue in #82430, but triggers it via the widening SEW combine
rather than a GEP that RISCVGatherScatterLowering doesn't detect.

(cherry picked from commit 2cd59bdc891ab59a1abfe5205feb45791a530a47)
---
 .../RISCV/rvv/fixed-vectors-masked-gather.ll  | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll 
b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
index 890707c6337fad..1724b48dd6be9e 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
@@ -15086,5 +15086,52 @@ define <32 x i64> @mgather_strided_split(ptr %base) {
   ret <32 x i64> %x
 }
 
+; FIXME: This is a miscompile triggered by the mgather ->
+; riscv.masked.strided.load combine. In order for it to trigger we need either 
a
+; strided gather that RISCVGatherScatterLowering doesn't pick up, or a new
+; strided gather generated by the widening sew combine.
+define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) {
+; RV32V-LABEL: masked_gather_widen_sew_negative_stride:
+; RV32V:   # %bb.0:
+; RV32V-NEXT:addi a0, a0, -128
+; RV32V-NEXT:li a1, -128
+; RV32V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
+; RV32V-NEXT:vlse64.v v8, (a0), a1
+; RV32V-NEXT:ret
+;
+; RV64V-LABEL: masked_gather_widen_sew_negative_stride:
+; RV64V:   # %bb.0:
+; RV64V-NEXT:addi a0, a0, -128
+; RV64V-NEXT:li a1, -128
+; RV64V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
+; RV64V-NEXT:vlse64.v v8, (a0), a1
+; RV64V-NEXT:ret
+;
+; RV32ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
+; RV32ZVE32F:   # %bb.0:
+; RV32ZVE32F-NEXT:lui a1, 16392
+; RV32ZVE32F-NEXT:addi a1, a1, 1152
+; RV32ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma
+; RV32ZVE32F-NEXT:vmv.s.x v9, a1
+; RV32ZVE32F-NEXT:vluxei8.v v8, (a0), v9
+; RV32ZVE32F-NEXT:ret
+;
+; RV64ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
+; RV64ZVE32F:   # %bb.0:
+; RV64ZVE32F-NEXT:addi a1, a0, 128
+; RV64ZVE32F-NEXT:lw a2, 132(a0)
+; RV64ZVE32F-NEXT:lw a3, 0(a0)
+; RV64ZVE32F-NEXT:lw a0, 4(a0)
+; RV64ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma
+; RV64ZVE32F-NEXT:vlse32.v v8, (a1), zero
+; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a2
+; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a3
+; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a0
+; RV64ZVE32F-NEXT:ret
+  %ptrs = getelementptr i32, ptr %base, <4 x i64> 
+  %x = call <4 x i32> @llvm.masked.gather.v4i32.v32p0(<4 x ptr> %ptrs, i32 8, 
<4 x i1> shufflevector(<4 x i1> insertelement(<4 x i1> poison, i1 true, i32 0), 
<4 x i1> poison, <4 x i32> zeroinitializer), <4 x i32> poison)
+  ret <4 x i32> %x
+}
+
 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
 ; RV64: {{.*}}

>From a9d4ed71707d36bc554bfe38408c74c285b11e6b Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Thu, 22 Feb 2024 11:05:06 +0800
Subject: [PATCH 2/3] [RISCV] Adjust test case to show wrong stride. NFC

See https://github.com/llvm/llvm-project/pull/82506#discussion_r1498080785

(cherry picked from commit 11d115d0569b212dfeb7fe6485be48070e068e19)
---
 .../RISCV/rvv/fixed-vectors-masked-gather.ll   | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll 
b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
index 1724b48dd6be9e..60eec356773bfa 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
@@ -15093,24 +15093,24 @@ define <32 x i64> @mgather_strided_split(ptr %base) {
 define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) {
 ; RV32V-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV32V:   # %bb.0:
-; RV32V-NEXT:addi a0, a0, -128
-; RV32V-NEXT:li a1, -128
+; RV32V-NEXT:addi a0, a0, -120
+; RV32V-NEXT:li a1, 120
 ; RV32V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
 ; RV32V-NEXT:vlse64.v v8, (a0), a1
 ; RV32V-NEXT:ret
 ;
 ; RV64V-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV64V:   # %bb.0:
-; RV64V-NEXT:addi a0, a0, -128
-; RV64V-NEXT:li a1, -128
+; RV64V-NEXT:addi a0, a0, -120
+; RV64V-NEXT:li a1, 120
 ; RV64V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
 ; RV64V-NEXT:vlse64.v v8, (a0), a1
 ; RV64V-NEXT:ret
 ;
 ; RV32ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV32ZVE32F:   # %bb.0:
-; RV32ZVE32F-NEXT:lui a1, 16392
-; RV32ZVE32F-NEXT:addi a1, a1, 1152
+; RV32ZVE32F-NEXT:lui a1, 16

[llvm-branch-commits] [llvm] 42f511c - [RISCV] Add test case for miscompile in gather -> strided load combine. NFC

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

Author: Luke Lau
Date: 2024-03-19T13:57:52-07:00
New Revision: 42f511c95c6f58a2ed8d6fe35af1cde14c750342

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

LOG: [RISCV] Add test case for miscompile in gather -> strided load combine. NFC

This shows the issue in #82430, but triggers it via the widening SEW combine
rather than a GEP that RISCVGatherScatterLowering doesn't detect.

(cherry picked from commit 2cd59bdc891ab59a1abfe5205feb45791a530a47)

Added: 


Modified: 
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll 
b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
index 890707c6337fad..1724b48dd6be9e 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
@@ -15086,5 +15086,52 @@ define <32 x i64> @mgather_strided_split(ptr %base) {
   ret <32 x i64> %x
 }
 
+; FIXME: This is a miscompile triggered by the mgather ->
+; riscv.masked.strided.load combine. In order for it to trigger we need either 
a
+; strided gather that RISCVGatherScatterLowering doesn't pick up, or a new
+; strided gather generated by the widening sew combine.
+define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) {
+; RV32V-LABEL: masked_gather_widen_sew_negative_stride:
+; RV32V:   # %bb.0:
+; RV32V-NEXT:addi a0, a0, -128
+; RV32V-NEXT:li a1, -128
+; RV32V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
+; RV32V-NEXT:vlse64.v v8, (a0), a1
+; RV32V-NEXT:ret
+;
+; RV64V-LABEL: masked_gather_widen_sew_negative_stride:
+; RV64V:   # %bb.0:
+; RV64V-NEXT:addi a0, a0, -128
+; RV64V-NEXT:li a1, -128
+; RV64V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
+; RV64V-NEXT:vlse64.v v8, (a0), a1
+; RV64V-NEXT:ret
+;
+; RV32ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
+; RV32ZVE32F:   # %bb.0:
+; RV32ZVE32F-NEXT:lui a1, 16392
+; RV32ZVE32F-NEXT:addi a1, a1, 1152
+; RV32ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma
+; RV32ZVE32F-NEXT:vmv.s.x v9, a1
+; RV32ZVE32F-NEXT:vluxei8.v v8, (a0), v9
+; RV32ZVE32F-NEXT:ret
+;
+; RV64ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
+; RV64ZVE32F:   # %bb.0:
+; RV64ZVE32F-NEXT:addi a1, a0, 128
+; RV64ZVE32F-NEXT:lw a2, 132(a0)
+; RV64ZVE32F-NEXT:lw a3, 0(a0)
+; RV64ZVE32F-NEXT:lw a0, 4(a0)
+; RV64ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma
+; RV64ZVE32F-NEXT:vlse32.v v8, (a1), zero
+; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a2
+; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a3
+; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a0
+; RV64ZVE32F-NEXT:ret
+  %ptrs = getelementptr i32, ptr %base, <4 x i64> 
+  %x = call <4 x i32> @llvm.masked.gather.v4i32.v32p0(<4 x ptr> %ptrs, i32 8, 
<4 x i1> shufflevector(<4 x i1> insertelement(<4 x i1> poison, i1 true, i32 0), 
<4 x i1> poison, <4 x i32> zeroinitializer), <4 x i32> poison)
+  ret <4 x i32> %x
+}
+
 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
 ; RV64: {{.*}}



___
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] a9d4ed7 - [RISCV] Adjust test case to show wrong stride. NFC

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

Author: Luke Lau
Date: 2024-03-19T13:57:52-07:00
New Revision: a9d4ed71707d36bc554bfe38408c74c285b11e6b

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

LOG: [RISCV] Adjust test case to show wrong stride. NFC

See https://github.com/llvm/llvm-project/pull/82506#discussion_r1498080785

(cherry picked from commit 11d115d0569b212dfeb7fe6485be48070e068e19)

Added: 


Modified: 
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll 
b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
index 1724b48dd6be9e..60eec356773bfa 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
@@ -15093,24 +15093,24 @@ define <32 x i64> @mgather_strided_split(ptr %base) {
 define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) {
 ; RV32V-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV32V:   # %bb.0:
-; RV32V-NEXT:addi a0, a0, -128
-; RV32V-NEXT:li a1, -128
+; RV32V-NEXT:addi a0, a0, -120
+; RV32V-NEXT:li a1, 120
 ; RV32V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
 ; RV32V-NEXT:vlse64.v v8, (a0), a1
 ; RV32V-NEXT:ret
 ;
 ; RV64V-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV64V:   # %bb.0:
-; RV64V-NEXT:addi a0, a0, -128
-; RV64V-NEXT:li a1, -128
+; RV64V-NEXT:addi a0, a0, -120
+; RV64V-NEXT:li a1, 120
 ; RV64V-NEXT:vsetivli zero, 2, e64, m1, ta, ma
 ; RV64V-NEXT:vlse64.v v8, (a0), a1
 ; RV64V-NEXT:ret
 ;
 ; RV32ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV32ZVE32F:   # %bb.0:
-; RV32ZVE32F-NEXT:lui a1, 16392
-; RV32ZVE32F-NEXT:addi a1, a1, 1152
+; RV32ZVE32F-NEXT:lui a1, 16393
+; RV32ZVE32F-NEXT:addi a1, a1, -888
 ; RV32ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma
 ; RV32ZVE32F-NEXT:vmv.s.x v9, a1
 ; RV32ZVE32F-NEXT:vluxei8.v v8, (a0), v9
@@ -15118,8 +15118,8 @@ define <4 x i32> 
@masked_gather_widen_sew_negative_stride(ptr %base) {
 ;
 ; RV64ZVE32F-LABEL: masked_gather_widen_sew_negative_stride:
 ; RV64ZVE32F:   # %bb.0:
-; RV64ZVE32F-NEXT:addi a1, a0, 128
-; RV64ZVE32F-NEXT:lw a2, 132(a0)
+; RV64ZVE32F-NEXT:addi a1, a0, 136
+; RV64ZVE32F-NEXT:lw a2, 140(a0)
 ; RV64ZVE32F-NEXT:lw a3, 0(a0)
 ; RV64ZVE32F-NEXT:lw a0, 4(a0)
 ; RV64ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma
@@ -15128,7 +15128,7 @@ define <4 x i32> 
@masked_gather_widen_sew_negative_stride(ptr %base) {
 ; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a3
 ; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a0
 ; RV64ZVE32F-NEXT:ret
-  %ptrs = getelementptr i32, ptr %base, <4 x i64> 
+  %ptrs = getelementptr i32, ptr %base, <4 x i64> 
   %x = call <4 x i32> @llvm.masked.gather.v4i32.v32p0(<4 x ptr> %ptrs, i32 8, 
<4 x i1> shufflevector(<4 x i1> insertelement(<4 x i1> poison, i1 true, i32 0), 
<4 x i1> poison, <4 x i32> zeroinitializer), <4 x i32> poison)
   ret <4 x i32> %x
 }



___
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] a2c93b3 - [RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506)

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

Author: Luke Lau
Date: 2024-03-19T13:57:52-07:00
New Revision: a2c93b34dfdf6b2e5d16a5068e92f30bbc5d0ba7

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

LOG: [RISCV] Fix mgather -> riscv.masked.strided.load combine not extending 
indices (#82506)

This fixes the miscompile reported in #82430 by telling
isSimpleVIDSequence to sign extend to XLen instead of the width of the
indices, since the "sequence" of indices generated by a strided load
will be at XLen.

This was the simplest way I could think of getting isSimpleVIDSequence
to treat the indexes as if they were zero extended to XLenVT.

Another way we could do this is by refactoring out the "get constant
integers" part from isSimpleVIDSequence and handle them as APInts so we
can separately zero extend it.

Fixes #82430

(cherry picked from commit 815644b4dd882ade2e5649d4f97c3dd6f7aea200)

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 80447d03c000b8..a0cec426002b6f 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -3192,7 +3192,8 @@ static std::optional getExactInteger(const 
APFloat &APF,
 // Note that this method will also match potentially unappealing index
 // sequences, like , however it is left to the caller to
 // determine whether this is worth generating code for.
-static std::optional isSimpleVIDSequence(SDValue Op) {
+static std::optional isSimpleVIDSequence(SDValue Op,
+  unsigned EltSizeInBits) {
   unsigned NumElts = Op.getNumOperands();
   assert(Op.getOpcode() == ISD::BUILD_VECTOR && "Unexpected BUILD_VECTOR");
   bool IsInteger = Op.getValueType().isInteger();
@@ -3200,7 +3201,7 @@ static std::optional 
isSimpleVIDSequence(SDValue Op) {
   std::optional SeqStepDenom;
   std::optional SeqStepNum, SeqAddend;
   std::optional> PrevElt;
-  unsigned EltSizeInBits = Op.getValueType().getScalarSizeInBits();
+  assert(EltSizeInBits >= Op.getValueType().getScalarSizeInBits());
   for (unsigned Idx = 0; Idx < NumElts; Idx++) {
 // Assume undef elements match the sequence; we just have to be careful
 // when interpolating across them.
@@ -3213,14 +3214,14 @@ static std::optional 
isSimpleVIDSequence(SDValue Op) {
   if (!isa(Op.getOperand(Idx)))
 return std::nullopt;
   Val = Op.getConstantOperandVal(Idx) &
-maskTrailingOnes(EltSizeInBits);
+maskTrailingOnes(Op.getScalarValueSizeInBits());
 } else {
   // The BUILD_VECTOR must be all constants.
   if (!isa(Op.getOperand(Idx)))
 return std::nullopt;
   if (auto ExactInteger = getExactInteger(
   cast(Op.getOperand(Idx))->getValueAPF(),
-  EltSizeInBits))
+  Op.getScalarValueSizeInBits()))
 Val = *ExactInteger;
   else
 return std::nullopt;
@@ -3276,11 +3277,11 @@ static std::optional 
isSimpleVIDSequence(SDValue Op) {
 uint64_t Val;
 if (IsInteger) {
   Val = Op.getConstantOperandVal(Idx) &
-maskTrailingOnes(EltSizeInBits);
+maskTrailingOnes(Op.getScalarValueSizeInBits());
 } else {
   Val = *getExactInteger(
   cast(Op.getOperand(Idx))->getValueAPF(),
-  EltSizeInBits);
+  Op.getScalarValueSizeInBits());
 }
 uint64_t ExpectedVal =
 (int64_t)(Idx * (uint64_t)*SeqStepNum) / *SeqStepDenom;
@@ -3550,7 +3551,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, 
SelectionDAG &DAG,
   // Try and match index sequences, which we can lower to the vid instruction
   // with optional modifications. An all-undef vector is matched by
   // getSplatValue, above.
-  if (auto SimpleVID = isSimpleVIDSequence(Op)) {
+  if (auto SimpleVID = isSimpleVIDSequence(Op, Op.getScalarValueSizeInBits())) 
{
 int64_t StepNumerator = SimpleVID->StepNumerator;
 unsigned StepDenominator = SimpleVID->StepDenominator;
 int64_t Addend = SimpleVID->Addend;
@@ -15562,7 +15563,10 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode 
*N,
 
 if (Index.getOpcode() == ISD::BUILD_VECTOR &&
 MGN->getExtensionType() == ISD::NON_EXTLOAD && isTypeLegal(VT)) {
-  if (std::optional SimpleVID = isSimpleVIDSequence(Index);
+  // The sequence will be XLenVT, not the type of Index. Tell
+  // isSimpleVIDSequence this so we avoid overflow.
+  if (std::optional SimpleVID =
+  isSimpleVIDSequence(Index, Subtarget.getXLen());
   SimpleVID && SimpleVID->StepDenominator == 1) {
 const int64_t StepNumerator = SimpleVID->StepNumera

[llvm-branch-commits] [llvm] release/18.x: [RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506) (PR #82572)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/82572
___
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] release/18.x: [X86] Add missing subvector_subreg_lowering for BF16 (#83720) (PR #83834)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/83834

>From 9cec3b7b1ea0491df688555a51750efe6c9bd075 Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 4 Mar 2024 18:09:41 +0800
Subject: [PATCH] [X86] Add missing subvector_subreg_lowering for BF16 (#83720)

---
 llvm/lib/Target/X86/X86InstrVecCompiler.td|  3 +++
 .../CodeGen/X86/avx512bf16-vl-intrinsics.ll   | 22 +++
 llvm/test/CodeGen/X86/bfloat.ll   |  1 -
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/X86/X86InstrVecCompiler.td 
b/llvm/lib/Target/X86/X86InstrVecCompiler.td
index bbd19cf8d5b25e..461b2badc13134 100644
--- a/llvm/lib/Target/X86/X86InstrVecCompiler.td
+++ b/llvm/lib/Target/X86/X86InstrVecCompiler.td
@@ -83,6 +83,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 // A 128-bit subvector extract from the first 512-bit vector position is a
 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
@@ -95,6 +96,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 // A 128-bit subvector extract from the first 512-bit vector position is a
 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
@@ -107,6 +109,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 
 // If we're inserting into an all zeros vector, just use a plain move which
diff --git a/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll 
b/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
index 0826faa1071b01..482713e12d15c7 100644
--- a/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
+++ b/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
@@ -381,3 +381,25 @@ entry:
   %1 = shufflevector <8 x bfloat> %0, <8 x bfloat> undef, <16 x i32> 
zeroinitializer
   ret <16 x bfloat> %1
 }
+
+define <16 x i32> @pr83358() {
+; X86-LABEL: pr83358:
+; X86:   # %bb.0:
+; X86-NEXT:vcvtneps2bf16y {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 # encoding: 
[0x62,0xf2,0x7e,0x28,0x72,0x05,A,A,A,A]
+; X86-NEXT:# fixup A - offset: 6, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: 
FK_Data_4
+; X86-NEXT:vshufi64x2 $0, %zmm0, %zmm0, %zmm0 # encoding: 
[0x62,0xf3,0xfd,0x48,0x43,0xc0,0x00]
+; X86-NEXT:# zmm0 = zmm0[0,1,0,1,0,1,0,1]
+; X86-NEXT:retl # encoding: [0xc3]
+;
+; X64-LABEL: pr83358:
+; X64:   # %bb.0:
+; X64-NEXT:vcvtneps2bf16y {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 # 
encoding: [0x62,0xf2,0x7e,0x28,0x72,0x05,A,A,A,A]
+; X64-NEXT:# fixup A - offset: 6, value: {{\.?LCPI[0-9]+_[0-9]+}}-4, kind: 
reloc_riprel_4byte
+; X64-NEXT:vshufi64x2 $0, %zmm0, %zmm0, %zmm0 # encoding: 
[0x62,0xf3,0xfd,0x48,0x43,0xc0,0x00]
+; X64-NEXT:# zmm0 = zmm0[0,1,0,1,0,1,0,1]
+; X64-NEXT:retq # encoding: [0xc3]
+  %1 = call <8 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256(<8 x float> 
)
+  %2 = bitcast <8 x bfloat> %1 to <4 x i32>
+  %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <16 x i32> 
+  ret <16 x i32> %3
+}
diff --git a/llvm/test/CodeGen/X86/bfloat.ll b/llvm/test/CodeGen/X86/bfloat.ll
index f2d3c4fb34199e..cd1dba17611628 100644
--- a/llvm/test/CodeGen/X86/bfloat.ll
+++ b/llvm/test/CodeGen/X86/bfloat.ll
@@ -2423,7 +2423,6 @@ define <16 x bfloat> @fptrunc_v16f32(<16 x float> %a) 
nounwind {
 ; AVXNC-LABEL: fptrunc_v16f32:
 ; AVXNC:   # %bb.0:
 ; AVXNC-NEXT:{vex} vcvtneps2bf16 %ymm0, %xmm0
-; AVXNC-NEXT:vinsertf128 $0, %xmm0, %ymm0, %ymm0
 ; AVXNC-NEXT:{vex} vcvtneps2bf16 %ymm1, %xmm1
 ; AVXNC-NEXT:vinsertf128 $1, %xmm1, %ymm0, %ymm0
 ; AVXNC-NEXT:retq

___
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] release/18.x: [Mips] Fix missing sign extension in expansion of sub-word atomic max (#77072) (PR #84566)

2024-03-19 Thread Brad Smith via llvm-branch-commits


@@ -2001,8 +2225,6 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext 
%val) {
 ; MIPSELR6-NEXT:  $BB6_1: # %entry
 ; MIPSELR6-NEXT:# =>This Inner Loop Header: Depth=1
 ; MIPSELR6-NEXT:ll $2, 0($6)
-; MIPSELR6-NEXT:and $2, $2, $8

brad0 wrote:

> @brad0 I think I missed this in the previous review. Why is it ok to remove 
> the AND from the unsigned tests? My original command about the AND being 
> unnecssary was for the signed cases.

Looking at the PR I am not sure that was clear and @yingopq might have 
interpreted your comment as to remove all together.

https://github.com/llvm/llvm-project/pull/84566
___
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] release/18.x: backport [C++20] [Moduls] Avoid computing odr hash for functions from comparing constraint expression (PR #84723)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/84723

>From 0bf7ff1028fb7cc81324e9c38c585e6533b754e4 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Mon, 11 Mar 2024 11:14:40 +0800
Subject: [PATCH] [C++20] [Moduls] Avoid computing odr hash for functions from
 comparing constraint expression

Previously we disabled to compute ODR hash for declarations from the
global module fragment. However, we missed the case that the functions
lives in the concept requiments (see the attached the test files for
example). And the mismatch causes the potential crashment.

Due to we will set the function body as lazy after we deserialize it and
we will only take its body when needed. However, we don't allow to take
the body during deserializing. So it is actually potentially problematic
if we set the body as lazy first and computing the hash value of the
function, which requires to deserialize its body. So we will meet a
crash here.

This patch tries to solve the issue by not taking the body of the
function from GMF. Note that we can't skip comparing the constraint
expression from the GMF directly since it is an key part of the
function selecting and it may be the reason why we can't return 0
directly for `FunctionDecl::getODRHash()` from the GMF.
---
 clang/include/clang/AST/DeclBase.h| 10 +++
 clang/include/clang/Serialization/ASTReader.h |  7 --
 clang/lib/AST/Decl.cpp|  2 +-
 clang/lib/AST/DeclBase.cpp|  5 ++
 clang/lib/Serialization/ASTReader.cpp |  2 +-
 clang/lib/Serialization/ASTReaderDecl.cpp |  8 +--
 clang/lib/Serialization/ASTWriter.cpp |  2 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  8 +--
 .../hashing-decls-in-exprs-from-gmf.cppm  | 67 +++
 9 files changed, 93 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/Modules/hashing-decls-in-exprs-from-gmf.cppm

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 9a4736019d1b1b..eb7a1a32060077 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -673,6 +673,16 @@ class alignas(8) Decl {
   /// fragment. See [module.global.frag]p3,4 for details.
   bool isDiscardedInGlobalModuleFragment() const { return false; }
 
+  /// Check if we should skip checking ODRHash for declaration \param D.
+  ///
+  /// The existing ODRHash mechanism seems to be not stable enough and
+  /// the false positive ODR violation reports are annoying and we rarely see
+  /// true ODR violation reports. Also we learned that MSVC disabled ODR checks
+  /// for declarations in GMF. So we try to disable ODR checks in the GMF to
+  /// get better user experiences before we make the ODR violation checks 
stable
+  /// enough.
+  bool shouldSkipCheckingODR() const;
+
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
   bool hasDefiningAttr() const;
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index cd28226c295b32..62c25f5b7a0df8 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2451,13 +2451,6 @@ class BitsUnpacker {
   uint32_t Value;
   uint32_t CurrentBitsIndex = ~0;
 };
-
-inline bool shouldSkipCheckingODR(const Decl *D) {
-  return D->getOwningModule() &&
- D->getASTContext().getLangOpts().SkipODRCheckInGMF &&
- D->getOwningModule()->isExplicitGlobalModule();
-}
-
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 26fdfa040796ed..1ee33fd7576d7d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4476,7 +4476,7 @@ unsigned FunctionDecl::getODRHash() {
   }
 
   class ODRHash Hash;
-  Hash.AddFunctionDecl(this);
+  Hash.AddFunctionDecl(this, /*SkipBody=*/shouldSkipCheckingODR());
   setHasODRHash(true);
   ODRHash = Hash.CalculateHash();
   return ODRHash;
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 8163f9bdaf8d97..6b3c13ff206d23 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1102,6 +1102,11 @@ bool Decl::isInAnotherModuleUnit() const {
   return M != getASTContext().getCurrentNamedModule();
 }
 
+bool Decl::shouldSkipCheckingODR() const {
+  return getASTContext().getLangOpts().SkipODRCheckInGMF && getOwningModule() 
&&
+ getOwningModule()->isExplicitGlobalModule();
+}
+
 static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
 
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 028610deb3001e..490b8cb10a4841 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9745,7 +9745,7 @@ void ASTReader::finishP

[llvm-branch-commits] [clang] 0bf7ff1 - [C++20] [Moduls] Avoid computing odr hash for functions from comparing constraint expression

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

Author: Chuanqi Xu
Date: 2024-03-19T14:03:55-07:00
New Revision: 0bf7ff1028fb7cc81324e9c38c585e6533b754e4

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

LOG: [C++20] [Moduls] Avoid computing odr hash for functions from comparing 
constraint expression

Previously we disabled to compute ODR hash for declarations from the
global module fragment. However, we missed the case that the functions
lives in the concept requiments (see the attached the test files for
example). And the mismatch causes the potential crashment.

Due to we will set the function body as lazy after we deserialize it and
we will only take its body when needed. However, we don't allow to take
the body during deserializing. So it is actually potentially problematic
if we set the body as lazy first and computing the hash value of the
function, which requires to deserialize its body. So we will meet a
crash here.

This patch tries to solve the issue by not taking the body of the
function from GMF. Note that we can't skip comparing the constraint
expression from the GMF directly since it is an key part of the
function selecting and it may be the reason why we can't return 0
directly for `FunctionDecl::getODRHash()` from the GMF.

Added: 
clang/test/Modules/hashing-decls-in-exprs-from-gmf.cppm

Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 9a4736019d1b1b..eb7a1a32060077 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -673,6 +673,16 @@ class alignas(8) Decl {
   /// fragment. See [module.global.frag]p3,4 for details.
   bool isDiscardedInGlobalModuleFragment() const { return false; }
 
+  /// Check if we should skip checking ODRHash for declaration \param D.
+  ///
+  /// The existing ODRHash mechanism seems to be not stable enough and
+  /// the false positive ODR violation reports are annoying and we rarely see
+  /// true ODR violation reports. Also we learned that MSVC disabled ODR checks
+  /// for declarations in GMF. So we try to disable ODR checks in the GMF to
+  /// get better user experiences before we make the ODR violation checks 
stable
+  /// enough.
+  bool shouldSkipCheckingODR() const;
+
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
   bool hasDefiningAttr() const;

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index cd28226c295b32..62c25f5b7a0df8 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2451,13 +2451,6 @@ class BitsUnpacker {
   uint32_t Value;
   uint32_t CurrentBitsIndex = ~0;
 };
-
-inline bool shouldSkipCheckingODR(const Decl *D) {
-  return D->getOwningModule() &&
- D->getASTContext().getLangOpts().SkipODRCheckInGMF &&
- D->getOwningModule()->isExplicitGlobalModule();
-}
-
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 26fdfa040796ed..1ee33fd7576d7d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4476,7 +4476,7 @@ unsigned FunctionDecl::getODRHash() {
   }
 
   class ODRHash Hash;
-  Hash.AddFunctionDecl(this);
+  Hash.AddFunctionDecl(this, /*SkipBody=*/shouldSkipCheckingODR());
   setHasODRHash(true);
   ODRHash = Hash.CalculateHash();
   return ODRHash;

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 8163f9bdaf8d97..6b3c13ff206d23 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1102,6 +1102,11 @@ bool Decl::isInAnotherModuleUnit() const {
   return M != getASTContext().getCurrentNamedModule();
 }
 
+bool Decl::shouldSkipCheckingODR() const {
+  return getASTContext().getLangOpts().SkipODRCheckInGMF && getOwningModule() 
&&
+ getOwningModule()->isExplicitGlobalModule();
+}
+
 static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
 

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 028610deb3001e..490b8cb10a4841 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9745,7 +9745,7 @@ void ASTReader::finishPendingActions() {
 !NonConstDefn->isLateTemplateParsed

[llvm-branch-commits] [clang] release/18.x: backport [C++20] [Moduls] Avoid computing odr hash for functions from comparing constraint expression (PR #84723)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/84723
___
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] release/18.x: [X86] Add missing subvector_subreg_lowering for BF16 (#83720) (PR #83834)

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

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/83834

>From 26a1d6601d727a96f4301d0d8647b5a42760ae0c Mon Sep 17 00:00:00 2001
From: Phoebe Wang 
Date: Mon, 4 Mar 2024 18:09:41 +0800
Subject: [PATCH] [X86] Add missing subvector_subreg_lowering for BF16 (#83720)

---
 llvm/lib/Target/X86/X86InstrVecCompiler.td|  3 +++
 .../CodeGen/X86/avx512bf16-vl-intrinsics.ll   | 22 +++
 llvm/test/CodeGen/X86/bfloat.ll   |  1 -
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/X86/X86InstrVecCompiler.td 
b/llvm/lib/Target/X86/X86InstrVecCompiler.td
index bbd19cf8d5b25e..461b2badc13134 100644
--- a/llvm/lib/Target/X86/X86InstrVecCompiler.td
+++ b/llvm/lib/Target/X86/X86InstrVecCompiler.td
@@ -83,6 +83,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 // A 128-bit subvector extract from the first 512-bit vector position is a
 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
@@ -95,6 +96,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 // A 128-bit subvector extract from the first 512-bit vector position is a
 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
@@ -107,6 +109,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 
 // If we're inserting into an all zeros vector, just use a plain move which
diff --git a/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll 
b/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
index 0826faa1071b01..482713e12d15c7 100644
--- a/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
+++ b/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
@@ -381,3 +381,25 @@ entry:
   %1 = shufflevector <8 x bfloat> %0, <8 x bfloat> undef, <16 x i32> 
zeroinitializer
   ret <16 x bfloat> %1
 }
+
+define <16 x i32> @pr83358() {
+; X86-LABEL: pr83358:
+; X86:   # %bb.0:
+; X86-NEXT:vcvtneps2bf16y {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 # encoding: 
[0x62,0xf2,0x7e,0x28,0x72,0x05,A,A,A,A]
+; X86-NEXT:# fixup A - offset: 6, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: 
FK_Data_4
+; X86-NEXT:vshufi64x2 $0, %zmm0, %zmm0, %zmm0 # encoding: 
[0x62,0xf3,0xfd,0x48,0x43,0xc0,0x00]
+; X86-NEXT:# zmm0 = zmm0[0,1,0,1,0,1,0,1]
+; X86-NEXT:retl # encoding: [0xc3]
+;
+; X64-LABEL: pr83358:
+; X64:   # %bb.0:
+; X64-NEXT:vcvtneps2bf16y {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 # 
encoding: [0x62,0xf2,0x7e,0x28,0x72,0x05,A,A,A,A]
+; X64-NEXT:# fixup A - offset: 6, value: {{\.?LCPI[0-9]+_[0-9]+}}-4, kind: 
reloc_riprel_4byte
+; X64-NEXT:vshufi64x2 $0, %zmm0, %zmm0, %zmm0 # encoding: 
[0x62,0xf3,0xfd,0x48,0x43,0xc0,0x00]
+; X64-NEXT:# zmm0 = zmm0[0,1,0,1,0,1,0,1]
+; X64-NEXT:retq # encoding: [0xc3]
+  %1 = call <8 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256(<8 x float> 
)
+  %2 = bitcast <8 x bfloat> %1 to <4 x i32>
+  %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <16 x i32> 
+  ret <16 x i32> %3
+}
diff --git a/llvm/test/CodeGen/X86/bfloat.ll b/llvm/test/CodeGen/X86/bfloat.ll
index f2d3c4fb34199e..cd1dba17611628 100644
--- a/llvm/test/CodeGen/X86/bfloat.ll
+++ b/llvm/test/CodeGen/X86/bfloat.ll
@@ -2423,7 +2423,6 @@ define <16 x bfloat> @fptrunc_v16f32(<16 x float> %a) 
nounwind {
 ; AVXNC-LABEL: fptrunc_v16f32:
 ; AVXNC:   # %bb.0:
 ; AVXNC-NEXT:{vex} vcvtneps2bf16 %ymm0, %xmm0
-; AVXNC-NEXT:vinsertf128 $0, %xmm0, %ymm0, %ymm0
 ; AVXNC-NEXT:{vex} vcvtneps2bf16 %ymm1, %xmm1
 ; AVXNC-NEXT:vinsertf128 $1, %xmm1, %ymm0, %ymm0
 ; AVXNC-NEXT:retq

___
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] 26a1d66 - [X86] Add missing subvector_subreg_lowering for BF16 (#83720)

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

Author: Phoebe Wang
Date: 2024-03-19T14:06:42-07:00
New Revision: 26a1d6601d727a96f4301d0d8647b5a42760ae0c

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

LOG: [X86] Add missing subvector_subreg_lowering for BF16 (#83720)

Added: 


Modified: 
llvm/lib/Target/X86/X86InstrVecCompiler.td
llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
llvm/test/CodeGen/X86/bfloat.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86InstrVecCompiler.td 
b/llvm/lib/Target/X86/X86InstrVecCompiler.td
index bbd19cf8d5b25e..461b2badc13134 100644
--- a/llvm/lib/Target/X86/X86InstrVecCompiler.td
+++ b/llvm/lib/Target/X86/X86InstrVecCompiler.td
@@ -83,6 +83,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 // A 128-bit subvector extract from the first 512-bit vector position is a
 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
@@ -95,6 +96,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 // A 128-bit subvector extract from the first 512-bit vector position is a
 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
@@ -107,6 +109,7 @@ defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
 defm : subvector_subreg_lowering;
+defm : subvector_subreg_lowering;
 
 
 // If we're inserting into an all zeros vector, just use a plain move which

diff  --git a/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll 
b/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
index 0826faa1071b01..482713e12d15c7 100644
--- a/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
+++ b/llvm/test/CodeGen/X86/avx512bf16-vl-intrinsics.ll
@@ -381,3 +381,25 @@ entry:
   %1 = shufflevector <8 x bfloat> %0, <8 x bfloat> undef, <16 x i32> 
zeroinitializer
   ret <16 x bfloat> %1
 }
+
+define <16 x i32> @pr83358() {
+; X86-LABEL: pr83358:
+; X86:   # %bb.0:
+; X86-NEXT:vcvtneps2bf16y {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 # encoding: 
[0x62,0xf2,0x7e,0x28,0x72,0x05,A,A,A,A]
+; X86-NEXT:# fixup A - offset: 6, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: 
FK_Data_4
+; X86-NEXT:vshufi64x2 $0, %zmm0, %zmm0, %zmm0 # encoding: 
[0x62,0xf3,0xfd,0x48,0x43,0xc0,0x00]
+; X86-NEXT:# zmm0 = zmm0[0,1,0,1,0,1,0,1]
+; X86-NEXT:retl # encoding: [0xc3]
+;
+; X64-LABEL: pr83358:
+; X64:   # %bb.0:
+; X64-NEXT:vcvtneps2bf16y {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 # 
encoding: [0x62,0xf2,0x7e,0x28,0x72,0x05,A,A,A,A]
+; X64-NEXT:# fixup A - offset: 6, value: {{\.?LCPI[0-9]+_[0-9]+}}-4, kind: 
reloc_riprel_4byte
+; X64-NEXT:vshufi64x2 $0, %zmm0, %zmm0, %zmm0 # encoding: 
[0x62,0xf3,0xfd,0x48,0x43,0xc0,0x00]
+; X64-NEXT:# zmm0 = zmm0[0,1,0,1,0,1,0,1]
+; X64-NEXT:retq # encoding: [0xc3]
+  %1 = call <8 x bfloat> @llvm.x86.avx512bf16.cvtneps2bf16.256(<8 x float> 
)
+  %2 = bitcast <8 x bfloat> %1 to <4 x i32>
+  %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <16 x i32> 
+  ret <16 x i32> %3
+}

diff  --git a/llvm/test/CodeGen/X86/bfloat.ll b/llvm/test/CodeGen/X86/bfloat.ll
index f2d3c4fb34199e..cd1dba17611628 100644
--- a/llvm/test/CodeGen/X86/bfloat.ll
+++ b/llvm/test/CodeGen/X86/bfloat.ll
@@ -2423,7 +2423,6 @@ define <16 x bfloat> @fptrunc_v16f32(<16 x float> %a) 
nounwind {
 ; AVXNC-LABEL: fptrunc_v16f32:
 ; AVXNC:   # %bb.0:
 ; AVXNC-NEXT:{vex} vcvtneps2bf16 %ymm0, %xmm0
-; AVXNC-NEXT:vinsertf128 $0, %xmm0, %ymm0, %ymm0
 ; AVXNC-NEXT:{vex} vcvtneps2bf16 %ymm1, %xmm1
 ; AVXNC-NEXT:vinsertf128 $1, %xmm1, %ymm0, %ymm0
 ; AVXNC-NEXT:retq



___
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] release/18.x: [X86] Add missing subvector_subreg_lowering for BF16 (#83720) (PR #83834)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/83834
___
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] release/18.x: [Mips] Fix missing sign extension in expansion of sub-word atomic max (#77072) (PR #84566)

2024-03-19 Thread Craig Topper via llvm-branch-commits

https://github.com/topperc edited 
https://github.com/llvm/llvm-project/pull/84566
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-19 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

___
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] 8ca9b98 - Revert "[llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (#84…"

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

Author: Jonas Devlieghere
Date: 2024-03-19T17:16:21-07:00
New Revision: 8ca9b987b47584519a5b370de8d97c1284ac7aff

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

LOG: Revert "[llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version 
(#84…"

This reverts commit 6885810e7de283ee8d3c8fc328a98544970b3db6.

Added: 


Modified: 
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CommandLine.cpp

Removed: 




diff  --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index da2a4b4cdec568..e18beddf7bc5b7 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -288,9 +288,6 @@ add_llvm_component_library(LLVMSupport
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
   ${Backtrace_INCLUDE_DIRS}
 
-  DEPENDS
-  llvm_vcsrevision_h
-
   LINK_LIBS
   ${system_libs} ${imported_libs} ${delayload_flags}
 

diff  --git a/llvm/lib/Support/CommandLine.cpp 
b/llvm/lib/Support/CommandLine.cpp
index 42dbc4de200303..c076ae8b843179 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -39,7 +39,6 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
-#include "llvm/Support/VCSRevision.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -2539,15 +2538,7 @@ class VersionPrinter {
 #else
 OS << "LLVM (http://llvm.org/):\n  ";
 #endif
-OS << PACKAGE_NAME << " version " << PACKAGE_VERSION;
-#ifdef LLVM_REPOSITORY
-OS << " (" << LLVM_REPOSITORY;
-#ifdef LLVM_REVISION
-OS << ' ' << LLVM_REVISION;
-#endif
-OS << ')';
-#endif
-OS << "\n  ";
+OS << PACKAGE_NAME << " version " << PACKAGE_VERSION << "\n  ";
 #if LLVM_IS_DEBUG_BUILD
 OS << "DEBUG build";
 #else



___
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] [lldb] 719069e - Revert "[lldb] Store SupportFile in FileEntry (NFC) (#85468)"

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

Author: Jonas Devlieghere
Date: 2024-03-19T17:47:26-07:00
New Revision: 719069e6b7e191e338bbb17e9e18b7974b5acef0

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

LOG: Revert "[lldb] Store SupportFile in FileEntry (NFC) (#85468)"

This reverts commit d5a277d309e92b1d3e493da6036cffdf815105b1.

Added: 


Modified: 
lldb/include/lldb/Core/Disassembler.h
lldb/include/lldb/Symbol/LineEntry.h
lldb/include/lldb/Utility/SupportFile.h
lldb/source/API/SBLineEntry.cpp
lldb/source/API/SBThread.cpp
lldb/source/Breakpoint/BreakpointResolver.cpp
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Core/Address.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Core/FormatEntity.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Core/SourceManager.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/Function.cpp
lldb/source/Symbol/LineEntry.cpp
lldb/source/Symbol/LineTable.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Target/StackFrame.cpp
lldb/source/Target/StackFrameList.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/TraceDumper.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Disassembler.h 
b/lldb/include/lldb/Core/Disassembler.h
index e037a49f152c74..885ac1bb4a7ef8 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -538,7 +538,7 @@ class Disassembler : public 
std::enable_shared_from_this,
   ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx,
  const SymbolContext &sc, LineEntry &line) 
{
 SourceLine sl;
-sl.file = line.GetFile();
+sl.file = line.file;
 sl.line = line.line;
 sl.column = line.column;
 return ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, sl);

diff  --git a/lldb/include/lldb/Symbol/LineEntry.h 
b/lldb/include/lldb/Symbol/LineEntry.h
index eb8ad6ee9368d2..c2daba916e3f98 100644
--- a/lldb/include/lldb/Symbol/LineEntry.h
+++ b/lldb/include/lldb/Symbol/LineEntry.h
@@ -130,28 +130,18 @@ struct LineEntry {
   /// Shared pointer to the target this LineEntry belongs to.
   void ApplyFileMappings(lldb::TargetSP target_sp);
 
-  const FileSpec &GetFile() const {
-assert(file_sp);
-return file_sp->GetSpecOnly();
-  }
-
-  /// The section offset address range for this line entry.
-  AddressRange range;
-
-  /// The source file, possibly mapped by the target.source-map setting.
-  lldb::SupportFileSP file_sp;
-
-  /// The original source file, from debug info.
-  lldb::SupportFileSP original_file_sp;
-
-  /// The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line
-  /// number information.
-  uint32_t line = LLDB_INVALID_LINE_NUMBER;
-
-  /// The column number of the source line, or zero if there is no column
-  /// information.
-  uint16_t column = 0;
-
+  // Member variables.
+  AddressRange range; ///< The section offset address range for this line 
entry.
+  FileSpec file; ///< The source file, possibly mapped by the target.source-map
+ ///setting
+  lldb::SupportFileSP
+  original_file_sp; ///< The original source file, from debug info.
+  uint32_t line = LLDB_INVALID_LINE_NUMBER; ///< The source line number, or 
zero
+///< if there is no line number
+/// information.
+  uint16_t column =
+  0; ///< The column number of the source line, or zero if there
+ /// is no column information.
   uint16_t is_start_of_statement : 1, ///< Indicates this entry is the 
beginning
   ///of a statement.
   is_start_of_basic_block : 1, ///< Indicates this entry is the beginning 
of

diff  --git a/lldb/include/lldb/Utility/SupportFile.h 
b/lldb/include/lldb/Utility/SupportFile.h
index 7505d7f345c5dd..0ea0ca4e7c97a1 100644
--- a/lldb/include/lldb/Utility/SupportFile.h
+++ b/lldb/include/lldb/Utility/SupportFile.h
@@ -45,9 +45,6 @@ class SupportFile {
   /// Materialize the file to disk and return the path to that temporary file.
   virtual const FileSpec &Materialize() { return m_file_spec; }
 
-  /// Change the file name.
-  void Update(const FileSpec &file_spec) { m_file_spec = file_spec; }
-
 protected:
   FileSpec m_file_spec;
   Checksum m_checksum;

diff  --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp
index f9fd750c2ee64e..28d12e65fdaf8a 100644
--- a/lldb/source/

[llvm-branch-commits] [llvm] release/18.x: [Mips] Fix missing sign extension in expansion of sub-word atomic max (#77072) (PR #84566)

2024-03-19 Thread Craig Topper via llvm-branch-commits


@@ -2001,8 +2225,6 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext 
%val) {
 ; MIPSELR6-NEXT:  $BB6_1: # %entry
 ; MIPSELR6-NEXT:# =>This Inner Loop Header: Depth=1
 ; MIPSELR6-NEXT:ll $2, 0($6)
-; MIPSELR6-NEXT:and $2, $2, $8

topperc wrote:

@yingopq I'm not really a Mips expert so I'm not sure. But my understanding is 
that the and was clearing the upper and lower bits so that the unsigned min/max 
would only consider the byte or half word that it should and not any other 
values around it in memory.

https://github.com/llvm/llvm-project/pull/84566
___
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] release/18.x: [Mips] Fix missing sign extension in expansion of sub-word atomic max (#77072) (PR #84566)

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


@@ -2001,8 +2225,6 @@ define i16 @test_umax_16(ptr nocapture %ptr, i16 signext 
%val) {
 ; MIPSELR6-NEXT:  $BB6_1: # %entry
 ; MIPSELR6-NEXT:# =>This Inner Loop Header: Depth=1
 ; MIPSELR6-NEXT:ll $2, 0($6)
-; MIPSELR6-NEXT:and $2, $2, $8

yingopq wrote:

Yes, I would submit again soon. Thanks.

https://github.com/llvm/llvm-project/pull/84566
___
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] release/18.x: Reland Print library module manifest path again (#84881) (PR #85637)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

mordante wrote:

Based on the [post review comments 
](https://github.com/llvm/llvm-project/pull/84881#issuecomment-2003793001) on 
the original PR I feel I need to do additional work. The feature originally 
landed shortly before branching. Based on the number of issues we had with I 
feel we should not backport it.

https://github.com/llvm/llvm-project/pull/85637
___
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] release/18.x: Reland Print library module manifest path again (#84881) (PR #85637)

2024-03-19 Thread Chuanqi Xu via llvm-branch-commits

https://github.com/ChuanqiXu9 closed 
https://github.com/llvm/llvm-project/pull/85637
___
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] release/18.x: Reland Print library module manifest path again (#84881) (PR #85637)

2024-03-19 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

Yeah, agreed.

https://github.com/llvm/llvm-project/pull/85637
___
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] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-19 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/85896

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting

>From 5597a07ac32a21d05b674d767395ee7583d11073 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  37 +
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  71 +
 .../time/time.syn/formatter.sys_info.pass.cpp | 138 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  48 ++
 8 files changed, 325 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..f5474e3ea6d078 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -202,6 +203,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __result;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  if constexpr (same_as<_Tp, chrono::sys_info>) {
+__result.__offset = __value.offset;
+__result.__abbrev = __value.abbrev;
+  }
+#  endif
   return __result;
 }
 
@@ -411,6 +418,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  else if constexpr (same_as<_Tp, chrono::sys_info>)
+return true;
+#  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
 }
@@ -451,6 +462,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool 
__weekday_name_ok(const _Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

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

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting

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


8 Files Affected:

- (modified) libcxx/docs/Status/FormatPaper.csv (+1-1) 
- (modified) libcxx/include/__chrono/convert_to_tm.h (+5) 
- (modified) libcxx/include/__chrono/formatter.h (+37) 
- (modified) libcxx/include/__chrono/ostream.h (+20) 
- (modified) libcxx/include/chrono (+5) 
- (added) 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 (+71) 
- (added) libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp (+138) 
- (added) 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 (+48) 


``diff
diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index 82da54284c7386..32166ec72da753 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..f5474e3ea6d078 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -202,6 +203,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __result;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  if constexpr (same_as<_Tp, chrono::sys_info>) {
+__result.__offset = __value.offset;
+__result.__abbrev = __value.abbrev;
+  }
+#  endif
   return __result;
 }
 
@@ -411,6 +418,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const 
_Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  else if constexpr (same_as<_Tp, chrono::sys_info>)
+return true;
+#  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
 }
@@ -451,6 +462,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool 
__weekday_name_ok(const _Tp& __value) {
 return __value.weekday().ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  else if constexpr (same_as<_Tp, chrono::sys_info>)
+return true;
+#  endif
   else
 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
 }
@@ -491,6 +506,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& 
__value) {
 return __value.ok();
   else if constexpr (__is_hh_mm_ss<_Tp>)
 return true;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  else if constexp

[llvm-branch-commits] [mlir] [MLIR][LLVM][SROA] Support incorrectly typed memory accesses (PR #85813)

2024-03-19 Thread Christian Ulmann via llvm-branch-commits


@@ -384,16 +468,17 @@ bool LLVM::GEPOp::canRewire(const 
DestructurableMemorySlot &slot,
   // dynamic indices can never be properly rewired.
   if (!getDynamicIndices().empty())
 return false;
+   TODO: This is not necessary, I think.
+  // if (slot.elemType != getElemType())
+  //   return false;

Dinistro wrote:

Whups, this is indeed a rebase/stash artefact.
I have some changes in the pipeline that will cover this case. 

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


  1   2   >