This is a follow up of D115458 and splits off the function change.
This truncates the worklist to 'MaxConstantsThreshold' candidates if the MaxConstantsThreshold was exceeded. It changes the behaviour of option -func-specialization-max-constants. Before it didn't specialise at all when this threshold was exceeded, but now it specialises up to MaxConstantsThreshold candidates from the sorted worklist.