<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I'm not sure if I understand exactly what you would like to do, but I would imagine one could write a pass that looks for the pattern of "%x = load ... store %x ..." and insert a function call that logs the copy. I don't know of any existing analysis or utility code that you could build on to make it easy to do that, though.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">It might be helpful if there is an example of the annotations you have in mind.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 19, 2020 at 3:07 PM Matt Fysh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>Given a couple of lines of C++ code `int x = 42; int y = x`, we end up with the following LLVM IR instructions:</div><div><br></div><div>%x = alloca i32, align 4<br>%y = alloca i32, align 4<br></div><div>store i32 42, i32* %x, align 4<br>%0 = load i32, i32* %x, align 4<br>store i32 %0, i32* %y, align 4<br></div><div><br></div><div>Is it possible to instrument the IR to perform a value trace?</div><div><br></div><div>What I'd like to do is stream a log of memory copies (reads then writes), such that in this example, the final instruction will produce a log event along the lines of:</div><div>"COPY: Value at <address of x> copied to <address of y>"?</div><div><br></div><div>Essentially what I'd like to do is annotate particular values, so that when these same values are encountered again later in the program, I can retrieve the annotation. I will also need the annotation to survive copies, moves, etc. This could be considered a lightweight, parallel symbolic trace performed at runtime on a very small subset of program values.</div><div><br></div><div>I am hoping to implement this tooling at the LLVM IR level, so that it can be useful beyond C++, but if it's easier to instrument the CLang AST instead then I guess I can start there. Looking forward to your responses :)</div><div><br></div><div><br></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>