summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2013-03-13 21:18:46 +0000
committerLang Hames <lhames@gmail.com>2013-03-13 21:18:46 +0000
commita991b254f71173f3911be3b313b5304dd9b3b862 (patch)
tree2164b3011b5de9b5f7a80e5834c7643b8b157264 /tools
parentb91ce4fd9be6e4b7d7cf061c9569b67f2a90713e (diff)
Make LTO codegen use a PassManager, rather than a FunctionPassManager, for the
codegen passes. This brings it in to line with clang and llc's codegen setup, and tidies up the code. If I understand correctly, adding ModulePasses to a FunctionPassManager is bogus. It only seems to explode if an added ModulePass depends on a FunctionPass though, which might be why this code has survived so long. Fixes <rdar://problem/13386816>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 75705154e4..cf7ffe2800 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -390,14 +390,14 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
// Make sure everything is still good.
passes.add(createVerifierPass());
- FunctionPassManager *codeGenPasses = new FunctionPassManager(mergedModule);
+ PassManager codeGenPasses;
- codeGenPasses->add(new DataLayout(*_target->getDataLayout()));
- _target->addAnalysisPasses(*codeGenPasses);
+ codeGenPasses.add(new DataLayout(*_target->getDataLayout()));
+ _target->addAnalysisPasses(codeGenPasses);
formatted_raw_ostream Out(out);
- if (_target->addPassesToEmitFile(*codeGenPasses, Out,
+ if (_target->addPassesToEmitFile(codeGenPasses, Out,
TargetMachine::CGFT_ObjectFile)) {
errMsg = "target file type not supported";
return true;
@@ -407,15 +407,7 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
passes.run(*mergedModule);
// Run the code generator, and write assembly file
- codeGenPasses->doInitialization();
-
- for (Module::iterator
- it = mergedModule->begin(), e = mergedModule->end(); it != e; ++it)
- if (!it->isDeclaration())
- codeGenPasses->run(*it);
-
- codeGenPasses->doFinalization();
- delete codeGenPasses;
+ codeGenPasses.run(*mergedModule);
return false; // success
}