Skip to content

Commit 1c3ec87

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
1 parent 0376d29 commit 1c3ec87

File tree

13 files changed

+86
-64
lines changed

13 files changed

+86
-64
lines changed

libcxx/docs/CodingGuidelines.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,16 @@ prevent compilers from generating said debug information. Aliases inside type tr
195195
should be annotated for the same reason.
196196

197197
This is enforced by the clang-tidy check ``libcpp-nodebug-on-aliases``.
198+
199+
Pointer field protection
200+
========================
201+
202+
To improve the effectiveness of Clang's `pointer field protection
203+
<https://clang.llvm.org/docs/StructureProtection.html>`_ feature,
204+
commonly used vocabulary types with pointer fields are marked with the
205+
``_LIBCPP_PFP`` attribute, to give Clang permission to use PFP to protect
206+
their pointer fields. Newly added vocabulary types should be marked with
207+
this attribute if they contain pointer fields.
208+
209+
For the time being, PFP is an experimental feature, so our criteria for
210+
marking types with ``_LIBCPP_PFP`` may change.

libcxx/include/__config

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,12 +1275,16 @@ typedef __char32_t char32_t;
12751275
# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
12761276
# endif
12771277

1278+
# if __has_cpp_attribute(_Clang::__no_field_protection__)
1279+
# define _LIBCPP_NO_PFP [[_Clang::__no_field_protection__]]
1280+
# else
1281+
# define _LIBCPP_NO_PFP
1282+
# endif
1283+
12781284
# if defined(__POINTER_FIELD_PROTECTION__)
1279-
# define _LIBCPP_PFP [[clang::pointer_field_protection]]
1280-
# define _LIBCPP_NO_PFP [[clang::no_field_protection]]
1285+
# define _LIBCPP_PFP [[_Clang::__pointer_field_protection__]]
12811286
# else
12821287
# define _LIBCPP_PFP
1283-
# define _LIBCPP_NO_PFP
12841288
# endif
12851289

12861290
#endif // __cplusplus

libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
// This test doesn't work as such on Windows.
2525
// UNSUPPORTED: windows
2626

27+
// GDB doesn't know how to read PFP fields correctly yet.
28+
// UNSUPPORTED: pfp
29+
2730
// RUN: %{cxx} %{flags} %s -o %t.exe %{compile_flags} -g %{link_flags}
2831
// Ensure locale-independence for unicode tests.
2932
// RUN: env LANG=en_US.UTF-8 %{gdb} -nx -batch -iex "set autoload off" -ex "source %S/../../../utils/gdb/libcxx/printers.py" -ex "python register_libcxx_printer_loader()" -ex "source %S/gdb_pretty_printer_test.py" %t.exe
@@ -256,12 +259,9 @@ void unique_ptr_test() {
256259
ComparePrettyPrintToRegex(std::move(forty_two),
257260
R"(std::unique_ptr<int> containing = {__ptr_ = 0x[a-f0-9]+})");
258261

259-
#if !defined(__POINTER_FIELD_PROTECTION__)
260-
// GDB doesn't know how to read PFP fields correctly yet.
261262
std::unique_ptr<int> this_is_null;
262263
ComparePrettyPrintToChars(std::move(this_is_null),
263264
R"(std::unique_ptr is nullptr)");
264-
#endif
265265
}
266266

