From: Lang Hames Date: Tue, 9 Jun 2015 02:43:27 +0000 (+0000) Subject: [lli] Make the OptLevel (-O=) option accessible to the lazy JIT. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=657c697363dd19265cb784612220628865d0e3d8;p=oota-llvm.git [lli] Make the OptLevel (-O=) option accessible to the lazy JIT. No test case - this only affects generated code performance. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239383 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/lli/OrcLazyJIT.cpp b/tools/lli/OrcLazyJIT.cpp index bda5d6dcd26..afccfa6b032 100644 --- a/tools/lli/OrcLazyJIT.cpp +++ b/tools/lli/OrcLazyJIT.cpp @@ -108,6 +108,9 @@ OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() { llvm_unreachable("Unknown DumpKind"); } +// Defined in lli.cpp. +CodeGenOpt::Level getOptLevel(); + int llvm::runOrcLazyJIT(std::unique_ptr M, int ArgC, char* ArgV[]) { // Add the program's symbols into the JIT's search space. if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) { @@ -117,7 +120,9 @@ int llvm::runOrcLazyJIT(std::unique_ptr M, int ArgC, char* ArgV[]) { // Grab a target machine and try to build a factory function for the // target-specific Orc callback manager. - auto TM = std::unique_ptr(EngineBuilder().selectTarget()); + EngineBuilder EB; + EB.setOptLevel(getOptLevel()); + auto TM = std::unique_ptr(EB.selectTarget()); auto &Context = getGlobalContext(); auto CallbackMgrBuilder = OrcLazyJIT::createCallbackManagerBuilder(Triple(TM->getTargetTriple())); diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 6916d1609b8..057841f0ad6 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -365,6 +365,19 @@ static void addCygMingExtraModule(ExecutionEngine *EE, EE->addModule(std::move(M)); } +CodeGenOpt::Level getOptLevel() { + switch (OptLevel) { + default: + errs() << "lli: Invalid optimization level.\n"; + exit(1); + case '0': return CodeGenOpt::None; + case '1': return CodeGenOpt::Less; + case ' ': + case '2': return CodeGenOpt::Default; + case '3': return CodeGenOpt::Aggressive; + } + llvm_unreachable("Unrecognized opt level."); +} //===----------------------------------------------------------------------===// // main Driver function @@ -451,18 +464,7 @@ int main(int argc, char **argv, char * const *envp) { exit(1); } - CodeGenOpt::Level OLvl = CodeGenOpt::Default; - switch (OptLevel) { - default: - errs() << argv[0] << ": invalid optimization level.\n"; - return 1; - case ' ': break; - case '0': OLvl = CodeGenOpt::None; break; - case '1': OLvl = CodeGenOpt::Less; break; - case '2': OLvl = CodeGenOpt::Default; break; - case '3': OLvl = CodeGenOpt::Aggressive; break; - } - builder.setOptLevel(OLvl); + builder.setOptLevel(getOptLevel()); TargetOptions Options; if (FloatABIForCalls != FloatABI::Default)