Reputation: 1406
On the context of cloning functions, one of the used objects is the ValueToValueMapTy &VMap
which is a typedef
ofValueMap<const Value *, WeakVH>
.
For example, it is used during cloneFunctionInto(...)
in llvm/lib/Transforms/Utils/CloneFunction.cpp
Thus I have questions that will help me clarify its purpose:
llvm::Value
has its on VMap? Or this only belongs to Functions or Modules or what?llvm::Values
of the function?ps.:
I have already checked those links that may be helpful to others asking questions on Vmap, but none of them could completely answer my questions.
What to pass for the vmap argument of CloneFunction in llvm?
Filling the LLVM CloneFunction VMAP
Upvotes: 2
Views: 1698
Reputation: 589
Purpose of the ValueMap in CloneFunction is to record the mapping from values in the source function to values in the cloned function.
Example:
Function *F;
Value *V = /* some register in F */;
ValueToValueMapTy VMap;
auto *Clone = CloneFunction(F, VMap);
// V2 represents essentially the same register as V,
// except it's in Clone instead of F
Value *V2 = VMap[V];
Upvotes: 5