This is an archive of the discontinued LLVM Phabricator instance.

Do not destroy external linkage when deleting function body
ClosedPublic

Authored by petarj on Sep 19 2014, 11:26 AM.

Details

Summary

The function deleteBody() converts the linkage to external and thus destroys
original linkage type value. Lack of correct linkage type causes wrong
relocations to be emitted later.
Calling dropAllReferences() instead of deleteBody() will fix the issue.

Diff Detail

Repository
rL LLVM

Event Timeline

petarj updated this revision to Diff 13880.Sep 19 2014, 11:26 AM
petarj retitled this revision from to Do not destroy external linkage when deleting function body.
petarj updated this object.
petarj edited the test plan for this revision. (Show Details)
petarj added reviewers: dexonsmith, rafael.
petarj set the repository for this revision to rL LLVM.
petarj added subscribers: Unknown Object (MLST), mseaborn.

LGTM. Is there a way to test this, though? Should there be a unit test to cover BitcodeReader::Dematerialize()?

petarj updated this revision to Diff 13934.Sep 22 2014, 8:07 AM

Added a test to unittests/Bitcode/BitReaderTest.cpp. PTAL.

petarj updated this revision to Diff 13935.Sep 22 2014, 8:10 AM

Minor update.

LGTM

unittests/Bitcode/BitReaderTest.cpp
61 ↗(On Diff #13935)

Nit: how about "DematerializeFunctionPreservesLinkageType" to capture the intent a little better?

77 ↗(On Diff #13935)

Nit: change to "Check that..." (otherwise the comment doesn't make it clear whether the test wants the linkage preserved or not)

petarj updated this revision to Diff 13987.Sep 23 2014, 6:01 AM

Nits addressed.

unittests/Bitcode/BitReaderTest.cpp
61 ↗(On Diff #13935)

Done.

77 ↗(On Diff #13935)

Done.

petarj closed this revision.Sep 23 2014, 6:04 AM
petarj updated this revision to Diff 13988.

Closed by commit rL218302 (authored by @petarj).