Title: [152301] branches/dfgFourthTier/Source
Revision
152301
Author
[email protected]
Date
2013-07-02 10:54:28 -0700 (Tue, 02 Jul 2013)

Log Message

fourthTier: FTL should use the equivalent of llvm opt -O2 by default
https://bugs.webkit.org/show_bug.cgi?id=118311

Source/_javascript_Core: 

Reviewed by Mark Hahnenberg.
        
Use a PassManagerBuilder instead of rolling our own.
        
This boosts our speed-up by another 5% or so.

* ftl/FTLCompile.cpp:
(JSC::FTL::compile):
* runtime/Options.h:
(JSC):

Source/WTF: 

Reviewed by Mark Hahnenberg.
        
* wtf/LLVMHeaders.h:

Modified Paths

Diff

Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (152300 => 152301)


--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-07-02 17:53:20 UTC (rev 152300)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-07-02 17:54:28 UTC (rev 152301)
@@ -1,3 +1,19 @@
+2013-07-02  Filip Pizlo  <[email protected]>
+
+        fourthTier: FTL should use the equivalent of llvm opt -O2 by default
+        https://bugs.webkit.org/show_bug.cgi?id=118311
+
+        Reviewed by Mark Hahnenberg.
+        
+        Use a PassManagerBuilder instead of rolling our own.
+        
+        This boosts our speed-up by another 5% or so.
+
+        * ftl/FTLCompile.cpp:
+        (JSC::FTL::compile):
+        * runtime/Options.h:
+        (JSC):
+
 2013-07-01  Filip Pizlo  <[email protected]>
 
         fourthTier: FTL should run LICM after AA setup

Modified: branches/dfgFourthTier/Source/_javascript_Core/ftl/FTLCompile.cpp (152300 => 152301)


--- branches/dfgFourthTier/Source/_javascript_Core/ftl/FTLCompile.cpp	2013-07-02 17:53:20 UTC (rev 152300)
+++ branches/dfgFourthTier/Source/_javascript_Core/ftl/FTLCompile.cpp	2013-07-02 17:54:28 UTC (rev 152301)
@@ -85,7 +85,7 @@
     
     LLVMMCJITCompilerOptions options;
     LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
-    options.OptLevel = Options::llvmOptimizationLevel();
+    options.OptLevel = Options::llvmBackendOptimizationLevel();
     options.NoFramePointerElim = true;
     if (Options::useLLVMSmallCodeModel())
         options.CodeModel = LLVMCodeModelSmall;
@@ -100,25 +100,35 @@
         CRASH();
     }
 
-    LLVMPassManagerRef pass = LLVMCreatePassManager();
-    LLVMAddTargetData(LLVMGetExecutionEngineTargetData(engine), pass);
-    LLVMAddConstantPropagationPass(pass);
-    LLVMAddInstructionCombiningPass(pass);
-    LLVMAddPromoteMemoryToRegisterPass(pass);
-    LLVMAddBasicAliasAnalysisPass(pass);
-    LLVMAddTypeBasedAliasAnalysisPass(pass);
-    if (Options::enableLLVMLICM())
-        LLVMAddLICMPass(pass);
-    LLVMAddGVNPass(pass);
-    LLVMAddCFGSimplificationPass(pass);
-    LLVMRunPassManager(pass, state.module);
+    LLVMPassManagerBuilderRef passBuilder = LLVMPassManagerBuilderCreate();
+    LLVMPassManagerBuilderSetOptLevel(passBuilder, Options::llvmOptimizationLevel());
+    LLVMPassManagerBuilderSetSizeLevel(passBuilder, Options::llvmSizeLevel());
+    
+    LLVMPassManagerRef functionPasses = LLVMCreateFunctionPassManagerForModule(state.module);
+    LLVMPassManagerRef modulePasses = LLVMCreatePassManager();
+    
+    LLVMAddTargetData(LLVMGetExecutionEngineTargetData(engine), modulePasses);
+    
+    LLVMPassManagerBuilderPopulateFunctionPassManager(passBuilder, functionPasses);
+    LLVMPassManagerBuilderPopulateModulePassManager(passBuilder, modulePasses);
+    
+    LLVMPassManagerBuilderDispose(passBuilder);
+
+    LLVMInitializeFunctionPassManager(functionPasses);
+    for (LValue function = LLVMGetFirstFunction(state.module); function; function = LLVMGetNextFunction(function))
+        LLVMRunFunctionPassManager(functionPasses, function);
+    LLVMFinalizeFunctionPassManager(functionPasses);
+    
+    LLVMRunPassManager(modulePasses, state.module);
+
     if (DFG::shouldShowDisassembly() || DFG::verboseCompilationEnabled())
         state.dumpState("after optimization");
     
     // FIXME: Need to add support for the case where JIT memory allocation failed.
     // https://bugs.webkit.org/show_bug.cgi?id=113620
     state.generatedFunction = reinterpret_cast<GeneratedFunction>(LLVMGetPointerToGlobal(engine, state.function));
