[llvm-branch-commits] [libcxx] [libc++][doc] Update the release notes for LLVM 19. (PR #100167)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 2df1cec9db73697a04e733de39ab9ac63c7b2d9b Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Tue, 23 Jul 2024 18:59:23 +0200
Subject: [PATCH] [libc++][doc] Update the release notes for LLVM 19. (#99061)

This is a preparation for the upcoming LLVM 19 release.
---
 libcxx/docs/ReleaseNotes/19.rst| 47 --
 libcxx/docs/ReleaseNotes/20.rst| 14 -
 libcxx/docs/Status/SpecialMath.rst |  2 +-
 3 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 439f552db59a8..c2c2bfbed4ac3 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -35,6 +35,20 @@ see the `releases page `_.
 What's New in Libc++ 19.0.0?
 ==
 
+The main focus of the libc++ team has been to implement new C++20, C++23,
+and C++26 features.
+
+Experimental support for the time zone database has progressed.
+
+Work on the ranges support has progressed. See
+:ref:`ranges-status` for the current status.
+
+Work on the experimental C++17 Parallel STL has progressed. See
+:ref:`pstl-status` for the current status.
+
+Work on the C++17 mathematical special functions has started. See
+:ref:`special-math-status` for the current status.
+
 Implemented Papers
 --
 
@@ -59,14 +73,21 @@ Implemented Papers
 - P0019R8 - ``std::atomic_ref``
 - P2389R2 - Alias template ``dims`` for the ``extents`` of ``mdspan``
 - P1223R5 - ``ranges::find_last()``, ``ranges::find_last_if()``, and 
``ranges::find_last_if_not()``
+- P2602R2 - Poison Pills are Too Toxic
+- P1981R0 - Rename ``leap`` to ``leap_second``
+- P1982R0 - Rename ``link`` to ``time_zone_link``
+
 
 Improvements and New Features
 -
 
 - The performance of growing ``std::vector`` has been improved for trivially 
relocatable types.
-- A lot of types are considered trivially relocatable now, including 
``vector`` and ``string``.
-- The performance of ``ranges::fill`` and ``ranges::fill_n`` has been improved 
for ``vector::iterator``\s,
+
+- A lot of types are considered trivially relocatable now, including 
``std::vector`` and ``std::string``.
+
+- The performance of ``std::ranges::fill`` and ``std::ranges::fill_n`` has 
been improved for ``std::vector::iterator``\s,
   resulting in a performance increase of up to 1400x.
+
 - The ``std::mismatch`` algorithm has been optimized for integral types, which 
can lead up to 40x performance
   improvements.
 
@@ -74,7 +95,7 @@ Improvements and New Features
   up to 100x.
 
 - The ``std::set_intersection`` and ``std::ranges::set_intersection`` 
algorithms have been optimized to fast-forward over
-  contiguous ranges of non-matching values, reducing the number of comparisons 
from linear to 
+  contiguous ranges of non-matching values, reducing the number of comparisons 
from linear to
   logarithmic growth with the number of elements in best-case scenarios.
 
 - The ``_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM`` macro has been added to make 
the declarations in  available.
@@ -101,15 +122,18 @@ Improvements and New Features
 
   Note: bounded iterators currently are not supported for ``vector``.
 
+- In C++23 and C++26 the number of transitive includes in several headers has 
been reduced, improving the compilation speed.
+
+
 Deprecations and Removals
 -
 
-- The C++20 synchronization library (, , 
``atomic::wait``, etc.) has been deprecated
+- The C++20 synchronization library (, , 
``std::atomic::wait``, etc.) has been deprecated
   in language modes prior to C++20. If you are using these features prior to 
C++20, please update to ``-std=c++20``.
   In LLVM 20, the C++20 synchronization library will be removed entirely in 
language modes prior to C++20.
 
 - ``_LIBCPP_DISABLE_NODISCARD_EXT`` has been removed. ``[[nodiscard]]`` 
applications are now unconditional.
-  This decision is based on LEWGs discussion on `P3122 
` and `P3162 `
+  This decision is based on LEWGs discussion on `P3122 
`_ and `P3162 `_
   to not use ``[[nodiscard]]`` in the standard.
 
 - The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable that was used to enable the 
safe mode has been deprecated and setting
@@ -151,10 +175,11 @@ Deprecations and Removals
 - libc++ no longer supports ``std::allocator`` and containers of 
``const``-qualified element type, such
   as ``std::vector`` and ``std::list``. This used to be 
supported as an undocumented extension.
   If you were using ``std::vector``, replace it with 
``std::vector`` instead. The
-  ``_LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST`` macro can be defined to 
temporarily re-enable this extension as
-  folks transition their code. This macro will be honored for one released and 
ignore

[llvm-branch-commits] [libcxx] 2df1cec - [libc++][doc] Update the release notes for LLVM 19. (#99061)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Mark de Wever
Date: 2024-07-26T09:20:03+02:00
New Revision: 2df1cec9db73697a04e733de39ab9ac63c7b2d9b

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

LOG: [libc++][doc] Update the release notes for LLVM 19. (#99061)

This is a preparation for the upcoming LLVM 19 release.

Added: 


Modified: 
libcxx/docs/ReleaseNotes/19.rst
libcxx/docs/ReleaseNotes/20.rst
libcxx/docs/Status/SpecialMath.rst

Removed: 




diff  --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 439f552db59a8..c2c2bfbed4ac3 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -35,6 +35,20 @@ see the `releases page `_.
 What's New in Libc++ 19.0.0?
 ==
 
+The main focus of the libc++ team has been to implement new C++20, C++23,
+and C++26 features.
+
+Experimental support for the time zone database has progressed.
+
+Work on the ranges support has progressed. See
+:ref:`ranges-status` for the current status.
+
+Work on the experimental C++17 Parallel STL has progressed. See
+:ref:`pstl-status` for the current status.
+
+Work on the C++17 mathematical special functions has started. See
+:ref:`special-math-status` for the current status.
+
 Implemented Papers
 --
 
@@ -59,14 +73,21 @@ Implemented Papers
 - P0019R8 - ``std::atomic_ref``
 - P2389R2 - Alias template ``dims`` for the ``extents`` of ``mdspan``
 - P1223R5 - ``ranges::find_last()``, ``ranges::find_last_if()``, and 
``ranges::find_last_if_not()``
+- P2602R2 - Poison Pills are Too Toxic
+- P1981R0 - Rename ``leap`` to ``leap_second``
+- P1982R0 - Rename ``link`` to ``time_zone_link``
+
 
 Improvements and New Features
 -
 
 - The performance of growing ``std::vector`` has been improved for trivially 
relocatable types.
-- A lot of types are considered trivially relocatable now, including 
``vector`` and ``string``.
-- The performance of ``ranges::fill`` and ``ranges::fill_n`` has been improved 
for ``vector::iterator``\s,
+
+- A lot of types are considered trivially relocatable now, including 
``std::vector`` and ``std::string``.
+
+- The performance of ``std::ranges::fill`` and ``std::ranges::fill_n`` has 
been improved for ``std::vector::iterator``\s,
   resulting in a performance increase of up to 1400x.
+
 - The ``std::mismatch`` algorithm has been optimized for integral types, which 
can lead up to 40x performance
   improvements.
 
@@ -74,7 +95,7 @@ Improvements and New Features
   up to 100x.
 
 - The ``std::set_intersection`` and ``std::ranges::set_intersection`` 
algorithms have been optimized to fast-forward over
-  contiguous ranges of non-matching values, reducing the number of comparisons 
from linear to 
+  contiguous ranges of non-matching values, reducing the number of comparisons 
from linear to
   logarithmic growth with the number of elements in best-case scenarios.
 
 - The ``_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM`` macro has been added to make 
the declarations in  available.
@@ -101,15 +122,18 @@ Improvements and New Features
 
   Note: bounded iterators currently are not supported for ``vector``.
 
+- In C++23 and C++26 the number of transitive includes in several headers has 
been reduced, improving the compilation speed.
+
+
 Deprecations and Removals
 -
 
-- The C++20 synchronization library (, , 
``atomic::wait``, etc.) has been deprecated
+- The C++20 synchronization library (, , 
``std::atomic::wait``, etc.) has been deprecated
   in language modes prior to C++20. If you are using these features prior to 
C++20, please update to ``-std=c++20``.
   In LLVM 20, the C++20 synchronization library will be removed entirely in 
language modes prior to C++20.
 
 - ``_LIBCPP_DISABLE_NODISCARD_EXT`` has been removed. ``[[nodiscard]]`` 
applications are now unconditional.
-  This decision is based on LEWGs discussion on `P3122 
` and `P3162 `
+  This decision is based on LEWGs discussion on `P3122 
`_ and `P3162 `_
   to not use ``[[nodiscard]]`` in the standard.
 
 - The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable that was used to enable the 
safe mode has been deprecated and setting
@@ -151,10 +175,11 @@ Deprecations and Removals
 - libc++ no longer supports ``std::allocator`` and containers of 
``const``-qualified element type, such
   as ``std::vector`` and ``std::list``. This used to be 
supported as an undocumented extension.
   If you were using ``std::vector``, replace it with 
``std::vector`` instead. The
-  ``_LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST`` macro can be defined to 
temporarily re-enable this extension as

[llvm-branch-commits] [libcxx] [libc++][doc] Update the release notes for LLVM 19. (PR #100167)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100167
___
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][headers] Including stddef.h always redefines NULL (#99727) (PR #100191)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 3120547296c558634261ec944d7846be56eba306 Mon Sep 17 00:00:00 2001
From: Ian Anderson 
Date: Tue, 23 Jul 2024 13:02:59 -0700
Subject: [PATCH] [clang][headers] Including stddef.h always redefines NULL
 (#99727)

stddef.h always includes __stddef_null.h. This is fine in modules
because it's not possible to re-include the pcm, and it's necessary to
export the _Builtin_stddef.null submodule. However, without modules it
causes NULL to always get redefined which disrupts some C++ code. Rework
the inclusion of __stddef_null.h so that with not building with modules
it's only included if __need_NULL is set by the includer, or it's the
first time stddef.h is being included.

(cherry picked from commit 92a9d4831d5e40c286247c30fcd794563adbef6e)
---
 clang/lib/Headers/stdarg.h |  4 +-
 clang/lib/Headers/stddef.h | 21 -
 clang/test/Headers/stddefneeds.cpp | 15 --
 clang/test/Modules/stddef.cpp  | 73 ++
 4 files changed, 105 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Modules/stddef.cpp

diff --git a/clang/lib/Headers/stdarg.h b/clang/lib/Headers/stdarg.h
index 8292ab907becf..6203d7a600a23 100644
--- a/clang/lib/Headers/stdarg.h
+++ b/clang/lib/Headers/stdarg.h
@@ -20,19 +20,18 @@
  * modules.
  */
 #if defined(__MVS__) && __has_include_next()
-#include <__stdarg_header_macro.h>
 #undef __need___va_list
 #undef __need_va_list
 #undef __need_va_arg
 #undef __need___va_copy
 #undef __need_va_copy
+#include <__stdarg_header_macro.h>
 #include_next 
 
 #else
 #if !defined(__need___va_list) && !defined(__need_va_list) &&  
\
 !defined(__need_va_arg) && !defined(__need___va_copy) &&   
\
 !defined(__need_va_copy)
-#include <__stdarg_header_macro.h>
 #define __need___va_list
 #define __need_va_list
 #define __need_va_arg
@@ -45,6 +44,7 @@
 !defined(__STRICT_ANSI__)
 #define __need_va_copy
 #endif
+#include <__stdarg_header_macro.h>
 #endif
 
 #ifdef __need___va_list
diff --git a/clang/lib/Headers/stddef.h b/clang/lib/Headers/stddef.h
index 8985c526e8fc5..99b275aebf5aa 100644
--- a/clang/lib/Headers/stddef.h
+++ b/clang/lib/Headers/stddef.h
@@ -20,7 +20,6 @@
  * modules.
  */
 #if defined(__MVS__) && __has_include_next()
-#include <__stddef_header_macro.h>
 #undef __need_ptrdiff_t
 #undef __need_size_t
 #undef __need_rsize_t
@@ -31,6 +30,7 @@
 #undef __need_max_align_t
 #undef __need_offsetof
 #undef __need_wint_t
+#include <__stddef_header_macro.h>
 #include_next 
 
 #else
@@ -40,7 +40,6 @@
 !defined(__need_NULL) && !defined(__need_nullptr_t) && 
\
 !defined(__need_unreachable) && !defined(__need_max_align_t) &&
\
 !defined(__need_offsetof) && !defined(__need_wint_t)
-#include <__stddef_header_macro.h>
 #define __need_ptrdiff_t
 #define __need_size_t
 /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
@@ -49,7 +48,24 @@
 #define __need_rsize_t
 #endif
 #define __need_wchar_t
+#if !defined(__STDDEF_H) || __has_feature(modules)
+/*
+ * __stddef_null.h is special when building without modules: if __need_NULL is
+ * set, then it will unconditionally redefine NULL. To avoid stepping on client
+ * definitions of NULL, __need_NULL should only be set the first time this
+ * header is included, that is when __STDDEF_H is not defined. However, when
+ * building with modules, this header is a textual header and needs to
+ * unconditionally include __stdef_null.h to support multiple submodules
+ * exporting _Builtin_stddef.null. Take module SM with submodules A and B, 
whose
+ * headers both include stddef.h When SM.A builds, __STDDEF_H will be defined.
+ * When SM.B builds, the definition from SM.A will leak when building without
+ * local submodule visibility. stddef.h wouldn't include __stddef_null.h, and
+ * SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't
+ * export NULL as expected. When building with modules, always include
+ * __stddef_null.h so that everything works as expected.
+ */
 #define __need_NULL
+#endif
 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) ||  
\
 defined(__cplusplus)
 #define __need_nullptr_t
@@ -65,6 +81,7 @@
 /* wint_t is provided by  and not . It's here
  * for compatibility, but must be explicitly requested. Therefore
  * __need_wint_t is intentionally not defined here. */
+#include <__stddef_header_macro.h>
 #endif
 
 #if defined(__need_ptrdiff_t)
diff --git a/clang/test/Headers/stddefneeds.cpp 
b/clang/test/Headers/stddefneeds.cpp
index 0763bbdee13ae..0282e8afa600d 100644
--- a/clang/test/Headers/stddefneeds.cpp
+++ b/clang/test/Headers/stddefneeds.cpp
@@ -56,14 +56,21 @@ max_align_t m5;
 #undef NULL
 #define NULL 0
 
-// glibc (and other) headers then define __need_NULL and rely on stddef.h
-// to redefine NULL to the correct value again.
-#define __need_NULL
+// Includin

[llvm-branch-commits] [clang] 3120547 - [clang][headers] Including stddef.h always redefines NULL (#99727)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Ian Anderson
Date: 2024-07-26T09:20:40+02:00
New Revision: 3120547296c558634261ec944d7846be56eba306

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

LOG: [clang][headers] Including stddef.h always redefines NULL (#99727)

stddef.h always includes __stddef_null.h. This is fine in modules
because it's not possible to re-include the pcm, and it's necessary to
export the _Builtin_stddef.null submodule. However, without modules it
causes NULL to always get redefined which disrupts some C++ code. Rework
the inclusion of __stddef_null.h so that with not building with modules
it's only included if __need_NULL is set by the includer, or it's the
first time stddef.h is being included.

(cherry picked from commit 92a9d4831d5e40c286247c30fcd794563adbef6e)

Added: 
clang/test/Modules/stddef.cpp

Modified: 
clang/lib/Headers/stdarg.h
clang/lib/Headers/stddef.h
clang/test/Headers/stddefneeds.cpp

Removed: 




diff  --git a/clang/lib/Headers/stdarg.h b/clang/lib/Headers/stdarg.h
index 8292ab907becf..6203d7a600a23 100644
--- a/clang/lib/Headers/stdarg.h
+++ b/clang/lib/Headers/stdarg.h
@@ -20,19 +20,18 @@
  * modules.
  */
 #if defined(__MVS__) && __has_include_next()
-#include <__stdarg_header_macro.h>
 #undef __need___va_list
 #undef __need_va_list
 #undef __need_va_arg
 #undef __need___va_copy
 #undef __need_va_copy
+#include <__stdarg_header_macro.h>
 #include_next 
 
 #else
 #if !defined(__need___va_list) && !defined(__need_va_list) &&  
\
 !defined(__need_va_arg) && !defined(__need___va_copy) &&   
\
 !defined(__need_va_copy)
-#include <__stdarg_header_macro.h>
 #define __need___va_list
 #define __need_va_list
 #define __need_va_arg
@@ -45,6 +44,7 @@
 !defined(__STRICT_ANSI__)
 #define __need_va_copy
 #endif
+#include <__stdarg_header_macro.h>
 #endif
 
 #ifdef __need___va_list

diff  --git a/clang/lib/Headers/stddef.h b/clang/lib/Headers/stddef.h
index 8985c526e8fc5..99b275aebf5aa 100644
--- a/clang/lib/Headers/stddef.h
+++ b/clang/lib/Headers/stddef.h
@@ -20,7 +20,6 @@
  * modules.
  */
 #if defined(__MVS__) && __has_include_next()
-#include <__stddef_header_macro.h>
 #undef __need_ptr
diff _t
 #undef __need_size_t
 #undef __need_rsize_t
@@ -31,6 +30,7 @@
 #undef __need_max_align_t
 #undef __need_offsetof
 #undef __need_wint_t
+#include <__stddef_header_macro.h>
 #include_next 
 
 #else
@@ -40,7 +40,6 @@
 !defined(__need_NULL) && !defined(__need_nullptr_t) && 
\
 !defined(__need_unreachable) && !defined(__need_max_align_t) &&
\
 !defined(__need_offsetof) && !defined(__need_wint_t)
-#include <__stddef_header_macro.h>
 #define __need_ptr
diff _t
 #define __need_size_t
 /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
@@ -49,7 +48,24 @@
 #define __need_rsize_t
 #endif
 #define __need_wchar_t
+#if !defined(__STDDEF_H) || __has_feature(modules)
+/*
+ * __stddef_null.h is special when building without modules: if __need_NULL is
+ * set, then it will unconditionally redefine NULL. To avoid stepping on client
+ * definitions of NULL, __need_NULL should only be set the first time this
+ * header is included, that is when __STDDEF_H is not defined. However, when
+ * building with modules, this header is a textual header and needs to
+ * unconditionally include __stdef_null.h to support multiple submodules
+ * exporting _Builtin_stddef.null. Take module SM with submodules A and B, 
whose
+ * headers both include stddef.h When SM.A builds, __STDDEF_H will be defined.
+ * When SM.B builds, the definition from SM.A will leak when building without
+ * local submodule visibility. stddef.h wouldn't include __stddef_null.h, and
+ * SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't
+ * export NULL as expected. When building with modules, always include
+ * __stddef_null.h so that everything works as expected.
+ */
 #define __need_NULL
+#endif
 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) ||  
\
 defined(__cplusplus)
 #define __need_nullptr_t
@@ -65,6 +81,7 @@
 /* wint_t is provided by  and not . It's here
  * for compatibility, but must be explicitly requested. Therefore
  * __need_wint_t is intentionally not defined here. */
+#include <__stddef_header_macro.h>
 #endif
 
 #if defined(__need_ptr
diff _t)

diff  --git a/clang/test/Headers/stddefneeds.cpp 
b/clang/test/Headers/stddefneeds.cpp
index 0763bbdee13ae..0282e8afa600d 100644
--- a/clang/test/Headers/stddefneeds.cpp
+++ b/clang/test/Headers/stddefneeds.cpp
@@ -56,14 +56,21 @@ max_align_t m5;
 #undef NULL
 #define NULL 0
 
-// glibc (and other) headers then define __need_NULL and rely on stddef.h
-// to redefine NULL to the correct value again.
-#define __need

[llvm-branch-commits] [libcxx] [libc++][doc] Update the release notes for LLVM 19. (PR #100167)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@mordante (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100167
___
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][headers] Including stddef.h always redefines NULL (#99727) (PR #100191)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100191
___
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] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263) (PR #100195)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From c5f34876cd00c01bf5ecd38a2bfc5377867e4b04 Mon Sep 17 00:00:00 2001
From: Wesley Wiser 
Date: Tue, 23 Jul 2024 11:43:30 -0500
Subject: [PATCH] [LLVM] [MC] Update frame layout & CFI generation to handle
 frames larger than 2gb (#99263)

Rebase of #84114. I've only included the core changes to frame layout
calculation & CFI generation which sidesteps the regressions found after
merging #84114. Since these changes are a necessary precursor to the
overall fix and are themselves slightly beneficial as CFI is now
generated correctly, I think it is reasonable to merge this first step.

---

For very large stack frames, the offset from the stack pointer to a
local can be more than 2^31 which overflows various `int` offsets in the
frame lowering code.

This patch updates the frame lowering code to calculate the offsets as
64-bit values and fixes CFI to use the corrected sizes.

After this patch, additional work is needed to fix offset truncations in
each target's codegen.

(cherry picked from commit ca076f7a63f6a80e2e38315ec462be354b196b8d)
---
 llvm/include/llvm/CodeGen/MachineFrameInfo.h  | 14 +++---
 .../llvm/CodeGen/TargetFrameLowering.h|  4 +-
 llvm/include/llvm/MC/MCAsmBackend.h   |  2 +-
 llvm/include/llvm/MC/MCDwarf.h| 44 +--
 llvm/lib/CodeGen/CFIInstrInserter.cpp | 10 ++---
 llvm/lib/CodeGen/MachineFrameInfo.cpp |  2 +-
 llvm/lib/CodeGen/PrologEpilogInserter.cpp |  4 +-
 llvm/lib/MC/MCDwarf.cpp   |  6 +--
 .../MCTargetDesc/AArch64AsmBackend.cpp|  8 ++--
 llvm/lib/Target/ARM/ARMFrameLowering.cpp  |  4 +-
 .../Target/ARM/MCTargetDesc/ARMAsmBackend.cpp |  2 +-
 .../ARM/MCTargetDesc/ARMAsmBackendDarwin.h|  2 +-
 .../Target/Hexagon/HexagonFrameLowering.cpp   |  4 +-
 .../lib/Target/MSP430/MSP430FrameLowering.cpp |  2 +-
 .../Target/X86/MCTargetDesc/X86AsmBackend.cpp | 12 ++---
 llvm/lib/Target/X86/X86FrameLowering.cpp  |  4 +-
 llvm/test/CodeGen/PowerPC/huge-frame-size.ll  |  2 +-
 llvm/test/CodeGen/RISCV/pr88365.ll|  2 +-
 llvm/test/CodeGen/X86/huge-stack.ll   |  2 +-
 19 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/MachineFrameInfo.h 
b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
index 466fed7fb3a29..213b7ec6b3fbf 100644
--- a/llvm/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
@@ -251,7 +251,7 @@ class MachineFrameInfo {
   /// targets, this value is only used when generating debug info (via
   /// TargetRegisterInfo::getFrameIndexReference); when generating code, the
   /// corresponding adjustments are performed directly.
-  int OffsetAdjustment = 0;
+  int64_t OffsetAdjustment = 0;
 
   /// The prolog/epilog code inserter may process objects that require greater
   /// alignment than the default alignment the target provides.
@@ -280,7 +280,7 @@ class MachineFrameInfo {
   /// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
   /// class).  This information is important for frame pointer elimination.
   /// It is only valid during and after prolog/epilog code insertion.
-  unsigned MaxCallFrameSize = ~0u;
+  uint64_t MaxCallFrameSize = ~UINT64_C(0);
 
   /// The number of bytes of callee saved registers that the target wants to
   /// report for the current function in the CodeView S_FRAMEPROC record.
@@ -593,10 +593,10 @@ class MachineFrameInfo {
   uint64_t estimateStackSize(const MachineFunction &MF) const;
 
   /// Return the correction for frame offsets.
-  int getOffsetAdjustment() const { return OffsetAdjustment; }
+  int64_t getOffsetAdjustment() const { return OffsetAdjustment; }
 
   /// Set the correction for frame offsets.
-  void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
+  void setOffsetAdjustment(int64_t Adj) { OffsetAdjustment = Adj; }
 
   /// Return the alignment in bytes that this function must be aligned to,
   /// which is greater than the default stack alignment provided by the target.
@@ -663,7 +663,7 @@ class MachineFrameInfo {
   /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
   /// then only during or after prolog/epilog code insertion.
   ///
-  unsigned getMaxCallFrameSize() const {
+  uint64_t getMaxCallFrameSize() const {
 // TODO: Enable this assert when targets are fixed.
 //assert(isMaxCallFrameSizeComputed() && "MaxCallFrameSize not computed 
yet");
 if (!isMaxCallFrameSizeComputed())
@@ -671,9 +671,9 @@ class MachineFrameInfo {
 return MaxCallFrameSize;
   }
   bool isMaxCallFrameSizeComputed() const {
-return MaxCallFrameSize != ~0u;
+return MaxCallFrameSize != ~UINT64_C(0);
   }
-  void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
+  void setMaxCallFrameSize(uint64_t S) { MaxCallFrameSize = S; }
 
   /// Returns how many bytes of callee-saved registers the target pushed in 

[llvm-branch-commits] [llvm] c5f3487 - [LLVM] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Wesley Wiser
Date: 2024-07-26T09:21:02+02:00
New Revision: c5f34876cd00c01bf5ecd38a2bfc5377867e4b04

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

LOG: [LLVM] [MC] Update frame layout & CFI generation to handle frames larger 
than 2gb (#99263)

Rebase of #84114. I've only included the core changes to frame layout
calculation & CFI generation which sidesteps the regressions found after
merging #84114. Since these changes are a necessary precursor to the
overall fix and are themselves slightly beneficial as CFI is now
generated correctly, I think it is reasonable to merge this first step.

---

For very large stack frames, the offset from the stack pointer to a
local can be more than 2^31 which overflows various `int` offsets in the
frame lowering code.

This patch updates the frame lowering code to calculate the offsets as
64-bit values and fixes CFI to use the corrected sizes.

After this patch, additional work is needed to fix offset truncations in
each target's codegen.

(cherry picked from commit ca076f7a63f6a80e2e38315ec462be354b196b8d)

Added: 


Modified: 
llvm/include/llvm/CodeGen/MachineFrameInfo.h
llvm/include/llvm/CodeGen/TargetFrameLowering.h
llvm/include/llvm/MC/MCAsmBackend.h
llvm/include/llvm/MC/MCDwarf.h
llvm/lib/CodeGen/CFIInstrInserter.cpp
llvm/lib/CodeGen/MachineFrameInfo.cpp
llvm/lib/CodeGen/PrologEpilogInserter.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
llvm/lib/Target/ARM/ARMFrameLowering.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/PowerPC/huge-frame-size.ll
llvm/test/CodeGen/RISCV/pr88365.ll
llvm/test/CodeGen/X86/huge-stack.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/MachineFrameInfo.h 
b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
index 466fed7fb3a29..213b7ec6b3fbf 100644
--- a/llvm/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
@@ -251,7 +251,7 @@ class MachineFrameInfo {
   /// targets, this value is only used when generating debug info (via
   /// TargetRegisterInfo::getFrameIndexReference); when generating code, the
   /// corresponding adjustments are performed directly.
-  int OffsetAdjustment = 0;
+  int64_t OffsetAdjustment = 0;
 
   /// The prolog/epilog code inserter may process objects that require greater
   /// alignment than the default alignment the target provides.
@@ -280,7 +280,7 @@ class MachineFrameInfo {
   /// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
   /// class).  This information is important for frame pointer elimination.
   /// It is only valid during and after prolog/epilog code insertion.
-  unsigned MaxCallFrameSize = ~0u;
+  uint64_t MaxCallFrameSize = ~UINT64_C(0);
 
   /// The number of bytes of callee saved registers that the target wants to
   /// report for the current function in the CodeView S_FRAMEPROC record.
@@ -593,10 +593,10 @@ class MachineFrameInfo {
   uint64_t estimateStackSize(const MachineFunction &MF) const;
 
   /// Return the correction for frame offsets.
-  int getOffsetAdjustment() const { return OffsetAdjustment; }
+  int64_t getOffsetAdjustment() const { return OffsetAdjustment; }
 
   /// Set the correction for frame offsets.
-  void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
+  void setOffsetAdjustment(int64_t Adj) { OffsetAdjustment = Adj; }
 
   /// Return the alignment in bytes that this function must be aligned to,
   /// which is greater than the default stack alignment provided by the target.
@@ -663,7 +663,7 @@ class MachineFrameInfo {
   /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
   /// then only during or after prolog/epilog code insertion.
   ///
-  unsigned getMaxCallFrameSize() const {
+  uint64_t getMaxCallFrameSize() const {
 // TODO: Enable this assert when targets are fixed.
 //assert(isMaxCallFrameSizeComputed() && "MaxCallFrameSize not computed 
yet");
 if (!isMaxCallFrameSizeComputed())
@@ -671,9 +671,9 @@ class MachineFrameInfo {
 return MaxCallFrameSize;
   }
   bool isMaxCallFrameSizeComputed() const {
-return MaxCallFrameSize != ~0u;
+return MaxCallFrameSize != ~UINT64_C(0);
   }
-  void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
+  void setMaxCallFrameSize(uint64_t S) { MaxCallFrameSize = S; }
 
   /// Returns how many bytes of callee-saved registers the target pushed in the
   /// prologue. Only used for debug inf

[llvm-branch-commits] [llvm] release/19.x: [LLVM] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263) (PR #100195)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100195
___
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][headers] Including stddef.h always redefines NULL (#99727) (PR #100191)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ian-twilightcoder (or anyone else). If you would like to add a note about this 
fix in the release notes (completely optional). Please reply to this comment 
with a one or two sentence description of the fix.  When you are done, please 
add the release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100191
___
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] Fix an assertion failure introduced by #93430 (#100313) (PR #100407)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 07e9f01f8935c0006bdaf209acdce29cda7685d3 Mon Sep 17 00:00:00 2001
From: cor3ntin 
Date: Wed, 24 Jul 2024 17:28:44 +0200
Subject: [PATCH] [Clang] Fix an assertion failure introduced by #93430
 (#100313)

The PR #93430 introduced an assertion that did not make any sense. and
caused a regression. The fix is to simply remove the assertion.

No changelog. the intent is to backport this fix to clang 19.

(cherry picked from commit dd82a84e0eeafb017c7220c4a9fbd0a8a407f8a9)
---
 clang/lib/Sema/SemaExpr.cpp| 1 -
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 6 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9207bf7a41349..206194930f3b4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5730,7 +5730,6 @@ static bool isParenthetizedAndQualifiedAddressOfExpr(Expr 
*Fn) {
   if (!UO || UO->getOpcode() != clang::UO_AddrOf)
 return false;
   if (auto *DRE = dyn_cast(UO->getSubExpr()->IgnoreParens())) {
-assert(isa(DRE->getDecl()) && "expected a function");
 return DRE->hasQualifier();
   }
   if (auto *OVL = dyn_cast(UO->getSubExpr()->IgnoreParens()))
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..4811b6052254c 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -895,6 +895,10 @@ void g() {
 }
 
 namespace P2797 {
+
+int bar(void) { return 55; }
+int (&fref)(void) = bar;
+
 struct C {
   void c(this const C&);// #first
   void c() &;   // #second
@@ -915,6 +919,8 @@ struct C {
 (&C::c)(C{});
 (&C::c)(*this); // expected-error {{call to non-static member function 
without an object argument}}
 (&C::c)();
+
+(&fref)();
   }
 };
 }

___
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] CodeGen: Move current call site out of MachineModuleInfo (PR #100369)

2024-07-26 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Jul 26, 3:21 AM EDT**: @arsenm started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/100369).


https://github.com/llvm/llvm-project/pull/100369
___
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] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263) (PR #100195)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@MaskRay (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100195
___
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] 07e9f01 - [Clang] Fix an assertion failure introduced by #93430 (#100313)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: cor3ntin
Date: 2024-07-26T09:21:28+02:00
New Revision: 07e9f01f8935c0006bdaf209acdce29cda7685d3

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

LOG: [Clang] Fix an assertion failure introduced by #93430 (#100313)

The PR #93430 introduced an assertion that did not make any sense. and
caused a regression. The fix is to simply remove the assertion.

No changelog. the intent is to backport this fix to clang 19.

(cherry picked from commit dd82a84e0eeafb017c7220c4a9fbd0a8a407f8a9)

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/cxx2b-deducing-this.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9207bf7a41349..206194930f3b4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5730,7 +5730,6 @@ static bool isParenthetizedAndQualifiedAddressOfExpr(Expr 
*Fn) {
   if (!UO || UO->getOpcode() != clang::UO_AddrOf)
 return false;
   if (auto *DRE = dyn_cast(UO->getSubExpr()->IgnoreParens())) {
-assert(isa(DRE->getDecl()) && "expected a function");
 return DRE->hasQualifier();
   }
   if (auto *OVL = dyn_cast(UO->getSubExpr()->IgnoreParens()))

diff  --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..4811b6052254c 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -895,6 +895,10 @@ void g() {
 }
 
 namespace P2797 {
+
+int bar(void) { return 55; }
+int (&fref)(void) = bar;
+
 struct C {
   void c(this const C&);// #first
   void c() &;   // #second
@@ -915,6 +919,8 @@ struct C {
 (&C::c)(C{});
 (&C::c)(*this); // expected-error {{call to non-static member function 
without an object argument}}
 (&C::c)();
+
+(&fref)();
   }
 };
 }



___
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] Fix an assertion failure introduced by #93430 (#100313) (PR #100407)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100407
___
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][NFC] Simplify initialization of `OverloadCandidate` objects. (#100318) (PR #100410)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 12a11dc676fd36d790b705b918597877fb34772a Mon Sep 17 00:00:00 2001
From: cor3ntin 
Date: Wed, 24 Jul 2024 17:27:58 +0200
Subject: [PATCH] [Clang][NFC] Simplify initialization of `OverloadCandidate`
 objects. (#100318)

Initialize some fields of OverloadCandidate in its constructor. The goal
here is try to fix read of uninitialized variable (which I was not able
to reproduce)
https://github.com/llvm/llvm-project/pull/93430#issuecomment-2187544278

We should certainly try to improve the construction of
`OverloadCandidate` further as it can be quite britle.

(cherry picked from commit 7d787df5b932b73aae6532d1e981152f103f9244)
---
 clang/include/clang/Sema/Overload.h |  4 +++-
 clang/lib/Sema/SemaOverload.cpp | 20 +---
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 9d8b797af6663..26ffe057c74a2 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -998,7 +998,9 @@ class Sema;
   private:
 friend class OverloadCandidateSet;
 OverloadCandidate()
-: IsSurrogate(false), IsADLCandidate(CallExpr::NotADL), 
RewriteKind(CRK_None) {}
+: IsSurrogate(false), IgnoreObjectArgument(false),
+  TookAddressOfOverload(false), IsADLCandidate(CallExpr::NotADL),
+  RewriteKind(CRK_None) {}
   };
 
   /// OverloadCandidateSet - A set of overload candidates, used in C++
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a8d250fbabfed..554a2df14bea6 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6857,10 +6857,7 @@ void Sema::AddOverloadCandidate(
   Candidate.Viable = true;
   Candidate.RewriteKind =
   CandidateSet.getRewriteInfo().getRewriteKind(Function, PO);
-  Candidate.IsSurrogate = false;
   Candidate.IsADLCandidate = IsADLCandidate;
-  Candidate.IgnoreObjectArgument = false;
-  Candidate.TookAddressOfOverload = false;
   Candidate.ExplicitCallArguments = Args.size();
 
   // Explicit functions are not actually candidates at all if we're not
@@ -7422,8 +7419,6 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, 
DeclAccessPair FoundDecl,
   Candidate.Function = Method;
   Candidate.RewriteKind =
   CandidateSet.getRewriteInfo().getRewriteKind(Method, PO);
-  Candidate.IsSurrogate = false;
-  Candidate.IgnoreObjectArgument = false;
   Candidate.TookAddressOfOverload =
   CandidateSet.getKind() == OverloadCandidateSet::CSK_AddressOfOverloadSet;
   Candidate.ExplicitCallArguments = Args.size();
@@ -7617,7 +7612,6 @@ void Sema::AddMethodTemplateCandidate(
 Candidate.IgnoreObjectArgument =
 cast(Candidate.Function)->isStatic() ||
 ObjectType.isNull();
-Candidate.TookAddressOfOverload = false;
 Candidate.ExplicitCallArguments = Args.size();
 if (Result == TemplateDeductionResult::NonDependentConversionFailure)
   Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -7705,7 +7699,6 @@ void Sema::AddTemplateOverloadCandidate(
 Candidate.IgnoreObjectArgument =
 isa(Candidate.Function) &&
 !isa(Candidate.Function);
-Candidate.TookAddressOfOverload = false;
 Candidate.ExplicitCallArguments = Args.size();
 if (Result == TemplateDeductionResult::NonDependentConversionFailure)
   Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -7886,9 +7879,6 @@ void Sema::AddConversionCandidate(
   OverloadCandidate &Candidate = CandidateSet.addCandidate(1);
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = Conversion;
-  Candidate.IsSurrogate = false;
-  Candidate.IgnoreObjectArgument = false;
-  Candidate.TookAddressOfOverload = false;
   Candidate.FinalConversion.setAsIdentityConversion();
   Candidate.FinalConversion.setFromType(ConvType);
   Candidate.FinalConversion.setAllToTypes(ToType);
@@ -8084,9 +8074,6 @@ void Sema::AddTemplateConversionCandidate(
 Candidate.Function = FunctionTemplate->getTemplatedDecl();
 Candidate.Viable = false;
 Candidate.FailureKind = ovl_fail_bad_deduction;
-Candidate.IsSurrogate = false;
-Candidate.IgnoreObjectArgument = false;
-Candidate.TookAddressOfOverload = false;
 Candidate.ExplicitCallArguments = 1;
 Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result,
   Info);
@@ -8119,10 +8106,8 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl 
*Conversion,
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = nullptr;
   Candidate.Surrogate = Conversion;
-  Candidate.Viable = true;
   Candidate.IsSurrogate = true;
-  Candidate.IgnoreObjectArgument = false;
-  Candidate.TookAddressOfOverload = false;
+  Candidate.Viable = true;
   Candidate.ExplicitCallArguments = Args.size();
 
   // Determine the implicit conversion sequence for the implicit
@@ -8328,9 +8313,6 @@ v

[llvm-branch-commits] [clang] 12a11dc - [Clang][NFC] Simplify initialization of `OverloadCandidate` objects. (#100318)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: cor3ntin
Date: 2024-07-26T09:24:55+02:00
New Revision: 12a11dc676fd36d790b705b918597877fb34772a

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

LOG: [Clang][NFC] Simplify initialization of `OverloadCandidate` objects. 
(#100318)

Initialize some fields of OverloadCandidate in its constructor. The goal
here is try to fix read of uninitialized variable (which I was not able
to reproduce)
https://github.com/llvm/llvm-project/pull/93430#issuecomment-2187544278

We should certainly try to improve the construction of
`OverloadCandidate` further as it can be quite britle.

(cherry picked from commit 7d787df5b932b73aae6532d1e981152f103f9244)

Added: 


Modified: 
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 9d8b797af6663..26ffe057c74a2 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -998,7 +998,9 @@ class Sema;
   private:
 friend class OverloadCandidateSet;
 OverloadCandidate()
-: IsSurrogate(false), IsADLCandidate(CallExpr::NotADL), 
RewriteKind(CRK_None) {}
+: IsSurrogate(false), IgnoreObjectArgument(false),
+  TookAddressOfOverload(false), IsADLCandidate(CallExpr::NotADL),
+  RewriteKind(CRK_None) {}
   };
 
   /// OverloadCandidateSet - A set of overload candidates, used in C++

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a8d250fbabfed..554a2df14bea6 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6857,10 +6857,7 @@ void Sema::AddOverloadCandidate(
   Candidate.Viable = true;
   Candidate.RewriteKind =
   CandidateSet.getRewriteInfo().getRewriteKind(Function, PO);
-  Candidate.IsSurrogate = false;
   Candidate.IsADLCandidate = IsADLCandidate;
-  Candidate.IgnoreObjectArgument = false;
-  Candidate.TookAddressOfOverload = false;
   Candidate.ExplicitCallArguments = Args.size();
 
   // Explicit functions are not actually candidates at all if we're not
@@ -7422,8 +7419,6 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, 
DeclAccessPair FoundDecl,
   Candidate.Function = Method;
   Candidate.RewriteKind =
   CandidateSet.getRewriteInfo().getRewriteKind(Method, PO);
-  Candidate.IsSurrogate = false;
-  Candidate.IgnoreObjectArgument = false;
   Candidate.TookAddressOfOverload =
   CandidateSet.getKind() == OverloadCandidateSet::CSK_AddressOfOverloadSet;
   Candidate.ExplicitCallArguments = Args.size();
@@ -7617,7 +7612,6 @@ void Sema::AddMethodTemplateCandidate(
 Candidate.IgnoreObjectArgument =
 cast(Candidate.Function)->isStatic() ||
 ObjectType.isNull();
-Candidate.TookAddressOfOverload = false;
 Candidate.ExplicitCallArguments = Args.size();
 if (Result == TemplateDeductionResult::NonDependentConversionFailure)
   Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -7705,7 +7699,6 @@ void Sema::AddTemplateOverloadCandidate(
 Candidate.IgnoreObjectArgument =
 isa(Candidate.Function) &&
 !isa(Candidate.Function);
-Candidate.TookAddressOfOverload = false;
 Candidate.ExplicitCallArguments = Args.size();
 if (Result == TemplateDeductionResult::NonDependentConversionFailure)
   Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -7886,9 +7879,6 @@ void Sema::AddConversionCandidate(
   OverloadCandidate &Candidate = CandidateSet.addCandidate(1);
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = Conversion;
-  Candidate.IsSurrogate = false;
-  Candidate.IgnoreObjectArgument = false;
-  Candidate.TookAddressOfOverload = false;
   Candidate.FinalConversion.setAsIdentityConversion();
   Candidate.FinalConversion.setFromType(ConvType);
   Candidate.FinalConversion.setAllToTypes(ToType);
@@ -8084,9 +8074,6 @@ void Sema::AddTemplateConversionCandidate(
 Candidate.Function = FunctionTemplate->getTemplatedDecl();
 Candidate.Viable = false;
 Candidate.FailureKind = ovl_fail_bad_deduction;
-Candidate.IsSurrogate = false;
-Candidate.IgnoreObjectArgument = false;
-Candidate.TookAddressOfOverload = false;
 Candidate.ExplicitCallArguments = 1;
 Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result,
   Info);
@@ -8119,10 +8106,8 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl 
*Conversion,
   Candidate.FoundDecl = FoundDecl;
   Candidate.Function = nullptr;
   Candidate.Surrogate = Conversion;
-  Candidate.Viable = true;
   Candidate.IsSurrogate = true;
-  Candidate.IgnoreObjectArgument = false;
-  Candidate.TookAddressOfOverload = false;
+  Candidate.Viable = true;
   Candidate.ExplicitCallArg

[llvm-branch-commits] [clang] release/19.x: [Clang][NFC] Simplify initialization of `OverloadCandidate` objects. (#100318) (PR #100410)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100410
___
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] CodeGen: Move current call site out of MachineModuleInfo (PR #100369)

2024-07-26 Thread Sergei Barannikov via llvm-branch-commits


@@ -188,6 +188,14 @@ class FunctionLoweringInfo {
   /// SelectionDAGISel::PrepareEHLandingPad().
   unsigned ExceptionPointerVirtReg, ExceptionSelectorVirtReg;
 
+  /// The current call site index being processed, if any. 0 if none.
+  unsigned CurCallSite = 0;
+  // TODO: Ideally, what we'd like is to have a switch that allows emitting
+  // synchronous (precise at call-sites only) CFA into .eh_frame. However,
+  // even under this switch, we'd like .debug_frame to be precise when using
+  // -g. At this moment, there's no way to specify that some CFI directives
+  // go into .eh_frame only, while others go into .debug_frame only.

s-barannikov wrote:

This comment should be somewhere else wherether the "switch" it refers to 
should be added.
Somewhere near MF.needsFrameMoves, probably?


https://github.com/llvm/llvm-project/pull/100369
___
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] release/19.x: [libc++] Improve behavior when using relative path for LIBCXX_ASSERTION_HANDLER_FILE (#100157) (PR #100411)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 5c03c4fc269039dad8db96c298aaacf819b32125 Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 24 Jul 2024 11:03:52 -0500
Subject: [PATCH] [libc++] Improve behavior when using relative path for
 LIBCXX_ASSERTION_HANDLER_FILE (#100157)

Fixes #80696

(cherry picked from commit 046a17717d9c5b5385ecd914621b48bdd91524d0)
---
 libcxx/CMakeLists.txt  | 8 ++--
 libcxx/docs/BuildingLibcxx.rst | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 332816b15260a..674082c7d1787 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -71,12 +71,16 @@ if (NOT "${LIBCXX_HARDENING_MODE}" IN_LIST 
LIBCXX_SUPPORTED_HARDENING_MODES)
 "Unsupported hardening mode: '${LIBCXX_HARDENING_MODE}'. Supported values 
are ${LIBCXX_SUPPORTED_HARDENING_MODES}.")
 endif()
 set(LIBCXX_ASSERTION_HANDLER_FILE
-  "${CMAKE_CURRENT_SOURCE_DIR}/vendor/llvm/default_assertion_handler.in"
+  "vendor/llvm/default_assertion_handler.in"
   CACHE STRING
   "Specify the path to a header that contains a custom implementation of the
assertion handler that gets invoked when a hardening assertion fails. If
provided, this header will be included by the library, replacing the
-   default assertion handler.")
+   default assertion handler. If this is specified as a relative path, it
+   is assumed to be relative to '/libcxx'.")
+if (NOT IS_ABSOLUTE "${LIBCXX_ASSERTION_HANDLER_FILE}")
+  set(LIBCXX_ASSERTION_HANDLER_FILE 
"${CMAKE_CURRENT_SOURCE_DIR}/${LIBCXX_ASSERTION_HANDLER_FILE}")
+endif()
 option(LIBCXX_ENABLE_RANDOM_DEVICE
   "Whether to include support for std::random_device in the library. Disabling
this can be useful when building the library for platforms that don't have
diff --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 66bb19bb5b2cd..5c224689e0f9f 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -406,7 +406,8 @@ libc++ Feature Options
   Specify the path to a header that contains a custom implementation of the
   assertion handler that gets invoked when a hardening assertion fails. If
   provided, this header will be included by the library, replacing the
-  default assertion handler.
+  default assertion handler. If this is specified as a relative path, it
+  is assumed to be relative to ``/libcxx``.
 
 
 libc++ ABI Feature 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] [clang] release/19.x: [Clang] Fix an assertion failure introduced by #93430 (#100313) (PR #100407)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@cor3ntin (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100407
___
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] 5c03c4f - [libc++] Improve behavior when using relative path for LIBCXX_ASSERTION_HANDLER_FILE (#100157)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Louis Dionne
Date: 2024-07-26T09:25:23+02:00
New Revision: 5c03c4fc269039dad8db96c298aaacf819b32125

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

LOG: [libc++] Improve behavior when using relative path for 
LIBCXX_ASSERTION_HANDLER_FILE (#100157)

Fixes #80696

(cherry picked from commit 046a17717d9c5b5385ecd914621b48bdd91524d0)

Added: 


Modified: 
libcxx/CMakeLists.txt
libcxx/docs/BuildingLibcxx.rst

Removed: 




diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 332816b15260a..674082c7d1787 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -71,12 +71,16 @@ if (NOT "${LIBCXX_HARDENING_MODE}" IN_LIST 
LIBCXX_SUPPORTED_HARDENING_MODES)
 "Unsupported hardening mode: '${LIBCXX_HARDENING_MODE}'. Supported values 
are ${LIBCXX_SUPPORTED_HARDENING_MODES}.")
 endif()
 set(LIBCXX_ASSERTION_HANDLER_FILE
-  "${CMAKE_CURRENT_SOURCE_DIR}/vendor/llvm/default_assertion_handler.in"
+  "vendor/llvm/default_assertion_handler.in"
   CACHE STRING
   "Specify the path to a header that contains a custom implementation of the
assertion handler that gets invoked when a hardening assertion fails. If
provided, this header will be included by the library, replacing the
-   default assertion handler.")
+   default assertion handler. If this is specified as a relative path, it
+   is assumed to be relative to '/libcxx'.")
+if (NOT IS_ABSOLUTE "${LIBCXX_ASSERTION_HANDLER_FILE}")
+  set(LIBCXX_ASSERTION_HANDLER_FILE 
"${CMAKE_CURRENT_SOURCE_DIR}/${LIBCXX_ASSERTION_HANDLER_FILE}")
+endif()
 option(LIBCXX_ENABLE_RANDOM_DEVICE
   "Whether to include support for std::random_device in the library. Disabling
this can be useful when building the library for platforms that don't have

diff  --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 66bb19bb5b2cd..5c224689e0f9f 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -406,7 +406,8 @@ libc++ Feature Options
   Specify the path to a header that contains a custom implementation of the
   assertion handler that gets invoked when a hardening assertion fails. If
   provided, this header will be included by the library, replacing the
-  default assertion handler.
+  default assertion handler. If this is specified as a relative path, it
+  is assumed to be relative to ``/libcxx``.
 
 
 libc++ ABI Feature 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] [libcxx] release/19.x: [libc++] Improve behavior when using relative path for LIBCXX_ASSERTION_HANDLER_FILE (#100157) (PR #100411)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100411
___
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][NFC] Simplify initialization of `OverloadCandidate` objects. (#100318) (PR #100410)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@cor3ntin (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100410
___
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++][spaceship] Implements X::iterator container requirements. (#99343) (PR #100440)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 05446fb31a97eb768c494ad7175809faf7d2000a Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 24 Jul 2024 19:42:48 +0200
Subject: [PATCH] [libc++][spaceship] Implements X::iterator container
 requirements. (#99343)

This implements the requirements for the container iterator requirements
for array, deque, vector, and `vector`.

Implements:
- LWG3352 strong_equality isn't a thing

Implements parts of:
- P1614R2 The Mothership has Landed

Fixes: https://github.com/llvm/llvm-project/issues/62486
---
 libcxx/docs/Status/Cxx20Issues.csv|  2 +-
 libcxx/docs/Status/SpaceshipProjects.csv  |  2 +-
 libcxx/include/__bit_reference| 14 +++
 libcxx/include/__iterator/bounded_iter.h  | 24 +
 libcxx/include/__iterator/wrap_iter.h | 23 +
 libcxx/include/deque  | 29 +-
 .../bounded_iter/comparison.pass.cpp  | 14 ++-
 .../sequences/array/iterators.pass.cpp| 18 
 .../sequences/deque/iterators.pass.cpp| 29 ++
 .../sequences/vector.bool/iterators.pass.cpp  | 37 
 .../sequences/vector/iterators.pass.cpp   | 49 +-
 .../span.iterators/iterator.pass.cpp  | 92 +++
 .../string.view.iterators/iterators.pass.cpp  | 85 +
 libcxx/test/support/test_iterators.h  |  2 +
 14 files changed, 413 insertions(+), 7 deletions(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp
 create mode 100644 
libcxx/test/std/strings/string.view/string.view.iterators/iterators.pass.cpp

diff --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index 1a40a4472a4056..8a431c922a2d94 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -264,7 +264,7 @@
 "`3349 `__","Missing 
``__cpp_lib_constexpr_complex``\  for P0415R1","Prague","|Complete|","16.0"
 "`3350 `__","Simplify return type of 
``lexicographical_compare_three_way``\ 
","Prague","|Complete|","17.0","|spaceship|"
 "`3351 `__","``ranges::enable_safe_range``\  should 
not be constrained","Prague","|Complete|","15.0","|ranges|"
-"`3352 `__","``strong_equality``\  isn't a 
thing","Prague","|Nothing To Do|","","|spaceship|"
+"`3352 `__","``strong_equality``\  isn't a 
thing","Prague","|Complete|","19.0","|spaceship|"
 "`3354 `__","``has_strong_structural_equality``\  
has a meaningless definition","Prague","|Nothing To Do|","","|spaceship|"
 "`3355 `__","The memory algorithms should support 
move-only input iterators introduced by 
P1207","Prague","|Complete|","15.0","|ranges|"
 "`3356 `__","``__cpp_lib_nothrow_convertible``\  
should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0"
diff --git a/libcxx/docs/Status/SpaceshipProjects.csv 
b/libcxx/docs/Status/SpaceshipProjects.csv
index e1cf2044cfd789..4dc43cdbbd08fd 100644
--- a/libcxx/docs/Status/SpaceshipProjects.csv
+++ b/libcxx/docs/Status/SpaceshipProjects.csv
@@ -83,7 +83,7 @@ Section,Description,Dependencies,Assignee,Complete
 "| `[string.view.synop] `_
 | `[string.view.comparison] `_",| 
`basic_string_view `_,None,Mark de 
Wever,|Complete|
 - `5.7 Clause 22: Containers library 
`_
-| `[container.requirements.general] 
`_,|,None,Unassigned,|Not 
Started|
+| `[container.requirements.general] 
`_,|,None,Mark de 
Wever,|Complete|
 | `[array.syn] `_ (`general 
`_),| `array 
`_,[expos.only.func],"| Adrian Vogelsgesang
 | Hristo Hristov",|Complete|
 | `[deque.syn] `_ (`general 
`_),| `deque 
`_,[expos.only.func],Hristo Hristov,|Complete|
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index 606069d98be727..22637d43974123 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -16,6 +16,7 @@
 #include <__bit/countr.h>
 #include <__bit/invert_if.h>
 #include <__bit/popcount.h>
+#include <__compare/ordering.h>
 #include <__config>
 #include <__fwd/bit_reference.h>
 #include <__iterator/iterator_traits.h>
@@ -913,6 +914,7 @@ public:
 return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;
   }
 
+#if _LIBCPP_STD_VER <= 17
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
   operator!=(const __bit_i

[llvm-branch-commits] [libcxx] 05446fb - [libc++][spaceship] Implements X::iterator container requirements. (#99343)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Mark de Wever
Date: 2024-07-26T09:25:49+02:00
New Revision: 05446fb31a97eb768c494ad7175809faf7d2000a

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

LOG: [libc++][spaceship] Implements X::iterator container requirements. (#99343)

This implements the requirements for the container iterator requirements
for array, deque, vector, and `vector`.

Implements:
- LWG3352 strong_equality isn't a thing

Implements parts of:
- P1614R2 The Mothership has Landed

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

Added: 
libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp
libcxx/test/std/strings/string.view/string.view.iterators/iterators.pass.cpp

Modified: 
libcxx/docs/Status/Cxx20Issues.csv
libcxx/docs/Status/SpaceshipProjects.csv
libcxx/include/__bit_reference
libcxx/include/__iterator/bounded_iter.h
libcxx/include/__iterator/wrap_iter.h
libcxx/include/deque
libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp
libcxx/test/std/containers/sequences/array/iterators.pass.cpp
libcxx/test/std/containers/sequences/deque/iterators.pass.cpp
libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
libcxx/test/std/containers/sequences/vector/iterators.pass.cpp
libcxx/test/support/test_iterators.h

Removed: 




diff  --git a/libcxx/docs/Status/Cxx20Issues.csv 
b/libcxx/docs/Status/Cxx20Issues.csv
index 1a40a4472a4056..8a431c922a2d94 100644
--- a/libcxx/docs/Status/Cxx20Issues.csv
+++ b/libcxx/docs/Status/Cxx20Issues.csv
@@ -264,7 +264,7 @@
 "`3349 `__","Missing 
``__cpp_lib_constexpr_complex``\  for P0415R1","Prague","|Complete|","16.0"
 "`3350 `__","Simplify return type of 
``lexicographical_compare_three_way``\ 
","Prague","|Complete|","17.0","|spaceship|"
 "`3351 `__","``ranges::enable_safe_range``\  should 
not be constrained","Prague","|Complete|","15.0","|ranges|"
-"`3352 `__","``strong_equality``\  isn't a 
thing","Prague","|Nothing To Do|","","|spaceship|"
+"`3352 `__","``strong_equality``\  isn't a 
thing","Prague","|Complete|","19.0","|spaceship|"
 "`3354 `__","``has_strong_structural_equality``\  
has a meaningless definition","Prague","|Nothing To Do|","","|spaceship|"
 "`3355 `__","The memory algorithms should support 
move-only input iterators introduced by 
P1207","Prague","|Complete|","15.0","|ranges|"
 "`3356 `__","``__cpp_lib_nothrow_convertible``\  
should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0"

diff  --git a/libcxx/docs/Status/SpaceshipProjects.csv 
b/libcxx/docs/Status/SpaceshipProjects.csv
index e1cf2044cfd789..4dc43cdbbd08fd 100644
--- a/libcxx/docs/Status/SpaceshipProjects.csv
+++ b/libcxx/docs/Status/SpaceshipProjects.csv
@@ -83,7 +83,7 @@ Section,Description,Dependencies,Assignee,Complete
 "| `[string.view.synop] `_
 | `[string.view.comparison] `_",| 
`basic_string_view `_,None,Mark de 
Wever,|Complete|
 - `5.7 Clause 22: Containers library 
`_
-| `[container.requirements.general] 
`_,|,None,Unassigned,|Not 
Started|
+| `[container.requirements.general] 
`_,|,None,Mark de 
Wever,|Complete|
 | `[array.syn] `_ (`general 
`_),| `array 
`_,[expos.only.func],"| Adrian Vogelsgesang
 | Hristo Hristov",|Complete|
 | `[deque.syn] `_ (`general 
`_),| `deque 
`_,[expos.only.func],Hristo Hristov,|Complete|

diff  --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index 606069d98be727..22637d43974123 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -16,6 +16,7 @@
 #include <__bit/countr.h>
 #include <__bit/invert_if.h>
 #include <__bit/popcount.h>
+#include <__compare/ordering.h>
 #include <__config>
 #include <__fwd/bit_reference.h>
 #include <__iterator/iterator_traits.h>
@@ -913,6 +914,7 @@ public:
 return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;
   }
 
+#if _LIBCPP_STD_VER <= 17
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
   operator!=(const __bit_iterator& __x, const __bit_iterator& __y) {
 return !(__x == __y);
@@ -937,6 +939,18 @@ public:
   operator>=(cons

[llvm-branch-commits] [libcxx] [libc++][spaceship] Implements X::iterator container requirements. (#99343) (PR #100440)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100440
___
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] release/19.x: [libc++] Improve behavior when using relative path for LIBCXX_ASSERTION_HANDLER_FILE (#100157) (PR #100411)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ldionne (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100411
___
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: [ExprConstant] Handle shift overflow the same way as other kinds of overflow (#99579) (PR #100452)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 577f886f2ef32dc19d7534a0d4873269cd4d1efe Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Wed, 24 Jul 2024 12:36:08 -0700
Subject: [PATCH] [ExprConstant] Handle shift overflow the same way as other
 kinds of overflow (#99579)

We have a mechanism to allow folding expressions that aren't ICEs as an
extension; use it more consistently.

This ends up causing bad effects on diagnostics in a few cases, but
that's not specific to shifts; it's a general issue with the way those
uses handle overflow diagnostics.

(cherry picked from commit 20eff684203287828d6722fc860b9d3621429542)
---
 clang/docs/ReleaseNotes.rst  |  2 ++
 clang/lib/AST/ExprConstant.cpp   | 26 
 clang/lib/AST/Interp/Interp.h| 22 
 clang/lib/Sema/SemaExpr.cpp  |  3 ++-
 clang/test/CXX/basic/basic.types/p10.cpp |  2 +-
 clang/test/Sema/constant-builtins-2.c| 12 ---
 clang/test/SemaCXX/class.cpp |  9 +++-
 clang/test/SemaCXX/enum.cpp  | 24 +++---
 8 files changed, 65 insertions(+), 35 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5b6ee9830b507..549da6812740f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -765,6 +765,8 @@ Improvements to Clang's diagnostics
 
  UsingWithAttr objUsingWA; // warning: 'UsingWithAttr' is deprecated
 
+- Clang now diagnoses undefined behavior in constant expressions more 
consistently. This includes invalid shifts, and signed overflow in arithmetic.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 03a606102a77e..5e57b5e8bc8f1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2839,6 +2839,8 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   // During constant-folding, a negative shift is an opposite shift. Such
   // a shift is not a constant expression.
   Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
+  if (!Info.noteUndefinedBehavior())
+return false;
   RHS = -RHS;
   goto shift_right;
 }
@@ -2849,19 +2851,23 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
 if (SA != RHS) {
   Info.CCEDiag(E, diag::note_constexpr_large_shift)
 << RHS << E->getType() << LHS.getBitWidth();
+  if (!Info.noteUndefinedBehavior())
+return false;
 } else if (LHS.isSigned() && !Info.getLangOpts().CPlusPlus20) {
   // C++11 [expr.shift]p2: A signed left shift must have a non-negative
   // operand, and must not overflow the corresponding unsigned type.
   // C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
   // E1 x 2^E2 module 2^N.
-  if (LHS.isNegative())
+  if (LHS.isNegative()) {
 Info.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS;
-  else if (LHS.countl_zero() < SA)
+if (!Info.noteUndefinedBehavior())
+  return false;
+  } else if (LHS.countl_zero() < SA) {
 Info.CCEDiag(E, diag::note_constexpr_lshift_discards);
+if (!Info.noteUndefinedBehavior())
+  return false;
+  }
 }
-if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
-Info.getLangOpts().CPlusPlus11)
-  return false;
 Result = LHS << SA;
 return true;
   }
@@ -2875,6 +2881,8 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   // During constant-folding, a negative shift is an opposite shift. Such a
   // shift is not a constant expression.
   Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
+  if (!Info.noteUndefinedBehavior())
+return false;
   RHS = -RHS;
   goto shift_left;
 }
@@ -2882,13 +2890,13 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
 // C++11 [expr.shift]p1: Shift width must be less than the bit width of the
 // shifted type.
 unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
-if (SA != RHS)
+if (SA != RHS) {
   Info.CCEDiag(E, diag::note_constexpr_large_shift)
 << RHS << E->getType() << LHS.getBitWidth();
+  if (!Info.noteUndefinedBehavior())
+return false;
+}
 
-if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
-Info.getLangOpts().CPlusPlus11)
-  return false;
 Result = LHS >> SA;
 return true;
   }
diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 8e96f78d90568..253a433e7340a 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -153,7 +153,8 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const LT 
&LHS, const RT &RHS,
   if (RHS.isNegative()) {
 const SourceInfo &Loc = S.

[llvm-branch-commits] [clang] 577f886 - [ExprConstant] Handle shift overflow the same way as other kinds of overflow (#99579)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Eli Friedman
Date: 2024-07-26T09:26:15+02:00
New Revision: 577f886f2ef32dc19d7534a0d4873269cd4d1efe

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

LOG: [ExprConstant] Handle shift overflow the same way as other kinds of 
overflow (#99579)

We have a mechanism to allow folding expressions that aren't ICEs as an
extension; use it more consistently.

This ends up causing bad effects on diagnostics in a few cases, but
that's not specific to shifts; it's a general issue with the way those
uses handle overflow diagnostics.

(cherry picked from commit 20eff684203287828d6722fc860b9d3621429542)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/Sema/SemaExpr.cpp
clang/test/CXX/basic/basic.types/p10.cpp
clang/test/Sema/constant-builtins-2.c
clang/test/SemaCXX/class.cpp
clang/test/SemaCXX/enum.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5b6ee9830b507..549da6812740f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -765,6 +765,8 @@ Improvements to Clang's diagnostics
 
  UsingWithAttr objUsingWA; // warning: 'UsingWithAttr' is deprecated
 
+- Clang now diagnoses undefined behavior in constant expressions more 
consistently. This includes invalid shifts, and signed overflow in arithmetic.
+
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 03a606102a77e..5e57b5e8bc8f1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2839,6 +2839,8 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   // During constant-folding, a negative shift is an opposite shift. Such
   // a shift is not a constant expression.
   Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
+  if (!Info.noteUndefinedBehavior())
+return false;
   RHS = -RHS;
   goto shift_right;
 }
@@ -2849,19 +2851,23 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
 if (SA != RHS) {
   Info.CCEDiag(E, diag::note_constexpr_large_shift)
 << RHS << E->getType() << LHS.getBitWidth();
+  if (!Info.noteUndefinedBehavior())
+return false;
 } else if (LHS.isSigned() && !Info.getLangOpts().CPlusPlus20) {
   // C++11 [expr.shift]p2: A signed left shift must have a non-negative
   // operand, and must not overflow the corresponding unsigned type.
   // C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
   // E1 x 2^E2 module 2^N.
-  if (LHS.isNegative())
+  if (LHS.isNegative()) {
 Info.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS;
-  else if (LHS.countl_zero() < SA)
+if (!Info.noteUndefinedBehavior())
+  return false;
+  } else if (LHS.countl_zero() < SA) {
 Info.CCEDiag(E, diag::note_constexpr_lshift_discards);
+if (!Info.noteUndefinedBehavior())
+  return false;
+  }
 }
-if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
-Info.getLangOpts().CPlusPlus11)
-  return false;
 Result = LHS << SA;
 return true;
   }
@@ -2875,6 +2881,8 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   // During constant-folding, a negative shift is an opposite shift. Such a
   // shift is not a constant expression.
   Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
+  if (!Info.noteUndefinedBehavior())
+return false;
   RHS = -RHS;
   goto shift_left;
 }
@@ -2882,13 +2890,13 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
 // C++11 [expr.shift]p1: Shift width must be less than the bit width of the
 // shifted type.
 unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
-if (SA != RHS)
+if (SA != RHS) {
   Info.CCEDiag(E, diag::note_constexpr_large_shift)
 << RHS << E->getType() << LHS.getBitWidth();
+  if (!Info.noteUndefinedBehavior())
+return false;
+}
 
-if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
-Info.getLangOpts().CPlusPlus11)
-  return false;
 Result = LHS >> SA;
 return true;
   }

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 8e96f78d90568..253a433e7340a 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -153,7 +153,8 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const LT 
&LHS, const RT &RHS,
   if (RHS.isNegative()) {
 const SourceInfo &Loc = S.Current->getSource(OpPC);
 S.CCEDiag(Lo

[llvm-branch-commits] [clang] release/19.x: [ExprConstant] Handle shift overflow the same way as other kinds of overflow (#99579) (PR #100452)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100452
___
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++][spaceship] Implements X::iterator container requirements. (#99343) (PR #100440)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@mordante (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100440
___
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] [flang] [llvm] release/19.x: [Flang][Docs] Update information about AArch64 trampolines (#100391) (PR #100471)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 01bd0394c9d5809be2d125ae1dfd3faef8bf0942 Mon Sep 17 00:00:00 2001
From: Carlos Seo 
Date: Wed, 24 Jul 2024 11:18:08 -0300
Subject: [PATCH 1/2] [AArch64] Implement INIT/ADJUST_TRAMPOLINE (#70267)

Add support for llvm.init.trampoline and llvm.adjust.trampoline
intrinsics for AArch64.

Fixes https://github.com/llvm/llvm-project/issues/65573
Fixes https://github.com/llvm/llvm-project/issues/76927
Fixes https://github.com/llvm/llvm-project/issues/83555
Updates https://github.com/llvm/llvm-project/pull/66157

(cherry picked from commit c4b66bf4d065d3bbc2e2fac8512a6df8e013c704)
---
 compiler-rt/lib/builtins/README.txt   |  5 ++
 compiler-rt/lib/builtins/trampoline_setup.c   | 42 ++
 .../builtins/Unit/trampoline_setup_test.c |  2 +-
 .../Target/AArch64/AArch64ISelLowering.cpp| 58 +++
 llvm/lib/Target/AArch64/AArch64ISelLowering.h |  2 +
 llvm/test/CodeGen/AArch64/trampoline.ll   | 19 ++
 6 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AArch64/trampoline.ll

diff --git a/compiler-rt/lib/builtins/README.txt 
b/compiler-rt/lib/builtins/README.txt
index 2d213d95f333a..19f26c92a0f94 100644
--- a/compiler-rt/lib/builtins/README.txt
+++ b/compiler-rt/lib/builtins/README.txt
@@ -272,6 +272,11 @@ switch32
 switch8
 switchu8
 
+// This function generates a custom trampoline function with the specific
+// realFunc and localsPtr values.
+void __trampoline_setup(uint32_t* trampOnStack, int trampSizeAllocated,
+const void* realFunc, void* localsPtr);
+
 // There is no C interface to the *_vfp_d8_d15_regs functions.  There are
 // called in the prolog and epilog of Thumb1 functions.  When the C++ ABI use
 // SJLJ for exceptions, each function with a catch clause or destructors needs
diff --git a/compiler-rt/lib/builtins/trampoline_setup.c 
b/compiler-rt/lib/builtins/trampoline_setup.c
index 844eb27944142..830e25e4c0303 100644
--- a/compiler-rt/lib/builtins/trampoline_setup.c
+++ b/compiler-rt/lib/builtins/trampoline_setup.c
@@ -41,3 +41,45 @@ COMPILER_RT_ABI void __trampoline_setup(uint32_t 
*trampOnStack,
   __clear_cache(trampOnStack, &trampOnStack[10]);
 }
 #endif // __powerpc__ && !defined(__powerpc64__)
+
+// The AArch64 compiler generates calls to __trampoline_setup() when creating
+// trampoline functions on the stack for use with nested functions.
+// This function creates a custom 36-byte trampoline function on the stack
+// which loads x18 with a pointer to the outer function's locals
+// and then jumps to the target nested function.
+// Note: x18 is a reserved platform register on Windows and macOS.
+
+#if defined(__aarch64__) && defined(__ELF__)
+COMPILER_RT_ABI void __trampoline_setup(uint32_t *trampOnStack,
+int trampSizeAllocated,
+const void *realFunc, void *localsPtr) 
{
+  // This should never happen, but if compiler did not allocate
+  // enough space on stack for the trampoline, abort.
+  if (trampSizeAllocated < 36)
+compilerrt_abort();
+
+  // create trampoline
+  // Load realFunc into x17. mov/movk 16 bits at a time.
+  trampOnStack[0] =
+  0xd280u | uint64_t)realFunc >> 0) & 0xu) << 5) | 0x11;
+  trampOnStack[1] =
+  0xf2a0u | uint64_t)realFunc >> 16) & 0xu) << 5) | 0x11;
+  trampOnStack[2] =
+  0xf2c0u | uint64_t)realFunc >> 32) & 0xu) << 5) | 0x11;
+  trampOnStack[3] =
+  0xf2e0u | uint64_t)realFunc >> 48) & 0xu) << 5) | 0x11;
+  // Load localsPtr into x18
+  trampOnStack[4] =
+  0xd280u | uint64_t)localsPtr >> 0) & 0xu) << 5) | 0x12;
+  trampOnStack[5] =
+  0xf2a0u | uint64_t)localsPtr >> 16) & 0xu) << 5) | 0x12;
+  trampOnStack[6] =
+  0xf2c0u | uint64_t)localsPtr >> 32) & 0xu) << 5) | 0x12;
+  trampOnStack[7] =
+  0xf2e0u | uint64_t)localsPtr >> 48) & 0xu) << 5) | 0x12;
+  trampOnStack[8] = 0xd61f0220; // br x17
+
+  // Clear instruction cache.
+  __clear_cache(trampOnStack, &trampOnStack[9]);
+}
+#endif // defined(__aarch64__) && !defined(__APPLE__) && !defined(_WIN64)
diff --git a/compiler-rt/test/builtins/Unit/trampoline_setup_test.c 
b/compiler-rt/test/builtins/Unit/trampoline_setup_test.c
index da115fe764271..d51d35acaa02f 100644
--- a/compiler-rt/test/builtins/Unit/trampoline_setup_test.c
+++ b/compiler-rt/test/builtins/Unit/trampoline_setup_test.c
@@ -7,7 +7,7 @@
 
 /*
  * Tests nested functions
- * The ppc compiler generates a call to __trampoline_setup
+ * The ppc and aarch64 compilers generates a call to __trampoline_setup
  * The i386 and x86_64 compilers generate a call to ___enable_execute_stack
  */
 
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 87e7750768d2d..6d413a09407a9 100644
--- a/llvm/lib/Target/AAr

