[PM] Update Clang for the new LLVM API in r227685 for managing the

TargetTransformInfo, and unify the code in a single place.

llvm-svn: 227686
This commit is contained in:
Chandler Carruth 2015-01-31 11:18:46 +00:00
parent 93dcdc47db
commit aab5ec078e

View File

@ -16,6 +16,7 @@
#include "clang/Frontend/Utils.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/CodeGen/SchedulerRegistry.h"
@ -60,12 +61,18 @@ class EmitAssemblyHelper {
mutable FunctionPassManager *PerFunctionPasses;
private:
TargetTransformInfo getTTI() const {
if (TM)
return TM->getTTI();
return TargetTransformInfo(TheModule->getDataLayout());
}
PassManager *getCodeGenPasses() const {
if (!CodeGenPasses) {
CodeGenPasses = new PassManager();
CodeGenPasses->add(new DataLayoutPass());
if (TM)
TM->addAnalysisPasses(*CodeGenPasses);
CodeGenPasses->add(createTargetTransformInfoWrapperPass(getTTI()));
}
return CodeGenPasses;
}
@ -74,8 +81,7 @@ private:
if (!PerModulePasses) {
PerModulePasses = new PassManager();
PerModulePasses->add(new DataLayoutPass());
if (TM)
TM->addAnalysisPasses(*PerModulePasses);
PerModulePasses->add(createTargetTransformInfoWrapperPass(getTTI()));
}
return PerModulePasses;
}
@ -84,8 +90,7 @@ private:
if (!PerFunctionPasses) {
PerFunctionPasses = new FunctionPassManager(TheModule);
PerFunctionPasses->add(new DataLayoutPass());
if (TM)
TM->addAnalysisPasses(*PerFunctionPasses);
PerFunctionPasses->add(createTargetTransformInfoWrapperPass(getTTI()));
}
return PerFunctionPasses;
}
@ -547,9 +552,6 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
createTLII(TargetTriple, CodeGenOpts));
PM->add(new TargetLibraryInfoWrapperPass(*TLII));
// Add Target specific analysis passes.
TM->addAnalysisPasses(*PM);
// Normal mode, emit a .s or .o file by running the code generator. Note,
// this also adds codegenerator level optimization passes.
TargetMachine::CodeGenFileType CGFT = TargetMachine::CGFT_AssemblyFile;