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
This commit is contained in:
Lang Hames 2013-03-13 21:18:46 +00:00
parent b91ce4fd9b
commit a991b254f7

View File

@ -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
}