[IRMover] Don't copy personality, etc unless creating def Function::copyAttributesFrom will copy the personality function, prefix data and prolog data from the source function to the new function, and is invoked when the IRMover copies the function prototype. This puts a reference to a constant in the source module on a function in the dest module, which causes an error when deleting the source module after importing, since the personality function in the source module still has uses (this would presumably also be an issue for the prologue and prefix data). Remove the copies added to the dest copy when creating the new prototype, as they are mapped properly when/if we link the function body. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257420 91177308-0d34-0410-b5e6-96231b3b80d8
[Linker] Also treat a DIImportedEntity scope DISubprogram as needed. Follow-up to r257000: DIImportedEntity can reach a DISubprogram via its entity, but also via its scope. Handle the latter case as well. PR26037. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257019 91177308-0d34-0410-b5e6-96231b3b80d8
Always treat DISubprogram reached by DIImportedEntity as needed. It is illegal to have a null entity in a DIImportedEntity, so we must link in a DISubprogram metadata node referenced by one, even if the associated function is not linked in or inlined anywhere. Fixes PR26037. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257000 91177308-0d34-0410-b5e6-96231b3b80d8
[ThinLTO] Rename variables used in metadata linking (NFC) As suggested in review for r255909, rename MDMaterialized to AllowTemps, and identify the name of the boolean flag being set in calls to saveMetadataList. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256653 91177308-0d34-0410-b5e6-96231b3b80d8
Ensure MDNode used as key in metadata linking map cannot be RAUWed As suggested in review for r255909, add a way to ensure that temporary MD used as keys in the MetadataToID map during ThinLTO importing are not RAUWed. Add support for marking an MDNode as not replaceable. Clear the new CanReplace flag when adding a temporary MD node to the MetadataToID map and clear it when destroying the map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256648 91177308-0d34-0410-b5e6-96231b3b80d8
Rename MDValue* to Metadata* (NFC) Renamed MDValue* to Metadata*, and MDValueToValIDMap to MetadataToIDs, as per review for r255909. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256593 91177308-0d34-0410-b5e6-96231b3b80d8
Handle empty Subprogram list when linking metadata. Use an iterator that handles an empty subprogram list. Fixes PR25915. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256224 91177308-0d34-0410-b5e6-96231b3b80d8
Drop support for dematerializing. It was only used on lib/Linker and the use was "dead" since it was used on a function the IRMover had just moved. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256019 91177308-0d34-0410-b5e6-96231b3b80d8
Rename variables to reflect linker split (NFC) Renamed variables to be more reflective of whether they are an instance of Linker, IRLinker or ModuleLinker. Also fix a stale comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256011 91177308-0d34-0410-b5e6-96231b3b80d8
[ThinLTO/LTO] Don't link in unneeded metadata Summary: Third patch split out from http://reviews.llvm.org/D14752. Only map in needed DISubroutine metadata (imported or otherwise linked in functions and other DISubroutine referenced by inlined instructions). This is supported for ThinLTO, LTO and llvm-link --only-needed, with associated tests for each one. Depends on D14838. Reviewers: dexonsmith, joker.eph Subscribers: davidxl, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D14843 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256003 91177308-0d34-0410-b5e6-96231b3b80d8
[ThinLTO] Metadata linking for imported functions Summary: Second patch split out from http://reviews.llvm.org/D14752. Maps metadata as a post-pass from each module when importing complete, suturing up final metadata to the temporary metadata left on the imported instructions. This entails saving the mapping from bitcode value id to temporary metadata in the importing pass, and from bitcode value id to final metadata during the metadata linking postpass. Depends on D14825. Reviewers: dexonsmith, joker.eph Subscribers: davidxl, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D14838 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255909 91177308-0d34-0410-b5e6-96231b3b80d8
Use diagnostic handler in the LLVMContext This patch converts code that has access to a LLVMContext to not take a diagnostic handler. This has a few advantages * It is easier to use a consistent diagnostic handler in a single program. * Less clutter since we are not passing a handler around. It does make it a bit awkward to implement some C APIs that return a diagnostic string. I will propose new versions of these APIs and deprecate the current ones. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255571 91177308-0d34-0410-b5e6-96231b3b80d8
Fix another case where the linkage was not set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255272 91177308-0d34-0410-b5e6-96231b3b80d8
Slit lib/Linker in two. A linker normally has two stages: symbol resolution and "moving stuff". In lib/Linker there is the complication of lazy linking some globals, but it was still far more mixed than it needed to. This splits the linker into a lower level IRMover and the linker proper. The IRMover just takes a list of globals to move and a callback that lets the user control what is lazy linked. The main motivation is that now tools/gold (and soon lld) can use their own symbol resolution to instruct IRMover what to do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255254 91177308-0d34-0410-b5e6-96231b3b80d8