[llvm-branch-commits] [compiler-rt] 01bd039 - [AArch64] Implement INIT/ADJUST_TRAMPOLINE (#70267)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Carlos Seo
Date: 2024-07-26T09:26:46+02:00
New Revision: 01bd0394c9d5809be2d125ae1dfd3faef8bf0942

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

LOG: [AArch64] Implement INIT/ADJUST_TRAMPOLINE (#70267)

Add support for llvm.init.trampoline and llvm.adjust.trampoline
intrinsics for AArch64.

Fixes https://github.com/llvm/llvm-project/issues/65573
Fixes https://github.com/llvm/llvm-project/issues/76927
Fixes https://github.com/llvm/llvm-project/issues/83555
Updates https://github.com/llvm/llvm-project/pull/66157

(cherry picked from commit c4b66bf4d065d3bbc2e2fac8512a6df8e013c704)

Added: 
llvm/test/CodeGen/AArch64/trampoline.ll

Modified: 
compiler-rt/lib/builtins/README.txt
compiler-rt/lib/builtins/trampoline_setup.c
compiler-rt/test/builtins/Unit/trampoline_setup_test.c
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h

Removed: 




diff  --git a/compiler-rt/lib/builtins/README.txt 
b/compiler-rt/lib/builtins/README.txt
index 2d213d95f333a..19f26c92a0f94 100644
--- a/compiler-rt/lib/builtins/README.txt
+++ b/compiler-rt/lib/builtins/README.txt
@@ -272,6 +272,11 @@ switch32
 switch8
 switchu8
 
+// This function generates a custom trampoline function with the specific
+// realFunc and localsPtr values.
+void __trampoline_setup(uint32_t* trampOnStack, int trampSizeAllocated,
+const void* realFunc, void* localsPtr);
+
 // There is no C interface to the *_vfp_d8_d15_regs functions.  There are
 // called in the prolog and epilog of Thumb1 functions.  When the C++ ABI use
 // SJLJ for exceptions, each function with a catch clause or destructors needs

diff  --git a/compiler-rt/lib/builtins/trampoline_setup.c 
b/compiler-rt/lib/builtins/trampoline_setup.c
index 844eb27944142..830e25e4c0303 100644
--- a/compiler-rt/lib/builtins/trampoline_setup.c
+++ b/compiler-rt/lib/builtins/trampoline_setup.c
@@ -41,3 +41,45 @@ COMPILER_RT_ABI void __trampoline_setup(uint32_t 
*trampOnStack,
   __clear_cache(trampOnStack, &trampOnStack[10]);
 }
 #endif // __powerpc__ && !defined(__powerpc64__)
+
+// The AArch64 compiler generates calls to __trampoline_setup() when creating
+// trampoline functions on the stack for use with nested functions.
+// This function creates a custom 36-byte trampoline function on the stack
+// which loads x18 with a pointer to the outer function's locals
+// and then jumps to the target nested function.
+// Note: x18 is a reserved platform register on Windows and macOS.
+
+#if defined(__aarch64__) && defined(__ELF__)
+COMPILER_RT_ABI void __trampoline_setup(uint32_t *trampOnStack,
+int trampSizeAllocated,
+const void *realFunc, void *localsPtr) 
{
+  // This should never happen, but if compiler did not allocate
+  // enough space on stack for the trampoline, abort.
+  if (trampSizeAllocated < 36)
+compilerrt_abort();
+
+  // create trampoline
+  // Load realFunc into x17. mov/movk 16 bits at a time.
+  trampOnStack[0] =
+  0xd280u | uint64_t)realFunc >> 0) & 0xu) << 5) | 0x11;
+  trampOnStack[1] =
+  0xf2a0u | uint64_t)realFunc >> 16) & 0xu) << 5) | 0x11;
+  trampOnStack[2] =
+  0xf2c0u | uint64_t)realFunc >> 32) & 0xu) << 5) | 0x11;
+  trampOnStack[3] =
+  0xf2e0u | uint64_t)realFunc >> 48) & 0xu) << 5) | 0x11;
+  // Load localsPtr into x18
+  trampOnStack[4] =
+  0xd280u | uint64_t)localsPtr >> 0) & 0xu) << 5) | 0x12;
+  trampOnStack[5] =
+  0xf2a0u | uint64_t)localsPtr >> 16) & 0xu) << 5) | 0x12;
+  trampOnStack[6] =
+  0xf2c0u | uint64_t)localsPtr >> 32) & 0xu) << 5) | 0x12;
+  trampOnStack[7] =
+  0xf2e0u | uint64_t)localsPtr >> 48) & 0xu) << 5) | 0x12;
+  trampOnStack[8] = 0xd61f0220; // br x17
+
+  // Clear instruction cache.
+  __clear_cache(trampOnStack, &trampOnStack[9]);
+}
+#endif // defined(__aarch64__) && !defined(__APPLE__) && !defined(_WIN64)

diff  --git a/compiler-rt/test/builtins/Unit/trampoline_setup_test.c 
b/compiler-rt/test/builtins/Unit/trampoline_setup_test.c
index da115fe764271..d51d35acaa02f 100644
--- a/compiler-rt/test/builtins/Unit/trampoline_setup_test.c
+++ b/compiler-rt/test/builtins/Unit/trampoline_setup_test.c
@@ -7,7 +7,7 @@
 
 /*
  * Tests nested functions
- * The ppc compiler generates a call to __trampoline_setup
+ * The ppc and aarch64 compilers generates a call to __trampoline_setup
  * The i386 and x86_64 compilers generate a call to ___enable_execute_stack
  */
 

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 87e7750768d2d..6d413a09407a9 100644
--- a/llvm/l

[llvm-branch-commits] [flang] 98b2bc5 - [Flang][Docs] Update information about AArch64 trampolines (#100391)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Carlos Seo
Date: 2024-07-26T09:26:46+02:00
New Revision: 98b2bc5b08802ab0ee79b28e10ed3ea531588d67

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

LOG: [Flang][Docs] Update information about AArch64 trampolines (#100391)

Commits c4b66bf and 7647174 add support for AArch64 trampolines. Updated
documentation to reflect the changes.

(cherry picked from commit c6e69b041a7e6d18463f6cf684b10fd46a62c496)

Added: 


Modified: 
flang/docs/InternalProcedureTrampolines.md

Removed: 




diff  --git a/flang/docs/InternalProcedureTrampolines.md 
b/flang/docs/InternalProcedureTrampolines.md
index ef02f1d737c82..41f6155332a47 100644
--- a/flang/docs/InternalProcedureTrampolines.md
+++ b/flang/docs/InternalProcedureTrampolines.md
@@ -239,7 +239,7 @@ automatically deallocated at the end of `host()` invocation.
 Unfortunately, this requires the program stack to be writeable and executable
 at the same time, which might be a security concern.
 
-> NOTE: LLVM's AArch64 backend supports `nest` attribute, but it does not seem 
to support trampoline intrinsics.
+> NOTE: LLVM's AArch64 backend supports `nest` attribute, but it requires the 
compiler-rt runtime selected via the `-rtlib=compiler-rt` flag.
 
 ## Alternative implementation(s)
 



___
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] [flang] [llvm] release/19.x: [Flang][Docs] Update information about AArch64 trampolines (#100391) (PR #100471)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100471
___
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: [PAC][clang] Enable `-fptrauth-indirect-gotos` as part of pauthtest ABI (#100480) (PR #100484)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 14fa8cd47eddf6f5837759872d99836b50eb55be Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Thu, 25 Jul 2024 02:13:30 +0300
Subject: [PATCH] [PAC][clang] Enable `-fptrauth-indirect-gotos` as part of
 pauthtest ABI (#100480)

(cherry picked from commit 3f6eb13abf643afec17a73448ede380606531226)
---
 clang/lib/Driver/ToolChains/Clang.cpp | 4 
 clang/test/Driver/aarch64-ptrauth.c   | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 78936fd634f33..5de29f1eca614 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1516,6 +1516,10 @@ static void handlePAuthABI(const ArgList &DriverArgs, 
ArgStringList &CC1Args) {
   options::OPT_fno_ptrauth_vtable_pointer_type_discrimination))
 CC1Args.push_back("-fptrauth-vtable-pointer-type-discrimination");
 
+  if (!DriverArgs.hasArg(options::OPT_fptrauth_indirect_gotos,
+ options::OPT_fno_ptrauth_indirect_gotos))
+CC1Args.push_back("-fptrauth-indirect-gotos");
+
   if (!DriverArgs.hasArg(options::OPT_fptrauth_init_fini,
  options::OPT_fno_ptrauth_init_fini))
 CC1Args.push_back("-fptrauth-init-fini");
diff --git a/clang/test/Driver/aarch64-ptrauth.c 
b/clang/test/Driver/aarch64-ptrauth.c
index d13930e8f4b37..eeb9500792d75 100644
--- a/clang/test/Driver/aarch64-ptrauth.c
+++ b/clang/test/Driver/aarch64-ptrauth.c
@@ -19,16 +19,16 @@
 // RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI1
 // PAUTHABI1:  "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
 // PAUTHABI1-SAME: "-target-abi" "pauthtest"
-// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-init-fini"
+// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini"
 
 // RUN: %clang -### -c --target=aarch64 -mabi=pauthtest 
-fno-ptrauth-intrinsics \
 // RUN:   -fno-ptrauth-calls -fno-ptrauth-returns -fno-ptrauth-auth-traps \
 // RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fno-ptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fno-ptrauth-init-fini %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI2
+// RUN:   -fno-ptrauth-indirect-gotos -fno-ptrauth-init-fini %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHABI2
 // RUN: %clang -### -c --target=aarch64-pauthtest -fno-ptrauth-intrinsics \
 // RUN:   -fno-ptrauth-calls -fno-ptrauth-returns -fno-ptrauth-auth-traps \
 // RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fno-ptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fno-ptrauth-init-fini %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI2
+// RUN:   -fno-ptrauth-indirect-gotos -fno-ptrauth-init-fini %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHABI2
 // PAUTHABI2: "-cc1"
 // PAUTHABI2-NOT: "-fptrauth-
 

___
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: [ExprConstant] Handle shift overflow the same way as other kinds of overflow (#99579) (PR #100452)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@efriedma-quic (or anyone else). If you would like to add a note about this fix 
in the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100452
___
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: [PAC][clang] Enable `-fptrauth-indirect-gotos` as part of pauthtest ABI (#100480) (PR #100484)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100484
___
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] 14fa8cd - [PAC][clang] Enable `-fptrauth-indirect-gotos` as part of pauthtest ABI (#100480)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Daniil Kovalev
Date: 2024-07-26T09:27:12+02:00
New Revision: 14fa8cd47eddf6f5837759872d99836b50eb55be

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

LOG: [PAC][clang] Enable `-fptrauth-indirect-gotos` as part of pauthtest ABI 
(#100480)

(cherry picked from commit 3f6eb13abf643afec17a73448ede380606531226)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/aarch64-ptrauth.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 78936fd634f33..5de29f1eca614 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1516,6 +1516,10 @@ static void handlePAuthABI(const ArgList &DriverArgs, 
ArgStringList &CC1Args) {
   options::OPT_fno_ptrauth_vtable_pointer_type_discrimination))
 CC1Args.push_back("-fptrauth-vtable-pointer-type-discrimination");
 
+  if (!DriverArgs.hasArg(options::OPT_fptrauth_indirect_gotos,
+ options::OPT_fno_ptrauth_indirect_gotos))
+CC1Args.push_back("-fptrauth-indirect-gotos");
+
   if (!DriverArgs.hasArg(options::OPT_fptrauth_init_fini,
  options::OPT_fno_ptrauth_init_fini))
 CC1Args.push_back("-fptrauth-init-fini");

diff  --git a/clang/test/Driver/aarch64-ptrauth.c 
b/clang/test/Driver/aarch64-ptrauth.c
index d13930e8f4b37..eeb9500792d75 100644
--- a/clang/test/Driver/aarch64-ptrauth.c
+++ b/clang/test/Driver/aarch64-ptrauth.c
@@ -19,16 +19,16 @@
 // RUN: %clang -### -c --target=aarch64-linux-pauthtest %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI1
 // PAUTHABI1:  "-cc1"{{.*}} "-triple" "aarch64-unknown-linux-pauthtest"
 // PAUTHABI1-SAME: "-target-abi" "pauthtest"
-// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-init-fini"
+// PAUTHABI1-SAME: "-fptrauth-intrinsics" "-fptrauth-calls" 
"-fptrauth-returns" "-fptrauth-auth-traps" 
"-fptrauth-vtable-pointer-address-discrimination" 
"-fptrauth-vtable-pointer-type-discrimination" "-fptrauth-indirect-gotos" 
"-fptrauth-init-fini"
 
 // RUN: %clang -### -c --target=aarch64 -mabi=pauthtest 
-fno-ptrauth-intrinsics \
 // RUN:   -fno-ptrauth-calls -fno-ptrauth-returns -fno-ptrauth-auth-traps \
 // RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fno-ptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fno-ptrauth-init-fini %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI2
+// RUN:   -fno-ptrauth-indirect-gotos -fno-ptrauth-init-fini %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHABI2
 // RUN: %clang -### -c --target=aarch64-pauthtest -fno-ptrauth-intrinsics \
 // RUN:   -fno-ptrauth-calls -fno-ptrauth-returns -fno-ptrauth-auth-traps \
 // RUN:   -fno-ptrauth-vtable-pointer-address-discrimination 
-fno-ptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fno-ptrauth-init-fini %s 2>&1 | FileCheck %s 
--check-prefix=PAUTHABI2
+// RUN:   -fno-ptrauth-indirect-gotos -fno-ptrauth-init-fini %s 2>&1 | 
FileCheck %s --check-prefix=PAUTHABI2
 // PAUTHABI2: "-cc1"
 // PAUTHABI2-NOT: "-fptrauth-
 



___
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] [libc] release/19.x: [libc] Only add '-fno-builtin-*' on the entrypoints that use them (#100481) (PR #100496)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From bdeb078aa24734ce6d2e573701f63e6111d7bab4 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Wed, 24 Jul 2024 21:06:19 -0500
Subject: [PATCH] [libc] Only add '-fno-builtin-*' on the entrypoints that use
 them (#100481)

Summary:
The GPU build needs to be able to inline stuff in LTO. Builtin
transformations cause problems on the functions that the optimizer does
heavy libcall recognition on. Previously we moved to using
`-fno-builtin-*` to allow us to only disable the problematic ones.
However, this still didn't allow inlining because each function had the
attribute that told the inliner not to inlining a nobuiltin function
into a non-nobuiltin function

This patch fixes that by only applying these attributes to the
entrypoints that define them. That is enough to prevent recursive calls
within the definitoins themselves.

(cherry picked from commit 8e43acbfedf53ded43ec693ddaaf518cb7416c1c)
---
 libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 11 +--
 libc/cmake/modules/LLVMLibCObjectRules.cmake| 11 +++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake 
b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 97d1c7262d24d..7a1c45a814eb6 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -104,16 +104,7 @@ function(_get_common_compile_options output_var flags)
   list(APPEND compile_options "-ffixed-point")
 endif()
 
-# Builtin recognition causes issues when trying to implement the builtin
-# functions themselves. The GPU backends do not use libcalls so we disable
-# the known problematic ones. This allows inlining during LTO linking.
-if(LIBC_TARGET_OS_IS_GPU)
-  set(libc_builtins bcmp strlen memmem bzero memcmp memcpy memmem memmove
-memset strcmp strstr)
-  foreach(builtin ${libc_builtins})
-list(APPEND compile_options "-fno-builtin-${builtin}")
-  endforeach()
-else()
+if(NOT LIBC_TARGET_OS_IS_GPU)
   list(APPEND compile_options "-fno-builtin")
 endif()
 
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake 
b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 2d3db38ecd8a3..68b5ed1ed51c0 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -279,6 +279,17 @@ function(create_entrypoint_object fq_target_name)
   add_dependencies(${fq_target_name} ${full_deps_list})
   target_link_libraries(${fq_target_name} ${full_deps_list})
 
+  # Builtin recognition causes issues when trying to implement the builtin
+  # functions themselves. The GPU backends do not use libcalls so we disable 
the
+  # known problematic ones on the entrypoints that implement them.
+  if(LIBC_TARGET_OS_IS_GPU)
+set(libc_builtins bcmp strlen memmem bzero memcmp memcpy memmem memmove
+  memset strcmp strstr)
+if(${ADD_ENTRYPOINT_OBJ_NAME} IN_LIST libc_builtins)
+  target_compile_options(${fq_target_name} PRIVATE 
-fno-builtin-${ADD_ENTRYPOINT_OBJ_NAME})
+endif()
+  endif()
+
   set_target_properties(
 ${fq_target_name}
 PROPERTIES

___
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] [libc] bdeb078 - [libc] Only add '-fno-builtin-*' on the entrypoints that use them (#100481)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Joseph Huber
Date: 2024-07-26T09:27:36+02:00
New Revision: bdeb078aa24734ce6d2e573701f63e6111d7bab4

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

LOG: [libc] Only add '-fno-builtin-*' on the entrypoints that use them (#100481)

Summary:
The GPU build needs to be able to inline stuff in LTO. Builtin
transformations cause problems on the functions that the optimizer does
heavy libcall recognition on. Previously we moved to using
`-fno-builtin-*` to allow us to only disable the problematic ones.
However, this still didn't allow inlining because each function had the
attribute that told the inliner not to inlining a nobuiltin function
into a non-nobuiltin function

This patch fixes that by only applying these attributes to the
entrypoints that define them. That is enough to prevent recursive calls
within the definitoins themselves.

(cherry picked from commit 8e43acbfedf53ded43ec693ddaaf518cb7416c1c)

Added: 


Modified: 
libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
libc/cmake/modules/LLVMLibCObjectRules.cmake

Removed: 




diff  --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake 
b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 97d1c7262d24d..7a1c45a814eb6 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -104,16 +104,7 @@ function(_get_common_compile_options output_var flags)
   list(APPEND compile_options "-ffixed-point")
 endif()
 
-# Builtin recognition causes issues when trying to implement the builtin
-# functions themselves. The GPU backends do not use libcalls so we disable
-# the known problematic ones. This allows inlining during LTO linking.
-if(LIBC_TARGET_OS_IS_GPU)
-  set(libc_builtins bcmp strlen memmem bzero memcmp memcpy memmem memmove
-memset strcmp strstr)
-  foreach(builtin ${libc_builtins})
-list(APPEND compile_options "-fno-builtin-${builtin}")
-  endforeach()
-else()
+if(NOT LIBC_TARGET_OS_IS_GPU)
   list(APPEND compile_options "-fno-builtin")
 endif()
 

diff  --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake 
b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 2d3db38ecd8a3..68b5ed1ed51c0 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -279,6 +279,17 @@ function(create_entrypoint_object fq_target_name)
   add_dependencies(${fq_target_name} ${full_deps_list})
   target_link_libraries(${fq_target_name} ${full_deps_list})
 
+  # Builtin recognition causes issues when trying to implement the builtin
+  # functions themselves. The GPU backends do not use libcalls so we disable 
the
+  # known problematic ones on the entrypoints that implement them.
+  if(LIBC_TARGET_OS_IS_GPU)
+set(libc_builtins bcmp strlen memmem bzero memcmp memcpy memmem memmove
+  memset strcmp strstr)
+if(${ADD_ENTRYPOINT_OBJ_NAME} IN_LIST libc_builtins)
+  target_compile_options(${fq_target_name} PRIVATE 
-fno-builtin-${ADD_ENTRYPOINT_OBJ_NAME})
+endif()
+  endif()
+
   set_target_properties(
 ${fq_target_name}
 PROPERTIES



___
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] [libc] release/19.x: [libc] Only add '-fno-builtin-*' on the entrypoints that use them (#100481) (PR #100496)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100496
___
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] release/19.x: [Flang][Driver] Enable config file options (#100343) (PR #100541)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 86e7adaa1b77089c7d8e39f13b8365a7fa92dde6 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan 
Date: Wed, 24 Jul 2024 16:28:24 +0100
Subject: [PATCH] [Flang][Driver] Enable config file options (#100343)

Config files provide a facility to invoke the compiler with a predefined
set of options. The patch only enables these options in the flang
driver. Functionality was always there.

(cherry picked from commit 8a77961280536b680c404a49002a00b988ca45fc)
---
 clang/include/clang/Driver/Options.td | 10 +--
 flang/test/Driver/Inputs/config-1.cfg |  1 +
 flang/test/Driver/Inputs/config-2.cfg |  1 +
 flang/test/Driver/Inputs/config-2a.cfg|  1 +
 flang/test/Driver/Inputs/config-6.cfg |  1 +
 flang/test/Driver/Inputs/config/config-4.cfg  |  1 +
 flang/test/Driver/Inputs/config2/config-4.cfg |  1 +
 flang/test/Driver/config-file.f90 | 63 +++
 8 files changed, 74 insertions(+), 5 deletions(-)
 create mode 100644 flang/test/Driver/Inputs/config-1.cfg
 create mode 100644 flang/test/Driver/Inputs/config-2.cfg
 create mode 100644 flang/test/Driver/Inputs/config-2a.cfg
 create mode 100644 flang/test/Driver/Inputs/config-6.cfg
 create mode 100644 flang/test/Driver/Inputs/config/config-4.cfg
 create mode 100644 flang/test/Driver/Inputs/config2/config-4.cfg
 create mode 100644 flang/test/Driver/config-file.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 69269cf7537b0d..359a698ea87dd0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1165,19 +1165,19 @@ def client__name : JoinedOrSeparate<["-"], 
"client_name">;
 def combine : Flag<["-", "--"], "combine">, Flags<[NoXarchOption, 
Unsupported]>;
 def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
 def config : Joined<["--"], "config=">, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>, MetaVarName<"">,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, 
MetaVarName<"">,
   HelpText<"Specify configuration file">;
-def : Separate<["--"], "config">, Alias;
+def : Separate<["--"], "config">, Visibility<[ClangOption, CLOption, 
DXCOption, FlangOption]>, Alias;
 def no_default_config : Flag<["--"], "no-default-config">,
-  Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
+  Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption, 
FlangOption]>,
   HelpText<"Disable loading default configuration files">;
 def config_system_dir_EQ : Joined<["--"], "config-system-dir=">,
   Flags<[NoXarchOption, HelpHidden]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"System directory for configuration files">;
 def config_user_dir_EQ : Joined<["--"], "config-user-dir=">,
   Flags<[NoXarchOption, HelpHidden]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"User directory for configuration files">;
 def coverage : Flag<["-", "--"], "coverage">, Group,
   Visibility<[ClangOption, CLOption]>;
diff --git a/flang/test/Driver/Inputs/config-1.cfg 
b/flang/test/Driver/Inputs/config-1.cfg
new file mode 100644
index 00..824e128a42b631
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-1.cfg
@@ -0,0 +1 @@
+-flto
diff --git a/flang/test/Driver/Inputs/config-2.cfg 
b/flang/test/Driver/Inputs/config-2.cfg
new file mode 100644
index 00..4e8d01b668e83c
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-2.cfg
@@ -0,0 +1 @@
+-fno-signed-zeros
diff --git a/flang/test/Driver/Inputs/config-2a.cfg 
b/flang/test/Driver/Inputs/config-2a.cfg
new file mode 100644
index 00..cd2916c98afe20
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-2a.cfg
@@ -0,0 +1 @@
+-fopenmp
diff --git a/flang/test/Driver/Inputs/config-6.cfg 
b/flang/test/Driver/Inputs/config-6.cfg
new file mode 100644
index 00..81e9830f63be4a
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-6.cfg
@@ -0,0 +1 @@
+-fstack-arrays
diff --git a/flang/test/Driver/Inputs/config/config-4.cfg 
b/flang/test/Driver/Inputs/config/config-4.cfg
new file mode 100644
index 00..d15a7108d4e216
--- /dev/null
+++ b/flang/test/Driver/Inputs/config/config-4.cfg
@@ -0,0 +1 @@
+-O3
diff --git a/flang/test/Driver/Inputs/config2/config-4.cfg 
b/flang/test/Driver/Inputs/config2/config-4.cfg
new file mode 100644
index 00..9d1c3e38c86805
--- /dev/null
+++ b/flang/test/Driver/Inputs/config2/config-4.cfg
@@ -0,0 +1 @@
+-ffp-contract=fast
diff --git a/flang/test/Driver/config-file.f90 
b/flang/test/Driver/config-file.f90
new file mode 100644
index 00..70316dd971f36b
--- /dev/null
+++ b/flang/test/Driver/config-file.f90
@@ -0,0 +1,63 @@
+!--- Config file (full path) in output of -###
+!
+! RUN: %flan

[llvm-branch-commits] [compiler-rt] [flang] [llvm] release/19.x: [Flang][Docs] Update information about AArch64 trampolines (#100391) (PR #100471)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ceseo (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100471
___
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] 86e7ada - [Flang][Driver] Enable config file options (#100343)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Kiran Chandramohan
Date: 2024-07-26T09:28:03+02:00
New Revision: 86e7adaa1b77089c7d8e39f13b8365a7fa92dde6

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

LOG: [Flang][Driver] Enable config file options (#100343)

Config files provide a facility to invoke the compiler with a predefined
set of options. The patch only enables these options in the flang
driver. Functionality was always there.

(cherry picked from commit 8a77961280536b680c404a49002a00b988ca45fc)

Added: 
flang/test/Driver/Inputs/config-1.cfg
flang/test/Driver/Inputs/config-2.cfg
flang/test/Driver/Inputs/config-2a.cfg
flang/test/Driver/Inputs/config-6.cfg
flang/test/Driver/Inputs/config/config-4.cfg
flang/test/Driver/Inputs/config2/config-4.cfg
flang/test/Driver/config-file.f90

Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 69269cf7537b0..359a698ea87dd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1165,19 +1165,19 @@ def client__name : JoinedOrSeparate<["-"], 
"client_name">;
 def combine : Flag<["-", "--"], "combine">, Flags<[NoXarchOption, 
Unsupported]>;
 def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
 def config : Joined<["--"], "config=">, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>, MetaVarName<"">,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, 
MetaVarName<"">,
   HelpText<"Specify configuration file">;
-def : Separate<["--"], "config">, Alias;
+def : Separate<["--"], "config">, Visibility<[ClangOption, CLOption, 
DXCOption, FlangOption]>, Alias;
 def no_default_config : Flag<["--"], "no-default-config">,
-  Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
+  Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption, 
FlangOption]>,
   HelpText<"Disable loading default configuration files">;
 def config_system_dir_EQ : Joined<["--"], "config-system-dir=">,
   Flags<[NoXarchOption, HelpHidden]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"System directory for configuration files">;
 def config_user_dir_EQ : Joined<["--"], "config-user-dir=">,
   Flags<[NoXarchOption, HelpHidden]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"User directory for configuration files">;
 def coverage : Flag<["-", "--"], "coverage">, Group,
   Visibility<[ClangOption, CLOption]>;

diff  --git a/flang/test/Driver/Inputs/config-1.cfg 
b/flang/test/Driver/Inputs/config-1.cfg
new file mode 100644
index 0..824e128a42b63
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-1.cfg
@@ -0,0 +1 @@
+-flto

diff  --git a/flang/test/Driver/Inputs/config-2.cfg 
b/flang/test/Driver/Inputs/config-2.cfg
new file mode 100644
index 0..4e8d01b668e83
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-2.cfg
@@ -0,0 +1 @@
+-fno-signed-zeros

diff  --git a/flang/test/Driver/Inputs/config-2a.cfg 
b/flang/test/Driver/Inputs/config-2a.cfg
new file mode 100644
index 0..cd2916c98afe2
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-2a.cfg
@@ -0,0 +1 @@
+-fopenmp

diff  --git a/flang/test/Driver/Inputs/config-6.cfg 
b/flang/test/Driver/Inputs/config-6.cfg
new file mode 100644
index 0..81e9830f63be4
--- /dev/null
+++ b/flang/test/Driver/Inputs/config-6.cfg
@@ -0,0 +1 @@
+-fstack-arrays

diff  --git a/flang/test/Driver/Inputs/config/config-4.cfg 
b/flang/test/Driver/Inputs/config/config-4.cfg
new file mode 100644
index 0..d15a7108d4e21
--- /dev/null
+++ b/flang/test/Driver/Inputs/config/config-4.cfg
@@ -0,0 +1 @@
+-O3

diff  --git a/flang/test/Driver/Inputs/config2/config-4.cfg 
b/flang/test/Driver/Inputs/config2/config-4.cfg
new file mode 100644
index 0..9d1c3e38c8680
--- /dev/null
+++ b/flang/test/Driver/Inputs/config2/config-4.cfg
@@ -0,0 +1 @@
+-ffp-contract=fast

diff  --git a/flang/test/Driver/config-file.f90 
b/flang/test/Driver/config-file.f90
new file mode 100644
index 0..70316dd971f36
--- /dev/null
+++ b/flang/test/Driver/config-file.f90
@@ -0,0 +1,63 @@
+!--- Config file (full path) in output of -###
+!
+! RUN: %flang --config-system-dir=%S/Inputs/config 
--config-user-dir=%S/Inputs/config2 -o /dev/null -v 2>&1 | FileCheck %s 
-check-prefix CHECK-DIRS
+! CHECK-DIRS: System configuration file directory: {{.*}}/Inputs/config
+! CHECK-DIRS: User configuration file directory: {{.*}}/Inputs/config2
+!
+!--- Config file (full path) in output of -###
+!
+! RUN: %flang --config %S/Inputs/config-1.cfg 

[llvm-branch-commits] [clang] [flang] release/19.x: [Flang][Driver] Enable config file options (#100343) (PR #100541)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100541
___
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: [AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers (#100143) (PR #100546)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 3e4abe985a584f3067448b5169c05509d3b571d2 Mon Sep 17 00:00:00 2001
From: Kerry McLaughlin 
Date: Wed, 24 Jul 2024 14:30:25 +0100
Subject: [PATCH] [AArch64][SME] Rewrite __arm_get_current_vg to preserve
 required registers (#100143)

The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.

(cherry picked from commit 6da6772bf0a33131aa8540c9d4f60d5db75c32b5)
---
 compiler-rt/lib/builtins/aarch64/sme-abi-vg.c | 28 
 compiler-rt/lib/builtins/aarch64/sme-abi.S| 44 +++
 2 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c 
b/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
index 062cf80fc6848..20061012e16c6 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
@@ -10,15 +10,6 @@ struct FEATURES {
 
 extern struct FEATURES __aarch64_cpu_features;
 
-struct SME_STATE {
-  long PSTATE;
-  long TPIDR2_EL0;
-};
-
-extern struct SME_STATE __arm_sme_state(void) __arm_streaming_compatible;
-
-extern bool __aarch64_has_sme_and_tpidr2_el0;
-
 #if __GNUC__ >= 9
 #pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
 #endif
@@ -28,22 +19,3 @@ __attribute__((constructor(90))) static void 
get_aarch64_cpu_features(void) {
 
   __init_cpu_features();
 }
-
-__attribute__((target("sve"))) long
-__arm_get_current_vg(void) __arm_streaming_compatible {
-  struct SME_STATE State = __arm_sme_state();
-  unsigned long long features =
-  __atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED);
-  bool HasSVE = features & (1ULL << FEAT_SVE);
-
-  if (!HasSVE && !__aarch64_has_sme_and_tpidr2_el0)
-return 0;
-
-  if (HasSVE || (State.PSTATE & 1)) {
-long vl;
-__asm__ __volatile__("cntd %0" : "=r"(vl));
-return vl;
-  }
-
-  return 0;
-}
diff --git a/compiler-rt/lib/builtins/aarch64/sme-abi.S 
b/compiler-rt/lib/builtins/aarch64/sme-abi.S
index 4c0ff66931db7..cd8153f60670f 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi.S
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi.S
@@ -12,11 +12,15 @@
 #if !defined(__APPLE__)
 #define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
 #define TPIDR2_SYMBOL_OFFSET 
:lo12:SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
+#define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)
+#define CPU_FEATS_SYMBOL_OFFSET :lo12:SYMBOL_NAME(__aarch64_cpu_features)
 #else
 // MachO requires @page/@pageoff directives because the global is defined
 // in a different file. Otherwise this file may fail to build.
 #define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@page
 #define TPIDR2_SYMBOL_OFFSET 
SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@pageoff
+#define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)@page
+#define CPU_FEATS_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_cpu_features)@pageoff
 #endif
 
 .arch armv9-a+sme
@@ -180,6 +184,46 @@ 
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
   ret
 END_COMPILERRT_OUTLINE_FUNCTION(__arm_za_disable)
 
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg)
+  .variant_pcs __arm_get_current_vg
+  BTI_C
+
+  stp x29, x30, [sp, #-16]!
+  .cfi_def_cfa_offset 16
+  mov x29, sp
+  .cfi_def_cfa w29, 16
+  .cfi_offset w30, -8
+  .cfi_offset w29, -16
+  adrpx17, CPU_FEATS_SYMBOL
+  ldr w17, [x17, CPU_FEATS_SYMBOL_OFFSET]
+  tbnzw17, #30, 0f
+  adrpx16, TPIDR2_SYMBOL
+  ldrbw16, [x16, TPIDR2_SYMBOL_OFFSET]
+  cbz w16, 1f
+0:
+  mov x18, x1
+  bl  __arm_sme_state
+  mov x1, x18
+  and x17, x17, #0x4000
+  bfxil   x17, x0, #0, #1
+  cbz x17, 1f
+  cntdx0
+  .cfi_def_cfa wsp, 16
+  ldp x29, x30, [sp], #16
+  .cfi_def_cfa_offset 0
+  .cfi_restore w30
+  .cfi_restore w29
+  ret
+1:
+  mov x0, xzr
+  .cfi_def_cfa wsp, 16
+  ldp x29, x30, [sp], #16
+  .cfi_def_cfa_offset 0
+  .cfi_restore w30
+  .cfi_restore w29
+  ret
+END_COMPILERRT_OUTLINE_FUNCTION(__arm_get_current_vg)
+
 NO_EXEC_STACK_DIRECTIVE
 
 // GNU property note for BTI and PAC

___
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] 3e4abe9 - [AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers (#100143)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2024-07-26T09:28:31+02:00
New Revision: 3e4abe985a584f3067448b5169c05509d3b571d2

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

LOG: [AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers 
(#100143)

The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.

(cherry picked from commit 6da6772bf0a33131aa8540c9d4f60d5db75c32b5)

Added: 


Modified: 
compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
compiler-rt/lib/builtins/aarch64/sme-abi.S

Removed: 




diff  --git a/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c 
b/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
index 062cf80fc68483..20061012e16c60 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi-vg.c
@@ -10,15 +10,6 @@ struct FEATURES {
 
 extern struct FEATURES __aarch64_cpu_features;
 
-struct SME_STATE {
-  long PSTATE;
-  long TPIDR2_EL0;
-};
-
-extern struct SME_STATE __arm_sme_state(void) __arm_streaming_compatible;
-
-extern bool __aarch64_has_sme_and_tpidr2_el0;
-
 #if __GNUC__ >= 9
 #pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
 #endif
@@ -28,22 +19,3 @@ __attribute__((constructor(90))) static void 
get_aarch64_cpu_features(void) {
 
   __init_cpu_features();
 }
-
-__attribute__((target("sve"))) long
-__arm_get_current_vg(void) __arm_streaming_compatible {
-  struct SME_STATE State = __arm_sme_state();
-  unsigned long long features =
-  __atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED);
-  bool HasSVE = features & (1ULL << FEAT_SVE);
-
-  if (!HasSVE && !__aarch64_has_sme_and_tpidr2_el0)
-return 0;
-
-  if (HasSVE || (State.PSTATE & 1)) {
-long vl;
-__asm__ __volatile__("cntd %0" : "=r"(vl));
-return vl;
-  }
-
-  return 0;
-}

diff  --git a/compiler-rt/lib/builtins/aarch64/sme-abi.S 
b/compiler-rt/lib/builtins/aarch64/sme-abi.S
index 4c0ff66931db7b..cd8153f60670fc 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-abi.S
+++ b/compiler-rt/lib/builtins/aarch64/sme-abi.S
@@ -12,11 +12,15 @@
 #if !defined(__APPLE__)
 #define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
 #define TPIDR2_SYMBOL_OFFSET 
:lo12:SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)
+#define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)
+#define CPU_FEATS_SYMBOL_OFFSET :lo12:SYMBOL_NAME(__aarch64_cpu_features)
 #else
 // MachO requires @page/@pageoff directives because the global is defined
 // in a 
diff erent file. Otherwise this file may fail to build.
 #define TPIDR2_SYMBOL SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@page
 #define TPIDR2_SYMBOL_OFFSET 
SYMBOL_NAME(__aarch64_has_sme_and_tpidr2_el0)@pageoff
+#define CPU_FEATS_SYMBOL SYMBOL_NAME(__aarch64_cpu_features)@page
+#define CPU_FEATS_SYMBOL_OFFSET SYMBOL_NAME(__aarch64_cpu_features)@pageoff
 #endif
 
 .arch armv9-a+sme
@@ -180,6 +184,46 @@ 
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
   ret
 END_COMPILERRT_OUTLINE_FUNCTION(__arm_za_disable)
 
+DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg)
+  .variant_pcs __arm_get_current_vg
+  BTI_C
+
+  stp x29, x30, [sp, #-16]!
+  .cfi_def_cfa_offset 16
+  mov x29, sp
+  .cfi_def_cfa w29, 16
+  .cfi_offset w30, -8
+  .cfi_offset w29, -16
+  adrpx17, CPU_FEATS_SYMBOL
+  ldr w17, [x17, CPU_FEATS_SYMBOL_OFFSET]
+  tbnzw17, #30, 0f
+  adrpx16, TPIDR2_SYMBOL
+  ldrbw16, [x16, TPIDR2_SYMBOL_OFFSET]
+  cbz w16, 1f
+0:
+  mov x18, x1
+  bl  __arm_sme_state
+  mov x1, x18
+  and x17, x17, #0x4000
+  bfxil   x17, x0, #0, #1
+  cbz x17, 1f
+  cntdx0
+  .cfi_def_cfa wsp, 16
+  ldp x29, x30, [sp], #16
+  .cfi_def_cfa_offset 0
+  .cfi_restore w30
+  .cfi_restore w29
+  ret
+1:
+  mov x0, xzr
+  .cfi_def_cfa wsp, 16
+  ldp x29, x30, [sp], #16
+  .cfi_def_cfa_offset 0
+  .cfi_restore w30
+  .cfi_restore w29
+  ret
+END_COMPILERRT_OUTLINE_FUNCTION(__arm_get_current_vg)
+
 NO_EXEC_STACK_DIRECTIVE
 
 // GNU property note for BTI and PAC



___
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: [AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers (#100143) (PR #100546)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100546
___
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] Remove `__is_layout_compatible` from revertible type traits list (#100572) (PR #100590)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From d767c52c26d7f9a143b23934917645efe0763364 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 25 Jul 2024 20:15:14 +0400
Subject: [PATCH] [clang] Remove `__is_layout_compatible` from revertible type
 traits list (#100572)

`__is_layout_compatible` was added in Clang 19 (#81506), and at that
time it wasn't entirely clear whether it should be a revertible type
trait or not. We decided to follow the example of other type traits.
Since then #95969 happened, and now we know that we don't want new
revertible type traits.

This patch removes `__is_layout_compatible` from revertible type traits
list, and leaves a comment what revertible type traits are, and that new
type traits should not be added there.

The intention is to also cherry-pick this to 19 branch.

(cherry picked from commit 3295d377f37a60597321f502d164b5d6b1948e28)
---
 clang/lib/Parse/ParseExpr.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 0a017ae79de753..e82b5652728317 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -763,6 +763,9 @@ class CastExpressionIdValidator final : public 
CorrectionCandidateCallback {
 bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
tok::TokenKind *Kind) {
   if (RevertibleTypeTraits.empty()) {
+// Revertible type trait is a feature for backwards compatibility with older
+// standard libraries that declare their own structs with the same name as
+// the builtins listed below. New builtins should NOT be added to this list.
 #define RTT_JOIN(X, Y) X##Y
 #define REVERTIBLE_TYPE_TRAIT(Name)
\
   RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
@@ -790,7 +793,6 @@ bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
 REVERTIBLE_TYPE_TRAIT(__is_fundamental);
 REVERTIBLE_TYPE_TRAIT(__is_integral);
 REVERTIBLE_TYPE_TRAIT(__is_interface_class);
-REVERTIBLE_TYPE_TRAIT(__is_layout_compatible);
 REVERTIBLE_TYPE_TRAIT(__is_literal);
 REVERTIBLE_TYPE_TRAIT(__is_lvalue_expr);
 REVERTIBLE_TYPE_TRAIT(__is_lvalue_reference);

___
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] d767c52 - [clang] Remove `__is_layout_compatible` from revertible type traits list (#100572)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Vlad Serebrennikov
Date: 2024-07-26T09:29:00+02:00
New Revision: d767c52c26d7f9a143b23934917645efe0763364

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

LOG: [clang] Remove `__is_layout_compatible` from revertible type traits list 
(#100572)

`__is_layout_compatible` was added in Clang 19 (#81506), and at that
time it wasn't entirely clear whether it should be a revertible type
trait or not. We decided to follow the example of other type traits.
Since then #95969 happened, and now we know that we don't want new
revertible type traits.

This patch removes `__is_layout_compatible` from revertible type traits
list, and leaves a comment what revertible type traits are, and that new
type traits should not be added there.

The intention is to also cherry-pick this to 19 branch.

(cherry picked from commit 3295d377f37a60597321f502d164b5d6b1948e28)

Added: 


Modified: 
clang/lib/Parse/ParseExpr.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 0a017ae79de753..e82b5652728317 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -763,6 +763,9 @@ class CastExpressionIdValidator final : public 
CorrectionCandidateCallback {
 bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
tok::TokenKind *Kind) {
   if (RevertibleTypeTraits.empty()) {
+// Revertible type trait is a feature for backwards compatibility with older
+// standard libraries that declare their own structs with the same name as
+// the builtins listed below. New builtins should NOT be added to this list.
 #define RTT_JOIN(X, Y) X##Y
 #define REVERTIBLE_TYPE_TRAIT(Name)
\
   RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
@@ -790,7 +793,6 @@ bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
 REVERTIBLE_TYPE_TRAIT(__is_fundamental);
 REVERTIBLE_TYPE_TRAIT(__is_integral);
 REVERTIBLE_TYPE_TRAIT(__is_interface_class);
-REVERTIBLE_TYPE_TRAIT(__is_layout_compatible);
 REVERTIBLE_TYPE_TRAIT(__is_literal);
 REVERTIBLE_TYPE_TRAIT(__is_lvalue_expr);
 REVERTIBLE_TYPE_TRAIT(__is_lvalue_reference);



___
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] Remove `__is_layout_compatible` from revertible type traits list (#100572) (PR #100590)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100590
___
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] release/19.x: [libc++] Add missing xlocale.h include on Apple and FreeBSD (#99689) (PR #100604)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From ec17a7a75911547b4567bb16fca72042abd105ff Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Thu, 25 Jul 2024 12:16:48 -0500
Subject: [PATCH] [libc++] Add missing xlocale.h include on Apple and FreeBSD
 (#99689)

The `` header uses `strtoll_l` and friends which are defined in
`` on these platforms. While this works via transitive
includes when modules are disabled, this doesn't work anymore if the
platforms are modularized properly.

(cherry picked from commit a55df237375e98cfc2520d5eb1a23b302ef02ba0)
---
 libcxx/include/locale | 4 
 1 file changed, 4 insertions(+)

diff --git a/libcxx/include/locale b/libcxx/include/locale
index dbec23a2c936d..573910a85bef5 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -232,6 +232,10 @@ template  class messages_byname;
 #include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
 #  endif
 
+#  if defined(__APPLE__) || defined(__FreeBSD__)
+#include 
+#  endif
+
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #  endif

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


[llvm-branch-commits] [libcxx] ec17a7a - [libc++] Add missing xlocale.h include on Apple and FreeBSD (#99689)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Louis Dionne
Date: 2024-07-26T09:29:22+02:00
New Revision: ec17a7a75911547b4567bb16fca72042abd105ff

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

LOG: [libc++] Add missing xlocale.h include on Apple and FreeBSD (#99689)

The `` header uses `strtoll_l` and friends which are defined in
`` on these platforms. While this works via transitive
includes when modules are disabled, this doesn't work anymore if the
platforms are modularized properly.

(cherry picked from commit a55df237375e98cfc2520d5eb1a23b302ef02ba0)

Added: 


Modified: 
libcxx/include/locale

Removed: 




diff  --git a/libcxx/include/locale b/libcxx/include/locale
index dbec23a2c936df..573910a85bef54 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -232,6 +232,10 @@ template  class messages_byname;
 #include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
 #  endif
 
+#  if defined(__APPLE__) || defined(__FreeBSD__)
+#include 
+#  endif
+
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #  endif



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


[llvm-branch-commits] [libcxx] release/19.x: [libc++] Add missing xlocale.h include on Apple and FreeBSD (#99689) (PR #100604)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100604
___
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: [PAC][clang] Enable `-fptrauth-indirect-gotos` as part of pauthtest ABI (#100480) (PR #100484)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@asl (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100484
___
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: Normalize ptrauth handling in sanitizer runtime (#100483) (PR #100634)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 511b8b094dd89f826cc95b52a68804e68d854a10 Mon Sep 17 00:00:00 2001
From: Anton Korobeynikov 
Date: Thu, 25 Jul 2024 11:57:46 -0700
Subject: [PATCH] Normalize ptrauth handling in sanitizer runtime (#100483)

1. Include `ptrauth.h` if `ptrauth_intrinsics` language feature is specified 
(per ptrauth spec, this is what enables `ptrauh.h` usage and functions like 
`ptrauth_strip`)
 2. For PAC-RET fallback implement two changes:
1. Switch to macro, so we can ignore key argument
2. Ensure the unsigned value is erased from LR, so the possibility of 
gadget reuse is reduced.

Fixes #100467

(cherry picked from commit cc4f98979b079b517edd8a71f56a8975f436e63d)
---
 .../lib/sanitizer_common/sanitizer_ptrauth.h  | 46 ++-
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
index 5200354694851e..b5215c0d49c06b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
@@ -9,31 +9,33 @@
 #ifndef SANITIZER_PTRAUTH_H
 #define SANITIZER_PTRAUTH_H
 
-#if __has_feature(ptrauth_calls)
-#include 
+#if __has_feature(ptrauth_intrinsics)
+#  include 
 #elif defined(__ARM_FEATURE_PAC_DEFAULT) && !defined(__APPLE__)
-inline unsigned long ptrauth_strip(void* __value, unsigned int __key) {
-  // On the stack the link register is protected with Pointer
-  // Authentication Code when compiled with -mbranch-protection.
-  // Let's stripping the PAC unconditionally because xpaclri is in
-  // the NOP space so will do nothing when it is not enabled or not available.
-  unsigned long ret;
-  asm volatile(
-  "mov x30, %1\n\t"
-  "hint #7\n\t"  // xpaclri
-  "mov %0, x30\n\t"
-  : "=r"(ret)
-  : "r"(__value)
-  : "x30");
-  return ret;
-}
-#define ptrauth_auth_data(__value, __old_key, __old_data) __value
-#define ptrauth_string_discriminator(__string) ((int)0)
+// On the stack the link register is protected with Pointer
+// Authentication Code when compiled with -mbranch-protection.
+// Let's stripping the PAC unconditionally because xpaclri is in
+// the NOP space so will do nothing when it is not enabled or not available.
+#  define ptrauth_strip(__value, __key) \
+({  \
+  unsigned long ret;\
+  asm volatile( \
+  "mov x30, %1\n\t" \
+  "hint #7\n\t" \
+  "mov %0, x30\n\t" \
+  "mov x30, xzr\n\t"\
+  : "=r"(ret)   \
+  : "r"(__value)\
+  : "x30"); \
+  ret;  \
+})
+#  define ptrauth_auth_data(__value, __old_key, __old_data) __value
+#  define ptrauth_string_discriminator(__string) ((int)0)
 #else
 // Copied from 
-#define ptrauth_strip(__value, __key) __value
-#define ptrauth_auth_data(__value, __old_key, __old_data) __value
-#define ptrauth_string_discriminator(__string) ((int)0)
+#  define ptrauth_strip(__value, __key) __value
+#  define ptrauth_auth_data(__value, __old_key, __old_data) __value
+#  define ptrauth_string_discriminator(__string) ((int)0)
 #endif
 
 #define STRIP_PAC_PC(pc) ((uptr)ptrauth_strip(pc, 0))

___
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] 511b8b0 - Normalize ptrauth handling in sanitizer runtime (#100483)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Anton Korobeynikov
Date: 2024-07-26T09:29:47+02:00
New Revision: 511b8b094dd89f826cc95b52a68804e68d854a10

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

LOG: Normalize ptrauth handling in sanitizer runtime (#100483)

1. Include `ptrauth.h` if `ptrauth_intrinsics` language feature is specified 
(per ptrauth spec, this is what enables `ptrauh.h` usage and functions like 
`ptrauth_strip`)
 2. For PAC-RET fallback implement two changes:
1. Switch to macro, so we can ignore key argument
2. Ensure the unsigned value is erased from LR, so the possibility of 
gadget reuse is reduced.

Fixes #100467

(cherry picked from commit cc4f98979b079b517edd8a71f56a8975f436e63d)

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
index 5200354694851..b5215c0d49c06 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
@@ -9,31 +9,33 @@
 #ifndef SANITIZER_PTRAUTH_H
 #define SANITIZER_PTRAUTH_H
 
-#if __has_feature(ptrauth_calls)
-#include 
+#if __has_feature(ptrauth_intrinsics)
+#  include 
 #elif defined(__ARM_FEATURE_PAC_DEFAULT) && !defined(__APPLE__)
-inline unsigned long ptrauth_strip(void* __value, unsigned int __key) {
-  // On the stack the link register is protected with Pointer
-  // Authentication Code when compiled with -mbranch-protection.
-  // Let's stripping the PAC unconditionally because xpaclri is in
-  // the NOP space so will do nothing when it is not enabled or not available.
-  unsigned long ret;
-  asm volatile(
-  "mov x30, %1\n\t"
-  "hint #7\n\t"  // xpaclri
-  "mov %0, x30\n\t"
-  : "=r"(ret)
-  : "r"(__value)
-  : "x30");
-  return ret;
-}
-#define ptrauth_auth_data(__value, __old_key, __old_data) __value
-#define ptrauth_string_discriminator(__string) ((int)0)
+// On the stack the link register is protected with Pointer
+// Authentication Code when compiled with -mbranch-protection.
+// Let's stripping the PAC unconditionally because xpaclri is in
+// the NOP space so will do nothing when it is not enabled or not available.
+#  define ptrauth_strip(__value, __key) \
+({  \
+  unsigned long ret;\
+  asm volatile( \
+  "mov x30, %1\n\t" \
+  "hint #7\n\t" \
+  "mov %0, x30\n\t" \
+  "mov x30, xzr\n\t"\
+  : "=r"(ret)   \
+  : "r"(__value)\
+  : "x30"); \
+  ret;  \
+})
+#  define ptrauth_auth_data(__value, __old_key, __old_data) __value
+#  define ptrauth_string_discriminator(__string) ((int)0)
 #else
 // Copied from 
-#define ptrauth_strip(__value, __key) __value
-#define ptrauth_auth_data(__value, __old_key, __old_data) __value
-#define ptrauth_string_discriminator(__string) ((int)0)
+#  define ptrauth_strip(__value, __key) __value
+#  define ptrauth_auth_data(__value, __old_key, __old_data) __value
+#  define ptrauth_string_discriminator(__string) ((int)0)
 #endif
 
 #define STRIP_PAC_PC(pc) ((uptr)ptrauth_strip(pc, 0))



___
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: Normalize ptrauth handling in sanitizer runtime (#100483) (PR #100634)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100634
___
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] [libc] release/19.x: [libc] Only add '-fno-builtin-*' on the entrypoints that use them (#100481) (PR #100496)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@jhuber6 (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100496
___
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] DebugInfo: Avoid some MMI::hasDebugInfo checks (PR #100333)

2024-07-26 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/100333

>From 9f6b09e1041ed88c95a7c51ac441769f4f82cfd6 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Wed, 24 Jul 2024 13:11:04 +0400
Subject: [PATCH] DebugInfo: Avoid some MMI::hasDebugInfo checks

I assume getSubprogram will do the correct thing in hasDebugInfo,
and this is redundant with the debug_compile_units distance check.
This is in preparation for removing the field.
---
 llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 9 +++--
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp   | 7 ---
 llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp| 4 ++--
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 6c70c47de8822..ed99eb3c459e5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -241,10 +241,7 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
  Ty->getTag() == dwarf::DW_TAG_unspecified_type;
 }
 
-static bool hasDebugInfo(const MachineModuleInfo *MMI,
- const MachineFunction *MF) {
-  if (!MMI->hasDebugInfo())
-return false;
+static bool hasDebugInfo(const MachineFunction *MF) {
   auto *SP = MF->getFunction().getSubprogram();
   if (!SP)
 return false;
@@ -258,7 +255,7 @@ static bool hasDebugInfo(const MachineModuleInfo *MMI,
 void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
   PrevInstBB = nullptr;
 
-  if (!Asm || !hasDebugInfo(MMI, MF)) {
+  if (!Asm || !hasDebugInfo(MF)) {
 skippedNonDebugFunction();
 return;
   }
@@ -415,7 +412,7 @@ void DebugHandlerBase::endInstruction() {
 }
 
 void DebugHandlerBase::endFunction(const MachineFunction *MF) {
-  if (Asm && hasDebugInfo(MMI, MF))
+  if (Asm && hasDebugInfo(MF))
 endFunctionImpl(MF);
   DbgValues.clear();
   DbgLabels.clear();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 5f1f315c5ab24..fbce7e92b7781 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1148,14 +1148,15 @@ 
sortGlobalExprs(SmallVectorImpl &GVEs) {
 void DwarfDebug::beginModule(Module *M) {
   DebugHandlerBase::beginModule(M);
 
-  if (!Asm || !MMI->hasDebugInfo())
+  if (!Asm)
 return;
 
   unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
M->debug_compile_units_end());
+  if (NumDebugCUs == 0)
+return;
+
   assert(NumDebugCUs > 0 && "Asm unexpectedly initialized");
-  assert(MMI->hasDebugInfo() &&
- "DebugInfoAvailabilty unexpectedly not initialized");
   SingleCU = NumDebugCUs == 1;
   DenseMap>
   GVMap;
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp 
b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 0b654abd2814c..b4eba07afe7c5 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -493,7 +493,7 @@ void NVPTXAsmPrinter::emitFunctionEntryLabel() {
   // Emit initial .loc debug directive for correct relocation symbol data.
   if (const DISubprogram *SP = MF->getFunction().getSubprogram()) {
 assert(SP->getUnit());
-if (!SP->getUnit()->isDebugDirectivesOnly() && MMI && MMI->hasDebugInfo())
+if (!SP->getUnit()->isDebugDirectivesOnly())
   emitInitialRawDwarfLocDirective(*MF);
   }
 }
@@ -912,7 +912,7 @@ void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
 if (HasFullDebugInfo)
   break;
   }
-  if (MMI && MMI->hasDebugInfo() && HasFullDebugInfo)
+  if (HasFullDebugInfo)
 O << ", debug";
 
   O << "\n";

___
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] CodeGen: Remove MachineModuleInfo reference from MachineFunction (PR #100357)

2024-07-26 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/100357

>From 88bb03cf2b3587d08ee5b73fbacb7b6c3bec1b40 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Sat, 20 Jul 2024 14:24:23 +0400
Subject: [PATCH 1/3] CodeGen: Remove MachineModuleInfo reference from
 MachineFunction

This avoids another unserializable field. Move the DbgInfoAvailable
field into the AsmPrinter, which is only really a cache/convenience
bit for checking a direct IR module metadata check.
---
 llvm/include/llvm/CodeGen/AsmPrinter.h |  6 ++
 llvm/include/llvm/CodeGen/MachineFunction.h| 18 --
 llvm/include/llvm/CodeGen/MachineModuleInfo.h  |  6 --
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 17 -
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp  |  4 ++--
 .../CodeGen/AsmPrinter/DebugHandlerBase.cpp|  4 ++--
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp |  2 +-
 llvm/lib/CodeGen/MachineFunction.cpp   | 12 ++--
 llvm/lib/CodeGen/MachineFunctionAnalysis.cpp   |  2 +-
 llvm/lib/CodeGen/MachineModuleInfo.cpp |  5 +
 llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp  |  4 +---
 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp  | 12 ++--
 llvm/tools/llvm-reduce/ReducerWorkItem.cpp |  2 +-
 .../CodeGen/AArch64SelectionDAGTest.cpp|  4 ++--
 llvm/unittests/CodeGen/InstrRefLDVTest.cpp |  2 +-
 llvm/unittests/CodeGen/MFCommon.inc|  3 ++-
 .../SelectionDAGAddressAnalysisTest.cpp|  2 +-
 .../CodeGen/SelectionDAGPatternMatchTest.cpp   |  2 +-
 .../AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp   |  3 ++-
 llvm/unittests/Target/AMDGPU/PALMetadata.cpp   |  2 +-
 .../Target/RISCV/RISCVInstrInfoTest.cpp|  2 +-
 21 files changed, 54 insertions(+), 60 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index f57be39076a783..36d1b479738704 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -225,6 +225,9 @@ class AsmPrinter : public MachineFunctionPass {
   /// split stack prologue.
   bool HasNoSplitStack = false;
 
+  /// True if debugging information is available in this module.
+  bool DbgInfoAvailable = false;
+
 protected:
   explicit AsmPrinter(TargetMachine &TM, std::unique_ptr Streamer);
 
@@ -430,6 +433,9 @@ class AsmPrinter : public MachineFunctionPass {
   /// Get the CFISection type for the module.
   CFISection getModuleCFISectionType() const { return ModuleCFISection; }
 
+  /// Returns true if valid debug info is present.
+  bool hasDebugInfo() const { return DbgInfoAvailable; }
+
   bool needsSEHMoves();
 
   /// Since emitting CFI unwind information is entangled with supporting the
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h 
b/llvm/include/llvm/CodeGen/MachineFunction.h
index 6e7292abeddbbd..142570b9ce551e 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -260,7 +260,6 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
   const LLVMTargetMachine &Target;
   const TargetSubtargetInfo *STI;
   MCContext &Ctx;
-  MachineModuleInfo &MMI;
 
   // RegInfo - Information about each register in use in the function.
   MachineRegisterInfo *RegInfo;
@@ -395,15 +394,15 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
 
   /// \}
 
-  /// Clear all the members of this MachineFunction, but the ones used
-  /// to initialize again the MachineFunction.
-  /// More specifically, this deallocates all the dynamically allocated
-  /// objects and get rid of all the XXXInfo data structure, but keep
-  /// unchanged the references to Fn, Target, MMI, and FunctionNumber.
+  /// Clear all the members of this MachineFunction, but the ones used to
+  /// initialize again the MachineFunction.  More specifically, this 
deallocates
+  /// all the dynamically allocated objects and get rid of all the XXXInfo data
+  /// structure, but keep unchanged the references to Fn, Target, and
+  /// FunctionNumber.
   void clear();
   /// Allocate and initialize the different members.
   /// In particular, the XXXInfo data structure.
-  /// \pre Fn, Target, MMI, and FunctionNumber are properly set.
+  /// \pre Fn, Target, and FunctionNumber are properly set.
   void init();
 
 public:
@@ -632,8 +631,8 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
   const static unsigned int DebugOperandMemNumber;
 
   MachineFunction(Function &F, const LLVMTargetMachine &Target,
-  const TargetSubtargetInfo &STI, unsigned FunctionNum,
-  MachineModuleInfo &MMI);
+  const TargetSubtargetInfo &STI, MCContext &Ctx,
+  unsigned FunctionNum);
   MachineFunction(const MachineFunction &) = delete;
   MachineFunction &operator=(const MachineFunction &) = delete;
   ~MachineFunction();
@@ -665,7 +664,6 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
 
   GISelChangeObserver *getObserver() const { re

[llvm-branch-commits] [clang] [flang] release/19.x: [Flang][Driver] Enable config file options (#100343) (PR #100541)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@kiranchandramohan (or anyone else). If you would like to add a note about this 
fix in the release notes (completely optional). Please reply to this comment 
with a one or two sentence description of the fix.  When you are done, please 
add the release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100541
___
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: [AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers (#100143) (PR #100546)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@kmclaughlin-arm (or anyone else). If you would like to add a note about this 
fix in the release notes (completely optional). Please reply to this comment 
with a one or two sentence description of the fix.  When you are done, please 
add the release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100546
___
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] release/19.x: [flang][OpenMP] Initialize privatised derived type variables (#100417) (PR #100587)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100587
___
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] 50b9db3 - [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (#100665)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Alan Zhao
Date: 2024-07-26T09:46:10+02:00
New Revision: 50b9db3a2df2a69c490b50fcd2021c882ae34b85

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

LOG: [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (#100665)

If the inline asm version of `ptrauth_strip` is used instead of the
builtin, the inline asm implementation currently returns an unsigned
long, causing an incompatible pointer conversion issue. The spec for
`ptrauth_sign` is that the result has the same type as the original
value, so we add a cast to the result of the inline asm.

(cherry picked from commit 25f9415713f9f57760a5322876906dc11385ef8e)

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
index b5215c0d49c06..265a9925a15a0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
@@ -18,7 +18,7 @@
 // the NOP space so will do nothing when it is not enabled or not available.
 #  define ptrauth_strip(__value, __key) \
 ({  \
-  unsigned long ret;\
+  __typeof(__value) ret;\
   asm volatile( \
   "mov x30, %1\n\t" \
   "hint #7\n\t" \



___
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][ubsan][nfc-ish] Fix a type conversion bug (#100665) (PR #100713)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100713
___
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][ubsan][nfc-ish] Fix a type conversion bug (#100665) (PR #100713)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 50b9db3a2df2a69c490b50fcd2021c882ae34b85 Mon Sep 17 00:00:00 2001
From: Alan Zhao 
Date: Thu, 25 Jul 2024 17:38:44 -0700
Subject: [PATCH] [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug
 (#100665)

If the inline asm version of `ptrauth_strip` is used instead of the
builtin, the inline asm implementation currently returns an unsigned
long, causing an incompatible pointer conversion issue. The spec for
`ptrauth_sign` is that the result has the same type as the original
value, so we add a cast to the result of the inline asm.

(cherry picked from commit 25f9415713f9f57760a5322876906dc11385ef8e)
---
 compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
index b5215c0d49c06..265a9925a15a0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
@@ -18,7 +18,7 @@
 // the NOP space so will do nothing when it is not enabled or not available.
 #  define ptrauth_strip(__value, __key) \
 ({  \
-  unsigned long ret;\
+  __typeof(__value) ret;\
   asm volatile( \
   "mov x30, %1\n\t" \
   "hint #7\n\t" \

___
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] release/19.x: [flang][OpenMP] Initialize privatised derived type variables (#100417) (PR #100587)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@tblah (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100587
___
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][ubsan][nfc-ish] Fix a type conversion bug (#100665) (PR #100713)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@asl (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100713
___
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: [BasicAA] Fix handling of indirect assumption based results (#100130) (PR #100553)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

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

>From 61b0a2fdf2c1d7432f54cfd0cd2e75556bdc0d33 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Thu, 25 Jul 2024 12:25:19 +0200
Subject: [PATCH] [BasicAA] Fix handling of indirect assumption based results
 (#100130)

If a result is potentially based on a not yet proven assumption,
BasicAA will remember it inside AssumptionBasedResults and remove
the cache entry if an assumption higher up is later disproved.
However, we currently miss the case where another cache entry ends
up depending on such an AssumptionBased result.

Fix this by introducing an additional AssumptionBased state for
cache entries. If such a result is used, we'll still increment
AAQI.NumAssumptionUses, which means that the using entry will
also become AssumptionBased and be cleared if the assumption is
disproved.

At the end of the root query, convert remaining AssumptionBased
results into definitive results.

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

(cherry picked from commit 91073380ac5a0dceebdd09f360a1dc194d7ee93f)
---
 llvm/include/llvm/Analysis/AliasAnalysis.h|  17 ++-
 llvm/lib/Analysis/BasicAliasAnalysis.cpp  |  28 -
 .../Transforms/SLPVectorizer/X86/pr98978.ll   | 106 ++
 3 files changed, 144 insertions(+), 7 deletions(-)
 create mode 100644 llvm/test/Transforms/SLPVectorizer/X86/pr98978.ll

diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 812b5a9f72a3a..4140387a1f341 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -244,12 +244,23 @@ class AAQueryInfo {
 public:
   using LocPair = std::pair;
   struct CacheEntry {
+/// Cache entry is neither an assumption nor does it use a (non-definitive)
+/// assumption.
+static constexpr int Definitive = -2;
+/// Cache entry is not an assumption itself, but may be using an assumption
+/// from higher up the stack.
+static constexpr int AssumptionBased = -1;
+
 AliasResult Result;
-/// Number of times a NoAlias assumption has been used.
-/// 0 for assumptions that have not been used, -1 for definitive results.
+/// Number of times a NoAlias assumption has been used, 0 for assumptions
+/// that have not been used. Can also take one of the Definitive or
+/// AssumptionBased values documented above.
 int NumAssumptionUses;
+
 /// Whether this is a definitive (non-assumption) result.
-bool isDefinitive() const { return NumAssumptionUses < 0; }
+bool isDefinitive() const { return NumAssumptionUses == Definitive; }
+/// Whether this is an assumption that has not been proven yet.
+bool isAssumption() const { return NumAssumptionUses >= 0; }
   };
 
   // Alias analysis result aggregration using which this query is performed.
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 161a3034e4829..e474899fb548e 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1692,9 +1692,12 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   if (!Pair.second) {
 auto &Entry = Pair.first->second;
 if (!Entry.isDefinitive()) {
-  // Remember that we used an assumption.
-  ++Entry.NumAssumptionUses;
+  // Remember that we used an assumption. This may either be a direct use
+  // of an assumption, or a use of an entry that may itself be based on an
+  // assumption.
   ++AAQI.NumAssumptionUses;
+  if (Entry.isAssumption())
+++Entry.NumAssumptionUses;
 }
 // Cache contains sorted {V1,V2} pairs but we should return original order.
 auto Result = Entry.Result;
@@ -1722,7 +1725,6 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   Entry.Result = Result;
   // Cache contains sorted {V1,V2} pairs.
   Entry.Result.swap(Swapped);
-  Entry.NumAssumptionUses = -1;
 
   // If the assumption has been disproven, remove any results that may have
   // been based on this assumption. Do this after the Entry updates above to
@@ -1734,8 +1736,26 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   // The result may still be based on assumptions higher up in the chain.
   // Remember it, so it can be purged from the cache later.
   if (OrigNumAssumptionUses != AAQI.NumAssumptionUses &&
-  Result != AliasResult::MayAlias)
+  Result != AliasResult::MayAlias) {
 AAQI.AssumptionBasedResults.push_back(Locs);
+Entry.NumAssumptionUses = AAQueryInfo::CacheEntry::AssumptionBased;
+  } else {
+Entry.NumAssumptionUses = AAQueryInfo::CacheEntry::Definitive;
+  }
+
+  // Depth is incremented before this function is called, so Depth==1 indicates
+  // a root query.
+  if (AAQI.Depth == 1) {
+// Any remaining assumption based results must be based on proven
+// assumptio

[llvm-branch-commits] [llvm] release/19.x: [BasicAA] Fix handling of indirect assumption based results (#100130) (PR #100553)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/100553
___
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] 61b0a2f - [BasicAA] Fix handling of indirect assumption based results (#100130)

2024-07-26 Thread Tobias Hieta via llvm-branch-commits

Author: Nikita Popov
Date: 2024-07-26T09:46:57+02:00
New Revision: 61b0a2fdf2c1d7432f54cfd0cd2e75556bdc0d33

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

LOG: [BasicAA] Fix handling of indirect assumption based results (#100130)

If a result is potentially based on a not yet proven assumption,
BasicAA will remember it inside AssumptionBasedResults and remove
the cache entry if an assumption higher up is later disproved.
However, we currently miss the case where another cache entry ends
up depending on such an AssumptionBased result.

Fix this by introducing an additional AssumptionBased state for
cache entries. If such a result is used, we'll still increment
AAQI.NumAssumptionUses, which means that the using entry will
also become AssumptionBased and be cleared if the assumption is
disproved.

At the end of the root query, convert remaining AssumptionBased
results into definitive results.

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

(cherry picked from commit 91073380ac5a0dceebdd09f360a1dc194d7ee93f)

Added: 
llvm/test/Transforms/SLPVectorizer/X86/pr98978.ll

Modified: 
llvm/include/llvm/Analysis/AliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 812b5a9f72a3a..4140387a1f341 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -244,12 +244,23 @@ class AAQueryInfo {
 public:
   using LocPair = std::pair;
   struct CacheEntry {
+/// Cache entry is neither an assumption nor does it use a (non-definitive)
+/// assumption.
+static constexpr int Definitive = -2;
+/// Cache entry is not an assumption itself, but may be using an assumption
+/// from higher up the stack.
+static constexpr int AssumptionBased = -1;
+
 AliasResult Result;
-/// Number of times a NoAlias assumption has been used.
-/// 0 for assumptions that have not been used, -1 for definitive results.
+/// Number of times a NoAlias assumption has been used, 0 for assumptions
+/// that have not been used. Can also take one of the Definitive or
+/// AssumptionBased values documented above.
 int NumAssumptionUses;
+
 /// Whether this is a definitive (non-assumption) result.
-bool isDefinitive() const { return NumAssumptionUses < 0; }
+bool isDefinitive() const { return NumAssumptionUses == Definitive; }
+/// Whether this is an assumption that has not been proven yet.
+bool isAssumption() const { return NumAssumptionUses >= 0; }
   };
 
   // Alias analysis result aggregration using which this query is performed.

diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 161a3034e4829..e474899fb548e 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1692,9 +1692,12 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   if (!Pair.second) {
 auto &Entry = Pair.first->second;
 if (!Entry.isDefinitive()) {
-  // Remember that we used an assumption.
-  ++Entry.NumAssumptionUses;
+  // Remember that we used an assumption. This may either be a direct use
+  // of an assumption, or a use of an entry that may itself be based on an
+  // assumption.
   ++AAQI.NumAssumptionUses;
+  if (Entry.isAssumption())
+++Entry.NumAssumptionUses;
 }
 // Cache contains sorted {V1,V2} pairs but we should return original order.
 auto Result = Entry.Result;
@@ -1722,7 +1725,6 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   Entry.Result = Result;
   // Cache contains sorted {V1,V2} pairs.
   Entry.Result.swap(Swapped);
-  Entry.NumAssumptionUses = -1;
 
   // If the assumption has been disproven, remove any results that may have
   // been based on this assumption. Do this after the Entry updates above to
@@ -1734,8 +1736,26 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   // The result may still be based on assumptions higher up in the chain.
   // Remember it, so it can be purged from the cache later.
   if (OrigNumAssumptionUses != AAQI.NumAssumptionUses &&
-  Result != AliasResult::MayAlias)
+  Result != AliasResult::MayAlias) {
 AAQI.AssumptionBasedResults.push_back(Locs);
+Entry.NumAssumptionUses = AAQueryInfo::CacheEntry::AssumptionBased;
+  } else {
+Entry.NumAssumptionUses = AAQueryInfo::CacheEntry::Definitive;
+  }
+
+  // Depth is incremented before this function is called, so Depth==1 indicates
+  // a root query.
+  if (AAQI.Depth == 1) {
+// Any remaining assumption based results must be based

[llvm-branch-commits] [llvm] release/19.x: [BasicAA] Fix handling of indirect assumption based results (#100130) (PR #100553)

2024-07-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@nikic (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/100553
___
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: [PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr (#100552) (PR #100716)

2024-07-26 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/100716
___
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: [PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr (#100552) (PR #100716)

2024-07-26 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/100716
___
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: [PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr (#100552) (PR #100716)

2024-07-26 Thread via llvm-branch-commits

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

Backport 56fd2472d887392855ad85c53df5782a2c3f8ddb

Requested by: @asl

>From 58f851dfb66dcd0af89d0e2da483a358c3643114 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Thu, 25 Jul 2024 22:21:03 +0300
Subject: [PATCH] [PAC] Sign LR with B key for non-leaf functions with
 ptrauth-returns attr (#100552)

For pauthtest ABI, there is a bunch of ptrauth-* options, including
ptrauth-returns. Use "ptrauth-returns" function attribute to indicate
need for LR signing with B key for non-leaf function to avoid using
"sign-return-address" and "sign-return-address-key" which were
originally designed for pac-ret.

Co-authored-by: Ahmed Bougacha 
Co-authored-by: Anatoly Trosinenko 
(cherry picked from commit 56fd2472d887392855ad85c53df5782a2c3f8ddb)
---
 llvm/lib/Target/AArch64/AArch64InstrInfo.cpp  |   7 +-
 .../AArch64/AArch64MachineFunctionInfo.cpp|   4 +
 .../lib/Target/AArch64/AArch64PointerAuth.cpp |   3 +-
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |   9 +-
 llvm/lib/Target/AArch64/AArch64Subtarget.h|   3 +-
 llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll |  98 
 llvm/test/CodeGen/AArch64/ptrauth-ret.ll  | 225 ++
 7 files changed, 344 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll
 create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-ret.ll

diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 1b301a4a05fc5..377bcd5868fb6 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -8339,7 +8339,8 @@ AArch64InstrInfo::getOutliningCandidateInfo(
 NumBytesToCreateFrame += 8;
 
 // PAuth is enabled - set extra tail call cost, if any.
-auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod();
+auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
+*RepeatedSequenceLocs[0].getMF());
 NumBytesToCheckLRInTCEpilogue =
 AArch64PAuth::getCheckerSizeInBytes(LRCheckMethod);
 // Checking the authenticated LR value may significantly impact
@@ -8700,6 +8701,10 @@ void AArch64InstrInfo::mergeOutliningCandidateAttributes(
   // behaviour of one of them
   const auto &CFn = Candidates.front().getMF()->getFunction();
 
+  if (CFn.hasFnAttribute("ptrauth-returns"))
+F.addFnAttr(CFn.getFnAttribute("ptrauth-returns"));
+  if (CFn.hasFnAttribute("ptrauth-auth-traps"))
+F.addFnAttr(CFn.getFnAttribute("ptrauth-auth-traps"));
   // Since all candidates belong to the same module, just copy the
   // function-level attributes of an arbitrary function.
   if (CFn.hasFnAttribute("sign-return-address"))
diff --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
index 201e8047b3686..e96c5a953ff2b 100644
--- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
@@ -38,6 +38,8 @@ void AArch64FunctionInfo::initializeBaseYamlFields(
 }
 
 static std::pair GetSignReturnAddress(const Function &F) {
+  if (F.hasFnAttribute("ptrauth-returns"))
+return {true, false}; // non-leaf
   // The function should be signed in the following situations:
   // - sign-return-address=all
   // - sign-return-address=non-leaf and the functions spills the LR
@@ -56,6 +58,8 @@ static std::pair GetSignReturnAddress(const 
Function &F) {
 }
 
 static bool ShouldSignWithBKey(const Function &F, const AArch64Subtarget &STI) 
{
+  if (F.hasFnAttribute("ptrauth-returns"))
+return true;
   if (!F.hasFnAttribute("sign-return-address-key")) {
 if (STI.getTargetTriple().isOSWindows())
   return true;
diff --git a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp 
b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
index 465e689d4a7a5..92ab4b5c3d251 100644
--- a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
+++ b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
@@ -341,7 +341,8 @@ bool AArch64PointerAuth::checkAuthenticatedLR(
   AArch64PACKey::ID KeyId =
   MFnI->shouldSignWithBKey() ? AArch64PACKey::IB : AArch64PACKey::IA;
 
-  AuthCheckMethod Method = Subtarget->getAuthenticatedLRCheckMethod();
+  AuthCheckMethod Method =
+  Subtarget->getAuthenticatedLRCheckMethod(*TI->getMF());
 
   if (Method == AuthCheckMethod::None)
 return false;
diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp 
b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
index 32a355fe38f1c..642006e706c13 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -565,8 +565,13 @@ bool AArch64Subtarget::useAA() const { return UseAA; }
 // exception on its own. Later, if the callee spills the signed LR value and
 // neither FEAT_PAuth2 nor FEAT_EPAC are implemented, the valid PAC replaces
 // the higher bits of LR thus hiding the authentication failure.
-AArch64PAuth::Au

[llvm-branch-commits] [llvm] release/19.x: [PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr (#100552) (PR #100716)

2024-07-26 Thread Anton Korobeynikov via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/100716
___
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] DebugInfo: Avoid some MMI::hasDebugInfo checks (PR #100333)

2024-07-26 Thread Sergei Barannikov via llvm-branch-commits

https://github.com/s-barannikov approved this pull request.


https://github.com/llvm/llvm-project/pull/100333
___
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] DebugInfo: Avoid some MMI::hasDebugInfo checks (PR #100333)

2024-07-26 Thread Sergei Barannikov via llvm-branch-commits


@@ -1148,14 +1148,15 @@ 
sortGlobalExprs(SmallVectorImpl &GVEs) {
 void DwarfDebug::beginModule(Module *M) {
   DebugHandlerBase::beginModule(M);
 
-  if (!Asm || !MMI->hasDebugInfo())
+  if (!Asm)
 return;
 
   unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
M->debug_compile_units_end());
+  if (NumDebugCUs == 0)
+return;
+
   assert(NumDebugCUs > 0 && "Asm unexpectedly initialized");

s-barannikov wrote:

Redundant with the above check.

https://github.com/llvm/llvm-project/pull/100333
___
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] DebugInfo: Avoid some MMI::hasDebugInfo checks (PR #100333)

2024-07-26 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Jul 26, 4:56 AM EDT**: @arsenm started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/100333).


https://github.com/llvm/llvm-project/pull/100333
___
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] CodeGen: Remove MachineModuleInfo reference from MachineFunction (PR #100357)

2024-07-26 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Jul 26, 4:56 AM EDT**: @arsenm started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/100357).


https://github.com/llvm/llvm-project/pull/100357
___
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] Remove `__is_layout_compatible` from revertible type traits list (#100572) (PR #100590)

2024-07-26 Thread Vlad Serebrennikov via llvm-branch-commits

Endilll wrote:

Release note for `__is_layout_compatible` is already present. This change in 
particular is not worth a release note.

https://github.com/llvm/llvm-project/pull/100590
___
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] Fix lifetimebound for field access (#100197) (PR #100725)

2024-07-26 Thread Utkarsh Saxena via llvm-branch-commits

https://github.com/usx95 created 
https://github.com/llvm/llvm-project/pull/100725

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

There is no way to switch this off without  `-Wno-dangling`.

>From f9e213895548bfaba21399cb337688e8f3839a3a Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 24 Jul 2024 15:58:52 +0200
Subject: [PATCH] Fix lifetimebound for field access (#100197)

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

There is no way to switch this off without  `-Wno-dangling`.
---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/CheckExprLifetime.cpp  |  9 
 clang/test/SemaCXX/attr-lifetimebound.cpp | 26 +++
 3 files changed, 38 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 549da6812740f..71d615553c613 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -767,6 +767,9 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses undefined behavior in constant expressions more 
consistently. This includes invalid shifts, and signed overflow in arithmetic.
 
+- Clang now diagnoses dangling references to fields of temporary objects. 
Fixes #GH81589.
+
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index 5c8ef564f30aa..112cf3d081822 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "CheckExprLifetime.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Sema/Initialization.h"
@@ -548,6 +549,14 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
EnableLifetimeWarnings);
   }
 
+  if (auto *M = dyn_cast(Init)) {
+// Lifetime of a non-reference type field is same as base object.
+if (auto *F = dyn_cast(M->getMemberDecl());
+F && !F->getType()->isReferenceType())
+  visitLocalsRetainedByInitializer(Path, M->getBase(), Visit, true,
+   EnableLifetimeWarnings);
+  }
+
   if (isa(Init)) {
 if (EnableLifetimeWarnings)
   handleGslAnnotatedTypes(Path, Init, Visit);
diff --git a/clang/test/SemaCXX/attr-lifetimebound.cpp 
b/clang/test/SemaCXX/attr-lifetimebound.cpp
index 70bc545c07bd9..7db0a4d64d259 100644
--- a/clang/test/SemaCXX/attr-lifetimebound.cpp
+++ b/clang/test/SemaCXX/attr-lifetimebound.cpp
@@ -47,6 +47,31 @@ namespace usage_ok {
 q = A(); // expected-warning {{object backing the pointer q will be 
destroyed at the end of the full-expression}}
 r = A(1); // expected-warning {{object backing the pointer r will be 
destroyed at the end of the full-expression}}
   }
+
+  struct FieldCheck {
+struct Set {
+  int a;
+};
+struct Pair {
+  const int& a;
+  int b;
+  Set c;
+  int * d;
+};
+Pair p;  
+FieldCheck(const int& a): p(a){}
+Pair& getR() [[clang::lifetimebound]] { return p; }
+Pair* getP() [[clang::lifetimebound]] { return &p; }
+Pair* getNoLB() { return &p; }
+  };
+  void test_field_access() {
+int x = 0;
+const int& a = FieldCheck{x}.getR().a;
+const int& b = FieldCheck{x}.getP()->b;   // expected-warning {{temporary 
bound to local reference 'b' will be destroyed at the end of the 
full-expression}}
+const int& c = FieldCheck{x}.getP()->c.a; // expected-warning {{temporary 
bound to local reference 'c' will be destroyed at the end of the 
full-expression}}
+const int& d = FieldCheck{x}.getNoLB()->c.a;
+const int* e = FieldCheck{x}.getR().d;
+  }
 }
 
 # 1 "" 1 3
@@ -239,3 +264,4 @@ namespace move_forward_et_al_examples {
   S X;
   S *AddressOfOk = std::addressof(X);
 } // namespace move_forward_et_al_examples
+

___
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] Fix lifetimebound for field access (#100197) (PR #100725)

2024-07-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Utkarsh Saxena (usx95)


Changes

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

There is no way to switch this off without  `-Wno-dangling`.

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/lib/Sema/CheckExprLifetime.cpp (+9) 
- (modified) clang/test/SemaCXX/attr-lifetimebound.cpp (+26) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 549da6812740f..71d615553c613 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -767,6 +767,9 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses undefined behavior in constant expressions more 
consistently. This includes invalid shifts, and signed overflow in arithmetic.
 
+- Clang now diagnoses dangling references to fields of temporary objects. 
Fixes #GH81589.
+
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index 5c8ef564f30aa..112cf3d081822 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "CheckExprLifetime.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Sema/Initialization.h"
@@ -548,6 +549,14 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
EnableLifetimeWarnings);
   }
 
+  if (auto *M = dyn_cast(Init)) {
+// Lifetime of a non-reference type field is same as base object.
+if (auto *F = dyn_cast(M->getMemberDecl());
+F && !F->getType()->isReferenceType())
+  visitLocalsRetainedByInitializer(Path, M->getBase(), Visit, true,
+   EnableLifetimeWarnings);
+  }
+
   if (isa(Init)) {
 if (EnableLifetimeWarnings)
   handleGslAnnotatedTypes(Path, Init, Visit);
diff --git a/clang/test/SemaCXX/attr-lifetimebound.cpp 
b/clang/test/SemaCXX/attr-lifetimebound.cpp
index 70bc545c07bd9..7db0a4d64d259 100644
--- a/clang/test/SemaCXX/attr-lifetimebound.cpp
+++ b/clang/test/SemaCXX/attr-lifetimebound.cpp
@@ -47,6 +47,31 @@ namespace usage_ok {
 q = A(); // expected-warning {{object backing the pointer q will be 
destroyed at the end of the full-expression}}
 r = A(1); // expected-warning {{object backing the pointer r will be 
destroyed at the end of the full-expression}}
   }
+
+  struct FieldCheck {
+struct Set {
+  int a;
+};
+struct Pair {
+  const int& a;
+  int b;
+  Set c;
+  int * d;
+};
+Pair p;  
+FieldCheck(const int& a): p(a){}
+Pair& getR() [[clang::lifetimebound]] { return p; }
+Pair* getP() [[clang::lifetimebound]] { return &p; }
+Pair* getNoLB() { return &p; }
+  };
+  void test_field_access() {
+int x = 0;
+const int& a = FieldCheck{x}.getR().a;
+const int& b = FieldCheck{x}.getP()->b;   // expected-warning {{temporary 
bound to local reference 'b' will be destroyed at the end of the 
full-expression}}
+const int& c = FieldCheck{x}.getP()->c.a; // expected-warning {{temporary 
bound to local reference 'c' will be destroyed at the end of the 
full-expression}}
+const int& d = FieldCheck{x}.getNoLB()->c.a;
+const int* e = FieldCheck{x}.getR().d;
+  }
 }
 
 # 1 "" 1 3
@@ -239,3 +264,4 @@ namespace move_forward_et_al_examples {
   S X;
   S *AddressOfOk = std::addressof(X);
 } // namespace move_forward_et_al_examples
+

``




https://github.com/llvm/llvm-project/pull/100725
___
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] Fix lifetimebound for field access (#100197) (PR #100725)

2024-07-26 Thread Utkarsh Saxena via llvm-branch-commits

https://github.com/usx95 milestoned 
https://github.com/llvm/llvm-project/pull/100725
___
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] [mlir] [MLIR][OpenMP] Create `LoopRelatedClause` (PR #99506)

2024-07-26 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/99506

>From 96ddba7f30440a83602e8f89d1193813a03dceee Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 16 Jul 2024 15:48:00 +0100
Subject: [PATCH 1/2] [MLIR][OpenMP] Create `LoopRelatedClause`

This patch introduces a new OpenMP clause definition not defined by the spec.

Its main purpose is to define the `loop_inclusive` (previously "inclusive",
renamed according to the parent of this PR in the stack) argument of
`omp.loop_nest` in such a way that a followup implementation of a tablegen
backend to automatically generate clause and operation operand structures
directly from `OpenMP_Op` and `OpenMP_Clause` definitions can properly generate
the `LoopNestOperands` structure.
---
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 19 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  6 ++
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  4 ++--
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  |  2 +-
 mlir/test/Dialect/OpenMP/ops.mlir |  2 +-
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td
index b6be8be63b328..24bd9b69e6cc1 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td
@@ -564,6 +564,25 @@ class OpenMP_LinearClauseSkip<
 
 def OpenMP_LinearClause : OpenMP_LinearClauseSkip<>;
 
+//===--===//
+// Not in the spec: Clause-like structure to hold loop related information.
+//===--===//
+
+class OpenMP_LoopRelatedClauseSkip<
+bit traits = false, bit arguments = false, bit assemblyFormat = false,
+bit description = false, bit extraClassDeclaration = false
+  > : OpenMP_Clause {
+  let arguments = (ins
+UnitAttr:$loop_inclusive
+  );
+
+  // Description and formatting integrated in the `omp.loop_nest` operation,
+  // which is the only one currently accepting this clause.
+}
+
+def OpenMP_LoopRelatedClause : OpenMP_LoopRelatedClauseSkip<>;
+
 
//===--===//
 // V5.2: [5.8.3] `map` clause
 
//===--===//
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index a42e32587e570..978b359e13280 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -297,7 +297,7 @@ def SingleOp : OpenMP_Op<"single", traits = [
 def LoopNestOp : OpenMP_Op<"loop_nest", traits = [
 RecursiveMemoryEffects, SameVariadicOperandSize
   ], clauses = [
-OpenMP_CollapseClause
+OpenMP_CollapseClause, OpenMP_LoopRelatedClause
   ], singleRegion = true> {
   let summary = "rectangular loop nest";
   let description = [{
@@ -306,7 +306,7 @@ def LoopNestOp : OpenMP_Op<"loop_nest", traits = [
 lower and upper bounds, as well as a step variable, must be defined.
 
 The lower and upper bounds specify a half-open range: the range includes 
the
-lower bound but does not include the upper bound. If the `inclusive`
+lower bound but does not include the upper bound. If the `loop_inclusive`
 attribute is specified then the upper bound is also included.
 
 The body region can contain any number of blocks. The region is terminated
@@ -335,8 +335,6 @@ def LoopNestOp : OpenMP_Op<"loop_nest", traits = [
 non-perfectly nested loops.
   }];
 
-  let arguments = !con(clausesArgs, (ins UnitAttr:$inclusive));
-
   let builders = [
 OpBuilder<(ins CArg<"const LoopNestOperands &">:$clauses)>
   ];
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp 
b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 18a1c2a1bd587..bcee137604eb7 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -2047,7 +2047,7 @@ ParseResult LoopNestOp::parse(OpAsmParser &parser, 
OperationState &result) {
 
   // Parse "inclusive" flag.
   if (succeeded(parser.parseOptionalKeyword("inclusive")))
-result.addAttribute("inclusive",
+result.addAttribute("loop_inclusive",
 UnitAttr::get(parser.getBuilder().getContext()));
 
   // Parse step values.
@@ -2076,7 +2076,7 @@ void LoopNestOp::print(OpAsmPrinter &p) {
   auto args = region.getArguments();
   p << " (" << args << ") : " << args[0].getType() << " = ("
 << getCollapseLowerBounds() << ") to (" << getCollapseUpperBounds() << ") 
";
-  if (getInclusive())
+  if (getLoopInclusive())
 p << "inclusive ";
   p << "step (" << getCollapseSteps() << ") ";
   p.printRegion(region, /*printEntryBlockArgs=*/false);
diff --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialec

[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Create `LoopRelatedClause` (PR #99506)

2024-07-26 Thread Sergio Afonso via llvm-branch-commits

skatrak wrote:

@Meinersbur I have updated this PR according to our discussion in #99505. Now 
the loop bounds and steps are now part of the `LoopRelatedClause` and named 
`loopLowerBounds`, `loopUpperBounds` and `loopSteps`.

https://github.com/llvm/llvm-project/pull/99506
___
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][OpenMP] Add missing clauses to OpenMP op definitions (PR #99507)

2024-07-26 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/99507

>From c80e6f18eabfc05804c1ac5320bf12af756f5b79 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 16 Jul 2024 17:18:13 +0100
Subject: [PATCH] [MLIR][OpenMP] Add missing clauses to OpenMP op definitions

This patch adds the missing `OpenMP_Clause` definitions to all existing
`OpenMP_Op`s and updates their operand structure based builders to initialize
the new arguments.

The result of this change is that operation operand structures are now based in
the same list of clauses as their tablegen counterparts. This means that all of
the information needed is now in place to automatically generate OpenMP operand
structures from tablegen defitions.

Since this change doesn't involve the introduction of actual support for these
clauses, new arguments are not initialized from values stored in the
corresponding operand structure fields but rather set to empty or null. Those
should be updated when support for these clauses on the corresponding operation
is added.
---
 .../Dialect/OpenMP/OpenMPClauseOperands.h |  7 +--
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 52 +
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  | 49 ++--
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 57 ---
 mlir/test/Dialect/OpenMP/invalid.mlir | 40 ++---
 mlir/test/Dialect/OpenMP/ops.mlir | 26 -
 6 files changed, 144 insertions(+), 87 deletions(-)

diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
index a680a85db0f25..38e4d8f245e4f 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
@@ -272,11 +272,10 @@ using ParallelOperands =
 using SectionsOperands = detail::Clauses;
 
-// TODO `linear` clause.
 using SimdOperands =
-detail::Clauses;
+detail::Clauses;
 
 using SingleOperands = detail::Clauses;
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 00dadc6e6538d..16b6f624ce042 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -195,10 +195,9 @@ def TerminatorOp : OpenMP_Op<"terminator", [Terminator, 
Pure]> {
 def TeamsOp : OpenMP_Op<"teams", traits = [
 AttrSizedOperandSegments, RecursiveMemoryEffects
   ], clauses = [
-// TODO: Complete clause list (private).
 // TODO: Sort clauses alphabetically.
 OpenMP_NumTeamsClause, OpenMP_IfClause, OpenMP_ThreadLimitClause,
-OpenMP_AllocateClause, OpenMP_ReductionClause
+OpenMP_AllocateClause, OpenMP_ReductionClause, OpenMP_PrivateClause
   ], singleRegion = true> {
   let summary = "teams construct";
   let description = [{
@@ -238,9 +237,9 @@ def SectionOp : OpenMP_Op<"section", 
[HasParent<"SectionsOp">],
 def SectionsOp : OpenMP_Op<"sections", traits = [
 AttrSizedOperandSegments
   ], clauses = [
-// TODO: Complete clause list (private).
 // TODO: Sort clauses alphabetically.
-OpenMP_ReductionClause, OpenMP_AllocateClause, OpenMP_NowaitClause
+OpenMP_ReductionClause, OpenMP_AllocateClause, OpenMP_NowaitClause,
+OpenMP_PrivateClause
   ], singleRegion = true> {
   let summary = "sections construct";
   let description = [{
@@ -271,8 +270,8 @@ def SectionsOp : OpenMP_Op<"sections", traits = [
 def SingleOp : OpenMP_Op<"single", traits = [
 AttrSizedOperandSegments
   ], clauses = [
-// TODO: Complete clause list (private).
-OpenMP_AllocateClause, OpenMP_CopyprivateClause, OpenMP_NowaitClause
+OpenMP_AllocateClause, OpenMP_CopyprivateClause, OpenMP_NowaitClause,
+OpenMP_PrivateClause
   ], singleRegion = true> {
   let summary = "single directive";
   let description = [{
@@ -363,14 +362,15 @@ def WsloopOp : OpenMP_Op<"wsloop", traits = [
 AttrSizedOperandSegments, DeclareOpInterfaceMethods,
 RecursiveMemoryEffects, SingleBlock
   ], clauses = [
-// TODO: Complete clause list (allocate, private).
 // TODO: Sort clauses alphabetically.
 OpenMP_LinearClauseSkip,
 OpenMP_ReductionClauseSkip,
 OpenMP_ScheduleClauseSkip,
 OpenMP_NowaitClauseSkip,
 OpenMP_OrderedClauseSkip,
-OpenMP_OrderClauseSkip
+OpenMP_OrderClauseSkip,
+OpenMP_AllocateClauseSkip,
+OpenMP_PrivateClauseSkip
   ], singleRegion = true> {
   let summary = "worksharing-loop construct";
   let description = [{
@@ -417,6 +417,13 @@ def WsloopOp : OpenMP_Op<"wsloop", traits = [
   |`nowait` $nowait
   |`ordered` `(` $ordered `)`
   |`order` `(` custom($order, $order_mod) `)`
+  |`allocate` `(`
+custom(
+  $allocate_vars, type($allocate_vars), $allocator_vars,
+  type($allocator_vars)) `)`
+  |`private` `(`
+custom(
+  $private_vars, type($private_vars

[llvm-branch-commits] [llvm] TTI: Check legalization cost of fptosi_sat/fptoui_sat nodes (PR #100521)

2024-07-26 Thread Simon Pilgrim via llvm-branch-commits

RKSimon wrote:

I'm not sure whether its better to just focus on removing some of the custom 
lowering (and improve TargetLowering::expandFP_TO_INT_SAT) or just add better 
cost table support.

https://github.com/llvm/llvm-project/pull/100521
___
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][Sema] Add support for OpenBSD's syslog format attribute (#97366) (PR #100703)

2024-07-26 Thread Vlad Serebrennikov via llvm-branch-commits

Endilll wrote:

I'm not sure we want to backport a feature this late.
I also don't see any discussion of this being critical for 19 in #97366

https://github.com/llvm/llvm-project/pull/100703
___
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] release/19.x: [flang][debug] Set scope of internal functions correctly. (#99531) (PR #100727)

2024-07-26 Thread via llvm-branch-commits

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

Backport 626022bfd18f335ef62a461992a05dfed4e6d715

Requested by: @pawosm-arm

>From 6eff3a7b1e6429984158e3707baad3f174f8c244 Mon Sep 17 00:00:00 2001
From: Abid Qadeer 
Date: Thu, 25 Jul 2024 13:52:50 +0100
Subject: [PATCH] [flang][debug] Set scope of internal functions correctly.
 (#99531)

Summary:
The functions internal to subroutine should have the scope set to the
parent function. This allows a user to evaluate local variables of
parent function when control is stopped in the child.

Fixes #96314

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: https://phabricator.intern.facebook.com/D60250527

(cherry picked from commit 626022bfd18f335ef62a461992a05dfed4e6d715)
---
 .../lib/Optimizer/Transforms/AddDebugInfo.cpp | 181 ++
 flang/test/Transforms/debug-96314.fir |  26 +++
 2 files changed, 132 insertions(+), 75 deletions(-)
 create mode 100644 flang/test/Transforms/debug-96314.fir

diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp 
b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index 685a8645fa2fc..8751a3b2c322f 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -66,6 +66,9 @@ class AddDebugInfoPass : public 
fir::impl::AddDebugInfoBase {
   void handleGlobalOp(fir::GlobalOp glocalOp, mlir::LLVM::DIFileAttr fileAttr,
   mlir::LLVM::DIScopeAttr scope,
   mlir::SymbolTable *symbolTable);
+  void handleFuncOp(mlir::func::FuncOp funcOp, mlir::LLVM::DIFileAttr fileAttr,
+mlir::LLVM::DICompileUnitAttr cuAttr,
+mlir::SymbolTable *symbolTable);
 };
 
 static uint32_t getLineFromLoc(mlir::Location loc) {
@@ -204,11 +207,112 @@ void AddDebugInfoPass::handleGlobalOp(fir::GlobalOp 
globalOp,
   globalOp->setLoc(builder.getFusedLoc({globalOp->getLoc()}, gvAttr));
 }
 
+void AddDebugInfoPass::handleFuncOp(mlir::func::FuncOp funcOp,
+mlir::LLVM::DIFileAttr fileAttr,
+mlir::LLVM::DICompileUnitAttr cuAttr,
+mlir::SymbolTable *symbolTable) {
+  mlir::Location l = funcOp->getLoc();
+  // If fused location has already been created then nothing to do
+  // Otherwise, create a fused location.
+  if (debugInfoIsAlreadySet(l))
+return;
+
+  mlir::ModuleOp module = getOperation();
+  mlir::MLIRContext *context = &getContext();
+  mlir::OpBuilder builder(context);
+  llvm::StringRef fileName(fileAttr.getName());
+  llvm::StringRef filePath(fileAttr.getDirectory());
+  unsigned int CC = (funcOp.getName() == fir::NameUniquer::doProgramEntry())
+? llvm::dwarf::getCallingConvention("DW_CC_program")
+: llvm::dwarf::getCallingConvention("DW_CC_normal");
+
+  if (auto funcLoc = mlir::dyn_cast(l)) {
+fileName = llvm::sys::path::filename(funcLoc.getFilename().getValue());
+filePath = llvm::sys::path::parent_path(funcLoc.getFilename().getValue());
+  }
+
+  mlir::StringAttr fullName = mlir::StringAttr::get(context, funcOp.getName());
+  mlir::Attribute attr = funcOp->getAttr(fir::getInternalFuncNameAttrName());
+  mlir::StringAttr funcName =
+  (attr) ? mlir::cast(attr)
+ : mlir::StringAttr::get(context, funcOp.getName());
+
+  auto result = fir::NameUniquer::deconstruct(funcName);
+  funcName = mlir::StringAttr::get(context, result.second.name);
+
+  llvm::SmallVector types;
+  fir::DebugTypeGenerator typeGen(module);
+  for (auto resTy : funcOp.getResultTypes()) {
+auto tyAttr = typeGen.convertType(resTy, fileAttr, cuAttr, 
funcOp.getLoc());
+types.push_back(tyAttr);
+  }
+  for (auto inTy : funcOp.getArgumentTypes()) {
+auto tyAttr = typeGen.convertType(fir::unwrapRefType(inTy), fileAttr,
+  cuAttr, funcOp.getLoc());
+types.push_back(tyAttr);
+  }
+
+  mlir::LLVM::DISubroutineTypeAttr subTypeAttr =
+  mlir::LLVM::DISubroutineTypeAttr::get(context, CC, types);
+  mlir::LLVM::DIFileAttr funcFileAttr =
+  mlir::LLVM::DIFileAttr::get(context, fileName, filePath);
+
+  // Only definitions need a distinct identifier and a compilation unit.
+  mlir::DistinctAttr id;
+  mlir::LLVM::DIScopeAttr Scope = fileAttr;
+  mlir::LLVM::DICompileUnitAttr compilationUnit;
+  mlir::LLVM::DISubprogramFlags subprogramFlags =
+  mlir::LLVM::DISubprogramFlags{};
+  if (isOptimized)
+subprogramFlags = mlir::LLVM::DISubprogramFlags::Optimized;
+  if (!funcOp.isExternal()) {
+id = mlir::DistinctAttr::create(mlir::UnitAttr::get(context));
+compilationUnit = cuAttr;
+subprogramFlags =
+subprogramFlags | mlir::LLVM::DISubprogramFlags::Definition;
+  }
+  unsigned line = getLineFromLoc(l);
+  if (fir::isInternalProcedure(funcOp)) {
+// For contained functions, the scope is the parent subroutine.
+ml

[llvm-branch-commits] [flang] release/19.x: [flang][debug] Set scope of internal functions correctly. (#99531) (PR #100727)

2024-07-26 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/100727
___
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] release/19.x: [flang][debug] Set scope of internal functions correctly. (#99531) (PR #100727)

2024-07-26 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/100727
___
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] release/19.x: [flang][debug] Set scope of internal functions correctly. (#99531) (PR #100727)

2024-07-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-fir-hlfir

Author: None (llvmbot)


Changes

Backport 626022bfd18f335ef62a461992a05dfed4e6d715

Requested by: @pawosm-arm

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


2 Files Affected:

- (modified) flang/lib/Optimizer/Transforms/AddDebugInfo.cpp (+106-75) 
- (added) flang/test/Transforms/debug-96314.fir (+26) 


``diff
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp 
b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index 685a8645fa2fc..8751a3b2c322f 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -66,6 +66,9 @@ class AddDebugInfoPass : public 
fir::impl::AddDebugInfoBase {
   void handleGlobalOp(fir::GlobalOp glocalOp, mlir::LLVM::DIFileAttr fileAttr,
   mlir::LLVM::DIScopeAttr scope,
   mlir::SymbolTable *symbolTable);
+  void handleFuncOp(mlir::func::FuncOp funcOp, mlir::LLVM::DIFileAttr fileAttr,
+mlir::LLVM::DICompileUnitAttr cuAttr,
+mlir::SymbolTable *symbolTable);
 };
 
 static uint32_t getLineFromLoc(mlir::Location loc) {
@@ -204,11 +207,112 @@ void AddDebugInfoPass::handleGlobalOp(fir::GlobalOp 
globalOp,
   globalOp->setLoc(builder.getFusedLoc({globalOp->getLoc()}, gvAttr));
 }
 
+void AddDebugInfoPass::handleFuncOp(mlir::func::FuncOp funcOp,
+mlir::LLVM::DIFileAttr fileAttr,
+mlir::LLVM::DICompileUnitAttr cuAttr,
+mlir::SymbolTable *symbolTable) {
+  mlir::Location l = funcOp->getLoc();
+  // If fused location has already been created then nothing to do
+  // Otherwise, create a fused location.
+  if (debugInfoIsAlreadySet(l))
+return;
+
+  mlir::ModuleOp module = getOperation();
+  mlir::MLIRContext *context = &getContext();
+  mlir::OpBuilder builder(context);
+  llvm::StringRef fileName(fileAttr.getName());
+  llvm::StringRef filePath(fileAttr.getDirectory());
+  unsigned int CC = (funcOp.getName() == fir::NameUniquer::doProgramEntry())
+? llvm::dwarf::getCallingConvention("DW_CC_program")
+: llvm::dwarf::getCallingConvention("DW_CC_normal");
+
+  if (auto funcLoc = mlir::dyn_cast(l)) {
+fileName = llvm::sys::path::filename(funcLoc.getFilename().getValue());
+filePath = llvm::sys::path::parent_path(funcLoc.getFilename().getValue());
+  }
+
+  mlir::StringAttr fullName = mlir::StringAttr::get(context, funcOp.getName());
+  mlir::Attribute attr = funcOp->getAttr(fir::getInternalFuncNameAttrName());
+  mlir::StringAttr funcName =
+  (attr) ? mlir::cast(attr)
+ : mlir::StringAttr::get(context, funcOp.getName());
+
+  auto result = fir::NameUniquer::deconstruct(funcName);
+  funcName = mlir::StringAttr::get(context, result.second.name);
+
+  llvm::SmallVector types;
+  fir::DebugTypeGenerator typeGen(module);
+  for (auto resTy : funcOp.getResultTypes()) {
+auto tyAttr = typeGen.convertType(resTy, fileAttr, cuAttr, 
funcOp.getLoc());
+types.push_back(tyAttr);
+  }
+  for (auto inTy : funcOp.getArgumentTypes()) {
+auto tyAttr = typeGen.convertType(fir::unwrapRefType(inTy), fileAttr,
+  cuAttr, funcOp.getLoc());
+types.push_back(tyAttr);
+  }
+
+  mlir::LLVM::DISubroutineTypeAttr subTypeAttr =
+  mlir::LLVM::DISubroutineTypeAttr::get(context, CC, types);
+  mlir::LLVM::DIFileAttr funcFileAttr =
+  mlir::LLVM::DIFileAttr::get(context, fileName, filePath);
+
+  // Only definitions need a distinct identifier and a compilation unit.
+  mlir::DistinctAttr id;
+  mlir::LLVM::DIScopeAttr Scope = fileAttr;
+  mlir::LLVM::DICompileUnitAttr compilationUnit;
+  mlir::LLVM::DISubprogramFlags subprogramFlags =
+  mlir::LLVM::DISubprogramFlags{};
+  if (isOptimized)
+subprogramFlags = mlir::LLVM::DISubprogramFlags::Optimized;
+  if (!funcOp.isExternal()) {
+id = mlir::DistinctAttr::create(mlir::UnitAttr::get(context));
+compilationUnit = cuAttr;
+subprogramFlags =
+subprogramFlags | mlir::LLVM::DISubprogramFlags::Definition;
+  }
+  unsigned line = getLineFromLoc(l);
+  if (fir::isInternalProcedure(funcOp)) {
+// For contained functions, the scope is the parent subroutine.
+mlir::SymbolRefAttr sym = mlir::cast(
+funcOp->getAttr(fir::getHostSymbolAttrName()));
+if (sym) {
+  if (auto func =
+  symbolTable->lookup(sym.getLeafReference())) 
{
+// Make sure that parent is processed.
+handleFuncOp(func, fileAttr, cuAttr, symbolTable);
+if (auto fusedLoc =
+mlir::dyn_cast_if_present(func.getLoc())) {
+  if (auto spAttr =
+  mlir::dyn_cast_if_present(
+  fusedLoc.getMetadata()))
+Scope = spAttr;
+}
+  }
+}
+  } else if (!result.second.modules.empty()) {
+Scope =

[llvm-branch-commits] [flang] [mlir] [MLIR][OpenMP] Automate operand structure definition (PR #99508)

2024-07-26 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/99508

>From 893b8de7264be5c290db38adee66b7e00d4b6fe6 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Wed, 17 Jul 2024 13:26:09 +0100
Subject: [PATCH] [MLIR][OpenMP] Automate operand structure definition

This patch adds the "gen-openmp-clause-ops" `mlir-tblgen` generator to produce
the structure definitions previously in OpenMPClauseOperands.h automatically
from the information contained in OpenMPOps.td and OpenMPClauses.td.

Changes introduced to the `ElementsAttrBase` common tablegen class, as well as
some of its subclasses, add more fine-grained information on their shape and
type of their elements. This information is needed in order to properly
generate the corresponding types to represent these attributes within the
produced operand structures.

The original header is maintained to enable the definition of similar
structures that are not directly related to any single `OpenMP_Clause` or
`OpenMP_Op` tablegen definition.
---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|   6 +-
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |   2 +-
 .../mlir/Dialect/OpenMP/CMakeLists.txt|   1 +
 .../Dialect/OpenMP/OpenMPClauseOperands.h | 292 +-
 mlir/include/mlir/IR/CommonAttrConstraints.td |  18 +-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  22 +-
 mlir/test/mlir-tblgen/openmp-clause-ops.td|  78 +
 mlir/tools/mlir-tblgen/OmpOpGen.cpp   | 184 ++-
 8 files changed, 292 insertions(+), 311 deletions(-)
 create mode 100644 mlir/test/mlir-tblgen/openmp-clause-ops.td

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 310c0b0b5fb63..4d510ebe7df58 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -181,7 +181,7 @@ static void addUseDeviceClause(
 
 static void convertLoopBounds(lower::AbstractConverter &converter,
   mlir::Location loc,
-  mlir::omp::LoopRelatedOps &result,
+  mlir::omp::LoopRelatedClauseOps &result,
   std::size_t loopVarTypeSize) {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
   // The types of lower bound, upper bound, and step are converted into the
@@ -203,7 +203,7 @@ static void convertLoopBounds(lower::AbstractConverter 
&converter,
 
 bool ClauseProcessor::processCollapse(
 mlir::Location currentLocation, lower::pft::Evaluation &eval,
-mlir::omp::LoopRelatedOps &result,
+mlir::omp::LoopRelatedClauseOps &result,
 llvm::SmallVectorImpl &iv) const {
   bool found = false;
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
@@ -875,7 +875,7 @@ bool ClauseProcessor::processIf(
 // Assume that, at most, a single 'if' clause will be applicable to the
 // given directive.
 if (operand) {
-  result.ifVar = operand;
+  result.ifExpr = operand;
   found = true;
 }
   });
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 2c4b3857fda9f..c870680b61756 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -55,7 +55,7 @@ class ClauseProcessor {
   // 'Unique' clauses: They can appear at most once in the clause list.
   bool
   processCollapse(mlir::Location currentLocation, lower::pft::Evaluation &eval,
-  mlir::omp::LoopRelatedOps &result,
+  mlir::omp::LoopRelatedClauseOps &result,
   llvm::SmallVectorImpl &iv) const;
   bool processDefault() const;
   bool processDevice(lower::StatementContext &stmtCtx,
diff --git a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt 
b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
index dd349d1392e7b..a65c6b1d3c96b 100644
--- a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
@@ -17,6 +17,7 @@ mlir_tablegen(OpenMPOpsDialect.h.inc -gen-dialect-decls 
-dialect=omp)
 mlir_tablegen(OpenMPOpsDialect.cpp.inc -gen-dialect-defs -dialect=omp)
 mlir_tablegen(OpenMPOps.h.inc -gen-op-decls)
 mlir_tablegen(OpenMPOps.cpp.inc -gen-op-defs)
+mlir_tablegen(OpenMPClauseOps.h.inc -gen-openmp-clause-ops)
 mlir_tablegen(OpenMPOpsTypes.h.inc -gen-typedef-decls -typedefs-dialect=omp)
 mlir_tablegen(OpenMPOpsTypes.cpp.inc -gen-typedef-defs -typedefs-dialect=omp)
 mlir_tablegen(OpenMPOpsEnums.h.inc -gen-enum-decls)
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
index 38e4d8f245e4f..1247a871f93c6 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h
@@ -23,303 +23,31 @@
 #define GET_ATTRDEF_CLASSES
 #include "mlir/Dialect/OpenMP/OpenMPOpsAttributes.h.inc"
 
+#include "mlir/Dialect/OpenMP/OpenMPClauseOps.h.inc

[llvm-branch-commits] [flang] release/19.x: [flang][debug] Set scope of internal functions correctly. (#99531) (PR #100727)

2024-07-26 Thread Tom Eccles via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/100727
___
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] 58f851d - [PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr (#100552)

2024-07-26 Thread via llvm-branch-commits

Author: Daniil Kovalev
Date: 2024-07-26T08:02:42Z
New Revision: 58f851dfb66dcd0af89d0e2da483a358c3643114

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

LOG: [PAC] Sign LR with B key for non-leaf functions with ptrauth-returns attr 
(#100552)

For pauthtest ABI, there is a bunch of ptrauth-* options, including
ptrauth-returns. Use "ptrauth-returns" function attribute to indicate
need for LR signing with B key for non-leaf function to avoid using
"sign-return-address" and "sign-return-address-key" which were
originally designed for pac-ret.

Co-authored-by: Ahmed Bougacha 
Co-authored-by: Anatoly Trosinenko 
(cherry picked from commit 56fd2472d887392855ad85c53df5782a2c3f8ddb)

Added: 
llvm/test/CodeGen/AArch64/ptrauth-ret-trap.ll
llvm/test/CodeGen/AArch64/ptrauth-ret.ll

Modified: 
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 1b301a4a05fc5..377bcd5868fb6 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -8339,7 +8339,8 @@ AArch64InstrInfo::getOutliningCandidateInfo(
 NumBytesToCreateFrame += 8;
 
 // PAuth is enabled - set extra tail call cost, if any.
-auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod();
+auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
+*RepeatedSequenceLocs[0].getMF());
 NumBytesToCheckLRInTCEpilogue =
 AArch64PAuth::getCheckerSizeInBytes(LRCheckMethod);
 // Checking the authenticated LR value may significantly impact
@@ -8700,6 +8701,10 @@ void AArch64InstrInfo::mergeOutliningCandidateAttributes(
   // behaviour of one of them
   const auto &CFn = Candidates.front().getMF()->getFunction();
 
+  if (CFn.hasFnAttribute("ptrauth-returns"))
+F.addFnAttr(CFn.getFnAttribute("ptrauth-returns"));
+  if (CFn.hasFnAttribute("ptrauth-auth-traps"))
+F.addFnAttr(CFn.getFnAttribute("ptrauth-auth-traps"));
   // Since all candidates belong to the same module, just copy the
   // function-level attributes of an arbitrary function.
   if (CFn.hasFnAttribute("sign-return-address"))

diff  --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
index 201e8047b3686..e96c5a953ff2b 100644
--- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
@@ -38,6 +38,8 @@ void AArch64FunctionInfo::initializeBaseYamlFields(
 }
 
 static std::pair GetSignReturnAddress(const Function &F) {
+  if (F.hasFnAttribute("ptrauth-returns"))
+return {true, false}; // non-leaf
   // The function should be signed in the following situations:
   // - sign-return-address=all
   // - sign-return-address=non-leaf and the functions spills the LR
@@ -56,6 +58,8 @@ static std::pair GetSignReturnAddress(const 
Function &F) {
 }
 
 static bool ShouldSignWithBKey(const Function &F, const AArch64Subtarget &STI) 
{
+  if (F.hasFnAttribute("ptrauth-returns"))
+return true;
   if (!F.hasFnAttribute("sign-return-address-key")) {
 if (STI.getTargetTriple().isOSWindows())
   return true;

diff  --git a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp 
b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
index 465e689d4a7a5..92ab4b5c3d251 100644
--- a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
+++ b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
@@ -341,7 +341,8 @@ bool AArch64PointerAuth::checkAuthenticatedLR(
   AArch64PACKey::ID KeyId =
   MFnI->shouldSignWithBKey() ? AArch64PACKey::IB : AArch64PACKey::IA;
 
-  AuthCheckMethod Method = Subtarget->getAuthenticatedLRCheckMethod();
+  AuthCheckMethod Method =
+  Subtarget->getAuthenticatedLRCheckMethod(*TI->getMF());
 
   if (Method == AuthCheckMethod::None)
 return false;

diff  --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp 
b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
index 32a355fe38f1c..642006e706c13 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -565,8 +565,13 @@ bool AArch64Subtarget::useAA() const { return UseAA; }
 // exception on its own. Later, if the callee spills the signed LR value and
 // neither FEAT_PAuth2 nor FEAT_EPAC are implemented, the valid PAC replaces
 // the higher bits of LR thus hiding the authentication failure.
-AArch64PAuth::AuthCheckMethod
-AArch64Subtarget::getAuthenticatedLRCheckMethod() const {
+AArch64PAuth::AuthCheckMethod AArch64Subtarget::getA

  1   2   >