[LLVMdev] about llvm::use
dberlin at dberlin.org
Tue Mar 24 13:26:10 PDT 2015
On Tue, Mar 24, 2015 at 1:15 PM, Hui Zhang <wayne.huizhang at gmail.com> wrote:
> Hello, all
> I don't quite understand the llvm::use class, from the class ref, I read
> *"A Use <http://llvm.org/docs/doxygen/html/classllvm_1_1Use.html>
> represents the edge between a Value
> <http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html> definition and
> its users.This is notionally a two-dimensional linked list"*
> I can image that it's like an edge between the operand<->User, but how to
> comprehend the "two-dimensional linked list" ?
Dunno what that comment is getting at, other than it covers both the user
and the use itself.
(*Instruction derives from User that derives from Value*)
> And I found "use_iterator()" in Value, for example: a Value 'v', if it's
> an operand of many Instructions 'i1,i2,i3...', then in my understanding,
> uses of v are just i1, i2, i3...
no, they are the specific parts of i1, i2, i3 that refer to v.
> but what's the difference between use and user in this case ??
Use points directly to the *place in the User* that the Value appears
User is the *thing holding the Use*.
So here, i1, i2, i3 are *Users* of Value v. If you use the user_iterator,
that is what it will return
If i1, i2, i3 were looked at as just arrays of operands, like so:
i1 = [foo, v]
i2 = [v, foo]
i3 = [foo, v, bar]
Then the user iterator for v would give you i1, i2, and i3. Those are the
containers that have the use in them.
The use iterator for v will give you something that points to &i1,
&i2, &i3, because those are the actual pointers to the use in those
Thus, if call setUse on a use, you are *actually changing that specific use
There is no setUser.
> Besides, if the Value 'v' here is itself an Instruction, then what are its
> 'uses' and 'users' ??
> I feel that the result of an instruction can be an operand of another
> instruction, but it should not be regarded as the instruction itself right
> Very confused...hope I can get some help to clarify my thoughts....
> Best regards
> Hui Zhang
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev