<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
The common use case I've seen for a black box like construct is when
writing microbenchmarks. In particular, you're generally looking
for a way to "sink" the result of a computation without having that
sink outweigh the cost of the thing you're trying to measure.<br>
<br>
Common alternate approaches are to use a volatile store (so that it
can't be eliminated or sunk out of loops) or a call to an external
function with a cheap calling convention. <br>
<br>
As an example:<br>
int a = 5; // initialization is not visible to compiler<br>
int b = 7;<br>
void add_two_globals()<br>
sink(a+b)<br>
}<br>
<br>
If what I'm look into is the code generation around addition, this
is a very useful way of testing the entire compiler - frontend,
middle end, and backend. <br>
<br>
I'll note that we use such a framework extensively. <br>
<br>
What I'm not clear on is why this needs to be an intrinsic. Why
does a call to an external function or a volatile store not
suffice? <br>
<br>
Philip<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 11/02/2015 07:16 PM, Daniel Berlin
via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:CAF4BwTVVcdMVV6EBuXivW+hoDYASyXASp7QnPOSL85zA2u4QNA@mail.gmail.com"
type="cite">
<div dir="ltr">I'm very unclear and why you think a generic black
box intrinsic will have any different performance impact ;-)
<div><br>
</div>
<div><br>
</div>
<div>I'm also unclear on what the goal with this intrinsic is.</div>
<div>I understand the symptoms you are trying to solve - what
exactly is the disease.</div>
<div><br>
</div>
<div>IE you say "</div>
<br class="">
<span style="font-size:12.8px">I'd like to propose a new
intrinsic for use in preventing optimizations from deleting IR
due to constant propagation, dead code elimination, etc."</span>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">But why are you trying to
achieve this goal?</span></div>
<div><span style="font-size:12.8px">Benchmarks that can be const
prop'd/etc away are often meaningless. Past that, if you
want to ensure a particular optimization does a particular
thing on a benchmark, ISTM it would be better to generate
the IR, run opt (or build your own pass-by-pass harness),
and then run "the passes you want on it" instead of "trying
to stop certain passes from doing things to it".</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Nov 2, 2015 at 5:23 PM, Richard
Diamond via llvm-dev <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a></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"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span class="">On Mon, Nov 2,
2015 at 7:19 PM, Sanjoy Das <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:sanjoy@playingwithpointers.com"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:sanjoy@playingwithpointers.com">sanjoy@playingwithpointers.com</a></a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Why
does this need to be an intrinsic (as opposed to
generic "unknown function" to llvm)?<br>
<br>
Secondly, have you looked into a volatile store /
load to an alloca? That should work with PNaCl and
WebAssembly.<br>
<br>
E.g.<br>
<br>
define i32 @blackbox(i32 %arg) {<br>
entry:<br>
%p = alloca i32<br>
store volatile i32 10, i32* %p ;; or store %arg<br>
%v = load volatile i32, i32* %p<br>
ret i32 %v<br>
}</blockquote>
<div><br>
</div>
</span>
<div>That volatility would have a negative performance
impact.</div>
</div>
<span class="HOEnZb"><font color="#888888"><br>
</font></span></div>
<span class="HOEnZb"><font color="#888888">
<div class="gmail_extra">Richard Diamond</div>
</font></span></div>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<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>
</body>
</html>