Index: include/llvm/Transforms/Utils/Cloning.h =================================================================== --- include/llvm/Transforms/Utils/Cloning.h +++ include/llvm/Transforms/Utils/Cloning.h @@ -40,6 +40,7 @@ class Function; class Instruction; class InvokeInst; +class LLVMContext; class Loop; class LoopInfo; class Module; @@ -58,6 +59,11 @@ CloneModule(const Module *M, ValueToValueMapTy &VMap, function_ref ShouldCloneDefinition); +std::unique_ptr +CloneModule(const Module *M, ValueToValueMapTy &VMap, + function_ref ShouldCloneDefinition, + LLVMContext &Context); + /// ClonedCodeInfo - This struct can be used to capture information about code /// being cloned, while it is being cloned. struct ClonedCodeInfo { Index: lib/Transforms/Utils/CloneModule.cpp =================================================================== --- lib/Transforms/Utils/CloneModule.cpp +++ lib/Transforms/Utils/CloneModule.cpp @@ -48,9 +48,16 @@ std::unique_ptr llvm::CloneModule( const Module *M, ValueToValueMapTy &VMap, function_ref ShouldCloneDefinition) { + return CloneModule(M, VMap, ShouldCloneDefinition, M->getContext()); +} + +std::unique_ptr llvm::CloneModule( + const Module *M, ValueToValueMapTy &VMap, + function_ref ShouldCloneDefinition, + LLVMContext &Context) { // First off, we need to create the new module. std::unique_ptr New = - llvm::make_unique(M->getModuleIdentifier(), M->getContext()); + llvm::make_unique(M->getModuleIdentifier(), Context); New->setDataLayout(M->getDataLayout()); New->setTargetTriple(M->getTargetTriple()); New->setModuleInlineAsm(M->getModuleInlineAsm());