I might be missing some context here, but is the main reason for cloning/internalizing before IPSCCP that it allows the existing IPO passes to benefit without needing to change each pass?
With the current approach, cloning seems to be limited to the subset of linkonce_odr functions that receive the frontend “likely TU-local” hint.
Would it make sense to also clone when we find an optimization opportunity? For example, ArgPromotion currently skips linkonce_odr functions, but if it finds promotable arguments and determines that cloning is profitable for one or more call sites, it could clone at that point.
That could potentially cover a broader set of linkonce_odr functions while controlling code size, since we would only clone when there is a profitable optimization opportunity.