<div dir="ltr">It depends on what you're trying to do.<div><br></div><div>If you're just looking for "*d = *c" as a source-level pattern, then clang's AST will be your best bet. You may find ASTMatchers to be highly useful. If you're new to working with clang, writing simple programs and "compiling" them with `clang -cc1 -ast-dump my_program_name.c` will give you a very detailed picture of what the AST for my_program_name.c looks like.<div><br></div><div>If you want to find all of the places in a program that can store to some arbitrary memory location pointed to by `d`, you need to work with LLVM IR. And good luck, because that's a really difficult problem to solve. :)</div><div><br></div><div>George</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 27, 2016 at 7:30 PM, Kai Wang 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">Hi all,<div>In my case, I want to find all assignment instructions for pointer variables.</div><div>For example,</div><div>int *d, *c;</div><div>*d = *c;</div><div><br></div><div>I want to know there is an assignment between *d and *c.</div><div><br></div><div>Here is the IR:</div><div>







<p><span>%3 = load i32** %c, align</span></p><p><span>%4 = load i32* %3, align </span><span>4</span></p>
<p><span> </span><span>%5 = load i32** %d, align </span><span>8</span></p>
<p><span> </span><span>store i32 %4, i32* %5, align </span><span>4</span></p></div><div><div>There are some temp variable %3, %4, %5. Is there any way to find the assignment "*d = *c" from IR?</div><div>Or should I look into clang AST?</div><div><br></div><div>Thank you.</div><span><font color="#888888">-- <br><div><div dir="ltr">Regards,<div>Kai</div></div></div>
</font></span></div></div>
<br>_______________________________________________<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="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></div>