Since Instruction derived from Value , it inherits both the users and uses functions. The difference is that the Value user has Value as one of his operands.
When you call uses , you get a list of all Use instances containing a link from Value for each of the users of a particular Value . Calling users gives you a list of User directly. The following code shows how to use users and uses .
for(auto U : V->users()){ // U is of type User* if (auto I = dyn_cast<Instruction>(U)){ // an instruction uses V } }
You can see users as a shortcut because you can do the same using:
for(auto U : V->uses()){ // U is of type Use* if (auto I = dyn_cast<Instruction>(U.getUser())){ // an instruction uses V } }
It is usually sufficient to use users to get all the dependencies of a Value .
All values used by Value are operands. This direction of the dependency is not included in the list of use of Value .
To the second question regarding instructions giving meaning: there is no guarantee that lack of use will result in it not producing meaning. Dead instruction can be meaningful and has no users. In addition, a non-producing entity may be used in metadata.
source share