[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-11-11 Thread Michael Kruse via llvm-branch-commits

Meinersbur wrote:

> We should do `check_cxx_compiler_flag(-nostdlib++ FLANG_RT_HAS_NOSTDLIBPP)`, 
> it's a lot more obvious when your program doesn't link than when a test fails 
> (but the test is still good).

`-nostdlib++` has no influence on `libflang_rt.a` which is created by `ar`, not 
the linker. The unittests do require the C++ runtime library due to transitive 
dependency through GTest / LLVMSupport. The `flang(-new)` driver will never add 
lib(std)c++ linker flags, and test using the driver are in `flang/`.

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


[llvm-branch-commits] [compiler-rt] [TySan] Improved compatability for tests (PR #96507)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -23,8 +24,8 @@ void f(int m) {
   }
 
   // CHECK:  TypeSanitizer: type-aliasing-violation on address
-  // CHECK-NEXT: READ of size 2 at {{.+}} with type short accesses an existing 
object of type long long
-  // CHECK-NEXT:in f violation-pr47137.c:30
+  // CHECK-NEXT: READ of size 2 at {{.+}} with type short accesses an existing 
object of type {{(long)+}}

jmorse wrote:

IMO having an optional (with `?`) long is preferable to having an unbound 
number of longs.

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


[llvm-branch-commits] [compiler-rt] [TySan] Improved compatability for tests (PR #96507)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -18,7 +18,7 @@ int main(void) {
 
   // CHECK:  TypeSanitizer: type-aliasing-violation on address
   // CHECK-NEXT: WRITE of size 8 at {{.+}} with type double accesses an 
existing object of type float
-  // CHECK-NEXT:   in main violation-pr45282.c:25
+  // CHECK-NEXT:   in main {{.*violation-pr45282.c:25.*}}

jmorse wrote:

Nit: IMO having `{{.*}}` to swallow extra path components is slightly 
preferable, as that avoids the filename being part of a regex. Almost certainly 
not ever going to be a problem, but it reduces what can go wrong. Does your 
environment also have trailing components after the line number? If there's any 
whitespace between '5' and the extra text then FileCheck will (99% confident) 
ignore those anyway.

Similar thoughts apply to all the other similar regexes.

https://github.com/llvm/llvm-project/pull/96507
___
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++] Stop copying headers to the build directory (PR #115380)

2024-11-11 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/115380

>From e26c0f6fd46cdc74eb96e342ff14acc5b8d64a84 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Thu, 7 Nov 2024 14:20:52 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 libcxx/CMakeLists.txt | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index d699135774ee0b..04596fccdfc923 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -414,15 +414,16 @@ set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE 
STRING
 set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared 
libc++ runtime library.")
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static 
libc++ runtime library.")
 
+set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
+set(LIBCXX_GENERATED_MODULE_DIR "${LIBCXX_BINARY_DIR}/modules/c++/v1")
+
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
   endif()
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR})
-  set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LIBCXX_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
   set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LIBCXX_TARGET_SUBDIR} CACHE STRING
   "Path where built libc++ libraries should be installed.")
   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LIBCXX_TARGET_SUBDIR}/c++/v1" CACHE STRING
@@ -431,12 +432,8 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 else()
   if(LLVM_LIBRARY_OUTPUT_INTDIR)
 set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
   else()
 set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-set(LIBCXX_GENERATED_MODULE_DIR "${CMAKE_BINARY_DIR}/modules/c++/v1")
   endif()
   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE STRING

___
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++] Stop copying headers to the build directory (PR #115380)

2024-11-11 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/115380

>From e26c0f6fd46cdc74eb96e342ff14acc5b8d64a84 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Thu, 7 Nov 2024 14:20:52 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 libcxx/CMakeLists.txt | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index d699135774ee0b..04596fccdfc923 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -414,15 +414,16 @@ set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE 
STRING
 set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared 
libc++ runtime library.")
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static 
libc++ runtime library.")
 
+set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
+set(LIBCXX_GENERATED_MODULE_DIR "${LIBCXX_BINARY_DIR}/modules/c++/v1")
+
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
   endif()
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR})
-  set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LIBCXX_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
   set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LIBCXX_TARGET_SUBDIR} CACHE STRING
   "Path where built libc++ libraries should be installed.")
   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LIBCXX_TARGET_SUBDIR}/c++/v1" CACHE STRING
@@ -431,12 +432,8 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 else()
   if(LLVM_LIBRARY_OUTPUT_INTDIR)
 set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
   else()
 set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-set(LIBCXX_GENERATED_MODULE_DIR "${CMAKE_BINARY_DIR}/modules/c++/v1")
   endif()
   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE STRING

___
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] [lldb] [libc++] Stop copying headers to the build directory (PR #115380)

2024-11-11 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/115380

>From e26c0f6fd46cdc74eb96e342ff14acc5b8d64a84 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Thu, 7 Nov 2024 14:20:52 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 libcxx/CMakeLists.txt | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index d699135774ee0b..04596fccdfc923 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -414,15 +414,16 @@ set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE 
STRING
 set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared 
libc++ runtime library.")
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static 
libc++ runtime library.")
 
+set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
+set(LIBCXX_GENERATED_MODULE_DIR "${LIBCXX_BINARY_DIR}/modules/c++/v1")
+
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
   endif()
   set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR})
-  set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LIBCXX_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
   set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LIBCXX_TARGET_SUBDIR} CACHE STRING
   "Path where built libc++ libraries should be installed.")
   set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LIBCXX_TARGET_SUBDIR}/c++/v1" CACHE STRING
@@ -431,12 +432,8 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 else()
   if(LLVM_LIBRARY_OUTPUT_INTDIR)
 set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
   else()
 set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
-set(LIBCXX_GENERATED_MODULE_DIR "${CMAKE_BINARY_DIR}/modules/c++/v1")
   endif()
   set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
   set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE STRING

>From a23259875f4a75c0e99b20be7c48e2154362932b Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Mon, 11 Nov 2024 16:13:55 -0800
Subject: [PATCH 2/2] Attempt to fix lldb tests for bootstrapping build

Created using spr 1.3.6-beta.1
---
 lldb/test/CMakeLists.txt  | 19 +--
 lldb/utils/lldb-dotest/CMakeLists.txt | 16 +++-
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 6449ac5a9247f6..d51b18d71f3980 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -157,15 +157,22 @@ if(TARGET clang)
   # TestFullLtoStepping depends on LTO, and only runs when the compiler is 
clang.
   add_lldb_test_dependency(LTO)
 
-  if (TARGET libcxx OR ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES))
+  if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
 set(LLDB_HAS_LIBCXX ON)
+# libc++ can only be used for tests after installing to a fake prefix
+# which is done by the install-cxx-test-suite-prefix target in libc++. We
+# ensure this is run by depending on the runtimes-test-depends target.
+# While this could build too many dependencies, it is currently the only
+# test dependencies target exposed by the runtimes build.
+add_lldb_test_dependency(runtimes-test-depends)
+set(LIBCXX_TEST_INSTALL_DIR 
"${CMAKE_BINARY_DIR}/runtimes/runtimes-${LLVM_DEFAULT_TARGET_TRIPLE}-bins/libcxx/test-suite-install")
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-  set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+  set(LIBCXX_LIBRARY_DIR 
${LIBCXX_TEST_INSTALL_DIR}/lib/${LLVM_DEFAULT_TARGET_TRIPLE})
+  set(LIBCXX_GENERATED_INCLUDE_DIR 
"${LIBCXX_TEST_INSTALL_DIR}/include/c++/v1")
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LIBCXX_TEST_INSTALL_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
 else()
-  set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
-  set(

[llvm-branch-commits] [libcxx] [lldb] [libc++] Stop copying headers to the build directory (PR #115380)

2024-11-11 Thread Alexander Richardson via llvm-branch-commits

arichardson wrote:

It looks like the lldb test suite depends on these files being copied as well, 
so I've updated it to depend on the runtimes-test-depends target to ensure the 
libc++ headers have been installed to the fake prefix in the build dir first. 
Hardcoding these paths is unfortunate but I couldn't see an obviously better 
solution. This dates back to https://reviews.llvm.org/D133973

https://github.com/llvm/llvm-project/pull/115380
___
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] [libcxxabi] 4a6b368 - Revert "Reapply "[libc++abi] Stop copying headers to the build directory""

2024-11-11 Thread via llvm-branch-commits

Author: Alexander Richardson
Date: 2024-11-11T16:19:47-08:00
New Revision: 4a6b368cefbddda3d98815557b991c0449262659

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

LOG: Revert "Reapply "[libc++abi] Stop copying headers to the build directory""

This reverts commit fd799add2186356dc19e81106a1428a2edf7c20b.

Added: 


Modified: 
libcxxabi/CMakeLists.txt
libcxxabi/include/CMakeLists.txt

Removed: 




diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 50e9a296a4a13b..da0e8b286cddc1 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -86,6 +86,12 @@ set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi" CACHE STRING 
"Output name for the stat
 
 set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE 
STRING "Path to install the libc++abi headers at.")
 
+if(LLVM_LIBRARY_OUTPUT_INTDIR)
+  set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
+else()
+  set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
+endif()
+
 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
 set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
 "Version of libc++abi. This will be reflected in the name of the shared \

diff  --git a/libcxxabi/include/CMakeLists.txt 
b/libcxxabi/include/CMakeLists.txt
index 0deb7b1eb9e715..5b1cc2545016ec 100644
--- a/libcxxabi/include/CMakeLists.txt
+++ b/libcxxabi/include/CMakeLists.txt
@@ -3,7 +3,20 @@ set(files
   cxxabi.h
   )
 
