From f1f1a4f16128ffa2910f0b1d5c7052b3697f9fcd Mon Sep 17 00:00:00 2001 From: Tanya Lattner Date: Tue, 11 Oct 2011 00:24:54 +0000 Subject: Make it possible to use the linker without destroying the source module. This is so the source module can be linked to multiple other destination modules. For all that used LinkModules() before, they will continue to destroy the source module as before. This line, and those below, will be ignored-- M include/llvm/Linker.h M tools/bugpoint/Miscompilation.cpp M tools/bugpoint/BugDriver.cpp M tools/llvm-link/llvm-link.cpp M lib/Linker/LinkModules.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141606 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/bugpoint/BugDriver.cpp | 3 ++- tools/bugpoint/Miscompilation.cpp | 8 +++++--- tools/llvm-link/llvm-link.cpp | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index aa3e290636..677d17887f 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -127,7 +127,8 @@ bool BugDriver::addSources(const std::vector &Filenames) { outs() << "Linking in input file: '" << Filenames[i] << "'\n"; std::string ErrorMessage; - if (Linker::LinkModules(Program, M.get(), &ErrorMessage)) { + if (Linker::LinkModules(Program, M.get(), Linker::DestroySource, + &ErrorMessage)) { errs() << ToolName << ": error linking in '" << Filenames[i] << "': " << ErrorMessage << '\n'; return true; diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 422ab62d82..7ff16dbf95 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -222,7 +222,7 @@ static Module *TestMergedProgram(const BugDriver &BD, Module *M1, Module *M2, M1 = CloneModule(M1); M2 = CloneModule(M2); } - if (Linker::LinkModules(M1, M2, &ErrorMsg)) { + if (Linker::LinkModules(M1, M2, Linker::DestroySource, &ErrorMsg)) { errs() << BD.getToolName() << ": Error linking modules together:" << ErrorMsg << '\n'; exit(1); @@ -396,7 +396,8 @@ static bool ExtractLoops(BugDriver &BD, // Replace the current program with the loop extracted version, and try to // extract another loop. std::string ErrorMsg; - if (Linker::LinkModules(ToNotOptimize, ToOptimizeLoopExtracted, &ErrorMsg)){ + if (Linker::LinkModules(ToNotOptimize, ToOptimizeLoopExtracted, + Linker::DestroySource, &ErrorMsg)){ errs() << BD.getToolName() << ": Error linking modules together:" << ErrorMsg << '\n'; exit(1); @@ -575,7 +576,8 @@ static bool ExtractBlocks(BugDriver &BD, I->getFunctionType())); std::string ErrorMsg; - if (Linker::LinkModules(ProgClone, Extracted, &ErrorMsg)) { + if (Linker::LinkModules(ProgClone, Extracted, Linker::DestroySource, + &ErrorMsg)) { errs() << BD.getToolName() << ": Error linking modules together:" << ErrorMsg << '\n'; exit(1); diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 3fb7ba42cd..95ad1ca5a1 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -103,7 +103,8 @@ int main(int argc, char **argv) { if (Verbose) errs() << "Linking in '" << InputFilenames[i] << "'\n"; - if (Linker::LinkModules(Composite.get(), M.get(), &ErrorMessage)) { + if (Linker::LinkModules(Composite.get(), M.get(), Linker::DestroySource, + &ErrorMessage)) { errs() << argv[0] << ": link error in '" << InputFilenames[i] << "': " << ErrorMessage << "\n"; return 1; -- cgit v1.2.3