This is an archive of the discontinued LLVM Phabricator instance.

Implement selective bitcode linking and internalization of linked symbols
ClosedPublic

Authored by tra on Aug 28 2015, 4:45 PM.

Details

Summary

In order to support CUDA we need a way to link in subset of functions from bitcode library.

Current way to do that suggested in NVPTX guide (http://llvm.org/docs/NVPTXUsage.html) requires linking in complete library, internalizing all symbols except those that were originally present in TU before linking and running GDCE pass to eliminate bitcode we don't need.

Considering that we only need fairly small subset of functions from the library, better way to do that would be to directly link in only the symbols needed by the destination module and internalize them in process, if required.

This patch adds two new linker flags to do exactly that.

  • -only-needed -- links in only symbols needed by destination module
  • -internalize -- internalize linked symbols.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 33254.Aug 28 2015, 4:45 PM
tra retitled this revision from to Implement selective bitcode linking and internalization of linked symbols.
tra updated this object.
tra added reviewers: echristo, dexonsmith, pcc.
tra added a subscriber: llvm-commits.
tra added inline comments.Aug 28 2015, 4:47 PM
lib/Target/NVPTX/NVPTXTargetMachine.cpp
184–186 ↗(On Diff #33254)

This change was included by mistake. I'll update the patch shortly to remove it.

tra updated this revision to Diff 33496.Aug 28 2015, 4:49 PM

Removed changes included by mistake.

tra updated this revision to Diff 33606.Aug 31 2015, 11:48 AM

Fixed a nit spotted by dexonsmith@.

tra accepted this revision.Sep 1 2015, 10:56 AM
tra added a reviewer: tra.

LGTM by dexonsmith@ on llvm-commits list.

This revision is now accepted and ready to land.Sep 1 2015, 10:56 AM
This revision was automatically updated to reflect the committed changes.