Browse Source

Get Runtime pointer from main function argument if available

cl-refactor
Paweł Bylica 10 years ago
parent
commit
6a16efad92
  1. 6
      libevmjit/CompilerHelper.cpp
  2. 5
      libevmjit/Runtime.cpp

6
libevmjit/CompilerHelper.cpp

@ -27,8 +27,10 @@ llvm::Function* CompilerHelper::getMainFunction()
{
assert(m_builder.GetInsertBlock());
auto mainFunc = m_builder.GetInsertBlock()->getParent();
assert(mainFunc && mainFunc->getName() == "main");
return mainFunc;
assert(mainFunc);
if (mainFunc->getName() == "main")
return mainFunc;
return nullptr;
}

5
libevmjit/Runtime.cpp

@ -122,8 +122,9 @@ RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_bui
llvm::Value* RuntimeManager::getRuntimePtr()
{
// TODO: If in main function - get it from param
return m_builder.CreateLoad(m_dataPtr);
if (auto mainFunc = getMainFunction())
return mainFunc->arg_begin()->getNextNode(); // Runtime is the second parameter of main function
return m_builder.CreateLoad(m_dataPtr, "rt");
}
llvm::Value* RuntimeManager::getPtr(RuntimeData::Index _index)

Loading…
Cancel
Save