<div dir="ltr"><div>Hi <span style="font-size:12.8px">Zhoulai, <br></span>The closest you can get is <a href="http://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs">http://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs</a></div>With this flavor of instrumentation the compiler inserts calls to __sanitizer_cov_trace_pc into the control flow. <div>The users (you) needs to define the function __sanitizer_cov_trace_pc and so you can call printf there. </div><div><br></div><div>By default, not all edges in the control flow are instrumented</div><div>This is an optimization, you can disable it by -mllvm -sanitizer-coverage-prune-blocks=0 </div><div><br></div><div>--kcc </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 12, 2016 at 11:46 AM, Zhoulai via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</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"><div>Hi, all<br><br>I want to instrument a program automatically so that
 it prints "hello" before each conditional statement. For example, 
consider the function P below.<br><br>    int P(int x) {<br>     if (x<3)<br>        if (x>0)<br>           return 1;<br>     return 0;<br>   }<br><br>Let P_instrum be the instrumented version of P.  It is expected that:<br><br>-- P_instrum(1)  prints two "hello"s <br>-- P_instrum(-1) prints one "hello"<br>-- P_instrum(5)  prints no "hello"<br> <br>From my understanding about <a href="http://clang.llvm.org/docs/SanitizerCoverage.html" target="_blank">Clang's sanitizer coverage,</a>
 we can use a sanitizer to achieve this instrumentation.  However, so 
far I have not found a working example or snippet code to get started. 
Any idea?<br><br></div>Thanks,<br clear="all"><br clear="all"><div><div data-smartmail="gmail_signature">Zhoulai</div></div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a 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>