From 1d5d10e020d536354b796a4ed0c3206fbd44270a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 16 Feb 2015 18:34:16 +0100 Subject: [PATCH] Testing some LLVM optimization passes --- evmjit/CMakeLists.txt | 2 +- evmjit/libevmjit/Optimizer.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/evmjit/CMakeLists.txt b/evmjit/CMakeLists.txt index 14fca2cde..050a7fae7 100644 --- a/evmjit/CMakeLists.txt +++ b/evmjit/CMakeLists.txt @@ -22,7 +22,7 @@ if(LLVM_DIR OR APPLE) # local LLVM build message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") add_definitions(${LLVM_DEFINITIONS}) # TODO: bitwriter is needed only for evmcc - llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen bitwriter) + llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen bitwriter ipo) else() # Workaround for Ubuntu broken LLVM package message(STATUS "Using llvm-3.5-dev package from Ubuntu. If does not work, build LLVM and set -DLLVM_DIR=llvm-build/share/llvm/cmake") diff --git a/evmjit/libevmjit/Optimizer.cpp b/evmjit/libevmjit/Optimizer.cpp index 2b8e41bd3..84a7c3a6a 100644 --- a/evmjit/libevmjit/Optimizer.cpp +++ b/evmjit/libevmjit/Optimizer.cpp @@ -3,6 +3,7 @@ #include "preprocessor/llvm_includes_start.h" #include #include +#include #include "preprocessor/llvm_includes_end.h" namespace dev @@ -15,6 +16,10 @@ namespace jit bool optimize(llvm::Module& _module) { auto pm = llvm::PassManager{}; + //pm.add(llvm::createFunctionInliningPass(2, 2)); // Produces invalid IR + pm.add(llvm::createCFGSimplificationPass()); + //pm.add(llvm::createInstructionCombiningPass()); // Produces invalid runtime results + pm.add(llvm::createAggressiveDCEPass()); pm.add(llvm::createLowerSwitchPass()); return pm.run(_module); }