[llvm] r255084 - Return std::unique_ptr from SplitFunctionsOutOfModule. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 16:34:10 PST 2015
Author: rafael
Date: Tue Dec 8 18:34:10 2015
New Revision: 255084
URL: http://llvm.org/viewvc/llvm-project?rev=255084&view=rev
Log:
Return std::unique_ptr from SplitFunctionsOutOfModule. NFC.
Modified:
llvm/trunk/tools/bugpoint/BugDriver.h
llvm/trunk/tools/bugpoint/ExtractFunction.cpp
llvm/trunk/tools/bugpoint/Miscompilation.cpp
Modified: llvm/trunk/tools/bugpoint/BugDriver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/BugDriver.h?rev=255084&r1=255083&r2=255084&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/BugDriver.h (original)
+++ llvm/trunk/tools/bugpoint/BugDriver.h Tue Dec 8 18:34:10 2015
@@ -331,11 +331,11 @@ void DeleteGlobalInitializer(GlobalVaria
//
void DeleteFunctionBody(Function *F);
-/// SplitFunctionsOutOfModule - Given a module and a list of functions in the
-/// module, split the functions OUT of the specified module, and place them in
-/// the new module.
-Module *SplitFunctionsOutOfModule(Module *M, const std::vector<Function*> &F,
- ValueToValueMapTy &VMap);
+/// Given a module and a list of functions in the module, split the functions
+/// OUT of the specified module, and place them in the new module.
+std::unique_ptr<Module>
+SplitFunctionsOutOfModule(Module *M, const std::vector<Function *> &F,
+ ValueToValueMapTy &VMap);
} // End llvm namespace
Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=255084&r1=255083&r2=255084&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Tue Dec 8 18:34:10 2015
@@ -303,13 +303,8 @@ static void SplitStaticCtorDtor(const ch
}
}
-
-/// SplitFunctionsOutOfModule - Given a module and a list of functions in the
-/// module, split the functions OUT of the specified module, and place them in
-/// the new module.
-Module *
-llvm::SplitFunctionsOutOfModule(Module *M,
- const std::vector<Function*> &F,
+std::unique_ptr<Module>
+llvm::SplitFunctionsOutOfModule(Module *M, const std::vector<Function *> &F,
ValueToValueMapTy &VMap) {
// Make sure functions & globals are all external so that linkage
// between the two modules will work.
@@ -323,7 +318,7 @@ llvm::SplitFunctionsOutOfModule(Module *
}
ValueToValueMapTy NewVMap;
- Module *New = CloneModule(M, NewVMap).release();
+ std::unique_ptr<Module> New = CloneModule(M, NewVMap);
// Remove the Test functions from the Safe module
std::set<Function *> TestFunctions;
@@ -364,9 +359,9 @@ llvm::SplitFunctionsOutOfModule(Module *
// Make sure that there is a global ctor/dtor array in both halves of the
// module if they both have static ctor/dtor functions.
- SplitStaticCtorDtor("llvm.global_ctors", M, New, NewVMap);
- SplitStaticCtorDtor("llvm.global_dtors", M, New, NewVMap);
-
+ SplitStaticCtorDtor("llvm.global_ctors", M, New.get(), NewVMap);
+ SplitStaticCtorDtor("llvm.global_dtors", M, New.get(), NewVMap);
+
return New;
}
Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=255084&r1=255083&r2=255084&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Tue Dec 8 18:34:10 2015
@@ -280,8 +280,8 @@ bool ReduceMiscompilingFunctions::TestFu
// Split the module into the two halves of the program we want.
VMap.clear();
Module *ToNotOptimize = CloneModule(BD.getProgram(), VMap).release();
- Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, FuncsOnClone,
- VMap);
+ Module *ToOptimize =
+ SplitFunctionsOutOfModule(ToNotOptimize, FuncsOnClone, VMap).release();
// Run the predicate, note that the predicate will delete both input modules.
bool Broken = TestFn(BD, ToOptimize, ToNotOptimize, Error);
@@ -319,8 +319,8 @@ static bool ExtractLoops(BugDriver &BD,
ValueToValueMapTy VMap;
std::unique_ptr<Module> ToNotOptimize = CloneModule(BD.getProgram(), VMap);
Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize.get(),
- MiscompiledFunctions,
- VMap);
+ MiscompiledFunctions, VMap)
+ .release();
std::unique_ptr<Module> ToOptimizeLoopExtracted =
BD.extractLoop(ToOptimize);
if (!ToOptimizeLoopExtracted) {
@@ -519,9 +519,8 @@ bool ReduceMiscompiledBlocks::TestFuncs(
VMap.clear();
Module *ToNotOptimize = CloneModule(BD.getProgram(), VMap).release();
- Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
- FuncsOnClone,
- VMap);
+ Module *ToOptimize =
+ SplitFunctionsOutOfModule(ToNotOptimize, FuncsOnClone, VMap).release();
// Try the extraction. If it doesn't work, then the block extractor crashed
// or something, in which case bugpoint can't chase down this possibility.
@@ -580,9 +579,9 @@ static bool ExtractBlocks(BugDriver &BD,
ValueToValueMapTy VMap;
Module *ProgClone = CloneModule(BD.getProgram(), VMap).release();
- Module *ToExtract = SplitFunctionsOutOfModule(ProgClone,
- MiscompiledFunctions,
- VMap);
+ Module *ToExtract =
+ SplitFunctionsOutOfModule(ProgClone, MiscompiledFunctions, VMap)
+ .release();
std::unique_ptr<Module> Extracted =
BD.extractMappedBlocksFromModule(Blocks, ToExtract);
if (!Extracted) {
@@ -762,9 +761,9 @@ void BugDriver::debugMiscompilation(std:
outs() << "Outputting reduced bitcode files which expose the problem:\n";
ValueToValueMapTy VMap;
Module *ToNotOptimize = CloneModule(getProgram(), VMap).release();
- Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
- MiscompiledFunctions,
- VMap);
+ Module *ToOptimize =
+ SplitFunctionsOutOfModule(ToNotOptimize, MiscompiledFunctions, VMap)
+ .release();
outs() << " Non-optimized portion: ";
EmitProgressBitcode(ToNotOptimize, "tonotoptimize", true);
@@ -1038,7 +1037,8 @@ bool BugDriver::debugCodeGenerator(std::
// Split the module into the two halves of the program we want.
ValueToValueMapTy VMap;
Module *ToNotCodeGen = CloneModule(getProgram(), VMap).release();
- Module *ToCodeGen = SplitFunctionsOutOfModule(ToNotCodeGen, Funcs, VMap);
+ Module *ToCodeGen =
+ SplitFunctionsOutOfModule(ToNotCodeGen, Funcs, VMap).release();
// Condition the modules
CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen);
More information about the llvm-commits
mailing list