From aab5ec078e92c0c8b4db80dfb10a4adf21a00c85 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 31 Jan 2015 11:18:46 +0000 Subject: [PATCH] [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 --- clang/lib/CodeGen/BackendUtil.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 702383572cc6..6df34af86e76 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -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;