267267
void bitset_test() {
@@ -357,8 +357,6 @@ void map_test() {
357357
}
358358

359359
void multimap_test() {
360-
#if !defined(__POINTER_FIELD_PROTECTION__)
361-
// GDB doesn't know how to read PFP fields correctly yet.
362360
std::multimap<int, int> i_am_empty{};
363361
ComparePrettyPrintToChars(i_am_empty, "std::multimap is empty");
364362

@@ -374,7 +372,6 @@ void multimap_test() {
374372
"std::multimap with 6 elements = "
375373
R"({[1] = "one", [1] = "ein", [1] = "bir", )"
376374
R"([2] = "two", [2] = "zwei", [3] = "three"})");
377-
#endif
378375
}
379376

380377
void queue_test() {
@@ -447,16 +444,13 @@ void stack_test() {
447444
}
448445

449446
void multiset_test() {
450-
#if !defined(__POINTER_FIELD_PROTECTION__)
451-
// GDB doesn't know how to read PFP fields correctly yet.
452447
std::multiset<int> i_am_empty;
453448
ComparePrettyPrintToChars(i_am_empty, "std::multiset is empty");
454449

455450
std::multiset<std::string> one_two_three {"1:one", "2:two", "3:three", "1:one"};
456451
ComparePrettyPrintToChars(one_two_three,
457452
"std::multiset with 4 elements = {"
458453
R"("1:one", "1:one", "2:two", "3:three"})");
459-
#endif
460454
}
461455

462456
void vector_test() {
@@ -490,13 +484,10 @@ void vector_test() {
490484
"std::vector of length "
491485
"3, capacity 3 = {5, 6, 7}");
492486

493-
#if !defined(__POINTER_FIELD_PROTECTION__)
494-
// GDB doesn't know how to read PFP fields correctly yet.
495487
std::vector<int, UncompressibleAllocator<int>> test3({7, 8});
496488
ComparePrettyPrintToChars(std::move(test3),
497489
"std::vector of length "
498490
"2, capacity 2 = {7, 8}");
499-
#endif
500491
}
501492

502493
void set_iterator_test() {
@@ -667,11 +658,8 @@ void shared_ptr_test() {
667658
test0,
668659
R"(std::shared_ptr<int> count [3\?], weak [0\?]( \(libc\+\+ missing debug info\))? containing = {__ptr_ = 0x[a-f0-9]+})");
669660

670-
#if !defined(__POINTER_FIELD_PROTECTION__)
671-
// GDB doesn't know how to read PFP fields correctly yet.
672661
std::shared_ptr<const int> test3;
673662
ComparePrettyPrintToChars(test3, "std::shared_ptr is nullptr");
674-
#endif
675663
}
676664

677665
void streampos_test() {

libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// With PFP we return different values for __libcpp_is_trivially_relocatable.
10+
// UNSUPPORTED: pfp
11+
912
#include <__type_traits/is_trivially_relocatable.h>
1013
#include <array>
1114
#include <deque>
@@ -26,12 +29,6 @@
2629
# include <locale>
2730
#endif
2831

29-
#if defined(__POINTER_FIELD_PROTECTION__)
30-
constexpr bool pfp_disabled = false;
31-
#else
32-
constexpr bool pfp_disabled = true;
33-
#endif
34-
3532
static_assert(std::__libcpp_is_trivially_relocatable<char>::value, "");
3633
static_assert(std::__libcpp_is_trivially_relocatable<int>::value, "");
3734
static_assert(std::__libcpp_is_trivially_relocatable<double>::value, "");
@@ -74,8 +71,8 @@ static_assert(!std::__libcpp_is_trivially_relocatable<NonTrivialDestructor>::val
7471
// ----------------------
7572

7673
// __split_buffer
77-
static_assert(std::__libcpp_is_trivially_relocatable<std::__split_buffer<int> >::value == pfp_disabled, "");
78-
static_assert(std::__libcpp_is_trivially_relocatable<std::__split_buffer<NotTriviallyCopyable> >::value == pfp_disabled, "");
74+
static_assert(std::__libcpp_is_trivially_relocatable<std::__split_buffer<int> >::value, "");
75+
static_assert(std::__libcpp_is_trivially_relocatable<std::__split_buffer<NotTriviallyCopyable> >::value, "");
7976
static_assert(!std::__libcpp_is_trivially_relocatable<std::__split_buffer<int, test_allocator<int> > >::value, "");
8077

8178
// standard library types
@@ -88,7 +85,7 @@ static_assert(std::__libcpp_is_trivially_relocatable<std::array<std::unique_ptr<
8885

8986
static_assert(std::__libcpp_is_trivially_relocatable<std::array<int, 1> >::value, "");
9087
static_assert(!std::__libcpp_is_trivially_relocatable<std::array<NotTriviallyCopyable, 1> >::value, "");
91-
static_assert(std::__libcpp_is_trivially_relocatable<std::array<std::unique_ptr<int>, 1> >::value == pfp_disabled, "");
88+
static_assert(std::__libcpp_is_trivially_relocatable<std::array<std::unique_ptr<int>, 1> >::value, "");
9289

9390
// basic_string
9491
#if !__has_feature(address_sanitizer) || !_LIBCPP_INSTRUMENTED_WITH_ASAN
@@ -103,17 +100,17 @@ struct NotTriviallyRelocatableCharTraits : constexpr_char_traits<T> {
103100
};
104101

105102
static_assert(std::__libcpp_is_trivially_relocatable<
106-
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::value == pfp_disabled,
103+
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::value,
107104
"");
108105
static_assert(std::__libcpp_is_trivially_relocatable<
109-
std::basic_string<char, NotTriviallyRelocatableCharTraits<char>, std::allocator<char> > >::value == pfp_disabled,
106+
std::basic_string<char, NotTriviallyRelocatableCharTraits<char>, std::allocator<char> > >::value,
110107
"");
111108
static_assert(std::__libcpp_is_trivially_relocatable<
112-
std::basic_string<MyChar, constexpr_char_traits<MyChar>, std::allocator<MyChar> > >::value == pfp_disabled,
109+
std::basic_string<MyChar, constexpr_char_traits<MyChar>, std::allocator<MyChar> > >::value,
113110
"");
114111
static_assert(
115112
std::__libcpp_is_trivially_relocatable<
116-
std::basic_string<MyChar, NotTriviallyRelocatableCharTraits<MyChar>, std::allocator<MyChar> > >::value == pfp_disabled,
113+
std::basic_string<MyChar, NotTriviallyRelocatableCharTraits<MyChar>, std::allocator<MyChar> > >::value,
117114
"");
118115
static_assert(!std::__libcpp_is_trivially_relocatable<
119116
std::basic_string<char, std::char_traits<char>, test_allocator<char> > >::value,
@@ -125,21 +122,21 @@ static_assert(
125122
#endif
126123

127124
// deque
128-
static_assert(std::__libcpp_is_trivially_relocatable<std::deque<int> >::value == pfp_disabled, "");
129-
static_assert(std::__libcpp_is_trivially_relocatable<std::deque<NotTriviallyCopyable> >::value == pfp_disabled, "");
125+
static_assert(std::__libcpp_is_trivially_relocatable<std::deque<int> >::value, "");
126+
static_assert(std::__libcpp_is_trivially_relocatable<std::deque<NotTriviallyCopyable> >::value, "");
130127
static_assert(!std::__libcpp_is_trivially_relocatable<std::deque<int, test_allocator<int> > >::value, "");
131128

132129
// exception_ptr
133130
#ifndef _LIBCPP_ABI_MICROSOFT // FIXME: Is this also the case on windows?
134-
static_assert(std::__libcpp_is_trivially_relocatable<std::exception_ptr>::value == pfp_disabled, "");
131+
static_assert(std::__libcpp_is_trivially_relocatable<std::exception_ptr>::value, "");
135132
#endif
136133

137134
// expected
138135
#if TEST_STD_VER >= 23
139-
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<int, int> >::value == pfp_disabled);
140-
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<std::unique_ptr<int>, int>>::value == pfp_disabled);
141-
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<int, std::unique_ptr<int>>>::value == pfp_disabled);
142-
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<std::unique_ptr<int>, std::unique_ptr<int>>>::value == pfp_disabled);
136+
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<int, int> >::value);
137+
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<std::unique_ptr<int>, int>>::value);
138+
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<int, std::unique_ptr<int>>>::value);
139+
static_assert(std::__libcpp_is_trivially_relocatable<std::expected<std::unique_ptr<int>, std::unique_ptr<int>>>::value);
143140

