This is an archive of the discontinued LLVM Phabricator instance.

LTOCodeGenerator: add linkonce to llvm.used when in "MustPreserve" set
ClosedPublic

Authored by mehdi_amini on Apr 26 2016, 3:22 AM.

Details

Summary

If the linker requested to preserve a linkonce function, we should
honor this even if we drop all uses.

Diff Detail

Event Timeline

mehdi_amini retitled this revision from to LTOCodeGenerator: add linkonce to llvm.used when in "MustPreserve" set.
mehdi_amini updated this object.
mehdi_amini added a reviewer: dexonsmith.
mehdi_amini added a subscriber: llvm-commits.

Fix typo in the test

david2050 added inline comments.
lib/LTO/LTOCodeGenerator.cpp
394

Is there a missing return here?

test/tools/lto/hide-linkonce-odr.ll
5–8

longer

Address David's comment

mehdi_amini marked 2 inline comments as done.Apr 26 2016, 9:35 AM

Thanks for the comments.

lib/LTO/LTOCodeGenerator.cpp
394

Yes, good catch. It turns out that the next variable declaration was unused, and was taken as body for the if block, which is why the code was still compiling...

In gold we just change it to weak_odr.

mehdi_amini marked an inline comment as done.

Address Duncan's comments: turn into weak(_odr) instead of using the llvm.used global

dexonsmith edited edge metadata.Apr 26 2016, 4:27 PM
dexonsmith added a subscriber: dexonsmith.

LGTM.

mehdi_amini accepted this revision.Apr 26 2016, 5:13 PM
mehdi_amini added a reviewer: mehdi_amini.

(mark as approved)

This revision is now accepted and ready to land.Apr 26 2016, 5:13 PM