From d95e67dac029d48984b72889a96a1bb389b8ac71 Mon Sep 17 00:00:00 2001 From: Dylan Noblesmith Date: Thu, 1 Dec 2011 21:49:21 +0000 Subject: [PATCH] ExecutionEngine: honor optimization level It was getting ignored after r144788. Also fix an accidental implicit cast from the OptLevel enum to an optional bool argument. MSVC warned on this, but gcc didn't. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145633 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 1 + lib/ExecutionEngine/ExecutionEngine.cpp | 8 ++++---- lib/ExecutionEngine/JIT/JIT.cpp | 6 +++--- lib/ExecutionEngine/TargetSelect.cpp | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index cf85671eb41..2b5d61cba65 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -580,6 +580,7 @@ public: const SmallVectorImpl& MAttrs, Reloc::Model RM, CodeModel::Model CM, + CodeGenOpt::Level OL, std::string *Err); ExecutionEngine *create(); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 525877b6890..d94f5465121 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -420,7 +420,7 @@ ExecutionEngine *ExecutionEngine::create(Module *M, ExecutionEngine *ExecutionEngine::createJIT(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, - CodeGenOpt::Level OptLevel, + CodeGenOpt::Level OL, bool GVsWithCode, Reloc::Model RM, CodeModel::Model CMM) { @@ -437,10 +437,10 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, SmallVector MAttrs; TargetMachine *TM = - EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, RM, CMM, ErrorStr); + EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, RM, CMM, OL, ErrorStr); if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; - return ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel, GVsWithCode, TM); + return ExecutionEngine::JITCtor(M, ErrorStr, JMM, OL, GVsWithCode, TM); } ExecutionEngine *EngineBuilder::create() { @@ -467,7 +467,7 @@ ExecutionEngine *EngineBuilder::create() { if (WhichEngine & EngineKind::JIT) { if (TargetMachine *TM = EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, RelocModel, CMModel, - ErrorStr)) { + OptLevel, ErrorStr)) { if (UseMCJIT && ExecutionEngine::MCJITCtor) { ExecutionEngine *EE = ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel, diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index d773009065b..664e1ca69e6 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -288,7 +288,7 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji, // Turn the machine code intermediate representation into bytes in memory that // may be executed. - if (TM.addPassesToEmitMachineCode(PM, *JCE, OptLevel)) { + if (TM.addPassesToEmitMachineCode(PM, *JCE)) { report_fatal_error("Target does not support machine code emission!"); } @@ -341,7 +341,7 @@ void JIT::addModule(Module *M) { // Turn the machine code intermediate representation into bytes in memory // that may be executed. - if (TM.addPassesToEmitMachineCode(PM, *JCE, CodeGenOpt::Default)) { + if (TM.addPassesToEmitMachineCode(PM, *JCE)) { report_fatal_error("Target does not support machine code emission!"); } @@ -372,7 +372,7 @@ bool JIT::removeModule(Module *M) { // Turn the machine code intermediate representation into bytes in memory // that may be executed. - if (TM.addPassesToEmitMachineCode(PM, *JCE, CodeGenOpt::Default)) { + if (TM.addPassesToEmitMachineCode(PM, *JCE)) { report_fatal_error("Target does not support machine code emission!"); } diff --git a/lib/ExecutionEngine/TargetSelect.cpp b/lib/ExecutionEngine/TargetSelect.cpp index 45480a6d590..cf2d9ff5618 100644 --- a/lib/ExecutionEngine/TargetSelect.cpp +++ b/lib/ExecutionEngine/TargetSelect.cpp @@ -32,6 +32,7 @@ TargetMachine *EngineBuilder::selectTarget(Module *Mod, const SmallVectorImpl& MAttrs, Reloc::Model RM, CodeModel::Model CM, + CodeGenOpt::Level OL, std::string *ErrorStr) { Triple TheTriple(Mod->getTargetTriple()); if (TheTriple.getTriple().empty()) @@ -87,7 +88,7 @@ TargetMachine *EngineBuilder::selectTarget(Module *Mod, // Allocate a target... TargetMachine *Target = TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr, - RM, CM); + RM, CM, OL); assert(Target && "Could not allocate target machine!"); return Target; }