On 08/01/2018 02:17 PM, Florian Rommel wrote: > Hi, > > I stumbled across this during my work on a gcc compiler plugin [1]. > > During the ipa-icf pass semantic items (`sem_function` and `sem_variable`) > are generated to find potential candidates for function or variable merging.
Hello. Sorry for late answer. > > In `ipa-icf.c` there is a static variable `optimizer` (of type > `sem_item_optimizer`) which is initialized before and destroyed after the > ipa-icf pass. This variable is used by the semantic items. Therefore it is > not possible to use `sem_function` or `sem_variable` outside of the icf pass > (as the static optimizer is NULL). E.g. create a `sem_function` variable > with `sem_function::parse`. > > Is this intended? I would like to use `sem_function` objects (independently > from the icf pass) to compare functions that were generated by our gcc plugin > (or is this a bad idea). That can definitely done better, if I see correctly only reference from sem_item, sem_function and sem_variable is in sem_item::add_type. That can be removed. > > It seems that (non-static) member functions like > `sem_item_optimizer::parse_func_and_vars` use this static `optimizer` > instance (through some indirections [2]) which looks kinda wrong to me. Sure, that's strange. But I can't find the reference in current trunk. Can you please update to trunk and check the remaining problematic references? Thanks, Martin > > Regards, > Flo > > > [1] https://github.com/luhsra/multiverse > > [2] Calls: > sem_item_optimizer::parse_funcs_and_vars [ipa_icf.c:2666] > sem_function::parse [ipa_icf.c:1691] > sem_function::init [ipa_icf.c:1387] > sem_function::hash_stmt [ipa_icf.c:1617] > sem_function::add_type [ipa_icf.c:1547] > uses static sem_item_optimizer optimzer [ipa_icf.c:94] > > >