<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 14, 2013 at 9:36 PM, Dallman, John <span dir="ltr"><<a href="mailto:john.dallman@siemens.com" target="_blank">john.dallman@siemens.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div lang="EN-GB" link="blue" vlink="purple">
<div><div class="im">
<p class="MsoNormal"><span style="font-family:"Courier New"">> I want to pass them to libraries later loaded into the application.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
</div><p class="MsoNormal"><span style="font-family:"Courier New"">> If the global is not used, would the linker be able to optimize
</span></p><div class="im">
<p class="MsoNormal"><span style="font-family:"Courier New"">> the global out and in turn optimize the function out again ?</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Potentially, but the fix is fairly simple. Create a global that holds pointers to the functions. Have the
</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">code that wants to pass pointers to those functions read the pointers from that global.
</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">However, this begs the question of why the part of your code that currently tries to pass the function
</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">pointers isn't being recognised as referring to the functions in question. How does that code work?</span></p>
</div></div></blockquote><div><br></div><div class="gmail_default" style="font-family:'courier new',monospace">Ok this is the whole story. These *unused* functions are defined in LLVM lli. and they are referenced in the bitcode lli is interpreting/JITting. the bitcode expects lli to able to resolve these functions at JIT time.  basically, the bitcode is somewhat like libraries loaded into the lli application. However, the linker optimized these functions out because it sees no invocation of them in the final executable.</div>
<div class="gmail_default" style="font-family:'courier new',monospace"></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple">
<div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">
</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1f497d">--
</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1f497d">John Dallman</span></p>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
</div><div class="im">
<p style="font-family:Arial;font-size:70%">-----------------<br>
Siemens Industry Software Limited is a limited company registered in England and Wales.<br>
Registered number: 3476850.<br>
Registered office: Faraday House, Sir William Siemens Square, Frimley, Surrey, GU16 8QD.
</p>
</div></div>

</blockquote></div><br></div></div>