[llvm] r255079 - Simplify memory management a bit. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 16:08:23 PST 2015
Author: rafael
Date: Tue Dec 8 18:08:22 2015
New Revision: 255079
URL: http://llvm.org/viewvc/llvm-project?rev=255079&view=rev
Log:
Simplify memory management a bit. NFC.
Modified:
llvm/trunk/tools/bugpoint/Miscompilation.cpp
Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=255079&r1=255078&r2=255079&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Tue Dec 8 18:08:22 2015
@@ -321,7 +321,8 @@ static bool ExtractLoops(BugDriver &BD,
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.
@@ -339,7 +340,7 @@ static bool ExtractLoops(BugDriver &BD,
// 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;
@@ -363,7 +364,7 @@ static bool ExtractLoops(BugDriver &BD,
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";
@@ -376,17 +377,18 @@ static bool ExtractLoops(BugDriver &BD,
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) {
@@ -411,7 +413,6 @@ static bool ExtractLoops(BugDriver &BD,
MiscompiledFunctions.push_back(NewF);
}
- delete ToOptimizeLoopExtracted;
BD.setNewProgram(ToNotOptimize);
return MadeChange;
}
@@ -432,8 +433,6 @@ static bool ExtractLoops(BugDriver &BD,
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.
More information about the llvm-commits
mailing list