Browse Source

Testing some LLVM optimization passes

cl-refactor
Paweł Bylica 10 years ago
parent
commit
1d5d10e020
  1. 2
      evmjit/CMakeLists.txt
  2. 5
      evmjit/libevmjit/Optimizer.cpp

2
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")

5
evmjit/libevmjit/Optimizer.cpp

@ -3,6 +3,7 @@
#include "preprocessor/llvm_includes_start.h"
#include <llvm/PassManager.h>
#include <llvm/Transforms/Scalar.h>
#include <llvm/Transforms/IPO.h>
#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);
}

Loading…
Cancel
Save