diff --git a/libevmjit/Compiler.cpp b/libevmjit/Compiler.cpp index 4bbebe9ea..33822f46e 100644 --- a/libevmjit/Compiler.cpp +++ b/libevmjit/Compiler.cpp @@ -157,10 +157,9 @@ std::unique_ptr Compiler::compile(bytes const& _bytecode) auto module = std::unique_ptr(new llvm::Module("main", m_builder.getContext())); // Create main function - llvm::Type* mainFuncArgTypes[] = {m_builder.getInt32Ty(), Type::RuntimePtr}; // There must be int in first place because LLVM does not support other signatures - auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, mainFuncArgTypes, false); + auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, Type::RuntimePtr, false); m_mainFunc = llvm::Function::Create(mainFuncType, llvm::Function::ExternalLinkage, "main", module.get()); - m_mainFunc->arg_begin()->getNextNode()->setName("rt"); + m_mainFunc->getArgumentList().front().setName("rt"); // Create the basic blocks. auto entryBlock = llvm::BasicBlock::Create(m_builder.getContext(), "entry", m_mainFunc); diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index 742aea90a..fb3b878e2 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -111,14 +111,14 @@ namespace { ReturnCode runEntryFunc(ExecBundle const& _exec, Runtime* _runtime) { - typedef ReturnCode(*EntryFuncPtr)(int, Runtime*); + typedef ReturnCode(*EntryFuncPtr)(Runtime*); auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc); auto entryFuncPtr = static_cast(entryFuncVoidPtr); ReturnCode returnCode{}; auto sj = setjmp(_runtime->getJmpBuf()); if (sj == 0) - returnCode = entryFuncPtr(0, _runtime); // FIXME: Remove int argument + returnCode = entryFuncPtr(_runtime); else returnCode = static_cast(sj); diff --git a/libevmjit/RuntimeManager.cpp b/libevmjit/RuntimeManager.cpp index 56efa0c64..9bb9b3698 100644 --- a/libevmjit/RuntimeManager.cpp +++ b/libevmjit/RuntimeManager.cpp @@ -80,7 +80,7 @@ RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_bui // Export data auto mainFunc = getMainFunction(); - llvm::Value* rtPtr = &mainFunc->getArgumentList().back(); + llvm::Value* rtPtr = &mainFunc->getArgumentList().front(); m_builder.CreateStore(rtPtr, m_rtPtr); auto dataPtr = m_builder.CreateStructGEP(rtPtr, 0, "dataPtr"); auto data = m_builder.CreateLoad(dataPtr, "data"); @@ -95,7 +95,7 @@ llvm::Value* RuntimeManager::getRuntimePtr() { // FIXME: Data ptr //if (auto mainFunc = getMainFunction()) - // return mainFunc->arg_begin()->getNextNode(); // Runtime is the second parameter of main function + // return mainFunc->arg_begin(); // Runtime is the parameter of main function return m_builder.CreateLoad(m_rtPtr, "rt"); } @@ -103,7 +103,7 @@ llvm::Value* RuntimeManager::getDataPtr() { // FIXME: Data ptr //if (auto mainFunc = getMainFunction()) - // return mainFunc->arg_begin()->getNextNode(); // Runtime is the second parameter of main function + // return mainFunc->arg_begin(); // Runtime is the parameter of main function return m_builder.CreateLoad(m_dataPtr, "data"); }