r227686 - [PM] Update Clang for the new LLVM API in r227685 for managing the
Chandler Carruth
chandlerc at gmail.com
Sat Jan 31 03:18:46 PST 2015
Author: chandlerc
Date: Sat Jan 31 05:18:46 2015
New Revision: 227686
URL: http://llvm.org/viewvc/llvm-project?rev=227686&view=rev
Log:
[PM] Update Clang for the new LLVM API in r227685 for managing the
TargetTransformInfo, and unify the code in a single place.
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=227686&r1=227685&r2=227686&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat Jan 31 05:18:46 2015
@@ -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(B
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;
More information about the cfe-commits
mailing list