After cloning a Module with CloneModule, there doesn't seem to be any easy way to convert a Value pointing into the old Module to a Value pointing into the new one. The CloneModule implementation already has to keep such a mapping internally, so I've written a patch that exposes it as a second inout parameter to CloneModule(), with the one param version being a simple wrapper for backward compatibility. The type of ValueMap is std::map<const Value *, Value*> and the semantics are simply: Value *New = ValueMap[Old]; Nick Lewycky -------------- next part -------------- A non-text attachment was scrubbed... Name: clonemodule.patch Type: text/x-patch Size: 2138 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060515/019a9326/attachment.bin>
On Mon, 15 May 2006, Nick Lewycky wrote:> After cloning a Module with CloneModule, there doesn't seem to be any > easy way to convert a Value pointing into the old Module to a Value > pointing into the new one.Sorry for the delay, your patch looks great, applied! http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20060515/034896.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20060515/034897.html -Chris> The CloneModule implementation already has to keep such a mapping > internally, so I've written a patch that exposes it as a second inout > parameter to CloneModule(), with the one param version being a simple > wrapper for backward compatibility. > > The type of ValueMap is std::map<const Value *, Value*> and the > semantics are simply: > Value *New = ValueMap[Old]; > > Nick Lewycky >-Chris -- http://nondot.org/sabre/ http://llvm.org/
Maybe Matching Threads
- [LLVMdev] Cloning Functions
- [LLVMdev] Hit assert(I != ValueMap.end() && "Value not in slotcalculator!") in ValueEnumerator.cpp
- [LLVMdev] Cloning Functions
- Handling of metadata in llvm::CloneModule
- [LLVMdev] patch: CloneModule resets GlobalVariable address space