Currently, DeadArgElim and ArgumentPromotion fail to preserve MD_Associated metadata pointing at the old function when a replacement function is created.
Since the replacement function is intended to be 'the same' as the old one (except for the changed arguments), any globals with MD_Associated metadata pointing to the old function should have it pointed at the new function.
I've added two helper functions to ModuleUtils which perform the metadata updating. It should be very easy to insert the proper calls to these functions into any other passes found to require the same logic.