[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
Wed Aug 9 08:13:56 PDT 2023


AlexVlx added a comment.

In D157452#4573076 <https://reviews.llvm.org/D157452#4573076>, @yaxunl wrote:

> It is a little concerning how far the global address will spread further. Compared to handling user-defined global variables, we keep the global address to its definition in the IR and any use of it will use the generic pointer addrcasted from its definition. This simplifies things a lot since the AST is not aware of the global address. Should we reconsider the handling of type id and type info here with a similar approach to how the user-defined global variables are handled? Or we are confident that the effect of global address can be confined.

This is a really good observation / question. I'm fairly confident this should be the last piece of noise, until (if) we decide to do something about functions. My reservation about address casting uses is that it might lead to a proliferation of casts, and it also appeared (when I tried) that it would be fairly spread out. `type_info` is special and a bit obnoxious because it is actually defined in the standard and has a mangled interface, so "lying" about the signature of its member functions in IR seems risky too. FWIW, this was silently incorrect in some cases today as well (without `assert`s we just do the bitcast, which happens to work on our target).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157452/new/

https://reviews.llvm.org/D157452



More information about the cfe-commits mailing list