This is a proposal to fix issue 51893.
As described there, we're seeing excessive memory usage at link time when using LTO + IPGO, and we traced it back to the appending of module flags during module linking.
This patch suggests to use temporary MD nodes for the list nodes that are newly created when module flags with SrcBehavior "append" are handled. Since we have to turn them into permanent nodes at some point, we keep track of the temp nodes in the module, and make them permanent when we know we're done with the linking.
If anyone has any better suggestions, please let me know.
@dexonsmith Apologies if you are not the right reviewer. The code has been implemented by Rafael originally, but IIRC he's no longer working on llvm.