Hi Florian, Thank you very much for your reply.
This is not related to ELF. What I am trying to do is simply obtain the 'Derived' type node from the parameter that is retrieved via the '__dynamic_cast' call. I believe this should be a relatively simple coding problem. However, I am not very familiar with GCC source code at present, and that is the reason why I am asking for help here. Thanks, Hanke Zhang Florian Weimer <fwei...@redhat.com> 于2025年1月18日周六 20:50写道: > > * Hanke Zhang via Gcc: > > > I have recently been delving into optimizing dynamic_cast calls in C++ > > within the context of GIMPLE code. In particular, for scenarios > > involving single inheritance, I'm aiming to convert the following > > code: > > > > _1 = __dynamic_cast (obj_1(D), &_ZTI7Base, &_ZTI10Derived, 0); > > if (_1!= 0B) > > > > into a more direct and efficient form, such as: > > > > _2 = MEM[obj_1(D)]; > > _3 = MEM[_2 + -8B]; > > if (_3 == &_ZTI10Derived) > > > > However, during this process, I encountered an issue. I attempted to > > obtain the type node of the Derived class through the _ZTI10Derived, > > which I believe should be a VAR_DECL. Regrettably, my efforts were > > unsuccessful. > > Is this for ELF? I think our ELF ABIs require that a full string > comparison is performed if the pointers do not match. Otherwise, types > with different vtables will suddenly be considered distinct under RTTI. > The symbols for vtables can be hidden if “local: *;” is used in a linker > script, for example. Currently, as far as I understand it, this does > not have a direct impact on RTTI. > > Thanks, > Florian >