I’m using @dynamo from IRTools to rewrite all calls inside a passed function. There is a set of functions - let’s call them primitives - that I don’t want to rewrite, and thus I need to check if a particular function is in this set during code transformation. However:
-
IRTools.@dynamoutilizes Julia’s generated functions to let us transform code. As we know, generated functions act during compilation (or rather compilation-evaluation loop). - In the transformed code functions are represented as unresolved
GlobalRefs. E.g. function+may be represented asGlobalRef(Base, :+)orGlobalRef(Main, :+), or in some other similar way. - In normal circumstances I would resolve
GlobalRefto function instance usingeval, howeverevalcannot be used in generated functions.
My current approach is to generate all possible GlobalRefs that can appear in the code, but it doesn’t seem to be very robust.
Is there a way to get a GlobalRef(some_module, function_name) and resolve it a generated function?