+foreach(f ${files})
+  set(src "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
+  set(dst "${LIBCXXABI_GENERATED_INCLUDE_DIR}/${f}")
+  add_custom_command(OUTPUT ${dst}
+DEPENDS ${src}
+COMMAND ${CMAKE_COMMAND} -E copy_if_
diff erent ${src} ${dst}
+COMMENT "Copying CXXABI header ${f}")
+  list(APPEND _all_includes "${dst}")
+endforeach()
+
+add_custom_target(generate-cxxabi-headers ALL DEPENDS ${_all_includes})
+
 add_library(cxxabi-headers INTERFACE)
+add_dependencies(cxxabi-headers generate-cxxabi-headers)
 target_include_directories(cxxabi-headers INTERFACE 
"${CMAKE_CURRENT_SOURCE_DIR}")
 
 if (LIBCXXABI_INSTALL_HEADERS)



___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-11-11 Thread Michael Kruse via llvm-branch-commits


@@ -0,0 +1,165 @@
+#===-- CMakeLists.txt 
--===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#======#
+#
+# Build instructions for the flang-rt library. This is file is intended to be
+# included using the LLVM_ENABLE_RUNTIMES mechanism.
+#
+#======#
+
+set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
+set(FLANGRT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FLANGRT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")
+
+enable_language(Fortran)
+
+list(APPEND CMAKE_MODULE_PATH
+"${FLANGRT_SOURCE_DIR}/cmake/modules"
+"${FLANG_SOURCE_DIR}/cmake/modules"
+  )
+include(AddFlangRT)
+include(FlangCommon)
+
+
+
+# Build Mode Introspection #
+
+
+# Setting these variables from an LLVM build is sufficient that flang-rt can
+# construct the output paths, so it can behave as if it were in-tree here.
+set(LLVM_TREE_AVAILABLE OFF)
+if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND 
PACKAGE_VERSION)
+  # This is a bootstap build
+  set(LLVM_TREE_AVAILABLE ON)
+endif()
+
+if (LLVM_TREE_AVAILABLE)
+  # Despite Clang in the name, get_clang_resource_dir does not depend on Clang 
being added to the build
+  # flang-new uses the same resource dir as clang.
+  include(GetClangResourceDir)
+  get_clang_resource_dir(FLANGRT_BUILD_LIB_DIR PREFIX 
"${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+  get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR 
"lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the 
install prefix itself
+else ()
+  set(FLANGRT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
+  set(FLANGRT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+endif ()
+
+if (DEFINED WIN32)
+  set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/windows")

Meinersbur wrote:

done

https://github.com/llvm/llvm-project/pull/110217
___
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] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Anatoly Trosinenko via llvm-branch-commits

https://github.com/atrosinenko updated 
https://github.com/llvm/llvm-project/pull/115185

>From c4fa68c7ad66911e006c175ec9acf9e3cca9c1d9 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Mon, 21 Oct 2024 17:56:40 +0300
Subject: [PATCH 1/2] [AArch64][PAC] Eliminate excessive MOVs when computing
 blend

As function calls do not generally preserve X16 and X17, it is beneficial
to allow AddrDisc operand of B(L)RA instruction to reside in these
registers and make use of this condition when computing the discriminator.

This can save up to two MOVs in cases such as loading a (signed) virtual
function pointer via a (signed) pointer to vtable, for example

ldr   x9, [x16]
mov   x8, x16
mov   x17, x8
movk  x17, #34646, lsl #48
blraa x9, x17

can be simplified to

ldr   x8, [x16]
movk  x16, #34646, lsl #48
blraa x8, x16
---
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 94 +++
 llvm/lib/Target/AArch64/AArch64InstrInfo.td   | 18 ++--
 llvm/test/CodeGen/AArch64/ptrauth-call.ll | 27 ++
 3 files changed, 89 insertions(+), 50 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp 
b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 436bb332053f75..3263bb38ef1fcc 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -163,8 +163,15 @@ class AArch64AsmPrinter : public AsmPrinter {
   // Emit the sequence for AUT or AUTPAC.
   void emitPtrauthAuthResign(const MachineInstr *MI);
 
-  // Emit the sequence to compute a discriminator into x17, or reuse AddrDisc.
-  unsigned emitPtrauthDiscriminator(uint16_t Disc, unsigned AddrDisc);
+  // Emit the sequence to compute the discriminator.
+  // ScratchReg should be x16/x17.
+  // The returned register is either unmodified AddrDisc or x16/x17.
+  // If the expanded pseudo is allowed to clobber AddrDisc register, setting
+  // MayUseAddrAsScratch may save one MOV instruction, provided the address
+  // is already in x16/x17.
+  Register emitPtrauthDiscriminator(uint16_t Disc, Register AddrDisc,
+Register ScratchReg,
+bool MayUseAddrAsScratch = false);
 
   // Emit the sequence for LOADauthptrstatic
   void LowerLOADauthptrstatic(const MachineInstr &MI);
@@ -1727,8 +1734,10 @@ void AArch64AsmPrinter::emitFMov0(const MachineInstr 
&MI) {
   }
 }
 
-unsigned AArch64AsmPrinter::emitPtrauthDiscriminator(uint16_t Disc,
- unsigned AddrDisc) {
+Register AArch64AsmPrinter::emitPtrauthDiscriminator(uint16_t Disc,
+ Register AddrDisc,
+ Register ScratchReg,
+ bool MayUseAddrAsScratch) 
{
   // So far we've used NoRegister in pseudos.  Now we need real encodings.
   if (AddrDisc == AArch64::NoRegister)
 AddrDisc = AArch64::XZR;
@@ -1738,16 +1747,24 @@ unsigned 
AArch64AsmPrinter::emitPtrauthDiscriminator(uint16_t Disc,
   if (!Disc)
 return AddrDisc;
 
-  // If there's only a constant discriminator, MOV it into x17.
+  // If there's only a constant discriminator, MOV it into the scratch 
register.
   if (AddrDisc == AArch64::XZR) {
-emitMOVZ(AArch64::X17, Disc, 0);
-return AArch64::X17;
+emitMOVZ(ScratchReg, Disc, 0);
+return ScratchReg;
   }
 
-  // If there are both, emit a blend into x17.
-  emitMovXReg(AArch64::X17, AddrDisc);
-  emitMOVK(AArch64::X17, Disc, 48);
-  return AArch64::X17;
+  // If there are both, emit a blend into the scratch register.
+
+  // Check if we can save one MOV instruction.
+  assert(MayUseAddrAsScratch || ScratchReg != AddrDisc);
+  bool AddrDiscIsSafe = AddrDisc == AArch64::X16 || AddrDisc == AArch64::X17;
+  if (MayUseAddrAsScratch && AddrDiscIsSafe)
+ScratchReg = AddrDisc;
+  else
+emitMovXReg(ScratchReg, AddrDisc);
+
+  emitMOVK(ScratchReg, Disc, 48);
+  return ScratchReg;
 }
 
 /// Emits a code sequence to check an authenticated pointer value.
@@ -1964,7 +1981,8 @@ void AArch64AsmPrinter::emitPtrauthAuthResign(const 
MachineInstr *MI) {
 
   // Compute aut discriminator into x17
   assert(isUInt<16>(AUTDisc));
-  unsigned AUTDiscReg = emitPtrauthDiscriminator(AUTDisc, AUTAddrDisc);
+  Register AUTDiscReg =
+  emitPtrauthDiscriminator(AUTDisc, AUTAddrDisc, AArch64::X17);
   bool AUTZero = AUTDiscReg == AArch64::XZR;
   unsigned AUTOpc = getAUTOpcodeForKey(AUTKey, AUTZero);
 
@@ -2005,7 +2023,8 @@ void AArch64AsmPrinter::emitPtrauthAuthResign(const 
MachineInstr *MI) {
 
   // Compute pac discriminator into x17
   assert(isUInt<16>(PACDisc));
-  unsigned PACDiscReg = emitPtrauthDiscriminator(PACDisc, PACAddrDisc);
+  Register PACDiscReg =
+  emitPtrauthDiscriminator(PACDisc, PACAddrDisc, AArch64::X17);
   bool PACZero = PACDiscReg == AArch64::XZR;
   unsigned PACOpc = getPACOpcodeForKey(PACKey, PACZero);

[llvm-branch-commits] [llvm] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Anatoly Trosinenko via llvm-branch-commits


@@ -163,8 +163,15 @@ class AArch64AsmPrinter : public AsmPrinter {
   // Emit the sequence for AUT or AUTPAC.
   void emitPtrauthAuthResign(const MachineInstr *MI);
 
-  // Emit the sequence to compute a discriminator into x17, or reuse AddrDisc.
-  unsigned emitPtrauthDiscriminator(uint16_t Disc, unsigned AddrDisc);
+  // Emit the sequence to compute the discriminator.
+  // ScratchReg should be x16/x17.
+  // The returned register is either unmodified AddrDisc or x16/x17.
+  // If the expanded pseudo is allowed to clobber AddrDisc register, setting
+  // MayUseAddrAsScratch may save one MOV instruction, provided the address

atrosinenko wrote:

I agree the comment is not very clear - hopefully the updated version is more 
readable. The reason that the commit message mentions two instructions and this 
comment mentions only one is that the second `mov` is saved due to relaxing the 
register class.

When the particular instruction clobbers both x16 and x17 and AddrDisc is not 
used after the discriminator is computed, by relaxing the register class this
```
ldr x9, [x16]
mov x8, x16
mov x17, x8
movkx17, #34646, lsl #48
blraa   x9, x17
```
can be simplified to
```
ldr x8, [x16]
mov x17, x16
movkx17, #34646, lsl #48
blraa   x8, x17
```
which can be further simplified to
```
ldr x8, [x16]
movkx16, #34646, lsl #48
blraa   x8, x16
```
by reusing AddrDisc in-place.

https://github.com/llvm/llvm-project/pull/115185
___
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] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Anatoly Trosinenko via llvm-branch-commits


@@ -188,6 +188,33 @@ define void @test_tailcall_omit_mov_x16_x16(ptr %objptr) 
#0 {
   ret void
 }
 
+define i32 @test_call_omit_extra_moves(ptr %objptr) #0 {

atrosinenko wrote:

Initially, I tried to implement a separate test case for tail calls, but then 
realized that AUTH_TCRETURN is already tested by your test case for `mov x16, 
x16` :)

https://github.com/llvm/llvm-project/pull/115185
___
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] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Anatoly Trosinenko via llvm-branch-commits


@@ -163,8 +163,15 @@ class AArch64AsmPrinter : public AsmPrinter {
   // Emit the sequence for AUT or AUTPAC.
   void emitPtrauthAuthResign(const MachineInstr *MI);
 
-  // Emit the sequence to compute a discriminator into x17, or reuse AddrDisc.
-  unsigned emitPtrauthDiscriminator(uint16_t Disc, unsigned AddrDisc);
+  // Emit the sequence to compute the discriminator.
+  // ScratchReg should be x16/x17.

atrosinenko wrote:

Sounds reasonable. Added, thank you!

https://github.com/llvm/llvm-project/pull/115185
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits

https://github.com/kyulee-com created 
https://github.com/llvm/llvm-project/pull/115750

None

>From 70dcb2ccba98b392c3539f349ccf7fec284a674c Mon Sep 17 00:00:00 2001
From: Kyungwoo Lee 
Date: Mon, 11 Nov 2024 10:06:56 -0800
Subject: [PATCH] [CGData] Refactor Global Merge Functions

---
 llvm/lib/CodeGen/GlobalMergeFunctions.cpp | 148 +-
 1 file changed, 59 insertions(+), 89 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp 
b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
index 2b367ca87d9008..df8dbb8a73b95d 100644
--- a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
+++ b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
@@ -31,14 +31,6 @@ static cl::opt DisableCGDataForMerging(
  "merging is still enabled within a module."),
 cl::init(false));
 
-STATISTIC(NumMismatchedFunctionHash,
-  "Number of mismatched function hash for global merge function");
-STATISTIC(NumMismatchedInstCount,
-  "Number of mismatched instruction count for global merge function");
-STATISTIC(NumMismatchedConstHash,
-  "Number of mismatched const hash for global merge function");
-STATISTIC(NumMismatchedModuleId,
-  "Number of mismatched Module Id for global merge function");
 STATISTIC(NumMergedFunctions,
   "Number of functions that are actually merged using function hash");
 STATISTIC(NumAnalyzedModues, "Number of modules that are analyzed");
@@ -203,9 +195,9 @@ void GlobalMergeFunc::analyze(Module &M) {
 struct FuncMergeInfo {
   StableFunctionMap::StableFunctionEntry *SF;
   Function *F;
-  std::unique_ptr IndexInstruction;
+  IndexInstrMap *IndexInstruction;
   FuncMergeInfo(StableFunctionMap::StableFunctionEntry *SF, Function *F,
-std::unique_ptr IndexInstruction)
+IndexInstrMap *IndexInstruction)
   : SF(SF), F(F), IndexInstruction(std::move(IndexInstruction)) {}
 };
 
@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);
+  auto &FI = FuncToFI.at(F);
 
-  if (SF->InstCount != FI.IndexInstruction->size()) {
-++NumMismatchedInstCount;
+  // Check if the function is compatible with any stable function
+  // in terms of the number of instructions and ignored operands.
+  assert(!SFS.empty());
+  auto &RFS = SFS[0];
+  if (RFS->InstCount != FI.IndexInstruction->size())
 continue;
-  }
-  bool HasValidSharedConst = true;
-  for (auto &[Index, Hash] : *SF->IndexOperandHashMap) {
-auto [InstIndex, OpndIndex] = Index;
-assert(InstIndex < FI.IndexInstruction->size());
-auto *Inst = FI.IndexInstruction->lookup(InstIndex);
-if (!ignoreOp(Inst, OpndIndex)) {
-  HasValidSharedConst = false;
-  break;
-}
-  }
-  if (!HasValidSharedConst) {
-++NumMismatchedConstHash;
-continue;
-  }
-  if (!checkConstHashCompatible(*SF->IndexOperandHashMap,
-*FI.IndexOperandHashMap)) {
-

[llvm-branch-commits] [llvm] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits


@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);
+  auto &FI = FuncToFI.at(F);
 
-  if (SF->InstCount != FI.IndexInstruction->size()) {
-++NumMismatchedInstCount;
+  // Check if the function is compatible with any stable function
+  // in terms of the number of instructions and ignored operands.
+  assert(!SFS.empty());
+  auto &RFS = SFS[0];

nocchijiang wrote:

Or maybe we can move the "lightweight" checks back into the nested loop below?

https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits


@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;

nocchijiang wrote:

```suggestion
  DenseMap>> 
HashToFuncs;
```

To save the cost of `FuncToFI`. Or maybe we could put `Function *` in 
`FunctionHashInfo`?

https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits

https://github.com/nocchijiang commented:

This refactoring makes much more sense to me than the previous implementation.

https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits


@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);

nocchijiang wrote:

Hopefully this will be hoisted out of the `for` loop by the compiler.

https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits

https://github.com/nocchijiang edited 
https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits


@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);
+  auto &FI = FuncToFI.at(F);
 
-  if (SF->InstCount != FI.IndexInstruction->size()) {
-++NumMismatchedInstCount;
+  // Check if the function is compatible with any stable function
+  // in terms of the number of instructions and ignored operands.
+  assert(!SFS.empty());
+  auto &RFS = SFS[0];

nocchijiang wrote:

I seem to understand the potential size increase introduced by the refactoring: 
is it possible that stable function entries with the same hash could have 
different numbers of / incompatible operands? If that is the case, I believe we 
can assume that the probability of hash collisions should be very low, 
otherwise we might actually need to improve the hashing algorithm.

https://github.com/llvm/llvm-project/pull/115750
___
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] a3f0f1d - Bump version to 19.1.4

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

Author: Tobias Hieta
Date: 2024-11-11T14:12:23+01:00
New Revision: a3f0f1d004a61ef94c115e7e28863ce0b476aa99

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

LOG: Bump version to 19.1.4

Added: 


Modified: 
cmake/Modules/LLVMVersion.cmake
libcxx/include/__config
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
llvm/utils/mlgo-utils/mlgo/__init__.py

Removed: 




diff  --git a/cmake/Modules/LLVMVersion.cmake b/cmake/Modules/LLVMVersion.cmake
index d57561fcd17482..6ccb934aef436b 100644
--- a/cmake/Modules/LLVMVersion.cmake
+++ b/cmake/Modules/LLVMVersion.cmake
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 3)
+  set(LLVM_VERSION_PATCH 4)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index ecb21a705c5152..a929db5d0f2d11 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -27,7 +27,7 @@
 // _LIBCPP_VERSION represents the version of libc++, which matches the version 
of LLVM.
 // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), 
_LIBCPP_VERSION is
 // defined to XXYYZZ.
-#  define _LIBCPP_VERSION 190103
+#  define _LIBCPP_VERSION 190104
 
 #  define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
 #  define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)

diff  --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index fa570bad3b1bea..0c2804f70a1475 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 19
 llvm_version_minor = 1
-llvm_version_patch = 3
+llvm_version_patch = 4
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"

diff  --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 9c7b53d82aae21..81b74db977b080 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (19, 1, 3)
+__versioninfo__ = (19, 1, 4)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []

diff  --git a/llvm/utils/mlgo-utils/mlgo/__init__.py 
b/llvm/utils/mlgo-utils/mlgo/__init__.py
index 95aa8e2684d06a..77fe60a0b15909 100644
--- a/llvm/utils/mlgo-utils/mlgo/__init__.py
+++ b/llvm/utils/mlgo-utils/mlgo/__init__.py
@@ -4,7 +4,7 @@
 
 from datetime import timezone, datetime
 
-__versioninfo__ = (19, 1, 3)
+__versioninfo__ = (19, 1, 4)
 __version__ = (
 ".".join(str(v) for v in __versioninfo__)
 + "dev"



___
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] [flang][OpenMP] Semantic checks for DOACROSS clause (PR #115397)

2024-11-11 Thread Tom Eccles via llvm-branch-commits

https://github.com/tblah edited https://github.com/llvm/llvm-project/pull/115397
___
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] [flang][OpenMP] Semantic checks for DOACROSS clause (PR #115397)

2024-11-11 Thread Tom Eccles via llvm-branch-commits

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

Thanks for this. LGTM with one nit

https://github.com/llvm/llvm-project/pull/115397
___
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] [flang][OpenMP] Semantic checks for DOACROSS clause (PR #115397)

2024-11-11 Thread Tom Eccles via llvm-branch-commits


@@ -541,6 +541,7 @@ void OmpStructureChecker::Leave(const 
parser::OpenMPConstruct &) {
 }
 
 void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
+  loopStack_.push_back(&x);

tblah wrote:

Thanks for the explanation!

https://github.com/llvm/llvm-project/pull/115397
___
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] [flang][OpenMP] Semantic checks for DOACROSS clause (PR #115397)

2024-11-11 Thread Tom Eccles via llvm-branch-commits


@@ -1656,6 +1664,11 @@ void OmpStructureChecker::ChecksOnOrderedAsStandalone() {
   "Only SINK or SOURCE dependence types are allowed when ORDERED 
construct is a standalone construct with no ORDERED region"_err_en_US);
 }
   }
+  auto doaClauses = FindClauses(llvm::omp::Clause::OMPC_doacross);

tblah wrote:

nit: elsewhere in this file braced initialization is used
```suggestion
  auto doaClauses{FindClauses(llvm::omp::Clause::OMPC_doacross)};
```

See also other cases in this diff

https://github.com/llvm/llvm-project/pull/115397
___
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] [flang][OpenMP] Semantic checks for DOACROSS clause (PR #115397)

2024-11-11 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/115397

>From 4165254e8c4a7b572e741cb62d632b462537dc0f Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 5 Nov 2024 12:01:43 -0600
Subject: [PATCH 1/5] [flang][OpenMP] Semantic checks for DOACROSS clause

Keep track of loop constructs and OpenMP loop constructs that have
been entered. Use the information to validate the variables in the
SINK loop iteration vector.
---
 flang/lib/Lower/OpenMP/Clauses.cpp  |  28 ++--
 flang/lib/Semantics/check-omp-structure.cpp | 141 ++--
 flang/lib/Semantics/check-omp-structure.h   |  25 +++-
 flang/lib/Semantics/resolve-directives.cpp  |  12 +-
 flang/test/Lower/OpenMP/Todo/ordered.f90|  20 +++
 flang/test/Semantics/OpenMP/doacross.f90|  28 
 flang/test/Semantics/OpenMP/ordered01.f90   |   4 +-
 flang/test/Semantics/OpenMP/ordered03.f90   |   2 +
 8 files changed, 230 insertions(+), 30 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/Todo/ordered.f90
 create mode 100644 flang/test/Semantics/OpenMP/doacross.f90

diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index f6633dd53f6f23..1764b3b79b4e34 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -574,20 +574,17 @@ Defaultmap make(const parser::OmpClause::Defaultmap &inp,
  /*VariableCategory=*/maybeApply(convert2, t1)}};
 }
 
