From 6c01383118f3a569dbb4c589f5092a7d6c03ab0f Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 23 Oct 2006 23:12:26 +0000 Subject: [PATCH] Add removeModule(). llvm-svn: 31142 --- llvm/include/llvm/LinkTimeOptimizer.h | 2 ++ llvm/tools/lto/lto.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/llvm/include/llvm/LinkTimeOptimizer.h b/llvm/include/llvm/LinkTimeOptimizer.h index 654623adff85..6c58706cf93b 100644 --- a/llvm/include/llvm/LinkTimeOptimizer.h +++ b/llvm/include/llvm/LinkTimeOptimizer.h @@ -91,6 +91,7 @@ namespace llvm { std::vector &, std::string &) = 0; virtual void getTargetTriple(const std::string &, std::string &) = 0; + virtual void removeModule (const std::string &InputFilename) = 0; virtual ~LinkTimeOptimizer() = 0; }; @@ -111,6 +112,7 @@ namespace llvm { std::vector &exportList, std::string &targetTriple); void getTargetTriple(const std::string &InputFilename, std::string &targetTriple); + void removeModule (const std::string &InputFilename); private: Module *getModule (const std::string &InputFilename); diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index c4face2712ab..b9d76d67381a 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -102,6 +102,18 @@ findExternalRefs(Value *value, std::set &references, findExternalRefs(c->getOperand(i), references, mangler); } +/// If Moduel with InputFilename is available then remove it. +void +LTO::removeModule (const std::string &InputFilename) +{ + NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str()); + if (pos != allModules.end()) { + Module *m = allModules[InputFilename.c_str()]; + allModules.erase(pos); + delete m; + } +} + /// InputFilename is a LLVM bytecode file. If Module with InputFilename is /// available then return it. Otherwise parseInputFilename. Module *