diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-17 18:05:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-17 18:05:35 +0000 |
commit | 782e60150eb9370a60fa51ed49bd23036588756a (patch) | |
tree | 48d4e79a3bc150efc8b9551c29b152fc1cdee1d6 /lib/Transforms/Utils/CloneModule.cpp | |
parent | c5d7d7c715f7b7a4eeea1ceaafefc3d1d6df2add (diff) |
Add a CloneModule call that exposes the mapping of values from the old module
to the new module. Patch provided by Nick Lewycky!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r-- | lib/Transforms/Utils/CloneModule.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp index a872551eea..229debf198 100644 --- a/lib/Transforms/Utils/CloneModule.cpp +++ b/lib/Transforms/Utils/CloneModule.cpp @@ -26,6 +26,14 @@ using namespace llvm; /// respectively) refer to the right globals. /// Module *llvm::CloneModule(const Module *M) { + // Create the value map that maps things from the old module over to the new + // module. + std::map<const Value*, Value*> ValueMap; + + return CloneModule(M, ValueMap); +} + +Module *llvm::CloneModule(const Module *M, std::map<const Value*, Value*> &ValueMap) { // First off, we need to create the new module... Module *New = new Module(M->getModuleIdentifier()); New->setEndianness(M->getEndianness()); @@ -44,10 +52,6 @@ Module *llvm::CloneModule(const Module *M) { for (Module::lib_iterator I = M->lib_begin(), E = M->lib_end(); I != E; ++I) New->addLibrary(*I); - // Create the value map that maps things from the old module over to the new - // module. - std::map<const Value*, Value*> ValueMap; - // Loop over all of the global variables, making corresponding globals in the // new module. Here we add them to the ValueMap and to the new Module. We // don't worry about attributes or initializers, they will come later. |