mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Fix checking memory requirements with size 0
This commit is contained in:
parent
a4927609d7
commit
0a642457f7
1 changed files with 6 additions and 0 deletions
|
|
@ -60,12 +60,18 @@ llvm::Function* Memory::createRequireFunc(GasMeter& _gasMeter, RuntimeManager& _
|
||||||
auto size = offset->getNextNode();
|
auto size = offset->getNextNode();
|
||||||
size->setName("size");
|
size->setName("size");
|
||||||
|
|
||||||
|
auto preBB = llvm::BasicBlock::Create(func->getContext(), "Pre", func);
|
||||||
auto checkBB = llvm::BasicBlock::Create(func->getContext(), "Check", func);
|
auto checkBB = llvm::BasicBlock::Create(func->getContext(), "Check", func);
|
||||||
auto resizeBB = llvm::BasicBlock::Create(func->getContext(), "Resize", func);
|
auto resizeBB = llvm::BasicBlock::Create(func->getContext(), "Resize", func);
|
||||||
auto returnBB = llvm::BasicBlock::Create(func->getContext(), "Return", func);
|
auto returnBB = llvm::BasicBlock::Create(func->getContext(), "Return", func);
|
||||||
|
|
||||||
InsertPointGuard guard(m_builder); // Restores insert point at function exit
|
InsertPointGuard guard(m_builder); // Restores insert point at function exit
|
||||||
|
|
||||||
|
// BB "Pre": Ignore checks with size 0
|
||||||
|
m_builder.SetInsertPoint(preBB);
|
||||||
|
auto sizeIsZero = m_builder.CreateICmpEQ(size, Constant::get(0));
|
||||||
|
m_builder.CreateCondBr(sizeIsZero, returnBB, checkBB);
|
||||||
|
|
||||||
// BB "Check"
|
// BB "Check"
|
||||||
m_builder.SetInsertPoint(checkBB);
|
m_builder.SetInsertPoint(checkBB);
|
||||||
auto uaddWO = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::uadd_with_overflow, Type::Word);
|
auto uaddWO = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::uadd_with_overflow, Type::Word);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue