if (BugpointIsInterrupted) return MadeChange;
ValueToValueMapTy VMap;
- Module *ToNotOptimize = CloneModule(BD.getProgram(), VMap).release();
- Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
+ std::unique_ptr<Module> ToNotOptimize = CloneModule(BD.getProgram(), VMap);
+ Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize.get(),
MiscompiledFunctions,
VMap);
std::unique_ptr<Module> ToOptimizeLoopExtracted =
if (!ToOptimizeLoopExtracted) {
// If the loop extractor crashed or if there were no extractible loops,
// then this chapter of our odyssey is over with.
- delete ToNotOptimize;
delete ToOptimize;
return MadeChange;
}
AbstractInterpreter *AI = BD.switchToSafeInterpreter();
bool Failure;
Module *New = TestMergedProgram(BD, ToOptimizeLoopExtracted.get(),
- ToNotOptimize, false, Error, Failure);
+ ToNotOptimize.get(), false, Error, Failure);
if (!New)
return false;
errs() << " Continuing on with un-loop-extracted version.\n";
BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-tno.bc",
- ToNotOptimize);
+ ToNotOptimize.get());
BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to.bc",
ToOptimize);
BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to-le.bc",
errs() << "Please submit the "
<< OutputPrefix << "-loop-extract-fail-*.bc files.\n";
delete ToOptimize;
- delete ToNotOptimize;
return MadeChange;
}
delete ToOptimize;
// Clone modules, the tester function will free them.
std::unique_ptr<Module> TOLEBackup =
CloneModule(ToOptimizeLoopExtracted.get(), VMap);
- Module *TNOBackup = CloneModule(ToNotOptimize, VMap).release();
+ std::unique_ptr<Module> TNOBackup = CloneModule(ToNotOptimize.get(), VMap);
for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i)
MiscompiledFunctions[i] = cast<Function>(VMap[MiscompiledFunctions[i]]);
- Failure = TestFn(BD, ToOptimizeLoopExtracted.get(), ToNotOptimize, Error);
+ Failure =
+ TestFn(BD, ToOptimizeLoopExtracted.get(), ToNotOptimize.get(), Error);
if (!Error.empty())
return false;
ToOptimizeLoopExtracted = std::move(TOLEBackup);
- ToNotOptimize = TNOBackup;
+ ToNotOptimize = std::move(TNOBackup);
if (!Failure) {
outs() << "*** Loop extraction masked the problem. Undoing.\n";
MiscompiledFunctions.push_back(NewF);
}
- BD.setNewProgram(ToNotOptimize);
+ BD.setNewProgram(ToNotOptimize.release());
return MadeChange;
}
MiscompiledFunctions.push_back(NewF);
}
- BD.setNewProgram(ToNotOptimize);
+ BD.setNewProgram(ToNotOptimize.release());
MadeChange = true;
}
}