<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Dear All,<br>
<br>
To add to what Zhengyang has written, the choice to optimize away
unused function declarations within the standard optimization
pipeline changes how instrumentation passes are written.<br>
<br>
Many instrumentation passes just add calls to functions.
Therefore, they could be written as a FunctionPass, and this
worked because any global changes that needed to be made could be
done within the doInitialization() method. To the best of my
recollection, the LLVM optimization passes would not remove these
declarations.<br>
<br>
Now these declarations are removed before the runOnFunction()
methods are called within the FunctionPasses. For regular
functions, this can be worked around by adding the functions to
the llvm.compiler.used array, but it does not work for intrinsics
(such as memset). This means that some instrumentation passes
that could be written as a FunctionPass can no longer be written
this way (at least not without modifying the pass pipeline, which
we try to avoid doing in SAFECode).<br>
<br>
I suspect this is an untended consequence of a change to either
the pass pipeline or the global optimization pass. It probably
affects very little code within LLVM, but it can affect a lot of
external code that uses LLVM for instrumentation purposes. I
thought we should mention this behavior in case it is something
that we want to change.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
On 6/30/16 7:59 AM, Zhengyang Liu via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:SG2PR06MB0427ED5D315FA4771881E734FD240@SG2PR06MB0427.apcprd06.prod.outlook.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<meta content="text/html; charset=UTF-8">
<div dir="ltr">
<div id="x_divtagdefaultwrapper">
<p>Dear Sanjoy Das and community.</p>
<p><br>
</p>
<p>I was tried to fix a bug in the pass InitAllocas from
SAFECode. This is a function pass and will insert a
prototype of '<span>llvm.memset.p0i8.i32' in the module at
doInitialize() stage of the pass. But, this prototype will
be eliminated by strip unused function optimization since
there is no call on this function after
doInitialization(). Therefore there will be no prototype
at the runOnFunction() stage, and this will cause a fail.
Previously I solve this kind of bug by inserting the
prototype of the function to llvm.compiler.used. In this
way, the compiler will not leave the prototype alone. This
time, the situation is a bit complicated, inserting the
intrinsic function to llvm.compiler.used will cause a fail
because only users of direct call/invokes are allowed on
intrinsic functions.</span></p>
<p><span><br>
</span></p>
<p><span>Fortunately, after some discussion with my GSoC
mentor, Prof. Criswell, we chose to rewrite the pass to a
module pass, this solves this issue perfectly. Thanks for
your patience.</span></p>
<p><span><br>
</span></p>
<p><span>Best regards,</span></p>
<p>Zhengyang.</p>
</div>
<hr tabindex="-1">
<div id="x_divRplyFwdMsg" dir="ltr"><b>From:</b> Sanjoy Das
<a class="moz-txt-link-rfc2396E" href="mailto:sanjoy@playingwithpointers.com"><sanjoy@playingwithpointers.com></a><br>
<b>Sent:</b> Thursday, June 23, 2016 3:44:09 PM<br>
<b>To:</b> Zhengyang Liu<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] How can I make llvm intrinsic
functions declarations survive from optimizations.
<div> </div>
</div>
</div>
<span>
<div class="PlainText">Hi Zhengyang,<br>
<br>
Do you mind sharing _why_ you need the intrinsic declarations
to stay<br>
around? It is possible that there is a better way of solving
your<br>
problem.<br>
<br>
Thanks!<br>
-- Sanjoy<br>
</div>
</span>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
</body>
</html>