Make appending var linking less of a special case.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 1 Dec 2015 17:17:04 +0000 (17:17 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 1 Dec 2015 17:17:04 +0000 (17:17 +0000)
commit2b3f97809d173409a1442d7925e4a64806a738f7
tree70532562444e59678e76b27ab78dfe2f0e5a30fb
parent3c43768b6387f77f9e11450b49e5ea7b56ce1800
Make appending var linking less of a special case.

It has to be a bit special because:
* materializeInitFor is not really supposed to call replaceAllUsesWith.
  The caller has a plain variable with Dst and expects just the
  initializer to be set, not for it to be removed.
* Calling mutateType as we used to do before gets some type
  inconsistency which breaks the bitcode writer.
* If linkAppendingVarProto create a dest decl with the correct type to
  avoid the above problems, it needs to put the original dst init in
  some side table for materializeInitFor to use.

In the end the simplest solution seems to be to just have
linkAppendingVarProto do all the work and set ValueMap[SrcGV to avoid
recursion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254424 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Linker/LinkModules.cpp