w2yehia wrote: I mistakenly thought ifunc can be forward declared with enough information to indicate it's an ifunc, so that all callsites of ifunc can be converted to indirect calls through the function descriptor (which is something that was planned as an immediate next step after this PR or included in it). But today I found out it's not; an ifunc declaration looks like a regular declaration. So the code in the function stub created during lowering became a focus point, and as it stands it requires some refinement.
I had some offline discussions with @RolandF77 and @mandlebug, and two solutions were proposed: 1. a constructor based approach, where the update of the descriptor is done in a constructor/initialization function. One init per ifunc or some aggregate constructor. The solution must not prevent dead functions from being garbage collected by the linker. One disadvantage is that: the resolvers of all (statically) live ifuncs are called at program startup, rather than individual resolvers lazily called upon function entry (which is the approach we tried here) 2. have a special function that calls the resolver and fixes up the descriptor, and tail calls the result. In both approaches the original ifunc function becomes a wrapper that indirect calls the function pointer in the descriptor (no checks). We would prefer a solution that doesn't require any input from the user (in the form of extra flags or user code changes (such as decorating ifunc declarations with some extra info)). I will evaluate the two approaches and post an update here soon. https://github.com/llvm/llvm-project/pull/153049 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits