mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Get Runtime pointer from main function argument if available
This commit is contained in:
parent
e273299a09
commit
6a16efad92
2 changed files with 7 additions and 4 deletions
|
|
@ -27,8 +27,10 @@ llvm::Function* CompilerHelper::getMainFunction()
|
|||
{
|
||||
assert(m_builder.GetInsertBlock());
|
||||
auto mainFunc = m_builder.GetInsertBlock()->getParent();
|
||||
assert(mainFunc && mainFunc->getName() == "main");
|
||||
assert(mainFunc);
|
||||
if (mainFunc->getName() == "main")
|
||||
return mainFunc;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue