From 6e9b8f6d571a6b5c6bdb3d0c0576fb47fbe5a03d Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 29 Apr 2009 23:53:23 +0000 Subject: [PATCH] Use the new code gen optimization enum instead of passing in the optimization level. This is more expressive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70451 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/clang-cc/Backend.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/clang-cc/Backend.cpp b/tools/clang-cc/Backend.cpp index 078c7a1fb9..3fcf84cb7a 100644 --- a/tools/clang-cc/Backend.cpp +++ b/tools/clang-cc/Backend.cpp @@ -256,12 +256,20 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) { // FIXME: This is disabled right now until bugs can be worked out. Reenable // this for fast -O0 compiles! FunctionPassManager *PM = getCodeGenPasses(); - + CodeGenOpt::Level OptLevel = CodeGenOpt::Default; + + switch (CompileOpts.OptimizationLevel) { + default: break; + case 0: OptLevel = CodeGenOpt::None; break; + case 1: OptLevel = CodeGenOpt::One; break; + case 2: OptLevel = CodeGenOpt::Two; break; + case 3: OptLevel = CodeGenOpt::Aggressive; break; + } + // Normal mode, emit a .s file by running the code generator. // Note, this also adds codegenerator level optimization passes. switch (TM->addPassesToEmitFile(*PM, *AsmOutStream, - TargetMachine::AssemblyFile, - CompileOpts.OptimizationLevel)) { + TargetMachine::AssemblyFile, OptLevel)) { default: case FileModel::Error: Error = "Unable to interface with target machine!\n"; @@ -270,8 +278,7 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) { break; } - if (TM->addPassesToEmitFileFinish(*CodeGenPasses, 0, - CompileOpts.OptimizationLevel)) { + if (TM->addPassesToEmitFileFinish(*CodeGenPasses, 0, OptLevel)) { Error = "Unable to interface with target machine!\n"; return false; } -- 2.40.0