144141
static_assert(!std::__libcpp_is_trivially_relocatable<std::expected<int, NotTriviallyCopyable>>::value);
145142
static_assert(!std::__libcpp_is_trivially_relocatable<std::expected<NotTriviallyCopyable, int>>::value);
@@ -149,42 +146,42 @@ static_assert(
149146

150147
// locale
151148
#ifndef TEST_HAS_NO_LOCALIZATION
152-
static_assert(std::__libcpp_is_trivially_relocatable<std::locale>::value == pfp_disabled, "");
149+
static_assert(std::__libcpp_is_trivially_relocatable<std::locale>::value, "");
153150
#endif
154151

155152
// optional
156153
#if TEST_STD_VER >= 17
157154
static_assert(std::__libcpp_is_trivially_relocatable<std::optional<int>>::value, "");
158155
static_assert(!std::__libcpp_is_trivially_relocatable<std::optional<NotTriviallyCopyable>>::value, "");
159-
static_assert(std::__libcpp_is_trivially_relocatable<std::optional<std::unique_ptr<int>>>::value == pfp_disabled, "");
156+
static_assert(std::__libcpp_is_trivially_relocatable<std::optional<std::unique_ptr<int>>>::value, "");
160157
#endif // TEST_STD_VER >= 17
161158

162159
// pair
163-
static_assert(std::__libcpp_is_trivially_relocatable<std::pair<int, int> >::value == pfp_disabled, "");
160+
static_assert(std::__libcpp_is_trivially_relocatable<std::pair<int, int> >::value, "");
164161
static_assert(!std::__libcpp_is_trivially_relocatable<std::pair<NotTriviallyCopyable, int> >::value, "");
165162
static_assert(!std::__libcpp_is_trivially_relocatable<std::pair<int, NotTriviallyCopyable> >::value, "");
166163
static_assert(!std::__libcpp_is_trivially_relocatable<std::pair<NotTriviallyCopyable, NotTriviallyCopyable> >::value,
167164
"");
168-
static_assert(std::__libcpp_is_trivially_relocatable<std::pair<std::unique_ptr<int>, std::unique_ptr<int> > >::value == pfp_disabled,
165+
static_assert(std::__libcpp_is_trivially_relocatable<std::pair<std::unique_ptr<int>, std::unique_ptr<int> > >::value,
169166
"");
170167

171168
// shared_ptr
172-
static_assert(std::__libcpp_is_trivially_relocatable<std::shared_ptr<NotTriviallyCopyable> >::value == pfp_disabled, "");
169+
static_assert(std::__libcpp_is_trivially_relocatable<std::shared_ptr<NotTriviallyCopyable> >::value, "");
173170

174171
// tuple
175172
#if TEST_STD_VER >= 11
176173
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<> >::value, "");
177174

178-
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<int> >::value == pfp_disabled, "");
175+
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<int> >::value, "");
179176
static_assert(!std::__libcpp_is_trivially_relocatable<std::tuple<NotTriviallyCopyable> >::value, "");
180-
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<std::unique_ptr<int> > >::value == pfp_disabled, "");
177+
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<std::unique_ptr<int> > >::value, "");
181178

