mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +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)
|
void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
||||||
{
|
{
|
||||||
getOrCreateBasicBlockAtPC(0);
|
getOrCreateBasicBlockAtPC(0); // First basic block
|
||||||
getOrCreateBasicBlockAtPC(bytecode.size());
|
|
||||||
|
|
||||||
for (auto curr = bytecode.cbegin(); curr != bytecode.cend(); ++curr)
|
for (auto curr = bytecode.cbegin(); curr != bytecode.cend(); ++curr)
|
||||||
{
|
{
|
||||||
|
|
@ -113,13 +112,6 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
||||||
val |= *iter;
|
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.
|
// Create a block following the JUMP.
|
||||||
if (next + 1 < bytecode.cend())
|
if (next + 1 < bytecode.cend())
|
||||||
{
|
{
|
||||||
|
|
@ -127,6 +119,13 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
||||||
getOrCreateBasicBlockAtPC(nextPC);
|
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
|
curr += 1; // skip over JUMP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,6 +157,8 @@ void Compiler::createBasicBlocks(const dev::bytes& bytecode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOrCreateBasicBlockAtPC(bytecode.size()); // Final basic block
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
|
std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue