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 | 2e266807c36cb8d489e176b44010407b911d5797 (patch) | |
tree | f8dc95fb893fe6a8764f884f5d4ce54fda4a728e /llvm/lib/Transforms/Utils/CloneModule.cpp | |
parent | 62f1b83c0e069dd94c0783b2d5ee0b90b09553ef (diff) | |
download | bcm5719-llvm-2e266807c36cb8d489e176b44010407b911d5797.tar.gz bcm5719-llvm-2e266807c36cb8d489e176b44010407b911d5797.zip |
Add a CloneModule call that exposes the mapping of values from the old module
to the new module. Patch provided by Nick Lewycky!
llvm-svn: 28349
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneModule.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index a872551eeae..229debf1980 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/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. |