182-
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<int, int> >::value == pfp_disabled, "");
179+
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<int, int> >::value, "");
183180
static_assert(!std::__libcpp_is_trivially_relocatable<std::tuple<NotTriviallyCopyable, int> >::value, "");
184181
static_assert(!std::__libcpp_is_trivially_relocatable<std::tuple<int, NotTriviallyCopyable> >::value, "");
185182
static_assert(!std::__libcpp_is_trivially_relocatable<std::tuple<NotTriviallyCopyable, NotTriviallyCopyable> >::value,
186183
"");
187-
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<std::unique_ptr<int>, std::unique_ptr<int> > >::value == pfp_disabled,
184+
static_assert(std::__libcpp_is_trivially_relocatable<std::tuple<std::unique_ptr<int>, std::unique_ptr<int> > >::value,
188185
"");
189186
#endif // TEST_STD_VER >= 11
190187

@@ -209,9 +206,9 @@ struct NotTriviallyRelocatablePointer {
209206
void operator()(T*);
210207
};
211208

212-
static_assert(std::__libcpp_is_trivially_relocatable<std::unique_ptr<int> >::value == pfp_disabled, "");
213-
static_assert(std::__libcpp_is_trivially_relocatable<std::unique_ptr<NotTriviallyCopyable> >::value == pfp_disabled, "");
214-
static_assert(std::__libcpp_is_trivially_relocatable<std::unique_ptr<int[]> >::value == pfp_disabled, "");
209+
static_assert(std::__libcpp_is_trivially_relocatable<std::unique_ptr<int> >::value, "");
210+
static_assert(std::__libcpp_is_trivially_relocatable<std::unique_ptr<NotTriviallyCopyable> >::value, "");
211+
static_assert(std::__libcpp_is_trivially_relocatable<std::unique_ptr<int[]> >::value, "");
215212
static_assert(!std::__libcpp_is_trivially_relocatable<std::unique_ptr<int, NotTriviallyRelocatableDeleter> >::value,
216213
"");
217214
static_assert(!std::__libcpp_is_trivially_relocatable<std::unique_ptr<int[], NotTriviallyRelocatableDeleter> >::value,
@@ -225,23 +222,23 @@ static_assert(!std::__libcpp_is_trivially_relocatable<std::unique_ptr<int[], Not
225222
#if TEST_STD_VER >= 17
226223
static_assert(std::__libcpp_is_trivially_relocatable<std::variant<int> >::value, "");
227224
static_assert(!std::__libcpp_is_trivially_relocatable<std::variant<NotTriviallyCopyable> >::value, "");
228-
static_assert(std::__libcpp_is_trivially_relocatable<std::variant<std::unique_ptr<int> > >::value == pfp_disabled, "");
225+
static_assert(std::__libcpp_is_trivially_relocatable<std::variant<std::unique_ptr<int> > >::value, "");
229226

230227
static_assert(std::__libcpp_is_trivially_relocatable<std::variant<int, int> >::value, "");
231228
static_assert(!std::__libcpp_is_trivially_relocatable<std::variant<NotTriviallyCopyable, int> >::value, "");
232229
static_assert(!std::__libcpp_is_trivially_relocatable<std::variant<int, NotTriviallyCopyable> >::value, "");
233230
static_assert(!std::__libcpp_is_trivially_relocatable<std::variant<NotTriviallyCopyable, NotTriviallyCopyable> >::value,
234231
"");
235-
static_assert(std::__libcpp_is_trivially_relocatable<std::variant<std::unique_ptr<int>, std::unique_ptr<int> > >::value == pfp_disabled,
232+
static_assert(std::__libcpp_is_trivially_relocatable<std::variant<std::unique_ptr<int>, std::unique_ptr<int> > >::value,
236233
"");
237234
#endif // TEST_STD_VER >= 17
238235

239236
// vector
240-
static_assert(std::__libcpp_is_trivially_relocatable<std::vector<int> >::value == pfp_disabled, "");
241-
static_assert(std::__libcpp_is_trivially_relocatable<std::vector<NotTriviallyCopyable> >::value == pfp_disabled, "");
237+
static_assert(std::__libcpp_is_trivially_relocatable<std::vector<int> >::value, "");
238+
static_assert(std::__libcpp_is_trivially_relocatable<std::vector<NotTriviallyCopyable> >::value, "");
242239
static_assert(!std::__libcpp_is_trivially_relocatable<std::vector<int, test_allocator<int> > >::value, "");
243240

244241
// weak_ptr
245-
static_assert(std::__libcpp_is_trivially_relocatable<std::weak_ptr<NotTriviallyCopyable> >::value == pfp_disabled, "");
242+
static_assert(std::__libcpp_is_trivially_relocatable<std::weak_ptr<NotTriviallyCopyable> >::value, "");
246243

247244
// TODO: Mark all the trivially relocatable STL types as such

libcxx/utils/libcxx/test/params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def getSuitableClangTidy(cfg):
355355
AddCompileFlag("--rtlib=compiler-rt"),
356356
AddLinkFlag("--rtlib=compiler-rt"),
357357
AddLinkFlag("--unwindlib=libunwind"),
358+
AddFeature("pfp"),
358359
],
359360
),
360361
Parameter(

libcxxabi/include/__cxxabi_config.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,8 @@
109109
# define _LIBCXXABI_NOEXCEPT noexcept
110110
#endif
111111

112-
#if defined(_LIBCXXABI_COMPILER_CLANG)
113-
# if defined(__POINTER_FIELD_PROTECTION__)
114-
# define _LIBCXXABI_NO_PFP [[clang::no_field_protection]]
115-
# else
116-
# define _LIBCXXABI_NO_PFP
117-
# endif
112+
#if defined(__POINTER_FIELD_PROTECTION__)
113+
# define _LIBCXXABI_NO_PFP [[_Clang::__no_field_protection__]]
118114
#else
119115
# define _LIBCXXABI_NO_PFP
120116
#endif

libcxxabi/test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ if (LLVM_USE_SANITIZER)
8080
serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
8181
endif()
8282

83-
serialize_lit_string_param(SERIALIZED_LIT_PARAMS pfp "${LIBCXX_PFP}")
83+
if (DEFINED LIBCXX_PFP)
84+
serialize_lit_string_param(SERIALIZED_LIT_PARAMS pfp "${LIBCXX_PFP}")
85+
endif()
8486

8587
if (CMAKE_CXX_COMPILER_TARGET)
8688
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")

llvm/docs/LangRef.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,13 +3092,16 @@ A "convergencectrl" operand bundle is only valid on a ``convergent`` operation.
30923092
When present, the operand bundle must contain exactly one value of token type.
30933093
See the :doc:`ConvergentOperations` document for details.
30943094

3095+
.. _deactivationsymbol:
3096+
30953097
Deactivation Symbol Operand Bundles
30963098
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30973099

30983100
A ``"deactivation-symbol"`` operand bundle is valid on the following
30993101
instructions (AArch64 only):
31003102

3101-
- Call to a normal function with ``notail`` attribute.
3103+
- Call to a normal function with ``notail`` attribute and a first argument and
3104+
return value of type ``ptr``.
31023105
- Call to ``llvm.ptrauth.sign`` or ``llvm.ptrauth.auth`` intrinsics.
31033106

31043107
This operand bundle specifies that if the deactivation symbol is defined
@@ -5148,7 +5151,7 @@ need to refer to the actual function body.
51485151
Pointer Authentication Constants
51495152
--------------------------------
51505153

5151-
``ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC]?]?)``
5154+
``ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC[, ptr DS]?]?]?)``
51525155