-    LLVMDisposePassManager(pass);
+    LLVMDisposePassManager(functionPasses);
+    LLVMDisposePassManager(modulePasses);
     LLVMDisposeExecutionEngine(engine);
 
     if (shouldShowDisassembly()) {

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/Options.h (152300 => 152301)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/Options.h	2013-07-02 17:53:20 UTC (rev 152300)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/Options.h	2013-07-02 17:54:28 UTC (rev 152301)
@@ -88,10 +88,11 @@
     \
     v(bool, useExperimentalFTL, false) \
     v(bool, useFTLTBAA, true) \
-    v(bool, enableLLVMLICM, true) \
     v(bool, enableLLVMFastISel, false) \
     v(bool, useLLVMSmallCodeModel, false) \
+    v(unsigned, llvmBackendOptimizationLevel, 2) \
     v(unsigned, llvmOptimizationLevel, 2) \
+    v(unsigned, llvmSizeLevel, 0) \
     \
     v(bool, enableConcurrentJIT, true) \
     v(unsigned, numberOfCompilerThreads, computeNumberOfWorkerThreads(2) - 1) \

Modified: branches/dfgFourthTier/Source/WTF/ChangeLog (152300 => 152301)


--- branches/dfgFourthTier/Source/WTF/ChangeLog	2013-07-02 17:53:20 UTC (rev 152300)
+++ branches/dfgFourthTier/Source/WTF/ChangeLog	2013-07-02 17:54:28 UTC (rev 152301)
@@ -1,3 +1,12 @@
+2013-07-02  Filip Pizlo  <[email protected]>
+
+        fourthTier: FTL should use the equivalent of llvm opt -O2 by default
+        https://bugs.webkit.org/show_bug.cgi?id=118311
+
+        Reviewed by Mark Hahnenberg.
+        
+        * wtf/LLVMHeaders.h:
+
 2013-06-27  Filip Pizlo  <[email protected]>
 
         fourthTier: JSC's disassembly infrastructure should be able to disassemble the code that LLVM generates

Modified: branches/dfgFourthTier/Source/WTF/wtf/LLVMHeaders.h (152300 => 152301)


--- branches/dfgFourthTier/Source/WTF/wtf/LLVMHeaders.h	2013-07-02 17:53:20 UTC (rev 152300)
+++ branches/dfgFourthTier/Source/WTF/wtf/LLVMHeaders.h	2013-07-02 17:54:28 UTC (rev 152301)
@@ -49,7 +49,7 @@
 #include <llvm-c/Disassembler.h>
 #include <llvm-c/ExecutionEngine.h>
 #include <llvm-c/Target.h>
-#include <llvm-c/Transforms/Scalar.h>
+#include <llvm-c/Transforms/PassManagerBuilder.h>
 
 #if COMPILER(CLANG)
 #pragma clang diagnostic pop
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to