<div dir="ltr">An Instruction /is/ its value - they aren't distinct things.<br><br>The loop you've written appears tautological - iterating a User's Uses and examining those Uses Users should produce the User you're iterating over in all cases. If there was a Use in a User's Uses that wasn't a Use by that User, that would seem to be broken as far as I understand.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 17, 2016 at 2:03 AM, Carlos Alba 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"><div><div><div><div><div>So, according to your explanation, do you think that it is possible to get the value produced by an instruction? something like the following (roughly):<br><br></div><div>for(auto operand : instruction->getOperandList())<br></div>      if( operand -> getUser == instruction ) <br>           return true;<br></div>      else<br></div>           continue;<br><br></div>Best,<br></div>Carlo<br><div><div><div><div><br></div></div></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 16, 2016 at 1:01 PM, Michael Kruse <span dir="ltr"><<a href="mailto:llvmdev@meinersbur.de" target="_blank">llvmdev@meinersbur.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>2016-02-16 10:24 GMT+01:00 Carlos Alba via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>:<br>
</span><span>> Hi everyone,<br>
><br>
> Instruction and Value classes have "Uses" and "User". What is the difference<br>
> between them?<br>
><br>
> I think that "Uses" gives all the instructions/values that a particular<br>
> Value depends on and "User" gives all the instructions/values that depend on<br>
> that particular value. Is that right?<br>
<br>
</span><div><div>Given as example the instruction %add in<br>
<br>
%add = add i32 %1, 1<br>
[...]<br>
%sub = sub i32 %add, 1<br>
<br>
You can think of an llvm::Use as a tuple (Instruction,ArgumentNo)<br>
Take for example the first argument of the add: (%add,0)<br>
Use::getUser() returns that Instruction (%add)<br>
Use::getOperandNo() returns that ArgumentNo (0)<br>
Use::get() returns the argument itself (%1); llvm::Use operator<br>
overloads may make the llvm::Use appear like it is the argument's<br>
llvm::Value itself<br>
<br>
add->operands() enumerates the llvm::Use(s), i.e. (%add,0) for the<br>
first argument (which is "%1") and (%add,1) for the second (which is<br>
"1")<br>
add->uses() enumerates where %add is used, i.e. (%sub,0) in this example.<br>
add->users() enumerates only the instructions which use %add, i.e.<br>
%sub in this example (without specifying the ArgumentNo)<br>
<br>
llvm::User is a base class of llvm::Instruction that implements the<br>
argument list mechanism (Lists of llvm::Value(s)).<br>
<br>
Hope that helps any corrections/additions are welcome.<br>
<br>
Michael<br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<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/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>