51535156
A '``ptrauth``' constant represents a pointer with a cryptographic
51545157
authentication signature embedded into some bits, as described in the
@@ -5177,6 +5180,11 @@ Otherwise, the expression is equivalent to:
51775180
%tmp2 = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 %tmp1)
51785181
%val = inttoptr i64 %tmp2 to ptr
51795182

5183+
If the deactivation symbol operand ``DS`` has a non-null value,
5184+
the semantics are as if a :ref:`deactivation-symbol operand bundle
5185+
<deactivationsymbol>` were added to the ``llvm.ptrauth.sign`` intrinsic
5186+
calls above, with ``DS`` as the only operand.
5187+
51805188
.. _constantexprs:
51815189

51825190
Constant Expressions

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,9 @@ Expected<Value *> BitcodeReader::materializeValue(unsigned StartValID,
16131613
ConstOps.size() > 4 ? ConstOps[4]
16141614
: ConstantPointerNull::get(cast<PointerType>(
16151615
ConstOps[3]->getType()));
1616+
if (!DeactivationSymbol->getType()->isPointerTy())
1617+
return error(
1618+
"ptrauth deactivation symbol operand must be a pointer");
16161619

16171620
C = ConstantPtrAuth::get(ConstOps[0], Key, Disc, ConstOps[3],
16181621
DeactivationSymbol);

llvm/lib/IR/Constants.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,7 @@ ConstantPtrAuth::ConstantPtrAuth(Constant *Ptr, ConstantInt *Key,
20822082
assert(Key->getBitWidth() == 32);
20832083
assert(Disc->getBitWidth() == 64);
20842084
assert(AddrDisc->getType()->isPointerTy());
2085+
assert(DeactivationSymbol->getType()->isPointerTy());
20852086
setOperand(0, Ptr);
20862087
setOperand(1, Key);
20872088
setOperand(2, Disc);

0 commit comments

Comments
 (0)