<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 10/31/13 8:42 AM, Feng Lu wrote:<br>
</div>
<blockquote
cite="mid:CANC70pytL1LYOJFd_gzDOxFNzZ1FdMPEu2d9BGaan9LgFcGBsw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">
<div>Hi, all,</div>
<div> I am new to LLVM and Clang,</div>
<div> I am interested in the following problem:</div>
<div> Given a function with parameters, obtain the part of
parameters which are used in branch conditions within the
function or sub-functions. </div>
<div> </div>
<div>For the following example, I hope to get v.c1</div>
<div> struct p {</div>
<div> int c1,</div>
<div> int c2</div>
<div> };</div>
<div> void foo (p v) {</div>
<div> if (v.c1) </div>
<div> ...</div>
<div> else</div>
<div> ...</div>
<div> }</div>
<div> </div>
<div>Does LLVM or Clang contains the code that could easily
achieve this efficiently?</div>
</div>
</blockquote>
<br>
For scalar function arguments, you can just follow the explict
def-use chains in the LLVM IR. See the Value::use_begin() and
Value::use_end() methods in the doxygen documentation:
<a class="moz-txt-link-freetext" href="http://llvm.org/doxygen/classllvm_1_1Value.html">http://llvm.org/doxygen/classllvm_1_1Value.html</a>.<br>
<br>
For values that live in or escape into memory, the problem is
trickier: you need to do classical Kam-Ullman data flow analysis
(specifically, reaching definitions analysis), and you'll need to
deal with aliasing of pointers. LLVM does not currently have an
analysis for this, as far as I know.<br>
<br>
Of course, all of this gets even more complicated if you're doing it
inter-procedurally or want to take into account external library
code.<br>
<br>
-- John T.<br>
<br>
<br>
<br>
<blockquote
cite="mid:CANC70pytL1LYOJFd_gzDOxFNzZ1FdMPEu2d9BGaan9LgFcGBsw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div> </div>
<div>Thanks,</div>
<div>Feng Lu</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>