[llvm-branch-commits] [libcxxabi] [libc++abi] Only store a single dst_ptr (PR #245190)
Nikolas Klauser via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 23 03:12:45 PST 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/245190
None
>From 877a2522df47a6c747f7ea08c761a5a975901bd3 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 23 Nov 2026 12:11:59 +0100
Subject: [PATCH] [libc++abi] Only store a single dst_ptr
---
libcxxabi/src/private_typeinfo.cpp | 28 ++++++++++++----------------
libcxxabi/src/private_typeinfo.h | 6 ++----
2 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp
index 9d8d390fa067fc..0745508120b853 100644
--- a/libcxxabi/src/private_typeinfo.cpp
+++ b/libcxxabi/src/private_typeinfo.cpp
@@ -172,7 +172,6 @@ const void* dyn_cast_to_derived(
static_ptr,
static_type,
0,
- 0,
path_kind::unknown,
path_kind::unknown,
path_kind::unknown,
@@ -205,7 +204,6 @@ const void* dyn_cast_to_derived(
static_ptr,
static_type,
0,
- 0,
path_kind::unknown,
path_kind::unknown,
path_kind::unknown,
@@ -259,7 +257,6 @@ const void* dyn_cast_try_downcast(
dst_ptr_to_static,
dst_type,
0,
- 0,
path_kind::unknown,
path_kind::unknown,
path_kind::unknown,
@@ -289,7 +286,7 @@ const void* dyn_cast_slow(
// Initialize info struct for this search.
__dynamic_cast_info info = {
- dst_type, static_ptr, static_type, 0, 0, path_kind::unknown, path_kind::unknown, path_kind::unknown, 0, true, 0};
+ dst_type, static_ptr, static_type, 0, path_kind::unknown, path_kind::unknown, path_kind::unknown, 0, true, 0};
result res = dynamic_type->search_below_dst<false>(&info, dynamic_ptr, path_kind::public_path);
#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST
@@ -315,7 +312,6 @@ const void* dyn_cast_slow(
static_ptr,
static_type,
0,
- 0,
path_kind::unknown,
path_kind::unknown,
path_kind::unknown,
@@ -332,10 +328,10 @@ const void* dyn_cast_slow(
if (info.path_dst_ptr_to_static_ptr == path_kind::public_path ||
(info.number_to_dst_ptr == 0 && info.path_dynamic_ptr_to_static_ptr == path_kind::public_path &&
info.path_dynamic_ptr_to_dst_ptr == path_kind::public_path))
- return info.dst_ptr_leading_to_static_ptr;
+ return info.dst_ptr;
} else if (info.number_to_dst_ptr == 1 && info.path_dynamic_ptr_to_static_ptr == path_kind::public_path &&
info.path_dynamic_ptr_to_dst_ptr == path_kind::public_path) {
- return info.dst_ptr_not_leading_to_static_ptr;
+ return info.dst_ptr;
}
return nullptr;
@@ -895,16 +891,16 @@ result __class_type_info::process_static_type_above_dst(
// We found (static_ptr, static_type). If we know this is the only one, returns success, otherwise that we found our
// static ptr.
- if (info->dst_ptr_leading_to_static_ptr == 0) {
+ if (info->dst_ptr == 0) {
// First time here
- info->dst_ptr_leading_to_static_ptr = dst_ptr;
+ info->dst_ptr = dst_ptr;
info->path_dst_ptr_to_static_ptr = path_below;
// If there is only one dst_type in the entire tree and the path from
// there to here is public then we are done!
return info->has_unique_dst_type && info->path_dst_ptr_to_static_ptr == path_kind::public_path
? result::success
: result::our_static_ptr;
- } else if (info->dst_ptr_leading_to_static_ptr == dst_ptr) {
+ } else if (info->dst_ptr == dst_ptr) {
// We've been here before. Update path to "most public"
if (info->path_dst_ptr_to_static_ptr == path_kind::not_public_path)
info->path_dst_ptr_to_static_ptr = path_below;
@@ -996,7 +992,7 @@ result __vmi_class_type_info::search_below_dst_impl(
} else if (is_equal(this, info->dst_type, use_strcmp)) {
// We've been here before if we've recorded current_ptr in one of these
// two places:
- if (current_ptr == info->dst_ptr_leading_to_static_ptr || current_ptr == info->dst_ptr_not_leading_to_static_ptr) {
+ if (current_ptr == info->dst_ptr || current_ptr == info->dst_ptr) {
// We've seen this node before, and therefore have already searched
// its base classes above.
// Update path to here that is "most public".
@@ -1077,7 +1073,7 @@ result __vmi_class_type_info::search_below_dst_impl(
// We found a dst_type that doesn't point to (static_ptr, static_type)
// So record the address of this dst_ptr and increment the
// count of the number of such dst_types found in the tree.
- info->dst_ptr_not_leading_to_static_ptr = current_ptr;
+ info->dst_ptr = current_ptr;
info->number_to_dst_ptr += 1;
return result::unknown;
}
@@ -1154,7 +1150,7 @@ result __si_class_type_info::search_below_dst_impl(
// We've been here before if we've recorded current_ptr in one of these
// two places:
- if (current_ptr == info->dst_ptr_leading_to_static_ptr || current_ptr == info->dst_ptr_not_leading_to_static_ptr) {
+ if (current_ptr == info->dst_ptr || current_ptr == info->dst_ptr) {
// We've seen this node before, and therefore have already searched
// its base classes above.
// Update path to here that is "most public".
@@ -1201,7 +1197,7 @@ result __si_class_type_info::search_below_dst_impl(
// We found a dst_type that doesn't point to (static_ptr, static_type)
// So record the address of this dst_ptr and increment the
// count of the number of such dst_types found in the tree.
- info->dst_ptr_not_leading_to_static_ptr = current_ptr;
+ info->dst_ptr = current_ptr;
info->number_to_dst_ptr += 1;
return result::unknown;
}
@@ -1224,7 +1220,7 @@ result __class_type_info::search_below_dst_impl(
// We've been here before if we've recorded current_ptr in one of these
// two places:
- if (current_ptr == info->dst_ptr_leading_to_static_ptr || current_ptr == info->dst_ptr_not_leading_to_static_ptr) {
+ if (current_ptr == info->dst_ptr) {
// We've seen this node before, and therefore have already searched
// its base classes above.
// Update path to here that is "most public".
@@ -1246,7 +1242,7 @@ result __class_type_info::search_below_dst_impl(
// We found a dst_type that doesn't point to (static_ptr, static_type)
// So record the address of this dst_ptr and increment the
// count of the number of such dst_types found in the tree.
- info->dst_ptr_not_leading_to_static_ptr = current_ptr;
+ info->dst_ptr = current_ptr;
info->number_to_dst_ptr += 1;
info->dst_type_might_be_derived_from_static_type = false;
return result::unknown;
diff --git a/libcxxabi/src/private_typeinfo.h b/libcxxabi/src/private_typeinfo.h
index af8fee1495600b..443ead5222ecc7 100644
--- a/libcxxabi/src/private_typeinfo.h
+++ b/libcxxabi/src/private_typeinfo.h
@@ -86,10 +86,8 @@ struct _LIBCXXABI_HIDDEN __dynamic_cast_info {
// Data that represents the answer:
- // pointer to a dst_type which has (static_ptr, static_type) above it
- const void* dst_ptr_leading_to_static_ptr;
- // pointer to a dst_type which does not have (static_ptr, static_type) above it
- const void* dst_ptr_not_leading_to_static_ptr;
+ // pointer to a dst_type
+ const void* dst_ptr;
// access of path from dst_ptr_leading_to_static_ptr to (static_ptr, static_type)
path_kind path_dst_ptr_to_static_ptr;
More information about the llvm-branch-commits
mailing list