/// MayModifySemantics argument is true, then the cleanups is allowed to
/// modify how the code behaves.
///
- std::unique_ptr<Module> performFinalCleanups(Module *M,
+ std::unique_ptr<Module> performFinalCleanups(std::unique_ptr<Module> M,
bool MayModifySemantics = false);
/// Given a module, extract up to one loop from it into a new function. This
if (!BugpointIsInterrupted) {
outs() << "\n*** Attempting to perform final cleanups: ";
std::unique_ptr<Module> M = CloneModule(BD.getProgram());
- M = BD.performFinalCleanups(M.release(), true);
+ M = BD.performFinalCleanups(std::move(M), true);
// Find out if the pass still crashes on the cleaned up program...
if (M && TestFn(BD, M.get()))
}
std::unique_ptr<Module>
-BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
+BugDriver::performFinalCleanups(std::unique_ptr<Module> M,
+ bool MayModifySemantics) {
// Make all functions external, so GlobalDCE doesn't delete them...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
I->setLinkage(GlobalValue::ExternalLinkage);
else
CleanupPasses.push_back("deadargelim");
- std::unique_ptr<Module> New = runPassesOn(M, CleanupPasses);
+ std::unique_ptr<Module> New = runPassesOn(M.get(), CleanupPasses);
if (!New) {
errs() << "Final cleanups failed. Sorry. :( Please report a bug!\n";
return nullptr;
}
- delete M;
return New;
}
/// Get the specified modules ready for code generator testing.
///
-static void CleanupAndPrepareModules(BugDriver &BD,
- std::unique_ptr<Module> &Test,
- Module *Safe) {
+static std::unique_ptr<Module>
+CleanupAndPrepareModules(BugDriver &BD, std::unique_ptr<Module> Test,
+ Module *Safe) {
// Clean up the modules, removing extra cruft that we don't need anymore...
- Test = BD.performFinalCleanups(Test.get());
+ Test = BD.performFinalCleanups(std::move(Test));
// If we are executing the JIT, we have several nasty issues to take care of.
if (!BD.isExecutingJIT())
- return;
+ return Test;
// First, if the main function is in the Safe module, we must add a stub to
// the Test module to call into it. Thus, we create a new function `main'
errs() << "Bugpoint has a bug, which corrupted a module!!\n";
abort();
}
+
+ return Test;
}
/// This is the predicate function used to check to see if the "Test" portion of
static Expected<bool> TestCodeGenerator(BugDriver &BD,
std::unique_ptr<Module> Test,
std::unique_ptr<Module> Safe) {
- CleanupAndPrepareModules(BD, Test, Safe.get());
+ Test = CleanupAndPrepareModules(BD, std::move(Test), Safe.get());
SmallString<128> TestModuleBC;
int TestModuleFD;
SplitFunctionsOutOfModule(ToNotCodeGen.get(), *Funcs, VMap);
// Condition the modules
- CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen.get());
+ ToCodeGen =
+ CleanupAndPrepareModules(*this, std::move(ToCodeGen), ToNotCodeGen.get());
SmallString<128> TestModuleBC;
int TestModuleFD;