From: Misha Brukman
Frequently, we might have an instance of the Value Class and we want to determine which -Users use the Value. The list of all Users of a -particular Value is called a def-use chain. For example, let's -say we have a Function* named F to a particular function -foo. Finding all of the instructions that use foo is as -simple as iterating over the def-use chain of F:
+href="/doxygen/structllvm_1_1Value.html">Value Class and we want to +determine which Users use the Value. The list of all +Users of a particular Value is called a def-use chain. +For example, let's say we have a Function* named F to a +particular function foo. Finding all of the instructions that +use foo is as simple as iterating over the def-use chain +of F:Function* F = ...;
for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) {
if (Instruction *Inst = dyn_cast<Instruction>(*i)) {
cerr << "F is used in instruction:\n";
cerr << *Inst << "\n";
}
}
Alternately, it's common to have an instance of the User Class and need to know what +href="/doxygen/classllvm_1_1User.html">User Class and need to know what Values are used by it. The list of all Values used by a User is known as a use-def chain. Instances of class Instruction are common Users, so we might want to iterate over @@ -912,8 +913,8 @@ and ReplaceInstWithInst.
You can use Value::replaceAllUsesWith and User::replaceUsesOfWith to change more than one use at a time. See the -doxygen documentation for the Value Class -and User Class, respectively, for more +doxygen documentation for the Value Class +and User Class, respectively, for more information.