<div dir="ltr">Hi Ming Zhang,<div><br></div><div>If you don't want to rely on Clang reproducibility, you could save the IR into a .bc file. Clang can directly take a .bc file as input.</div><div><br></div><div>You then:</div><div>- instrument a copy of that .bc file and run your counting</div><div>- add control flow checking on an other copy of the original .bc file and you have your final binary</div><div><br></div><div>For the reproducibility, I think we try to preserve that, but sometime we lose it, you may have to specify <span style="color:rgb(0,0,0);white-space:pre-wrap">-frandom-seed.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 16, 2017 at 4:22 AM, 章明 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"><p>
        Hi, there,
</p>
<p>
        <br>
</p>
<p>
        I am working on a project on software control flow checking, which instruments a program to check if the control flow at runtime matches the control flow graph computed at compile-time.
</p>
<p>
        <br>
</p>
<p>
        My instrumentation process has to make use of control flow information, including as control flow graph and dominator/post-dominator trees, so it is better part of the compiler. On the other hand, I don't want any transformation pass to mess up the additional instrumentation code, so my instrumentation process has to be run after other transformation passes are complete. Therefore, I'd like to implement my instrumentation process as the last pass before the machine intermediate representation (MIR) is translated to native assembly code.
</p>
<p>
        <br>
</p>
<p>
        My instrumentation process also needs to take basic block execution frequencies into consideration. So I have to compile the same program twice. First, the program is compiled, adding code to collect execution frequencies. Then, when the execution frequencies have been collected, the same program is compiled again to add control flow checking instructions, which takes execution frequencies into consideration. Obviously, the program profiled to collect execution frequencies and the program instrumented with control flow checking instructions have to be consistent. At least, they have to have the same basic blocks and identical control flow graphs. So my question is this: If I compile the same program twice using Clang, with the same command line, is it guaranteed that, at the point right before the MIRs are converted to native assembly code, the MIRs are identical?
</p>
<p>
        <br>
</p>
<p>
        Thank you!
</p>
<p>
        <br>
</p>
<p>
        Ming Zhang
</p><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><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div>