Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
MiscompiledFunctions,
VMap);
- Module *ToOptimizeLoopExtracted = BD.extractLoop(ToOptimize).release();
+ std::unique_ptr<Module> ToOptimizeLoopExtracted =
+ BD.extractLoop(ToOptimize);
if (!ToOptimizeLoopExtracted) {
// If the loop extractor crashed or if there were no extractible loops,
// then this chapter of our odyssey is over with.
// extraction.
AbstractInterpreter *AI = BD.switchToSafeInterpreter();
bool Failure;
- Module *New = TestMergedProgram(BD, ToOptimizeLoopExtracted,
+ Module *New = TestMergedProgram(BD, ToOptimizeLoopExtracted.get(),
ToNotOptimize, false, Error, Failure);
if (!New)
return false;
BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to.bc",
ToOptimize);
BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to-le.bc",
- ToOptimizeLoopExtracted);
+ ToOptimizeLoopExtracted.get());
errs() << "Please submit the "
<< OutputPrefix << "-loop-extract-fail-*.bc files.\n";
outs() << " Testing after loop extraction:\n";
// Clone modules, the tester function will free them.
- Module *TOLEBackup = CloneModule(ToOptimizeLoopExtracted, VMap).release();
+ std::unique_ptr<Module> TOLEBackup =
+ CloneModule(ToOptimizeLoopExtracted.get(), VMap);
Module *TNOBackup = CloneModule(ToNotOptimize, VMap).release();
for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i)
MiscompiledFunctions[i] = cast<Function>(VMap[MiscompiledFunctions[i]]);
- Failure = TestFn(BD, ToOptimizeLoopExtracted, ToNotOptimize, Error);
+ Failure = TestFn(BD, ToOptimizeLoopExtracted.get(), ToNotOptimize, Error);
if (!Error.empty())
return false;
- ToOptimizeLoopExtracted = TOLEBackup;
+ ToOptimizeLoopExtracted = std::move(TOLEBackup);
ToNotOptimize = TNOBackup;
if (!Failure) {
MiscompiledFunctions.push_back(NewF);
}
- delete ToOptimizeLoopExtracted;
BD.setNewProgram(ToNotOptimize);
return MadeChange;
}
diagnosticHandler))
exit(1);
- delete ToOptimizeLoopExtracted;
-
// All of the Function*'s in the MiscompiledFunctions list are in the old
// module. Update this list to include all of the functions in the
// optimized and loop extracted module.