This is an archive of the discontinued LLVM Phabricator instance.

Linker: Remove unnecessary call to copyMetadata in IRLinker::linkGlobalVariable.
ClosedPublic

Authored by pcc on Nov 14 2016, 11:20 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 77845.Nov 14 2016, 11:20 AM
pcc retitled this revision from to Linker: Remove unnecessary call to copyMetadata in IRLinker::linkGlobalVariable..
pcc updated this object.
pcc added a reviewer: aprantl.
pcc added a subscriber: llvm-commits.
pcc updated this object.Nov 14 2016, 11:23 AM
aprantl accepted this revision.Nov 14 2016, 11:28 AM
aprantl edited edge metadata.

Thanks for the quick turnaround. One question inline, but otherwise this looks good.

llvm/lib/Linker/IRMover.cpp
953 ↗(On Diff #77845)

So, is the metadata attached to Dst always identical to the one in Src, or could there be a situation where one is more complete / otherwise better than the other?

This revision is now accepted and ready to land.Nov 14 2016, 11:28 AM
pcc planned changes to this revision.Nov 14 2016, 11:43 AM

Actually I'm not sure that this is quite right yet. It isn't clear to me that we're doing the right thing in the case where we link a declaration followed by a definition. We at least need test cases covering that case.

pcc updated this revision to Diff 77856.Nov 14 2016, 12:06 PM
pcc edited edge metadata.

Add tests cases for declaration/definition and weak/strong

This revision is now accepted and ready to land.Nov 14 2016, 12:06 PM
pcc updated this revision to Diff 77862.Nov 14 2016, 12:29 PM

One more test case

llvm/lib/Linker/IRMover.cpp
953 ↗(On Diff #77845)

As far as I know for our current uses of metadata on globals we only need to keep the metadata for whichever definition "wins". At this point Dst will always be a fresh global variable with metadata cloned from Src's metadata, as far as I can tell from following the logic around IRLinker. The actual replacement of the definitions happens on line 943 after which we delete the old definition.

This revision was automatically updated to reflect the committed changes.