diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-03-14 10:51:38 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-03-14 10:51:38 +0000 |
commit | 647735c781c5b37061ee03d6e9e6c7dda92218e2 (patch) | |
tree | 5a5e56606d41060263048b5a5586b3d2380898ba /tools/opt/opt.cpp | |
parent | 6aed25d93d1cfcde5809a73ffa7dc1b0d6396f66 (diff) | |
parent | f635ef401786c84df32090251a8cf45981ecca33 (diff) |
Updating branches/google/stable to r176857
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@177040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r-- | tools/opt/opt.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 8e88e3aee2..81a2de2d55 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -12,23 +12,23 @@ // //===----------------------------------------------------------------------===// -#include "llvm/LLVMContext.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/Analysis/CallGraphSCCPass.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/RegionPass.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CallGraphSCCPass.h" #include "llvm/CodeGen/CommandFlags.h" -#include "llvm/DataLayout.h" #include "llvm/DebugInfo.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/Module.h" +#include "llvm/LinkAllIR.h" #include "llvm/LinkAllPasses.h" -#include "llvm/LinkAllVMCore.h" #include "llvm/MC/SubtargetFeature.h" -#include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Support/Debug.h" #include "llvm/Support/IRReader.h" @@ -523,16 +523,11 @@ CodeGenOpt::Level GetCodeGenOptLevel() { } // Returns the TargetMachine instance or zero if no triple is provided. -static TargetMachine* GetTargetMachine(std::string TripleStr) { - if (TripleStr.empty()) - return 0; - - // Get the target specific parser. +static TargetMachine* GetTargetMachine(Triple TheTriple) { std::string Error; - Triple TheTriple(Triple::normalize(TargetTriple)); - const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, Error); + // Some modules don't specify a triple, and this is okay. if (!TheTarget) { return 0; } @@ -572,6 +567,7 @@ int main(int argc, char **argv) { PassRegistry &Registry = *PassRegistry::getPassRegistry(); initializeCore(Registry); initializeScalarOpts(Registry); + initializeObjCARCOpts(Registry); initializeVectorization(Registry); initializeIPO(Registry); initializeAnalysis(Registry); @@ -655,11 +651,15 @@ int main(int argc, char **argv) { if (TD) Passes.add(TD); - std::auto_ptr<TargetMachine> TM(GetTargetMachine(TargetTriple)); - if (TM.get()) { - Passes.add(new TargetTransformInfo(TM->getScalarTargetTransformInfo(), - TM->getVectorTargetTransformInfo())); - } + Triple ModuleTriple(M->getTargetTriple()); + TargetMachine *Machine = 0; + if (ModuleTriple.getArch()) + Machine = GetTargetMachine(Triple(ModuleTriple)); + std::auto_ptr<TargetMachine> TM(Machine); + + // Add internal analysis passes from the target machine. + if (TM.get()) + TM->addAnalysisPasses(Passes); OwningPtr<FunctionPassManager> FPasses; if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) { |