mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
Correct the order of basic blocks
This commit is contained in:
parent
e52d421955
commit
577438e243
1 changed files with 10 additions and 9 deletions
|
|
@ -53,8 +53,7 @@ BasicBlock& Compiler::getOrCreateBasicBlockAtPC(ProgramCounter pc)
|
|||
|
||||
void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
||||
{
|
||||
getOrCreateBasicBlockAtPC(0);
|
||||
getOrCreateBasicBlockAtPC(bytecode.size());
|
||||
getOrCreateBasicBlockAtPC(0); // First basic block
|
||||
|
||||
for (auto curr = bytecode.cbegin(); curr != bytecode.cend(); ++curr)
|
||||
{
|
||||
|
|
@ -113,13 +112,6 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
|||
val |= *iter;
|
||||
}
|
||||
|
||||
// Create a block for the JUMP target.
|
||||
ProgramCounter targetPC = val.convert_to<ProgramCounter>();
|
||||
auto& targetBlock = getOrCreateBasicBlockAtPC(targetPC);
|
||||
|
||||
ProgramCounter jumpPC = (next - bytecode.cbegin());
|
||||
jumpTargets[jumpPC] = targetBlock;
|
||||
|
||||
// Create a block following the JUMP.
|
||||
if (next + 1 < bytecode.cend())
|
||||
{
|
||||
|
|
@ -127,6 +119,13 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
|||
getOrCreateBasicBlockAtPC(nextPC);
|
||||
}
|
||||
|
||||
// Create a block for the JUMP target.
|
||||
ProgramCounter targetPC = val.convert_to<ProgramCounter>();
|
||||
auto& targetBlock = getOrCreateBasicBlockAtPC(targetPC);
|
||||
|
||||
ProgramCounter jumpPC = (next - bytecode.cbegin());
|
||||
jumpTargets[jumpPC] = targetBlock;
|
||||
|
||||
curr += 1; // skip over JUMP
|
||||
}
|
||||
|
||||
|
|
@ -158,6 +157,8 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getOrCreateBasicBlockAtPC(bytecode.size()); // Final basic block
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
|
||||
|
|
|
|||
Loading…
Reference in a new issue