[PATCH] D157452: [RFC][Clang][Codegen] `std::type_info` needs special care with explicit address spaces
Alex Voicu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 15 06:57:16 PDT 2023
AlexVlx added a comment.
In D157452#4586554 <https://reviews.llvm.org/D157452#4586554>, @rjmccall wrote:
> The path of least resistance here is that IRGen should just insert conversions from the global AS to the default AS as part of evaluating `typeid`. I haven't looked at it closely, but that seems to be what this patch is doing.
>
> However, `std::type_info` is an interesting special case in that we actually know statically that all objects of that type will be allocated in the global AS, so there's really no reason to pass around pointers in the default AS; `std::type_info *` should just default to being in the global AS. It'd be a non-trivial feature in support of a somewhat uncommonly-used C++ feature, and I can't tell how best to spend your time, *but*... if you're so inclined, I think it would make a somewhat compelling feature to be able to declare a default AS for a class type, which your target could then adopt in the headers for `std::type_info`.
I've reworked things along these lines, as both you and @yaxunl, thank you; turns out that what I was doing was unsound / would not catch all cases, whereas this does. As for the feature suggestion, that actually seems as if it would be very useful, beyond this application; I will add it to my TODO list, although I cannot promise to get to investigating it right away.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157452/new/
https://reviews.llvm.org/D157452
More information about the cfe-commits
mailing list