<div dir="ltr">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.<div>
<br></div><div style>- Lang.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 3, 2013 at 4:40 PM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div>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.</div>

<div><br></div><div>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.</div><div><br></div><div>
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.</div>

<div><br></div><div>Cheers,</div><div>Lang.</div></div>
</blockquote></div><br></div>