Browse Source

Allways generate stack_get() call to detect stack underflow cases

cl-refactor
Paweł Bylica 10 years ago
parent
commit
5096dbfc22
  1. 15
      evmjit/libevmjit/BasicBlock.cpp

15
evmjit/libevmjit/BasicBlock.cpp

@ -168,16 +168,13 @@ void BasicBlock::synchronizeLocalStack(Stack& _evmStack)
if (val == nullptr) if (val == nullptr)
continue; continue;
assert(llvm::isa<llvm::PHINode>(val));
llvm::PHINode* phi = llvm::cast<llvm::PHINode>(val); llvm::PHINode* phi = llvm::cast<llvm::PHINode>(val);
if (! phi->use_empty()) // Insert call to get() just before the PHI node and replace
{ // the uses of PHI with the uses of this new instruction.
// Insert call to get() just before the PHI node and replace m_builder.SetInsertPoint(phi);
// the uses of PHI with the uses of this new instruction. auto newVal = _evmStack.get(idx); // OPT: Value may be never user but we need to check stack heigth
m_builder.SetInsertPoint(phi); // It is probably a good idea to keep heigth as a local variable accesible by LLVM directly
auto newVal = _evmStack.get(idx); phi->replaceAllUsesWith(newVal);
phi->replaceAllUsesWith(newVal);
}
phi->eraseFromParent(); phi->eraseFromParent();
} }

Loading…
Cancel
Save