git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255084
91177308-0d34-0410-b5e6-
96231b3b80d8
//
void DeleteFunctionBody(Function *F);
//
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);
-
-/// 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.
ValueToValueMapTy &VMap) {
// Make sure functions & globals are all external so that linkage
// between the two modules will work.
}
ValueToValueMapTy NewVMap;
}
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;
// Remove the Test functions from the Safe module
std::set<Function *> TestFunctions;
// Make sure that there is a global ctor/dtor array in both halves of the
// module if they both have static ctor/dtor functions.
// 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);
+
// Split the module into the two halves of the program we want.
VMap.clear();
Module *ToNotOptimize = CloneModule(BD.getProgram(), VMap).release();
// 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);
// Run the predicate, note that the predicate will delete both input modules.
bool Broken = TestFn(BD, ToOptimize, ToNotOptimize, Error);
ValueToValueMapTy VMap;
std::unique_ptr<Module> ToNotOptimize = CloneModule(BD.getProgram(), VMap);
Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize.get(),
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) {
std::unique_ptr<Module> ToOptimizeLoopExtracted =
BD.extractLoop(ToOptimize);
if (!ToOptimizeLoopExtracted) {
VMap.clear();
Module *ToNotOptimize = CloneModule(BD.getProgram(), VMap).release();
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.
// 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.
ValueToValueMapTy VMap;
Module *ProgClone = CloneModule(BD.getProgram(), VMap).release();
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) {
std::unique_ptr<Module> Extracted =
BD.extractMappedBlocksFromModule(Blocks, ToExtract);
if (!Extracted) {
outs() << "Outputting reduced bitcode files which expose the problem:\n";
ValueToValueMapTy VMap;
Module *ToNotOptimize = CloneModule(getProgram(), VMap).release();
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);
outs() << " Non-optimized portion: ";
EmitProgressBitcode(ToNotOptimize, "tonotoptimize", true);
// Split the module into the two halves of the program we want.
ValueToValueMapTy VMap;
Module *ToNotCodeGen = CloneModule(getProgram(), VMap).release();
// 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);
// Condition the modules
CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen);