Browse Source

Fix compilation with LLVM pre-3.5 (Ubuntu 14.04) (reverted from commit 6094aa30ad)

cl-refactor
Paweł Bylica 10 years ago
parent
commit
75fa67200e
  1. 7
      libevmjit/BasicBlock.cpp
  2. 9
      libevmjit/Compiler.cpp
  3. 2
      libevmjit/ExecutionEngine.cpp
  4. 2
      libevmjit/Ext.cpp
  5. 2
      libevmjit/Memory.cpp

7
libevmjit/BasicBlock.cpp

@ -3,17 +3,12 @@
#include <iostream>
#include <llvm/IR/CFG.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/Support/raw_os_ostream.h>
#if defined(LLVM_VERSION_PATCH) // Correct llvm-3.5
#include <llvm/IR/CFG.h>
#else // Ubuntu 14.04 crap
#include <llvm/Support/CFG.h>
#endif
#include "Type.h"
namespace dev

9
libevmjit/Compiler.cpp

@ -8,18 +8,13 @@
#include <boost/dynamic_bitset.hpp>
#include <llvm/ADT/PostOrderIterator.h>
#include <llvm/IR/CFG.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/IntrinsicInst.h>
#include <llvm/PassManager.h>
#include <llvm/Transforms/Scalar.h>
#if defined(LLVM_VERSION_PATCH) // Correct llvm-3.5
#include <llvm/IR/CFG.h>
#else // Ubuntu 14.04 crap
#include <llvm/Support/CFG.h>
#endif
#include "Instruction.h"
#include "Type.h"
#include "Memory.h"
@ -486,7 +481,7 @@ void Compiler::compileBasicBlock(BasicBlock& _basicBlock, bytes const& _bytecode
auto idx = stack.pop();
auto word = stack.pop();
auto k32_ = m_builder.CreateTrunc(idx, llvm::IntegerType::get(m_builder.getContext(), 5), "k_32");
auto k32_ = m_builder.CreateTrunc(idx, m_builder.getIntNTy(5), "k_32");
auto k32 = m_builder.CreateZExt(k32_, Type::Word);
auto k32x8 = m_builder.CreateMul(k32, Constant::get(8), "kx8");

2
libevmjit/ExecutionEngine.cpp

@ -63,10 +63,8 @@ ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeDa
builder.setOptLevel(llvm::CodeGenOpt::None);
auto triple = llvm::Triple(llvm::sys::getProcessTriple());
#if defined(LLVM_VERSION_PATCH) // Not available in llvm-3.5-dev on Ubuntu 14.04
if (triple.getOS() == llvm::Triple::OSType::Win32)
triple.setObjectFormat(llvm::Triple::ObjectFormatType::ELF); // MCJIT does not support COFF format
#endif
_module->setTargetTriple(triple.str());
ExecBundle exec;

2
libevmjit/Ext.cpp

@ -27,7 +27,7 @@ Ext::Ext(RuntimeManager& _runtimeManager, Memory& _memoryMan):
auto&& ctx = m_builder.getContext();
auto module = getModule();
auto i256Ty = Type::Word;
auto i256Ty = m_builder.getIntNTy(256);
m_args[0] = m_builder.CreateAlloca(i256Ty, nullptr, "ext.index");
m_args[1] = m_builder.CreateAlloca(i256Ty, nullptr, "ext.value");

2
libevmjit/Memory.cpp

@ -42,7 +42,7 @@ Memory::Memory(RuntimeManager& _runtimeManager, GasMeter& _gasMeter):
llvm::Type* resizeArgs[] = {Type::RuntimePtr, Type::WordPtr};
m_resize = llvm::Function::Create(llvm::FunctionType::get(Type::BytePtr, resizeArgs, false), llvm::Function::ExternalLinkage, "mem_resize", module);
llvm::AttrBuilder attrBuilder;
attrBuilder.addAttribute(llvm::Attribute::NoAlias).addAttribute(llvm::Attribute::NoCapture).addAttribute(llvm::Attribute::ReadOnly);
attrBuilder.addAttribute(llvm::Attribute::NoAlias).addAttribute(llvm::Attribute::NoCapture).addAttribute(llvm::Attribute::NonNull).addAttribute(llvm::Attribute::ReadOnly);
m_resize->setAttributes(llvm::AttributeSet::get(m_resize->getContext(), 1, attrBuilder));
m_require = createRequireFunc(_gasMeter, _runtimeManager);

Loading…
Cancel
Save