diff --git a/libevmjit/Compiler.cpp b/libevmjit/Compiler.cpp index ebc743d50e..bc65bafa8d 100644 --- a/libevmjit/Compiler.cpp +++ b/libevmjit/Compiler.cpp @@ -71,7 +71,7 @@ void Compiler::createBasicBlocks(bytes const& _bytecode) if (nextInst == Instruction::JUMP || nextInst == Instruction::JUMPI) { // Create a block for the JUMP target. - ProgramCounter targetPC = val < _bytecode.size() ? val.convert_to() : _bytecode.size(); + ProgramCounter targetPC = val.ult(_bytecode.size()) ? val.getZExtValue() : _bytecode.size(); splitPoints.insert(targetPC); ProgramCounter jumpPC = (next - _bytecode.begin()); diff --git a/libevmjit/Instruction.h b/libevmjit/Instruction.h index 86c529e181..502c4b66e3 100644 --- a/libevmjit/Instruction.h +++ b/libevmjit/Instruction.h @@ -2,6 +2,11 @@ #include "Common.h" +namespace llvm +{ + class APInt; +} + namespace dev { namespace eth @@ -156,7 +161,7 @@ enum class Instruction: uint8_t /// Reads PUSH data from pointed fragment of bytecode and constructs number out of it /// Reading out of bytecode means reading 0 /// @param _curr is updates and points the last real byte read -u256 readPushData(bytes::const_iterator& _curr, bytes::const_iterator _end); +llvm::APInt readPushData(bytes::const_iterator& _curr, bytes::const_iterator _end); #define ANY_PUSH PUSH1: \ case Instruction::PUSH2: \ diff --git a/libevmjit/Type.cpp b/libevmjit/Type.cpp index dcff241539..22ccea12e2 100644 --- a/libevmjit/Type.cpp +++ b/libevmjit/Type.cpp @@ -51,11 +51,9 @@ llvm::ConstantInt* Constant::get(int64_t _n) return llvm::ConstantInt::getSigned(Type::Word, _n); } -llvm::ConstantInt* Constant::get(u256 _n) +llvm::ConstantInt* Constant::get(llvm::APInt const& _n) { - llvm::APInt n(256, _n.str(0, std::ios_base::hex), 16); - assert(n.toString(10, false) == _n.str()); - return static_cast(llvm::ConstantInt::get(Type::Word, n)); + return llvm::ConstantInt::get(Type::Word->getContext(), _n); } llvm::ConstantInt* Constant::get(ReturnCode _returnCode) diff --git a/libevmjit/Type.h b/libevmjit/Type.h index 0a98cb8a12..d4804ee596 100644 --- a/libevmjit/Type.h +++ b/libevmjit/Type.h @@ -43,7 +43,7 @@ struct Constant { /// Returns word-size constant static llvm::ConstantInt* get(int64_t _n); - static llvm::ConstantInt* get(u256 _n); + static llvm::ConstantInt* get(llvm::APInt const& _n); static llvm::ConstantInt* get(ReturnCode _returnCode); }; diff --git a/libevmjit/Utils.cpp b/libevmjit/Utils.cpp index 6c2bd81ba9..f1ffbf67f2 100644 --- a/libevmjit/Utils.cpp +++ b/libevmjit/Utils.cpp @@ -38,12 +38,12 @@ i256 eth2llvm(u256 _u) return i; } -u256 readPushData(bytes::const_iterator& _curr, bytes::const_iterator _end) +llvm::APInt readPushData(bytes::const_iterator& _curr, bytes::const_iterator _end) { auto pushInst = *_curr; assert(Instruction(pushInst) >= Instruction::PUSH1 && Instruction(pushInst) <= Instruction::PUSH32); auto numBytes = pushInst - static_cast(Instruction::PUSH1) + 1; - u256 value; + llvm::APInt value(256, 0); ++_curr; // Point the data for (decltype(numBytes) i = 0; i < numBytes; ++i) {