Index: tools/bugpoint/Miscompilation.cpp =================================================================== --- tools/bugpoint/Miscompilation.cpp +++ tools/bugpoint/Miscompilation.cpp @@ -226,18 +226,19 @@ /// function deletes both input modules before it returns. /// static Expected> -testMergedProgram(const BugDriver &BD, std::unique_ptr M1, - std::unique_ptr M2, bool &Broken) { - if (Linker::linkModules(*M1, std::move(M2))) +testMergedProgram(const BugDriver &BD, Module &M1, Module &M2, bool &Broken) { + // Resulting merge of M1 and M2. + auto Merged = CloneModule(&M1); + if (Linker::linkModules(*Merged, CloneModule(&M2))) // TODO: Shouldn't we thread the error up instead of exiting? exit(1); // Execute the program. - Expected Diff = BD.diffProgram(M1.get(), "", "", false); + Expected Diff = BD.diffProgram(Merged.get(), "", "", false); if (Error E = Diff.takeError()) return std::move(E); Broken = *Diff; - return std::move(M1); + return std::move(Merged); } /// TestFuncs - split functions in a Module into two groups: those that are @@ -335,9 +336,8 @@ // extraction. AbstractInterpreter *AI = BD.switchToSafeInterpreter(); bool Failure; - Expected> New = - testMergedProgram(BD, std::move(ToOptimizeLoopExtracted), - std::move(ToNotOptimize), Failure); + Expected> New = testMergedProgram( + BD, *ToOptimizeLoopExtracted, *ToNotOptimize, Failure); if (Error E = New.takeError()) return std::move(E); if (!*New) @@ -726,8 +726,7 @@ outs() << " Checking to see if the merged program executes correctly: "; bool Broken; - auto Result = - testMergedProgram(BD, std::move(Optimized), std::move(Safe), Broken); + auto Result = testMergedProgram(BD, *Optimized, *Safe, Broken); if (Error E = Result.takeError()) return std::move(E); if (auto New = std::move(*Result)) {