[llvm-dev] Difference between “uses” and “user”
David Blaikie via llvm-dev
llvm-dev at lists.llvm.org
Wed Feb 17 08:11:48 PST 2016
An Instruction /is/ its value - they aren't distinct things.
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.
On Wed, Feb 17, 2016 at 2:03 AM, Carlos Alba via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> So, according to your explanation, do you think that it is possible to get
> the value produced by an instruction? something like the following
> for(auto operand : instruction->getOperandList())
> if( operand -> getUser == instruction )
> return true;
> On Tue, Feb 16, 2016 at 1:01 PM, Michael Kruse <llvmdev at meinersbur.de>
>> 2016-02-16 10:24 GMT+01:00 Carlos Alba via llvm-dev <
>> llvm-dev at lists.llvm.org>:
>> > Hi everyone,
>> > Instruction and Value classes have "Uses" and "User". What is the
>> > between them?
>> > I think that "Uses" gives all the instructions/values that a particular
>> > Value depends on and "User" gives all the instructions/values that
>> depend on
>> > that particular value. Is that right?
>> Given as example the instruction %add in
>> %add = add i32 %1, 1
>> %sub = sub i32 %add, 1
>> You can think of an llvm::Use as a tuple (Instruction,ArgumentNo)
>> Take for example the first argument of the add: (%add,0)
>> Use::getUser() returns that Instruction (%add)
>> Use::getOperandNo() returns that ArgumentNo (0)
>> Use::get() returns the argument itself (%1); llvm::Use operator
>> overloads may make the llvm::Use appear like it is the argument's
>> llvm::Value itself
>> add->operands() enumerates the llvm::Use(s), i.e. (%add,0) for the
>> first argument (which is "%1") and (%add,1) for the second (which is
>> add->uses() enumerates where %add is used, i.e. (%sub,0) in this example.
>> add->users() enumerates only the instructions which use %add, i.e.
>> %sub in this example (without specifying the ArgumentNo)
>> llvm::User is a base class of llvm::Instruction that implements the
>> argument list mechanism (Lists of llvm::Value(s)).
>> Hope that helps any corrections/additions are welcome.
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev