[PATCH] Make discardable symbols externally visible to prevent discarding in llvm-extract.

Lang Hames lhames at gmail.com
Sun Mar 3 17:10:15 PST 2013


An alternative fix for this would be modifying the ExtractGV pass directly.
At present it checks "hasLocalLinkage" when deciding whether to bump the
linkage type. I think it should be checking isDiscardableIfUnused()
instead. Alternate patch attached.

- Lang.


On Sun, Mar 3, 2013 at 4:40 PM, Lang Hames <lhames at gmail.com> wrote:

> Hi All,
>
> llvm-extract has tricked me a couple of times by handing me back an empty
> module when I asked it to extract a linkonce function. The problem is that
> when DCE tidies up the module, it strips out the function that you wanted
> to extract.
>
> To avoid that problem, this patch sets the linkage on any function that
> was requested on the command line, and that would be discarded by DCE, to
> ExternalLinkage.
>
> Given the use cases that I'm aware of for llvm-extract I think this should
> be an improvement. It certainly seems better than handing back an empty
> module. If anybody is concerned about this quietly changing the linkage
> type then I can improve the patch to restore the original linkage types
> after DCE is run.
>
> Cheers,
> Lang.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130303/b52bc3f1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-discardable-globals-externally-visible-alternate.patch
Type: application/octet-stream
Size: 675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130303/b52bc3f1/attachment.obj>


More information about the llvm-commits mailing list