<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 2/8/16 10:54 AM, Mohammad Norouzi
wrote:<br>
</div>
<blockquote
cite="mid:CAFVz=BU95QWG1hcAdDwe0BwA7UoQ=0H0_N74BCTSr+h8HHgUkQ@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<div dir="ltr"><br>
<div class="gmail_extra"><span class=""></span>
<div class="gmail_quote">
<blockquote class="gmail_quote">
<div><span class="">
<blockquote type="cite">
<div dir="ltr">
<div>Hi,<br>
<br>
I need to check if a variable belongs to the
program originally. Consider the following code
line:<br>
<br>
</div>
<div>y = x + 4<br>
</div>
<div><br>
and its corresponding llvm ir (roughly):<br>
<br>
%16 = load i32 %x<br>
%add = add i32 %16, i32 4<br>
</div>
store i32 %add, %y<br>
<div> <br>
I need to distinguish between %16, %add and %x,
%y. <br>
</div>
</div>
</blockquote>
<br>
</span> You might be able to use the Debug information
embedded within the LLVM IR to determine what is an
original variable and what is a temporary added by
LLVM. However, I think that such an approach is
fragile.<br>
</div>
</blockquote>
<div><br>
</div>
<div>yes, Debug info provides lots of useful info and i
think there should be sth about this case. But I don't
know which api or method does this. <br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
Look at the Doxygen documentation on the LLVM web site for
documentation on the Value and Instruction classes. They probably
have methods for retrieving the Debug Metadata (and if they don't,
one of their subclasses/superclasses does). You can search through
the LLVM source code for examples as well, plus I think there's a
document that describes the format of the LLVM Debug Metadata on the
LLVM web page.<br>
<br>
<blockquote
cite="mid:CAFVz=BU95QWG1hcAdDwe0BwA7UoQ=0H0_N74BCTSr+h8HHgUkQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div> </div>
<blockquote class="gmail_quote">
<div> <br>
It sounds like you need to be analyzing Clang ASTs
instead of LLVM IR. The Clang AST represents a program
in its original source form, so you can tell what is a
program variable, in what file it was defined, its
original source type, etc.<br>
</div>
</blockquote>
<div><br>
</div>
<div>I'm not sure about Clang ASTs but this is part of an
llvm pass which analyzes llvm IR. So, i doubt if i can use
Clang AST.<br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
Why are you restricted to using LLVM IR?<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<blockquote
cite="mid:CAFVz=BU95QWG1hcAdDwe0BwA7UoQ=0H0_N74BCTSr+h8HHgUkQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div><br>
</div>
<div>Best,<br>
</div>
<div>Mohammad<br>
</div>
<div> </div>
<blockquote class="gmail_quote">
<div> <br>
Regards,<br>
<br>
John Criswell<br>
<br>
<blockquote type="cite"><span class="">
<div dir="ltr">
<div> <br>
Any help is appreciated.<br>
<br>
Best,<br>
Mohammad</div>
</div>
<br>
<fieldset></fieldset>
<br>
</span>
<pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a moz-do-not-send="true" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><span class="">
</span></pre>
<span class=""> </span></blockquote>
<span class=""> <br>
<br>
<pre cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a moz-do-not-send="true" href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
</span></div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
</body>
</html>