<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<div class="moz-cite-prefix">On 09/16/2017 06:49 PM, Sean Silva via
llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:CAHnXoa=csMur4gywVDp-kUV0b=CTCmJSh411h1zu3DDxzAxCaw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="auto">Actually maybe something like:
<div dir="auto"><br>
</div>
<div dir="auto">if (auto &E = ORE.emitMissed(DEBUG_TYPE)) {</div>
<div dir="auto"> E.emit(...) << ...;</div>
<div dir="auto">}</div>
<div dir="auto"><br>
</div>
<div dir="auto">Credit to Chandler for that (if I'm remembering
it right. This is vaguely recollected from a LLVM social
conversation a long time ago about reducing overhead of clang
diagnostics that are not enabled, which sounds like the same
problem)<br>
</div>
</div>
</blockquote>
<br>
This also seems like a good option.<br>
<br>
-Hal<br>
<br>
<blockquote
cite="mid:CAHnXoa=csMur4gywVDp-kUV0b=CTCmJSh411h1zu3DDxzAxCaw@mail.gmail.com"
type="cite">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sep 16, 2017 4:39 PM, "Sean Silva"
<<a moz-do-not-send="true"
href="mailto:chisophugis@gmail.com">chisophugis@gmail.com</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto">
<div dir="auto">Another alternative could be:</div>
<div dir="auto"><br>
</div>
<div dir="auto">ORE.emitMissed(DEBUG_TYPE, ...) <<
...</div>
<div dir="auto"><br>
</div>
<div dir="auto">Then the first line of emitMissed does a
check if it is enabled and if not then returns a dummy
stream that does nothing for operator<< (and
short-circuits all the stream operations)</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sep 15, 2017 2:21 PM, "Adam
Nemet via llvm-dev" <<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>
wrote:<br type="attribution">
<blockquote class="m_-4736550687993114039quote"
style="margin:0 0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div style="word-wrap:break-word">For better
readability we typically create remarks and call
OptimizationRemarkEmitter::emi<wbr>t unconditionally.
E.g.:
<div>
<div><br>
</div>
<div>
<div>Transforms/IPO/Inliner.cpp:
ORE.emit(OptimizationRemarkMi<wbr>ssed(DEBUG_TYPE,
"TooCostly", Call)</div>
<div>Transforms/IPO/Inliner.cpp-
<< NV("Callee", Callee) << " not
inlined into "</div>
<div>Transforms/IPO/Inliner.cpp-
<< NV("Caller", Caller) << "
because too costly to inline (cost="</div>
<div>Transforms/IPO/Inliner.cpp-
<< NV("Cost", IC.getCost())</div>
<div>Transforms/IPO/Inliner.cpp-
<< ", threshold=" <<
NV("Threshold", IC.getThreshold()) <<
")");</div>
</div>
<div><br>
</div>
<div>Then inside ORE we return right away if the
remarks for the given pass is not enabled.
<div><br>
</div>
<div>This is nice and concise however there is
still some overhead involved in this if
remarks are not enabled:</div>
<div><br>
</div>
<div>1. Constructing the remark object</div>
<div>2. Computing and inserting the strings,
named-value arguments</div>
</div>
<div>3. Performing the comparison between the pass
name and the passes enabled by the user</div>
<div>4. Virtual destructor</div>
<div><br>
</div>
<div>Now that Vivek added support for asking
LLVMContext for what remarks are enabled by the
user [1] we can improve this. The idea is to
allow ORE::emit to take a closure. This delays
all this work until we know remarks are
enabled. E.g. the above code with closure:</div>
<div><br>
</div>
<div>
<div> ORE.emit(<b>[&]() {</b></div>
<div> <b>return</b>
OptimizationRemarkMissed(DEBUG<wbr>_TYPE,
"TooCostly", Call)</div>
<div> << NV("Callee", Callee)
<< " not inlined into "</div>
<div> << NV("Caller", Caller)
<< " because too costly to inline
(cost="</div>
<div> << NV("Cost",
IC.getCost())</div>
<div> << ", threshold="
<< NV("Threshold", IC.getThreshold())
<< ")"<b>;</b></div>
<div><b> }</b>);</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>I have a proof-of-concept implementation at <a
moz-do-not-send="true"
href="https://reviews.llvm.org/D37921"
target="_blank">https://reviews.llvm.org/D3<wbr>7921</a>.</div>
<div> </div>
<div>The main change is that since in the lambda
the remark is now returned by value, we need to
preserve its type in the insertion operator.
This requires making the insertion operator
generic. I am also curious if people see C++
portability problems with the code.</div>
<div><br>
</div>
<div>Feedback welcome.</div>
<div><br>
</div>
<div>Adam</div>
<div><br>
</div>
<div>[1] <a moz-do-not-send="true"
href="https://reviews.llvm.org/D33514"
target="_blank">https://reviews.llvm.org/D<wbr>33514</a></div>
</div>
<div><br>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org"
target="_blank">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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
</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>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>