-Depend make(const parser::OmpClause::Depend &inp,
-semantics::SemanticsContext &semaCtx) {
-  // inp.v -> parser::OmpDependClause
-  using wrapped = parser::OmpDependClause;
-  using Variant = decltype(Depend::u);
+Doacross makeDoacross(const parser::OmpDoacross &doa,
+  semantics::SemanticsContext &semaCtx) {
   // Iteration is the equivalent of parser::OmpIteration
   using Iteration = Doacross::Vector::value_type; // LoopIterationT
 
-  auto visitSource = [&](const parser::OmpDoacross::Source &) -> Variant {
+  auto visitSource = [&](const parser::OmpDoacross::Source &) {
 return Doacross{{/*DependenceType=*/Doacross::DependenceType::Source,
  /*Vector=*/{}}};
   };
 
-  auto visitSink = [&](const parser::OmpDoacross::Sink &s) -> Variant {
+  auto visitSink = [&](const parser::OmpDoacross::Sink &s) {
 using IterOffset = parser::OmpIterationOffset;
 auto convert2 = [&](const parser::OmpIteration &v) {
   auto &t0 = std::get(v.t);
@@ -605,6 +602,15 @@ Depend make(const parser::OmpClause::Depend &inp,
  /*Vector=*/makeList(s.v.v, convert2)}};
   };
 
+  return common::visit(common::visitors{visitSink, visitSource}, doa.u);
+}
+
+Depend make(const parser::OmpClause::Depend &inp,
+semantics::SemanticsContext &semaCtx) {
+  // inp.v -> parser::OmpDependClause
+  using wrapped = parser::OmpDependClause;
+  using Variant = decltype(Depend::u);
+
   auto visitTaskDep = [&](const wrapped::TaskDep &s) -> Variant {
 auto &t0 = std::get>(s.t);
 auto &t1 = std::get(s.t);
@@ -617,11 +623,11 @@ Depend make(const parser::OmpClause::Depend &inp,
 /*LocatorList=*/makeObjects(t2, semaCtx)}};
   };
 
-  return Depend{Fortran::common::visit( //
+  return Depend{common::visit( //
   common::visitors{
   // Doacross
   [&](const parser::OmpDoacross &s) -> Variant {
-return common::visit(common::visitors{visitSink, visitSource}, 
s.u);
+return makeDoacross(s, semaCtx);
   },
   // Depend::TaskDep
   visitTaskDep,
@@ -692,8 +698,8 @@ DistSchedule make(const parser::OmpClause::DistSchedule 
&inp,
 
 Doacross make(const parser::OmpClause::Doacross &inp,
   semantics::SemanticsContext &semaCtx) {
-  // inp -> empty
-  llvm_unreachable("Empty: doacross");
+  // inp.v -> OmpDoacrossClause
+  return makeDoacross(inp.v.v, semaCtx);
 }
 
 // DynamicAllocators: empty
diff --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index 132fb6484bcfc5..67360b983a7d19 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -541,6 +541,7 @@ void OmpStructureChecker::Leave(const 
parser::OpenMPConstruct &) {
 }
 
 void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
+  loopStack_.push_back(&x);
   const auto &beginLoopDir{std::get(x.t)};
   const auto &beginDir{std::get(beginLoopDir.t)};
 
@@ -933,11 +934,19 @@ void OmpStructureChecker::CheckDistLinear(
   }
 }
 
-void OmpStructureChecker::Leave(const parser::OpenMPLoopConstruct &) {
+void OmpStructureChecker::Leave(const parser::OpenMPLoopConstruct &x) {
   if (llvm::omp::allSimdSet.test(GetContext().directive)) {
 ExitDirectiveNest(SIMDNest);
   }
   dirContext_.pop_back();
+
+  assert(!loopStack_.empty() && "Expecting non-empty loop stack");
+  const LoopConstruct &top = loopStack_.back();
+#ifndef NDEBUG
+  auto *loopc = std

[llvm-branch-commits] [flang] [flang][OpenMP] Semantic checks for DOACROSS clause (PR #115397)

2024-11-11 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/115397

>From 4165254e8c4a7b572e741cb62d632b462537dc0f Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 5 Nov 2024 12:01:43 -0600
Subject: [PATCH 1/6] [flang][OpenMP] Semantic checks for DOACROSS clause

Keep track of loop constructs and OpenMP loop constructs that have
been entered. Use the information to validate the variables in the
SINK loop iteration vector.
---
 flang/lib/Lower/OpenMP/Clauses.cpp  |  28 ++--
 flang/lib/Semantics/check-omp-structure.cpp | 141 ++--
 flang/lib/Semantics/check-omp-structure.h   |  25 +++-
 flang/lib/Semantics/resolve-directives.cpp  |  12 +-
 flang/test/Lower/OpenMP/Todo/ordered.f90|  20 +++
 flang/test/Semantics/OpenMP/doacross.f90|  28 
 flang/test/Semantics/OpenMP/ordered01.f90   |   4 +-
 flang/test/Semantics/OpenMP/ordered03.f90   |   2 +
 8 files changed, 230 insertions(+), 30 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/Todo/ordered.f90
 create mode 100644 flang/test/Semantics/OpenMP/doacross.f90

diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp 
b/flang/lib/Lower/OpenMP/Clauses.cpp
index f6633dd53f6f23..1764b3b79b4e34 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -574,20 +574,17 @@ Defaultmap make(const parser::OmpClause::Defaultmap &inp,
  /*VariableCategory=*/maybeApply(convert2, t1)}};
 }
 
-Depend make(const parser::OmpClause::Depend &inp,
-semantics::SemanticsContext &semaCtx) {
-  // inp.v -> parser::OmpDependClause
-  using wrapped = parser::OmpDependClause;
-  using Variant = decltype(Depend::u);
+Doacross makeDoacross(const parser::OmpDoacross &doa,
+  semantics::SemanticsContext &semaCtx) {
   // Iteration is the equivalent of parser::OmpIteration
   using Iteration = Doacross::Vector::value_type; // LoopIterationT
 
-  auto visitSource = [&](const parser::OmpDoacross::Source &) -> Variant {
+  auto visitSource = [&](const parser::OmpDoacross::Source &) {
 return Doacross{{/*DependenceType=*/Doacross::DependenceType::Source,
  /*Vector=*/{}}};
   };
 
-  auto visitSink = [&](const parser::OmpDoacross::Sink &s) -> Variant {
+  auto visitSink = [&](const parser::OmpDoacross::Sink &s) {
 using IterOffset = parser::OmpIterationOffset;
 auto convert2 = [&](const parser::OmpIteration &v) {
   auto &t0 = std::get(v.t);
@@ -605,6 +602,15 @@ Depend make(const parser::OmpClause::Depend &inp,
  /*Vector=*/makeList(s.v.v, convert2)}};
   };
 
+  return common::visit(common::visitors{visitSink, visitSource}, doa.u);
+}
+
+Depend make(const parser::OmpClause::Depend &inp,
+semantics::SemanticsContext &semaCtx) {
+  // inp.v -> parser::OmpDependClause
+  using wrapped = parser::OmpDependClause;
+  using Variant = decltype(Depend::u);
+
   auto visitTaskDep = [&](const wrapped::TaskDep &s) -> Variant {
 auto &t0 = std::get>(s.t);
 auto &t1 = std::get(s.t);
@@ -617,11 +623,11 @@ Depend make(const parser::OmpClause::Depend &inp,
 /*LocatorList=*/makeObjects(t2, semaCtx)}};
   };
 
-  return Depend{Fortran::common::visit( //
+  return Depend{common::visit( //
   common::visitors{
   // Doacross
   [&](const parser::OmpDoacross &s) -> Variant {
-return common::visit(common::visitors{visitSink, visitSource}, 
s.u);
+return makeDoacross(s, semaCtx);
   },
   // Depend::TaskDep
   visitTaskDep,
@@ -692,8 +698,8 @@ DistSchedule make(const parser::OmpClause::DistSchedule 
&inp,
 
 Doacross make(const parser::OmpClause::Doacross &inp,
   semantics::SemanticsContext &semaCtx) {
-  // inp -> empty
-  llvm_unreachable("Empty: doacross");
+  // inp.v -> OmpDoacrossClause
+  return makeDoacross(inp.v.v, semaCtx);
 }
 
 // DynamicAllocators: empty
diff --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index 132fb6484bcfc5..67360b983a7d19 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -541,6 +541,7 @@ void OmpStructureChecker::Leave(const 
parser::OpenMPConstruct &) {
 }
 
 void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
+  loopStack_.push_back(&x);
   const auto &beginLoopDir{std::get(x.t)};
   const auto &beginDir{std::get(beginLoopDir.t)};
 
@@ -933,11 +934,19 @@ void OmpStructureChecker::CheckDistLinear(
   }
 }
 
-void OmpStructureChecker::Leave(const parser::OpenMPLoopConstruct &) {
+void OmpStructureChecker::Leave(const parser::OpenMPLoopConstruct &x) {
   if (llvm::omp::allSimdSet.test(GetContext().directive)) {
 ExitDirectiveNest(SIMDNest);
   }
   dirContext_.pop_back();
+
+  assert(!loopStack_.empty() && "Expecting non-empty loop stack");
+  const LoopConstruct &top = loopStack_.back();
+#ifndef NDEBUG
+  auto *loopc = std

[llvm-branch-commits] [llvm] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Daniil Kovalev via llvm-branch-commits


@@ -163,8 +163,15 @@ class AArch64AsmPrinter : public AsmPrinter {
   // Emit the sequence for AUT or AUTPAC.
   void emitPtrauthAuthResign(const MachineInstr *MI);
 
-  // Emit the sequence to compute a discriminator into x17, or reuse AddrDisc.
-  unsigned emitPtrauthDiscriminator(uint16_t Disc, unsigned AddrDisc);
+  // Emit the sequence to compute the discriminator.
+  // ScratchReg should be x16/x17.

kovdan01 wrote:

Probably it's worth adding an assertion for this pre-condition (I might be 
missing smth but I don't see it)

https://github.com/llvm/llvm-project/pull/115185
___
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] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Daniil Kovalev via llvm-branch-commits


@@ -163,8 +163,15 @@ class AArch64AsmPrinter : public AsmPrinter {
   // Emit the sequence for AUT or AUTPAC.
   void emitPtrauthAuthResign(const MachineInstr *MI);
 
-  // Emit the sequence to compute a discriminator into x17, or reuse AddrDisc.
-  unsigned emitPtrauthDiscriminator(uint16_t Disc, unsigned AddrDisc);
+  // Emit the sequence to compute the discriminator.
+  // ScratchReg should be x16/x17.
+  // The returned register is either unmodified AddrDisc or x16/x17.
+  // If the expanded pseudo is allowed to clobber AddrDisc register, setting
+  // MayUseAddrAsScratch may save one MOV instruction, provided the address

kovdan01 wrote:

Could you please add a comment with an example of optimized sequence (which is 
present in PR description) to code? W/o that, it might not be very clear what 
particularly is meant when talking about saving mov instruction. Also, it looks 
like that two instructions are saved, not one (as said in comment here), if I 
understand the example from the PR description correctly.

https://github.com/llvm/llvm-project/pull/115185
___
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] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Daniil Kovalev via llvm-branch-commits


@@ -188,6 +188,33 @@ define void @test_tailcall_omit_mov_x16_x16(ptr %objptr) 
#0 {
   ret void
 }
 
+define i32 @test_call_omit_extra_moves(ptr %objptr) #0 {

kovdan01 wrote:

As far as I see, there are two places where `emitPtrauthDiscriminator` is 
called with `/*MayUseAddrAsScratch=*/true`: `emitPtrauthBranch` and 
`emitInstruction` for `AUTH_TCRETURN`/`AUTH_TCRETURN_BTI`. Are both cases 
tested? It looks like that this new test case is designed for signed tail call 
which covers only one of two code paths, doesn't it?

https://github.com/llvm/llvm-project/pull/115185
___
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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

2024-11-11 Thread Joseph Huber via llvm-branch-commits

https://github.com/jhuber6 commented:

Does anyone know why this patch keeps failing the libc++ tests? Seems related 
to something in `libc` for some reason. If we could get the CI green I'd be 
happy to say it's good enough for now.

https://github.com/llvm/llvm-project/pull/110217
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -221,7 +221,24 @@ __tysan_check(void *addr, int size, tysan_type_descriptor 
*td, int flags) {
 OldTDPtr -= i;
 OldTD = *OldTDPtr;
 
-if (!isAliasingLegal(td, OldTD))
+// When shadow memory is set for global objects, the entire object is 
tagged with the struct type
+// This means that when you access a member variable, tysan reads that as 
you accessing a struct midway
+// through, with 'i' being the offset
+// Therefore, if you are accessing a struct, we need to find the member 
type. We can go through the
+// members of the struct type and see if there is a member at the offset 
you are accessing the struct by.
+// If there is indeed a member starting at offset 'i' in the struct, we 
should check aliasing legality
+// with that type. If there isn't, we run alias checking on the struct 
with will give us the correct error.
+tysan_type_descriptor *InternalMember = OldTD;
+if (OldTD->Tag == TYSAN_STRUCT_TD) {
+  for (int j = 0; j < OldTD->Struct.MemberCount; j++) {

jmorse wrote:

Style guide says `++j`

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits

https://github.com/jmorse commented:

I'm not familiar with TySan, but here's some style feedback and similar inline.

The comments in tysan.cpp are too long (clang-format-bot would have bitten you 
if it was live when you uploaded this), please clang-format.

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+#include 
+
+struct X {
+  int a, b, c;
+} x;
+
+static struct X xArray[2];
+
+int main() {
+  x.a = 1;
+  x.b = 2;
+  x.c = 3;
+
+  printf("%d %d %d\n", x.a, x.b, x.c);
+  // CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation
+
+  for (size_t i = 0; i < 2; i++) {
+xArray[i].a = 1;
+xArray[i].b = 1;
+xArray[i].c = 1;
+  }
+
+  struct X *xPtr = (struct X *)&(xArray[0].c);
+  xPtr->a = 1;
+  // CHECK: ERROR: TypeSanitizer: type-aliasing-violation
+  // CHECK: WRITE of size 4 at {{.*}} with type int (in X at offset 0) 
accesses an existing object of type int (in X at offset 8)
+  // CHECK: {{#0 0x.* in main .*struct-members.c:}}[[@LINE-3]]

jmorse wrote:

Is it possible to strengthen this test even further by making the latter two 
"CHECK-NEXT", to ensure the error appears all in one block? (Reduces the risk 
of spurious extra output matching CHECK lines).

I'd recommend reducing the portions of the CHECK-line that are regexes to be as 
small as possible, so `{{.*}}struct-members.c` and similar.

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -221,7 +221,24 @@ __tysan_check(void *addr, int size, tysan_type_descriptor 
*td, int flags) {
 OldTDPtr -= i;
 OldTD = *OldTDPtr;
 
-if (!isAliasingLegal(td, OldTD))
+// When shadow memory is set for global objects, the entire object is 
tagged with the struct type
+// This means that when you access a member variable, tysan reads that as 
you accessing a struct midway
+// through, with 'i' being the offset
+// Therefore, if you are accessing a struct, we need to find the member 
type. We can go through the
+// members of the struct type and see if there is a member at the offset 
you are accessing the struct by.
+// If there is indeed a member starting at offset 'i' in the struct, we 
should check aliasing legality
+// with that type. If there isn't, we run alias checking on the struct 
with will give us the correct error.

jmorse wrote:

```suggestion
// with that type. If there isn't, we run alias checking on the struct 
which will give us the correct error.
```
Doesn't parse without this change?

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -221,7 +221,17 @@ __tysan_check(void *addr, int size, tysan_type_descriptor 
*td, int flags) {
 OldTDPtr -= i;
 OldTD = *OldTDPtr;
 
-if (!isAliasingLegal(td, OldTD))
+tysan_type_descriptor *InternalMember = OldTD;

jmorse wrote:

I feel like you should name the variable declared here "AccessedType" or 
similar, as the default-path is to check access to OldTD rather than an 
internal member of it, right?

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


[llvm-branch-commits] [compiler-rt] [TySan] Fixed false positive when accessing offset member variables (PR #95387)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -0,0 +1,31 @@
+// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+#include 
+
+struct X {
+  int a, b, c;
+} x;
+
+static struct X xArray[2];
+
+int main() {
+  x.a = 1;
+  x.b = 2;
+  x.c = 3;
+
+  printf("%d %d %d\n", x.a, x.b, x.c);
+  // CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation

jmorse wrote:

I'm not familiar with the output of TySan, but this CHECK-NOT paired with the 
CHECK on line 28 is going to test that "there's no error until there's an 
error", which makes this specific CHECK-NOT redundant. If you're looking to 
ensure there's only one instance of that error-output then you need to put 
another CHECK-NOT under the CHECK lines below, or add `--implicit-check-not` to 
FileCheck. Also consider just not having this CHECK-NOT line, if TySan will 
never produce more than one error.

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


[llvm-branch-commits] [compiler-rt] [TySan] Fix struct access with different bases (PR #108385)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits

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


[llvm-branch-commits] [compiler-rt] [TySan] Fix struct access with different bases (PR #108385)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -128,6 +128,10 @@ static bool isAliasingLegalUp(tysan_type_descriptor *TDA,
   break;
   }
 
+  //You can't have negative offset, you must be partially inside the last 
type

jmorse wrote:

Space at start of comment; better to write the comment in a passive tone, "The 
offset can't be negative, thus we must be..."

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


[llvm-branch-commits] [compiler-rt] [TySan] Fix struct access with different bases (PR #108385)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits


@@ -0,0 +1,31 @@
+// RUN: %clangxx_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+#include 
+
+struct inner {
+   char buffer;
+   int i;
+};
+
+void init_inner(inner *iPtr) {
+   iPtr->i = 0;
+}
+
+struct outer {
+   inner foo;
+char buffer;
+};
+
+int main(void) {
+outer *l = new outer();
+
+init_inner(&l->foo);
+
+int access_offsets_with_different_base = l->foo.i;
+printf("%d\n", access_offsets_with_different_base);
+
+return 0;
+}
+
+// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation

jmorse wrote:

Nit: please also include a test for /something/ in the output to ensure that 
the test is positively checking for something. Otherwise we could replace 
%clangxx_tysan with any program that succeeds , such as `true`, and this test 
would pass.

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


[llvm-branch-commits] [compiler-rt] [TySan] Fix struct access with different bases (PR #108385)

2024-11-11 Thread Jeremy Morse via llvm-branch-commits

https://github.com/jmorse commented:

(Minor style and test feedbacks)

https://github.com/llvm/llvm-project/pull/108385
___
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] [WIP][flang] Introduce HLFIR lowerings to omp.workshare_loop_nest (PR #104748)

2024-11-11 Thread Tom Eccles via llvm-branch-commits

tblah wrote:

@ivanradanov is anything blocking this from becoming ready for review?

https://github.com/llvm/llvm-project/pull/104748
___
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] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)

2024-11-11 Thread Anatoly Trosinenko via llvm-branch-commits

atrosinenko wrote:

@kovdan01 Thank you for the review, I have just pushed the commit that should 
resolve the comments.

Additionally, I discovered that I misunderstood BRA pseudo to be kind of tail 
call instruction - it is actually used for computed goto. While my original 
changes are still harmless, it is not so natural to declare BRA to clobber both 
X16 and X17 as it is not actually a call instruction, so I adjusted the 
definition of BRA and `emitPtrauthBranch` function a bit.

https://github.com/llvm/llvm-project/pull/115185
___
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] [flang] Lower omp.workshare to other omp constructs (PR #101446)

2024-11-11 Thread Tom Eccles via llvm-branch-commits

tblah wrote:

@ivanradanov is there anything blocking these 4 patches?

https://github.com/llvm/llvm-project/pull/101446
___
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] [clang] Fix C23 constexpr crashes (#112708) (PR #112855)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/112855

>From 906ef5b56486091a20b9ae6e32b38c8bda75dfb1 Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva 
Date: Fri, 18 Oct 2024 10:18:34 +0200
Subject: [PATCH] [clang] Fix C23 constexpr crashes (#112708)

Before using a constexpr variable that is not properly initialized check
that it is valid.

Fixes https://github.com/llvm/llvm-project/issues/109095
Fixes https://github.com/llvm/llvm-project/issues/112516
---
 clang/lib/AST/Decl.cpp  | 10 +++---
 clang/test/Sema/constexpr.c | 17 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 490c4a2fc525cd..bc7cce0bcd7fc2 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2503,7 +2503,8 @@ bool VarDecl::isUsableInConstantExpressions(const 
ASTContext &Context) const {
   if (!DefVD->mightBeUsableInConstantExpressions(Context))
 return false;
   //   ... and its initializer is a constant initializer.
-  if (Context.getLangOpts().CPlusPlus && !DefVD->hasConstantInitialization())
+  if ((Context.getLangOpts().CPlusPlus || getLangOpts().C23) &&
+  !DefVD->hasConstantInitialization())
 return false;
   // C++98 [expr.const]p1:
   //   An integral constant-expression can involve only [...] const variables
@@ -2610,8 +2611,11 @@ bool VarDecl::hasICEInitializer(const ASTContext 
&Context) const {
 }
 
 bool VarDecl::hasConstantInitialization() const {
-  // In C, all globals (and only globals) have constant initialization.
-  if (hasGlobalStorage() && !getASTContext().getLangOpts().CPlusPlus)
+  // In C, all globals and constexpr variables should have constant
+  // initialization. For constexpr variables in C check that initializer is a
+  // constant initializer because they can be used in constant expressions.
+  if (hasGlobalStorage() && !getASTContext().getLangOpts().CPlusPlus &&
+  !isConstexpr())
 return true;
 
   // In C++, it depends on whether the evaluation at the point of definition
diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c
index a874fd64808404..ad2c2ba98a1e3f 100644
--- a/clang/test/Sema/constexpr.c
+++ b/clang/test/Sema/constexpr.c
@@ -364,3 +364,20 @@ void constexprif() {
 void constevalif() {
   if consteval (300) {} //expected-error {{expected '(' after 'if'}}
 }
+
+struct S11 {
+  int len;
+};
+void ghissue112516() {
+  struct S11 *s11 = 0;
+  constexpr int num = s11->len; // expected-error {{constexpr variable 'num' 
must be initialized by a constant expression}}
+  void *Arr[num];
+}
+
+void ghissue109095() {
+  constexpr char c[] = { 'a' };
+  constexpr int i = c[1]; // expected-error {{constexpr variable 'i' must be 
initialized by a constant expression}}\
+  // expected-note {{declared here}}
+  _Static_assert(i == c[0]); // expected-error {{static assertion expression 
is not an integral constant expression}}\
+ // expected-note {{initializer of 'i' is not a 
constant expression}}
+}

___
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] [clang] Fix C23 constexpr crashes (#112708) (PR #112855)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

I had to resolve some conflicts again - can you have a look @AaronBallman ?

https://github.com/llvm/llvm-project/pull/112855
___
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/19.x: [RISCV] Don't delete all fixups in RISCVMCCodeEmitter::expandLongCondBr. (#109513) (PR #114089)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/114089

>From 3cee44a5c61e5a5f7c59984be3d1be825cd1c5af Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Sun, 22 Sep 2024 22:31:36 -0700
Subject: [PATCH] [RISCV] Don't delete all fixups in
 RISCVMCCodeEmitter::expandLongCondBr. (#109513)

The Fixups vector passed into this function may already have fixups in
it from earlier instructions. We should not erase those. We just want to
erase fixups added by this function.

Fixes #108612.

(cherry picked from commit c3d3cef8d58377b02032b07b5f094a402a70435a)
---
 llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp | 7 ++-
 llvm/test/MC/RISCV/rv64-relax-all.s   | 6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp 
b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
index 0863345b0c6dc6..c9636b2c702508 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
@@ -283,13 +283,18 @@ void RISCVMCCodeEmitter::expandLongCondBr(const MCInst 
&MI,
 Offset = 4;
   }
 
+  // Save the number fixups.
+  size_t FixupStartIndex = Fixups.size();
+
   // Emit an unconditional jump to the destination.
   MCInst TmpInst =
   MCInstBuilder(RISCV::JAL).addReg(RISCV::X0).addOperand(SrcSymbol);
   uint32_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI);
   support::endian::write(CB, Binary, llvm::endianness::little);
 
-  Fixups.clear();
+  // Drop any fixup added so we can add the correct one.
+  Fixups.resize(FixupStartIndex);
+
   if (SrcSymbol.isExpr()) {
 Fixups.push_back(MCFixup::create(Offset, SrcSymbol.getExpr(),
  MCFixupKind(RISCV::fixup_riscv_jal),
diff --git a/llvm/test/MC/RISCV/rv64-relax-all.s 
b/llvm/test/MC/RISCV/rv64-relax-all.s
index 70a3f77540c997..6705d6ecfb5b62 100644
--- a/llvm/test/MC/RISCV/rv64-relax-all.s
+++ b/llvm/test/MC/RISCV/rv64-relax-all.s
@@ -14,3 +14,9 @@ c.beqz a0, NEAR
 # INSTR:   c.j0x0 
 # RELAX-INSTR: jalzero, 0x0 
 c.j NEAR
+
+bnez s0, .foo
+j.foo
+beqz s0, .foo
+.foo:
+ret

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


[llvm-branch-commits] [compiler-rt] release/19.x: [compiler-rt] [test] Fix using toolchains that rely on Clang default configs (#113491) (PR #114229)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/114229

>From 599bc9db3e23fe8e550970f0be895190115fd3aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Thu, 24 Oct 2024 23:45:14 +0300
Subject: [PATCH] [compiler-rt] [test] Fix using toolchains that rely on Clang
 default configs (#113491)

The use of CLANG_NO_DEFAULT_CONFIG in the tests was added because some
Linux distributions had a global default config file, that added flags
relating to hardening, which interfere with the sanitizer tests. By
setting CLANG_NO_DEFAULT_CONFIG, the global default config files that
are found are ignored, and the sanitizers get the expected default
compiler behaviour.

(This was https://github.com/llvm/llvm-project/issues/60394, which was
fixed in 8ab762557fb057af1a3015211ee116a975027e78.)

However, some toolchains may rely on default config files for mandatory
parts required for functioning at all - setting things like sysroots,
-rtlib, -unwindlib, -stdlib, -fuse-ld etc. In such a case we can't
forcibly disable any default config, because it will break the otherwise
working toolchain.

Add a test for whether the compiler works while passing
--no-default-config to it. If the option is accepted and the toolchain
still works while that is set, set CLANG_NO_DEFAULT_CONFIG while running
tests.

(This adds a little bit of inconsistency, as we're testing for the
command line option, while using the environment variable. However doing
compile testing with an environment variable isn't quite as easily
doable, and passing an extra command line flag to all compile commands
while testing, is a bit clumsy - therefore this inconsistency.)

(cherry picked from commit a14a83d9a102253eca7c02ff4c35a2ce3f7de6e5)
---
 compiler-rt/CMakeLists.txt| 16 
 compiler-rt/test/CMakeLists.txt   |  2 ++
 compiler-rt/test/lit.common.cfg.py|  6 +-
 compiler-rt/test/lit.common.configured.in |  1 +
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 2207555b03a03f..6cf20ab7c183ce 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -39,6 +39,22 @@ include(CompilerRTUtils)
 include(CMakeDependentOption)
 include(GetDarwinLinkerVersion)
 
+include(CheckCXXCompilerFlag)
+
+# Check if we can compile with --no-default-config, or if that omits a config
+# file that is essential for the toolchain to work properly.
+#
+# Using CMAKE_REQUIRED_FLAGS to make sure the flag is used both for compilation
+# and for linking.
+#
+# Doing this test early on, to see if the flag works on the toolchain
+# out of the box. Later on, we end up adding -nostdlib and similar flags
+# to all test compiles, which easily can give false positives on this test.
+set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --no-default-config")
+check_cxx_compiler_flag("" COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)
+set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
+
 option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
 mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
 option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi 
Versioning support" OFF)
diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt
index 84a98f36747495..f9e23710d3e4f7 100644
--- a/compiler-rt/test/CMakeLists.txt
+++ b/compiler-rt/test/CMakeLists.txt
@@ -12,6 +12,8 @@ pythonize_bool(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
 
 pythonize_bool(COMPILER_RT_HAS_AARCH64_SME)
 
+pythonize_bool(COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)
+
 configure_compiler_rt_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
diff --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index 0690c3a18efdbc..d4b1e1d71d3c54 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -980,7 +980,11 @@ def is_windows_lto_supported():
 # default configs for the test runs. In particular, anything hardening
 # related is likely to cause issues with sanitizer tests, because it may
 # preempt something we're looking to trap (e.g. _FORTIFY_SOURCE vs our ASAN).
-config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
+#
+# Only set this if we know we can still build for the target while disabling
+# default configs.
+if config.has_no_default_config_flag:
+config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
 
 if config.has_compiler_rt_libatomic:
   base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.atomic%s.so"
diff --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 8889b816b149fc..f7276627995520 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -53,6 +53,7 @@ set_default("test_standalone_build_libs", 
@COMPILER_RT_TEST_STANDALONE_BUILD

[llvm-branch-commits] [clang] release/19.x: [clang-format] Fix a regression in parsing `switch` in macro call (#114506) (PR #114640)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/114640

>From 53f3ba06f5238d82953ae372516c39c700537c44 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 1 Nov 2024 18:47:50 -0700
Subject: [PATCH] [clang-format] Fix a regression in parsing `switch` in macro
 call (#114506)

Fixes #114408.

(cherry picked from commit 6ca816f88d5f0f2032d1610207023133eaf40a1e)
---
 clang/lib/Format/UnwrappedLineParser.cpp  | 8 ++--
 clang/unittests/Format/TokenAnnotatorTest.cpp | 7 +++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index a5268e153bcc5b..bfb592ae074938 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2086,7 +2086,8 @@ void UnwrappedLineParser::parseStructuralElement(
 case tok::kw_switch:
   if (Style.Language == FormatStyle::LK_Java)
 parseSwitch(/*IsExpr=*/true);
-  nextToken();
+  else
+nextToken();
   break;
 case tok::kw_case:
   // Proto: there are no switch/case statements.
@@ -2637,7 +2638,10 @@ bool UnwrappedLineParser::parseParens(TokenType 
AmpAmpTokenType) {
 nextToken();
   break;
 case tok::kw_switch:
-  parseSwitch(/*IsExpr=*/true);
+  if (Style.Language == FormatStyle::LK_Java)
+parseSwitch(/*IsExpr=*/true);
+  else
+nextToken();
   break;
 case tok::kw_requires: {
   auto RequiresToken = FormatTok;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 4acd900ff061f8..07999116ab0cf0 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3412,6 +3412,13 @@ TEST_F(TokenAnnotatorTest, TemplateInstantiation) {
   EXPECT_TOKEN(Tokens[18], tok::greater, TT_TemplateCloser);
 }
 
+TEST_F(TokenAnnotatorTest, SwitchInMacroArgument) {
+  auto Tokens = annotate("FOOBAR(switch);\n"
+ "void f() {}");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_FunctionLBrace);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang

___
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/19.x: [SLP]Check that operand of abs does not overflow before making it part of minbitwidth transformation (PR #113146)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

What's the status of this one? Can it / should it be merged?

https://github.com/llvm/llvm-project/pull/113146
___
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/19.x: [C++20] [Modules] Fix the duplicated static initializer problem (#114193) (PR #114197)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

@ChuanqiXu9 is this one ready to be merged?

https://github.com/llvm/llvm-project/pull/114197
___
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] [NVPTX] Promote v2i8 to v2i16 (#111189) (PR #115081)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

This seems to have some CI errors, Can you rebase on latest and see if the 
windows build errors are legit?

https://github.com/llvm/llvm-project/pull/115081
___
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/19.x: [llvm] Fix __builtin_object_size interaction between Negative Offset … (#111827) (PR #114786)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

Who can review this? @nikic?

I am very hesitant to merge more stuff that changes the public headers. But I 
want to hear what other people say.

https://github.com/llvm/llvm-project/pull/114786
___
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/19.x: [Clang] Consider outer instantiation scopes for constraint normalization (PR #114951)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/114951

>From 41c6461093b984acaa7f9f12ca07388df0615401 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 5 Nov 2024 16:25:35 +0800
Subject: [PATCH] release/19.x: [Clang] Consider outer instantiation scopes for
 constraint normalization

Backport 227afac3
---
 clang/lib/Sema/SemaConcept.cpp   |  2 +-
 .../SemaTemplate/concepts-out-of-line-def.cpp| 16 
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 244f6ef2f53faa..c45443d76e6bad 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -967,7 +967,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // parameters that the surrounding function hasn't been instantiated yet. 
Note
   // this may happen while we're comparing two templates' constraint
   // equivalence.
-  LocalInstantiationScope ScopeForParameters(S);
+  LocalInstantiationScope ScopeForParameters(S, 
/*CombineWithOuterScope=*/true);
   if (auto *FD = DeclInfo.getDecl()->getAsFunction())
 for (auto *PVD : FD->parameters()) {
   if (!PVD->isParameterPack()) {
diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index 333187b0d74ad6..c5dd855f0c000b 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -622,3 +622,19 @@ void A::method(Ts&... ts)
   } {}
 
 }
+
+namespace GH114685 {
+
+template  struct ptr {
+  template 
+  friend ptr make_item(auto &&args)
+requires(sizeof(args) > 1);
+};
+
+template 
+ptr make_item(auto &&args)
+  requires(sizeof(args) > 1) {}
+
+ptr p;
+
+} // namespace GH114685

___
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/19.x: [LoongArch][Clang] Make the parameters and return value of {x, }vxor.v builti ns `unsigned char` vectors (#114513) (PR #114958)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/114958

>From 9039cd7f1b83f2deaa85b1e88b2bdd199424f635 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao 
Date: Sat, 2 Nov 2024 15:39:15 +0800
Subject: [PATCH 1/5] [LoongArch][Clang] Add tests for #110834 (#114509)

(cherry picked from commit 96d2196f6f73e5712f1df8cd26de8a12c7f24de4)
---
 clang/test/Headers/lasxintrin.c | 6 ++
 clang/test/Headers/lsxintrin.c  | 6 ++
 2 files changed, 12 insertions(+)
 create mode 100644 clang/test/Headers/lasxintrin.c
 create mode 100644 clang/test/Headers/lsxintrin.c

diff --git a/clang/test/Headers/lasxintrin.c b/clang/test/Headers/lasxintrin.c
new file mode 100644
index 00..6126c6350455c1
--- /dev/null
+++ b/clang/test/Headers/lasxintrin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx
+// RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature 
+lasx -flax-vector-conversions=none
+// RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature 
+lasx -flax-vector-conversions=none -fno-signed-char
+// FIXME: "not" should be removed once we fix GH#110834.
+
+#include 
diff --git a/clang/test/Headers/lsxintrin.c b/clang/test/Headers/lsxintrin.c
new file mode 100644
index 00..930d3efe62e543
--- /dev/null
+++ b/clang/test/Headers/lsxintrin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx
+// RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature 
+lsx -flax-vector-conversions=none
+// RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature 
+lsx -flax-vector-conversions=none -fno-signed-char
+// FIXME: "not" should be removed once we fix GH#110834.
+
+#include 

>From 3ea2adba903db2125fe29331a5aeb4c71860f731 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao 
Date: Sat, 2 Nov 2024 15:49:40 +0800
Subject: [PATCH 2/5] [LoongArch][clang] Use `signed char` vectors instead of
 `char` vectors for LSX and LASX builtins (#114510)

`-flax-vector-conversions=none` does not allow an implicit conversion
from `signed char` vector to `char` vector, and we cannot remove
`signed`
from `v16i8` or `v32i8` because doing so will break our expectation with
`-fno-signed-char`.  So to make lsxintrin.h and lasxintrin.h work fine
with `-flax-vector-conversions=none`, we must use `signed char` instead
of `char`.

The change is just done via

sed 's/V16c/V16Sc/g' -i BuiltinsLoongArchLSX.def
sed 's/V32c/V32Sc/g' -i BuiltinsLoongArchLASX.def

Depends on #114509.  Part of #110834 fix.

(cherry picked from commit b88505414d47ca267f4df8823309264f78935686)
---
 .../clang/Basic/BuiltinsLoongArchLASX.def | 142 +-
 .../clang/Basic/BuiltinsLoongArchLSX.def  | 128 
 2 files changed, 135 insertions(+), 135 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsLoongArchLASX.def 
b/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
index 4cf51cc000f6fc..0d7c2df5c5c503 100644
--- a/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
+++ b/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
@@ -12,29 +12,29 @@
 //
 
//===--===//
 
-TARGET_BUILTIN(__builtin_lasx_xvadd_b, "V32cV32cV32c", "nc", "lasx")
+TARGET_BUILTIN(__builtin_lasx_xvadd_b, "V32ScV32ScV32Sc", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvadd_h, "V16sV16sV16s", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvadd_w, "V8iV8iV8i", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvadd_d, "V4LLiV4LLiV4LLi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvadd_q, "V4LLiV4LLiV4LLi", "nc", "lasx")
 
-TARGET_BUILTIN(__builtin_lasx_xvsub_b, "V32cV32cV32c", "nc", "lasx")
+TARGET_BUILTIN(__builtin_lasx_xvsub_b, "V32ScV32ScV32Sc", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsub_h, "V16sV16sV16s", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsub_w, "V8iV8iV8i", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsub_d, "V4LLiV4LLiV4LLi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsub_q, "V4LLiV4LLiV4LLi", "nc", "lasx")
 
-TARGET_BUILTIN(__builtin_lasx_xvaddi_bu, "V32cV32cIUi", "nc", "lasx")
+TARGET_BUILTIN(__builtin_lasx_xvaddi_bu, "V32ScV32ScIUi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvaddi_hu, "V16sV16sIUi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvaddi_wu, "V8iV8iIUi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvaddi_du, "V4LLiV4LLiIUi", "nc", "lasx")
 
-TARGET_BUILTIN(__builtin_lasx_xvsubi_bu, "V32cV32cIUi", "nc", "lasx")
+TARGET_BUILTIN(__builtin_lasx_xvsubi_bu, "V32ScV32ScIUi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsubi_hu, "V16sV16sIUi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsubi_wu, "V8iV8iIUi", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvsubi_du, "V4LLiV4LLiIUi", "nc", "lasx")
 
-TARGET_BUILTIN(__builtin_lasx_xvneg_b, "V32cV32c", "nc", "lasx")
+TARGET_BUILTIN(__builtin_lasx_xvneg_b, "V32ScV32Sc", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvneg_h, "V16sV16

[llvm-branch-commits] [compiler-rt] release/19.x: [compiler-rt] Stop using x86 builtin on AArch64 with GCC (#93890) (PR #115006)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/115006

>From 67321c871a18a20240e23476048eea0ee8ebdd25 Mon Sep 17 00:00:00 2001
From: Alan Wu 
Date: Fri, 16 Aug 2024 08:16:17 -0400
Subject: [PATCH] [compiler-rt] Stop using x86 builtin on AArch64 with GCC
 (#93890)

Previously, building `multc3.c` on A64 with GCC 7 or up but 9 and lower
will attempt to reference `__builtin_copysignq`, an [x86-specific
intrinsic][1]:

```
$ gcc -c multc3.c
In file included from fp_lib.h:24,
 from multc3.c:14:
multc3.c: In function '__multc3':
int_math.h:71:32: warning: implicit declaration of function 
'__builtin_copysignq'; did you mean '__builtin_copysign'? 
[-Wimplicit-function-declaration]
 #define crt_copysignf128(x, y) __builtin_copysignq((x), (y))
^~~
```

This is because `__has_builtin` is from GCC 10, and defined to 0 at the
top of int_math.h for affected GCC versions, so the fallback definition
is used. But `__builtin_copysignq` is unavailable on A64.

Use version detection to find `__builtin_copysignf128` instead. It's
available since GCC 7 and [available][2] on both x86 and A64, given this
macro is only used when `CRT_HAS_IEEE_TF`.

---

I realize this is fixing a problem for an out-of-tree build
configuration, but help would be greatly appreciated. Rust
[builds](https://github.com/rust-lang/compiler-builtins) `multc3.c` with
GCC 8 and this mis-selection is causing [build
issues](https://github.com/rust-lang/rust/issues/125619) way downstream.

ref: d2ce3e9621411f3391def327f89e3a650918989f

[1]: https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html
[2]: https://gcc.gnu.org/gcc-7/changes.html

(cherry picked from commit 8aa9d6206ce55bdaaf422839c351fbd63f033b89)
---
 compiler-rt/lib/builtins/int_math.h | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/builtins/int_math.h 
b/compiler-rt/lib/builtins/int_math.h
index 74d3e311db5e71..08bfe922ffa13b 100644
--- a/compiler-rt/lib/builtins/int_math.h
+++ b/compiler-rt/lib/builtins/int_math.h
@@ -65,9 +65,12 @@
 #define crt_copysign(x, y) __builtin_copysign((x), (y))
 #define crt_copysignf(x, y) __builtin_copysignf((x), (y))
 #define crt_copysignl(x, y) __builtin_copysignl((x), (y))
-#if __has_builtin(__builtin_copysignf128)
+// We define __has_builtin to always return 0 for GCC versions below 10,
+// but __builtin_copysignf128 is available since version 7.
+#if __has_builtin(__builtin_copysignf128) ||   
\
+(defined(__GNUC__) && __GNUC__ >= 7)
 #define crt_copysignf128(x, y) __builtin_copysignf128((x), (y))
-#elif __has_builtin(__builtin_copysignq) || (defined(__GNUC__) && __GNUC__ >= 
7)
+#elif __has_builtin(__builtin_copysignq)
 #define crt_copysignf128(x, y) __builtin_copysignq((x), (y))
 #endif
 #endif
@@ -80,9 +83,11 @@
 #define crt_fabs(x) __builtin_fabs((x))
 #define crt_fabsf(x) __builtin_fabsf((x))
 #define crt_fabsl(x) __builtin_fabsl((x))
-#if __has_builtin(__builtin_fabsf128)
+// We define __has_builtin to always return 0 for GCC versions below 10,
+// but __builtin_fabsf128 is available since version 7.
+#if __has_builtin(__builtin_fabsf128) || (defined(__GNUC__) && __GNUC__ >= 7)
 #define crt_fabsf128(x) __builtin_fabsf128((x))
-#elif __has_builtin(__builtin_fabsq) || (defined(__GNUC__) && __GNUC__ >= 7)
+#elif __has_builtin(__builtin_fabsq)
 #define crt_fabsf128(x) __builtin_fabsq((x))
 #endif
 #endif

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


[llvm-branch-commits] [llvm] release/19.x: [loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on loongarch (#107791) (PR #109093)

2024-11-11 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

@nikic @arsenm can someone re-review the new version without the abi break?

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


[llvm-branch-commits] [compiler-rt] 8a6c047 - Revert "[libfuzzer] use timer_create() instead of setitimer() for linux (#110…"

2024-11-11 Thread via llvm-branch-commits

Author: Florian Mayer
Date: 2024-11-11T19:50:12-08:00
New Revision: 8a6c047367e258ace4dc5a9416bea088572ca635

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

LOG: Revert "[libfuzzer] use timer_create() instead of setitimer() for linux 
(#110…"

This reverts commit 3b29a8a00809e868e3df7e687695670ff5077fbd.

Added: 


Modified: 
compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp

Removed: 




diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp 
b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
index 36a1122c9f7cc8..392c1e5be4eea3 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -104,19 +104,14 @@ bool ExecuteCommand(const Command &Cmd, std::string 
*CmdOutput) {
 }
 
 void SetTimer(int Seconds) {
-  timer_t TimerId;
-  struct itimerspec T {
+  struct itimerval T {
 {Seconds, 0}, { Seconds, 0 }
   };
-  SetSigaction(SIGALRM, AlarmHandler);
-  if (timer_create(CLOCK_REALTIME, nullptr, &TimerId) == -1) {
-Printf("libFuzzer: timer_create failed with %d\n", errno);
-exit(1);
-  }
-  if (timer_settime(TimerId, 0, &T, nullptr) == -1) {
-Printf("libFuzzer: timer_settime failed with %d\n", errno);
+  if (setitimer(ITIMER_REAL, &T, nullptr)) {
+Printf("libFuzzer: setitimer failed with %d\n", errno);
 exit(1);
   }
+  SetSigaction(SIGALRM, AlarmHandler);
 }
 
 void SetSignalHandler(const FuzzingOptions& Options) {



___
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][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer updated 
https://github.com/llvm/llvm-project/pull/114940

>From 8a49434df62e394cd109f0189349b4d28dafa525 Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Sat, 9 Nov 2024 12:29:16 +0100
Subject: [PATCH] [mlir][IR] Add `OpBuilder::setInsertionPointAfterValues`

---
 mlir/include/mlir/IR/Builders.h  | 14 +++
 mlir/include/mlir/IR/Dominance.h | 23 ++
 mlir/lib/IR/Builders.cpp | 41 
 3 files changed, 78 insertions(+)

diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 6fb71ccefda151..7ef03b87179523 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -16,6 +16,7 @@
 namespace mlir {
 
 class AffineExpr;
+class PostDominanceInfo;
 class IRMapping;
 class UnknownLoc;
 class FileLineColLoc;
@@ -341,6 +342,19 @@ class OpBuilder : public Builder {
 InsertPoint(Block *insertBlock, Block::iterator insertPt)
 : block(insertBlock), point(insertPt) {}
 
+/// Compute an insertion point to a place that post-dominates the
+/// definitions of all given values. Returns an "empty" insertion point if
+/// no such insertion point exists.
+///
+/// There may be multiple suitable insertion points. This function chooses
+/// an insertion right after one of the given values.
+///
+/// Note: Some of the given values may already have gone out of scope at 
the
+/// selected insertion point. (E.g., because they are defined in a nested
+/// region or because they are not visible in an IsolatedFromAbove region.)
+static InsertPoint after(ArrayRef values,
+ const PostDominanceInfo &domInfo);
+
 /// Returns true if this insert point is set.
 bool isSet() const { return (block != nullptr); }
 
diff --git a/mlir/include/mlir/IR/Dominance.h b/mlir/include/mlir/IR/Dominance.h
index 63504cad211a4d..be2dcec380b6cc 100644
--- a/mlir/include/mlir/IR/Dominance.h
+++ b/mlir/include/mlir/IR/Dominance.h
@@ -187,6 +187,17 @@ class DominanceInfo : public 
detail::DominanceInfoBase {
   /// dominance" of ops, the single block is considered to properly dominate
   /// itself in a graph region.
   bool properlyDominates(Block *a, Block *b) const;
+
+  bool properlyDominantes(Block *aBlock, Block::iterator aIt, Block *bBlock,
+  Block::iterator bIt, bool enclosingOk = true) const {
+return super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
+
+  bool dominantes(Block *aBlock, Block::iterator aIt, Block *bBlock,
+  Block::iterator bIt, bool enclosingOk = true) const {
+return (aBlock == bBlock && aIt == bIt) ||
+   super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
 };
 
 /// A class for computing basic postdominance information.
@@ -210,6 +221,18 @@ class PostDominanceInfo : public 
detail::DominanceInfoBase {
   bool postDominates(Block *a, Block *b) const {
 return a == b || properlyPostDominates(a, b);
   }
+
+  bool properlyPostDominantes(Block *aBlock, Block::iterator aIt, Block 
*bBlock,
+  Block::iterator bIt,
+  bool enclosingOk = true) const {
+return super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
+
+  bool postDominantes(Block *aBlock, Block::iterator aIt, Block *bBlock,
+  Block::iterator bIt, bool enclosingOk = true) const {
+return (aBlock == bBlock && aIt == bIt) ||
+   super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
 };
 
 } // namespace mlir
diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp
index 5397fbabc5c95e..4714c3cace6c78 100644
--- a/mlir/lib/IR/Builders.cpp
+++ b/mlir/lib/IR/Builders.cpp
@@ -11,6 +11,7 @@
 #include "mlir/IR/AffineMap.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Dialect.h"
+#include "mlir/IR/Dominance.h"
 #include "mlir/IR/IRMapping.h"
 #include "mlir/IR/IntegerSet.h"
 #include "mlir/IR/Matchers.h"
@@ -641,3 +642,43 @@ void OpBuilder::cloneRegionBefore(Region ®ion, Region 
&parent,
 void OpBuilder::cloneRegionBefore(Region ®ion, Block *before) {
   cloneRegionBefore(region, *before->getParent(), before->getIterator());
 }
+
+OpBuilder::InsertPoint
+OpBuilder::InsertPoint::after(ArrayRef values,
+  const PostDominanceInfo &domInfo) {
+  // Helper function that computes the point after v's definition.
+  auto computeAfterIp = [](Value v) -> std::pair {
+if (auto blockArg = dyn_cast(v))
+  return std::make_pair(blockArg.getOwner(), blockArg.getOwner()->begin());
+Operation *op = v.getDefiningOp();
+return std::make_pair(op->getBlock(), ++op->getIterator());
+  };
+
+  // Compute the insertion point after the first value is defined.
+  assert(!values.empty() && "expected at least one Value");
+  auto [block, blockIt] = computeAfterIp(values.fron

[llvm-branch-commits] [mlir] [mlir][Transforms] Dialect Conversion: Add `replaceOpWithMultiple` (PR #115816)

2024-11-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)


Changes

This commit adds a new function 
`ConversionPatternRewriter::replaceOpWithMultiple`. This function is similar to 
`replaceOp`, but it accepts multiple `ValueRange` replacements, one per op 
result.

Note: This function is not an overload of `replaceOp` because of ambiguous 
overload resolution that would make the API difficult to use.

This commit aligns "block signature conversions" with "op replacements": both 
support 1:N replacements now. Due to incomplete 1:N support in the dialect 
conversion driver, an argument materialization is inserted when an SSA value is 
replaced with multiple values; same as block signature conversions already work 
around the problem. These argument materializations are going to be removed in 
a subsequent commit that adds full 1:N support. The purpose of this PR is to 
add missing features gradually in small increments.

This commit also updates two MLIR transformations that have their custom 
workarounds around missing 1:N support. These can already start using 
`replaceOpWithMultiple`.

Depends on #114940.


---

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


7 Files Affected:

- (modified) mlir/include/mlir/IR/Builders.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+22-2) 
- (modified) mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp 
(+12-28) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp 
(+25-23) 
- (modified) 
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp 
(+13-8) 
- (modified) mlir/lib/IR/Builders.cpp (+11-5) 
- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+102-51) 


``diff
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 7ef03b87179523..78729376507208 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -353,7 +353,7 @@ class OpBuilder : public Builder {
 /// selected insertion point. (E.g., because they are defined in a nested
 /// region or because they are not visible in an IsolatedFromAbove region.)
 static InsertPoint after(ArrayRef values,
- const PostDominanceInfo &domInfo);
+ const PostDominanceInfo *domInfo = nullptr);
 
 /// Returns true if this insert point is set.
 bool isSet() const { return (block != nullptr); }
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h 
b/mlir/include/mlir/Transforms/DialectConversion.h
index 5e5957170e646c..e461b7d11602a0 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -795,12 +795,32 @@ class ConversionPatternRewriter final : public 
PatternRewriter {
   /// patterns even if a failure is encountered during the rewrite step.
   bool canRecoverFromRewriteFailure() const override { return true; }
 
-  /// PatternRewriter hook for replacing an operation.
+  /// Replace the given operation with the new values. The number of op results
+  /// and replacement values must match. The types may differ: the dialect
+  /// conversion driver will reconcile any surviving type mismatches at the end
+  /// of the conversion process with source materializations. The given
+  /// operation is erased.
   void replaceOp(Operation *op, ValueRange newValues) override;
 
-  /// PatternRewriter hook for replacing an operation.
+  /// Replace the given operation with the results of the new op. The number of
+  /// op results must match. The types may differ: the dialect conversion
+  /// driver will reconcile any surviving type mismatches at the end of the
+  /// conversion process with source materializations. The original operation
+  /// is erased.
   void replaceOp(Operation *op, Operation *newOp) override;
 
+  /// Replace the given operation with the new value range. The number of op
+  /// results and value ranges must match. If an original SSA value is replaced
+  /// by multiple SSA values (i.e., value range has more than 1 element), the
+  /// conversion driver will insert an argument materialization to convert the
+  /// N SSA values back into 1 SSA value of the original type. The given
+  /// operation is erased.
+  ///
+  /// Note: The argument materialization is a workaround until we have full 1:N
+  /// support in the dialect conversion. (It is going to disappear from both
+  /// `replaceOpWithMultiple` and `applySignatureConversion`.)
+  void replaceOpWithMultiple(Operation *op, ArrayRef newValues);
+
   /// PatternRewriter hook for erasing a dead operation. The uses of this
   /// operation *must* be made dead by the end of the conversion process,
   /// otherwise an assert will be issued.
diff --git a/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp 
b/mlir/lib/Dialect/Func/Transforms/DecomposeCallGr

[llvm-branch-commits] [mlir] [mlir][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer edited 
https://github.com/llvm/llvm-project/pull/114940
___
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][Transforms] Dialect Conversion: Add `replaceOpWithMultiple` (PR #115816)

2024-11-11 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer created 
https://github.com/llvm/llvm-project/pull/115816

This commit adds a new function 
`ConversionPatternRewriter::replaceOpWithMultiple`. This function is similar to 
`replaceOp`, but it accepts multiple `ValueRange` replacements, one per op 
result.

Note: This function is not an overload of `replaceOp` because of ambiguous 
overload resolution that would make the API difficult to use.

This commit aligns "block signature conversions" with "op replacements": both 
support 1:N replacements now. Due to incomplete 1:N support in the dialect 
conversion driver, an argument materialization is inserted when an SSA value is 
replaced with multiple values; same as block signature conversions already work 
around the problem. These argument materializations are going to be removed in 
a subsequent commit that adds full 1:N support. The purpose of this PR is to 
add missing features gradually in small increments.

This commit also updates two MLIR transformations that have their custom 
workarounds around missing 1:N support. These can already start using 
`replaceOpWithMultiple`.

Depends on #114940.


>From b425caab826e5d9ad2f078d6f548f3215005bf7f Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Tue, 12 Nov 2024 05:14:43 +0100
Subject: [PATCH] replace with multiple

---
 mlir/include/mlir/IR/Builders.h   |   2 +-
 .../mlir/Transforms/DialectConversion.h   |  24 ++-
 .../Transforms/DecomposeCallGraphTypes.cpp|  40 ++---
 .../Transforms/SparseTensorCodegen.cpp|  48 +++---
 .../Utils/SparseTensorDescriptor.cpp  |  21 ++-
 mlir/lib/IR/Builders.cpp  |  16 +-
 .../Transforms/Utils/DialectConversion.cpp| 153 --
 7 files changed, 186 insertions(+), 118 deletions(-)

diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 7ef03b87179523..78729376507208 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -353,7 +353,7 @@ class OpBuilder : public Builder {
 /// selected insertion point. (E.g., because they are defined in a nested
 /// region or because they are not visible in an IsolatedFromAbove region.)
 static InsertPoint after(ArrayRef values,
- const PostDominanceInfo &domInfo);
+ const PostDominanceInfo *domInfo = nullptr);
 
 /// Returns true if this insert point is set.
 bool isSet() const { return (block != nullptr); }
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h 
b/mlir/include/mlir/Transforms/DialectConversion.h
index 5e5957170e646c..e461b7d11602a0 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -795,12 +795,32 @@ class ConversionPatternRewriter final : public 
PatternRewriter {
   /// patterns even if a failure is encountered during the rewrite step.
   bool canRecoverFromRewriteFailure() const override { return true; }
 
-  /// PatternRewriter hook for replacing an operation.
+  /// Replace the given operation with the new values. The number of op results
+  /// and replacement values must match. The types may differ: the dialect
+  /// conversion driver will reconcile any surviving type mismatches at the end
+  /// of the conversion process with source materializations. The given
+  /// operation is erased.
   void replaceOp(Operation *op, ValueRange newValues) override;
 
-  /// PatternRewriter hook for replacing an operation.
+  /// Replace the given operation with the results of the new op. The number of
+  /// op results must match. The types may differ: the dialect conversion
+  /// driver will reconcile any surviving type mismatches at the end of the
+  /// conversion process with source materializations. The original operation
+  /// is erased.
   void replaceOp(Operation *op, Operation *newOp) override;
 
+  /// Replace the given operation with the new value range. The number of op
+  /// results and value ranges must match. If an original SSA value is replaced
+  /// by multiple SSA values (i.e., value range has more than 1 element), the
+  /// conversion driver will insert an argument materialization to convert the
+  /// N SSA values back into 1 SSA value of the original type. The given
+  /// operation is erased.
+  ///
+  /// Note: The argument materialization is a workaround until we have full 1:N
+  /// support in the dialect conversion. (It is going to disappear from both
+  /// `replaceOpWithMultiple` and `applySignatureConversion`.)
+  void replaceOpWithMultiple(Operation *op, ArrayRef newValues);
+
   /// PatternRewriter hook for erasing a dead operation. The uses of this
   /// operation *must* be made dead by the end of the conversion process,
   /// otherwise an assert will be issued.
diff --git a/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp 
b/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp
index de4aba2ed327db

[llvm-branch-commits] [mlir] [mlir][Transforms] Dialect Conversion: Add `replaceOpWithMultiple` (PR #115816)

2024-11-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-core

Author: Matthias Springer (matthias-springer)


Changes

This commit adds a new function 
`ConversionPatternRewriter::replaceOpWithMultiple`. This function is similar to 
`replaceOp`, but it accepts multiple `ValueRange` replacements, one per op 
result.

Note: This function is not an overload of `replaceOp` because of ambiguous 
overload resolution that would make the API difficult to use.

This commit aligns "block signature conversions" with "op replacements": both 
support 1:N replacements now. Due to incomplete 1:N support in the dialect 
conversion driver, an argument materialization is inserted when an SSA value is 
replaced with multiple values; same as block signature conversions already work 
around the problem. These argument materializations are going to be removed in 
a subsequent commit that adds full 1:N support. The purpose of this PR is to 
add missing features gradually in small increments.

This commit also updates two MLIR transformations that have their custom 
workarounds around missing 1:N support. These can already start using 
`replaceOpWithMultiple`.

Depends on #114940.


---

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


7 Files Affected:

- (modified) mlir/include/mlir/IR/Builders.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+22-2) 
- (modified) mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp 
(+12-28) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp 
(+25-23) 
- (modified) 
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp 
(+13-8) 
- (modified) mlir/lib/IR/Builders.cpp (+11-5) 
- (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+102-51) 


``diff
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 7ef03b87179523..78729376507208 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -353,7 +353,7 @@ class OpBuilder : public Builder {
 /// selected insertion point. (E.g., because they are defined in a nested
 /// region or because they are not visible in an IsolatedFromAbove region.)
 static InsertPoint after(ArrayRef values,
- const PostDominanceInfo &domInfo);
+ const PostDominanceInfo *domInfo = nullptr);
 
 /// Returns true if this insert point is set.
 bool isSet() const { return (block != nullptr); }
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h 
b/mlir/include/mlir/Transforms/DialectConversion.h
index 5e5957170e646c..e461b7d11602a0 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -795,12 +795,32 @@ class ConversionPatternRewriter final : public 
PatternRewriter {
   /// patterns even if a failure is encountered during the rewrite step.
   bool canRecoverFromRewriteFailure() const override { return true; }
 
-  /// PatternRewriter hook for replacing an operation.
+  /// Replace the given operation with the new values. The number of op results
+  /// and replacement values must match. The types may differ: the dialect
+  /// conversion driver will reconcile any surviving type mismatches at the end
+  /// of the conversion process with source materializations. The given
+  /// operation is erased.
   void replaceOp(Operation *op, ValueRange newValues) override;
 
-  /// PatternRewriter hook for replacing an operation.
+  /// Replace the given operation with the results of the new op. The number of
+  /// op results must match. The types may differ: the dialect conversion
+  /// driver will reconcile any surviving type mismatches at the end of the
+  /// conversion process with source materializations. The original operation
+  /// is erased.
   void replaceOp(Operation *op, Operation *newOp) override;
 
+  /// Replace the given operation with the new value range. The number of op
+  /// results and value ranges must match. If an original SSA value is replaced
+  /// by multiple SSA values (i.e., value range has more than 1 element), the
+  /// conversion driver will insert an argument materialization to convert the
+  /// N SSA values back into 1 SSA value of the original type. The given
+  /// operation is erased.
+  ///
+  /// Note: The argument materialization is a workaround until we have full 1:N
+  /// support in the dialect conversion. (It is going to disappear from both
+  /// `replaceOpWithMultiple` and `applySignatureConversion`.)
+  void replaceOpWithMultiple(Operation *op, ArrayRef newValues);
+
   /// PatternRewriter hook for erasing a dead operation. The uses of this
   /// operation *must* be made dead by the end of the conversion process,
   /// otherwise an assert will be issued.
diff --git a/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp 
b/mlir/lib/Dialect/Func/Transforms/DecomposeC

[llvm-branch-commits] [mlir] [mlir][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer ready_for_review 
https://github.com/llvm/llvm-project/pull/114940
___
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][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread Matthias Springer via llvm-branch-commits


@@ -341,6 +342,19 @@ class OpBuilder : public Builder {
 InsertPoint(Block *insertBlock, Block::iterator insertPt)
 : block(insertBlock), point(insertPt) {}
 
+/// Compute an insertion point to a place that post-dominates the
+/// definitions of all given values. Returns an "empty" insertion point if
+/// no such insertion point exists.
+///
+/// There may be multiple suitable insertion points. This function chooses
+/// an insertion right after one of the given values.
+///
+/// Note: Some of the given values may already have gone out of scope at 
the

matthias-springer wrote:

Note: if there exists an insertion point that post-dominates all definitions 
and where all values are in scope, this function is guaranteed to find it.

https://github.com/llvm/llvm-project/pull/114940
___
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][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer edited 
https://github.com/llvm/llvm-project/pull/114940
___
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][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer updated 
https://github.com/llvm/llvm-project/pull/114940

>From f1dbd8a29305afc1fcb19ef293c3de8383b48e79 Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Sat, 9 Nov 2024 12:29:16 +0100
Subject: [PATCH] [mlir][IR] Add `OpBuilder::setInsertionPointAfterValues`

---
 mlir/include/mlir/IR/Builders.h  | 14 +++
 mlir/include/mlir/IR/Dominance.h | 23 +
 mlir/lib/IR/Builders.cpp | 42 
 3 files changed, 79 insertions(+)

diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 6fb71ccefda151..bd3642f9f413dc 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -16,6 +16,7 @@
 namespace mlir {
 
 class AffineExpr;
+class PostDominanceInfo;
 class IRMapping;
 class UnknownLoc;
 class FileLineColLoc;
@@ -435,6 +436,19 @@ class OpBuilder : public Builder {
 }
   }
 
+  /// Sets the insertion point to a place that post-dominates the definitions
+  /// of all given values. Returns "failure" and leaves the current insertion
+  /// point unchanged if no such insertion point exists.
+  ///
+  /// There may be multiple suitable insertion points. This function chooses an
+  /// insertion right after one of the given values.
+  ///
+  /// Note: Some of the given values may already have gone out of scope at the
+  /// selected insertion point. (E.g., because they are defined in a nested
+  /// region.)
+  LogicalResult setInsertionPointAfterValues(ArrayRef values,
+ const PostDominanceInfo &domInfo);
+
   /// Sets the insertion point to the start of the specified block.
   void setInsertionPointToStart(Block *block) {
 setInsertionPoint(block, block->begin());
diff --git a/mlir/include/mlir/IR/Dominance.h b/mlir/include/mlir/IR/Dominance.h
index 63504cad211a4d..be2dcec380b6cc 100644
--- a/mlir/include/mlir/IR/Dominance.h
+++ b/mlir/include/mlir/IR/Dominance.h
@@ -187,6 +187,17 @@ class DominanceInfo : public 
detail::DominanceInfoBase {
   /// dominance" of ops, the single block is considered to properly dominate
   /// itself in a graph region.
   bool properlyDominates(Block *a, Block *b) const;
+
+  bool properlyDominantes(Block *aBlock, Block::iterator aIt, Block *bBlock,
+  Block::iterator bIt, bool enclosingOk = true) const {
+return super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
+
+  bool dominantes(Block *aBlock, Block::iterator aIt, Block *bBlock,
+  Block::iterator bIt, bool enclosingOk = true) const {
+return (aBlock == bBlock && aIt == bIt) ||
+   super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
 };
 
 /// A class for computing basic postdominance information.
@@ -210,6 +221,18 @@ class PostDominanceInfo : public 
detail::DominanceInfoBase {
   bool postDominates(Block *a, Block *b) const {
 return a == b || properlyPostDominates(a, b);
   }
+
+  bool properlyPostDominantes(Block *aBlock, Block::iterator aIt, Block 
*bBlock,
+  Block::iterator bIt,
+  bool enclosingOk = true) const {
+return super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
+
+  bool postDominantes(Block *aBlock, Block::iterator aIt, Block *bBlock,
+  Block::iterator bIt, bool enclosingOk = true) const {
+return (aBlock == bBlock && aIt == bIt) ||
+   super::properlyDominatesImpl(aBlock, aIt, bBlock, bIt, enclosingOk);
+  }
 };
 
 } // namespace mlir
diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp
index 5397fbabc5c95e..0f4b5123326502 100644
--- a/mlir/lib/IR/Builders.cpp
+++ b/mlir/lib/IR/Builders.cpp
@@ -11,6 +11,7 @@
 #include "mlir/IR/AffineMap.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Dialect.h"
+#include "mlir/IR/Dominance.h"
 #include "mlir/IR/IRMapping.h"
 #include "mlir/IR/IntegerSet.h"
 #include "mlir/IR/Matchers.h"
@@ -641,3 +642,44 @@ void OpBuilder::cloneRegionBefore(Region ®ion, Region 
&parent,
 void OpBuilder::cloneRegionBefore(Region ®ion, Block *before) {
   cloneRegionBefore(region, *before->getParent(), before->getIterator());
 }
+
+LogicalResult
+OpBuilder::setInsertionPointAfterValues(ArrayRef values,
+const PostDominanceInfo &domInfo) {
+  // Helper function that computes the point after v's definition.
+  auto computeAfterIp = [](Value v) -> std::pair {
+if (auto blockArg = dyn_cast(v))
+  return std::make_pair(blockArg.getOwner(), blockArg.getOwner()->begin());
+Operation *op = v.getDefiningOp();
+return std::make_pair(op->getBlock(), op->getIterator());
+  };
+
+  // Compute the insertion point after the first value is defined.
+  assert(!values.empty() && "expected at least one Value");
+  auto [block, blockIt] = computeAfterIp(values.front());
+
+  // Check the other values one-by-one and update

[llvm-branch-commits] [llvm] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits

https://github.com/kyulee-com updated 
https://github.com/llvm/llvm-project/pull/115750

>From 70dcb2ccba98b392c3539f349ccf7fec284a674c Mon Sep 17 00:00:00 2001
From: Kyungwoo Lee 
Date: Mon, 11 Nov 2024 10:06:56 -0800
Subject: [PATCH 1/2] [CGData] Refactor Global Merge Functions

---
 llvm/lib/CodeGen/GlobalMergeFunctions.cpp | 148 +-
 1 file changed, 59 insertions(+), 89 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp 
b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
index 2b367ca87d9008..df8dbb8a73b95d 100644
--- a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
+++ b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
@@ -31,14 +31,6 @@ static cl::opt DisableCGDataForMerging(
  "merging is still enabled within a module."),
 cl::init(false));
 
-STATISTIC(NumMismatchedFunctionHash,
-  "Number of mismatched function hash for global merge function");
-STATISTIC(NumMismatchedInstCount,
-  "Number of mismatched instruction count for global merge function");
-STATISTIC(NumMismatchedConstHash,
-  "Number of mismatched const hash for global merge function");
-STATISTIC(NumMismatchedModuleId,
-  "Number of mismatched Module Id for global merge function");
 STATISTIC(NumMergedFunctions,
   "Number of functions that are actually merged using function hash");
 STATISTIC(NumAnalyzedModues, "Number of modules that are analyzed");
@@ -203,9 +195,9 @@ void GlobalMergeFunc::analyze(Module &M) {
 struct FuncMergeInfo {
   StableFunctionMap::StableFunctionEntry *SF;
   Function *F;
-  std::unique_ptr IndexInstruction;
+  IndexInstrMap *IndexInstruction;
   FuncMergeInfo(StableFunctionMap::StableFunctionEntry *SF, Function *F,
-std::unique_ptr IndexInstruction)
+IndexInstrMap *IndexInstruction)
   : SF(SF), F(F), IndexInstruction(std::move(IndexInstruction)) {}
 };
 
@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);
+  auto &FI = FuncToFI.at(F);
 
-  if (SF->InstCount != FI.IndexInstruction->size()) {
-++NumMismatchedInstCount;
+  // Check if the function is compatible with any stable function
+  // in terms of the number of instructions and ignored operands.
+  assert(!SFS.empty());
+  auto &RFS = SFS[0];
+  if (RFS->InstCount != FI.IndexInstruction->size())
 continue;
-  }
-  bool HasValidSharedConst = true;
-  for (auto &[Index, Hash] : *SF->IndexOperandHashMap) {
-auto [InstIndex, OpndIndex] = Index;
-assert(InstIndex < FI.IndexInstruction->size());
-auto *Inst = FI.IndexInstruction->lookup(InstIndex);
-if (!ignoreOp(Inst, OpndIndex)) {
-  HasValidSharedConst = false;
-  break;
-}
-  }
-  if (!HasValidSharedConst) {
-++NumMismatchedConstHash;
-continue;
-  }
-  if (!checkConstHashCompatible(*SF->IndexOperandHashMap,
-*FI.IndexOperandHashMap)) {
-  

[llvm-branch-commits] [llvm] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits

https://github.com/kyulee-com edited 
https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits

https://github.com/kyulee-com ready_for_review 
https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits


@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);
+  auto &FI = FuncToFI.at(F);
 
-  if (SF->InstCount != FI.IndexInstruction->size()) {
-++NumMismatchedInstCount;
+  // Check if the function is compatible with any stable function
+  // in terms of the number of instructions and ignored operands.
+  assert(!SFS.empty());
+  auto &RFS = SFS[0];

kyulee-com wrote:

If the codegen data is not stale —meaning there has been no source change in 
the first or second pass— the size regression is less of a concern. My main 
worry was about the stability of optimization when the codegen data becomes 
outdated.

https://github.com/llvm/llvm-project/pull/115750
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Kyungwoo Lee via llvm-branch-commits

https://github.com/kyulee-com updated 
https://github.com/llvm/llvm-project/pull/115750

>From 70dcb2ccba98b392c3539f349ccf7fec284a674c Mon Sep 17 00:00:00 2001
From: Kyungwoo Lee 
Date: Mon, 11 Nov 2024 10:06:56 -0800
Subject: [PATCH 1/2] [CGData] Refactor Global Merge Functions

---
 llvm/lib/CodeGen/GlobalMergeFunctions.cpp | 148 +-
 1 file changed, 59 insertions(+), 89 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp 
b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
index 2b367ca87d9008..df8dbb8a73b95d 100644
--- a/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
+++ b/llvm/lib/CodeGen/GlobalMergeFunctions.cpp
@@ -31,14 +31,6 @@ static cl::opt DisableCGDataForMerging(
  "merging is still enabled within a module."),
 cl::init(false));
 
-STATISTIC(NumMismatchedFunctionHash,
-  "Number of mismatched function hash for global merge function");
-STATISTIC(NumMismatchedInstCount,
-  "Number of mismatched instruction count for global merge function");
-STATISTIC(NumMismatchedConstHash,
-  "Number of mismatched const hash for global merge function");
-STATISTIC(NumMismatchedModuleId,
-  "Number of mismatched Module Id for global merge function");
 STATISTIC(NumMergedFunctions,
   "Number of functions that are actually merged using function hash");
 STATISTIC(NumAnalyzedModues, "Number of modules that are analyzed");
@@ -203,9 +195,9 @@ void GlobalMergeFunc::analyze(Module &M) {
 struct FuncMergeInfo {
   StableFunctionMap::StableFunctionEntry *SF;
   Function *F;
-  std::unique_ptr IndexInstruction;
+  IndexInstrMap *IndexInstruction;
   FuncMergeInfo(StableFunctionMap::StableFunctionEntry *SF, Function *F,
-std::unique_ptr IndexInstruction)
+IndexInstrMap *IndexInstruction)
   : SF(SF), F(F), IndexInstruction(std::move(IndexInstruction)) {}
 };
 
@@ -420,101 +412,79 @@ static ParamLocsVecTy computeParamInfo(
 bool GlobalMergeFunc::merge(Module &M, const StableFunctionMap *FunctionMap) {
   bool Changed = false;
 
-  // Build a map from stable function name to function.
-  StringMap StableNameToFuncMap;
-  for (auto &F : M)
-StableNameToFuncMap[get_stable_name(F.getName())] = &F;
-  // Track merged functions
-  DenseSet MergedFunctions;
-
-  auto ModId = M.getModuleIdentifier();
-  for (auto &[Hash, SFS] : FunctionMap->getFunctionMap()) {
-// Parameter locations based on the unique hash sequences
-// across the candidates.
+  // Collect stable functions related to the current module.
+  DenseMap> HashToFuncs;
+  DenseMap FuncToFI;
+  auto &Maps = FunctionMap->getFunctionMap();
+  for (auto &F : M) {
+if (!isEligibleFunction(&F))
+  continue;
+auto FI = llvm::StructuralHashWithDifferences(F, ignoreOp);
+if (Maps.contains(FI.FunctionHash)) {
+  HashToFuncs[FI.FunctionHash].push_back(&F);
+  FuncToFI.try_emplace(&F, std::move(FI));
+}
+  }
+
+  for (auto &[Hash, Funcs] : HashToFuncs) {
 std::optional ParamLocsVec;
-Function *MergedFunc = nullptr;
-std::string MergedModId;
 SmallVector FuncMergeInfos;
-for (auto &SF : SFS) {
-  // Get the function from the stable name.
-  auto I = StableNameToFuncMap.find(
-  *FunctionMap->getNameForId(SF->FunctionNameId));
-  if (I == StableNameToFuncMap.end())
-continue;
-  Function *F = I->second;
-  assert(F);
-  // Skip if the function has been merged before.
-  if (MergedFunctions.count(F))
-continue;
-  // Consider the function if it is eligible for merging.
-  if (!isEligibleFunction(F))
-continue;
 
-  auto FI = llvm::StructuralHashWithDifferences(*F, ignoreOp);
-  uint64_t FuncHash = FI.FunctionHash;
-  if (Hash != FuncHash) {
-++NumMismatchedFunctionHash;
-continue;
-  }
+// Iterate functions with the same hash.
+for (auto &F : Funcs) {
+  auto &SFS = Maps.at(Hash);
+  auto &FI = FuncToFI.at(F);
 
-  if (SF->InstCount != FI.IndexInstruction->size()) {
-++NumMismatchedInstCount;
+  // Check if the function is compatible with any stable function
+  // in terms of the number of instructions and ignored operands.
+  assert(!SFS.empty());
+  auto &RFS = SFS[0];
+  if (RFS->InstCount != FI.IndexInstruction->size())
 continue;
-  }
-  bool HasValidSharedConst = true;
-  for (auto &[Index, Hash] : *SF->IndexOperandHashMap) {
-auto [InstIndex, OpndIndex] = Index;
-assert(InstIndex < FI.IndexInstruction->size());
-auto *Inst = FI.IndexInstruction->lookup(InstIndex);
-if (!ignoreOp(Inst, OpndIndex)) {
-  HasValidSharedConst = false;
-  break;
-}
-  }
-  if (!HasValidSharedConst) {
-++NumMismatchedConstHash;
-continue;
-  }
-  if (!checkConstHashCompatible(*SF->IndexOperandHashMap,
-*FI.IndexOperandHashMap)) {
-  

[llvm-branch-commits] [mlir] [mlir][IR] `DominanceInfo`: Deduplicate `properlyDominates` implementation (PR #115433)

2024-11-11 Thread River Riddle via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/115433
___
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] [CGData] Refactor Global Merge Functions (PR #115750)

2024-11-11 Thread Zhaoxuan Jiang via llvm-branch-commits

nocchijiang wrote:

Hit an assertion in `ignoreOp` when testing the refactored code.

```
Assertion failed: (OpIdx < I->getNumOperands() && "Invalid operand index"), 
function ignoreOp, file GlobalMergeFunctions.cpp, line 129.
Stop reason: hit program assert
expr I->dump()
  %6 = tail call ptr @objc_retain(ptr %5), !dbg !576

p I->getNumOperands()

(unsigned int) 2
p OpIdx

(unsigned int) 4
```

https://github.com/llvm/llvm-project/pull/115750
___
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][IR] Add `InsertPoint::after(ValueRange)` (PR #114940)

2024-11-11 Thread River Riddle via llvm-branch-commits

River707 wrote:

> > Why don't the various transforms just use DominanceInfo? Answering these 
> > queries is what it's intended for.
> 
> Block reachability and block dominance are two different things. Just because 
> there is a path from `block A -> block B` does not necessarily mean that 
> `block A dominates block B`. I'm not sure how "block reachability" could be 
> implemented with `DominanceInfo`.
> 
> That being said, in the dialect conversion I actually need dominance, so what 
> I implemented here is not useful there...

Yes, my comment was geared towards the fact that several of the usages are 
already conflating reachability with dominance (for example the original usage 
in the followup IRBuilder PR). My concern is/was around the general utility of 
such a function, given that it cannot be used in most situations people would 
reach for it (i.e. dominance outside of purely structured control flow) so it 
wasn't clear the utility in adding it to Block. That being said I don't have an 
issue with this singular function, given that it's a tiny amount of graph 
traversal code. I would clearly mark in the comment that this function is not a 
replacement for dominance in any reasonable situation (given that a successor 
block can easily reach a predecessor in a situation such as a loop).

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