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

Jim Grosbach grosbach at apple.com
Mon Mar 4 11:23:42 PST 2013


Hi Lang,

Either of these approaches seem fine to me. I slightly prefer actually making the symbol external, as that way if/when I run 'opt' on the new module, the function won't go missing again. If we keep the original internal linkage on the symbol, I'll end up just modifying it manually anyway. May as well have the tool do it directly.

-Jim

On Mar 3, 2013, at 5:10 PM, Lang Hames <lhames at gmail.com> wrote:

> 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.
> 
> <make-discardable-globals-externally-visible-alternate.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130304/fecb2815/attachment.html>


More information about the llvm-commits mailing list