The 10/31/2025 17:47, Wilco Dijkstra wrote: > Hi Alfie, > > > + inform (DECL_SOURCE_LOCATION (new_decl), > > + "previous declaration of %qD", new_decl); > > That should really say "other declaration" or something similar since it is > not > known whether it is the previous or the newer declaration... > Ah thanks, will fix. > > @@ -15571,60 +15573,78 @@ disjoint_version_decls (tree fn1, tree fn2) > > > I think all this is hopelessy complicated. It doesn't make any sense at all > to go over the full crossproduct when all we need is a set of strings. > I expect the code to be as trivial as: > > > auto_vec<string_slice> old_versions = get_all_clones (old_decl); > auto_vec<string_slice> new_versions = get_all_clones (new_decl); > > for (string_slice v1 : old_versions) > for (string_slice v2 : new_versions) > if (targetm.target_option.same_function_versions (v1, v2)) > return false; > return true; > > This uses a tiny helper get_all_clones (needs better name) that either returns > get_clone_versions or get_target_version or "default". That's all. >
I dont think thats what this code is doing. The point of this code is to check if the versions that the two decls define are *disjoint*. That is, there is no specific function version defined by both decls. If they are disjoint, then they do not conflict and can be added to to an FMV structure to be dispatched at a later point. But if they do, then there is later logic to check if they can be merged (which requires that they define the same set of versions as your example code implements). I dont think theres a better way to check disjoint-ness than doing a cross product? Thanks, Alfie > Cheers, > Wilco -- Alfie Richards
