Skip to content

Commit

Permalink
- add log for optimizeEmptyBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
whtoo committed Dec 18, 2023
1 parent 61a0640 commit 336925e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ep20/src/main/java/org/teachfx/antlr4/ep20/ir/Prog.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ private void optimizeEmptyBlock(@NotNull LinearIRBlock linearIRBlock) {
if (linearIRBlock.getStmts().isEmpty()){
// Drop empty block
if (linearIRBlock.getSuccessors().isEmpty()) {
logger.debug("Block %s will be removed".formatted(linearIRBlock));
needRemovedBlocks.add(linearIRBlock);
return;
}
// Auto-fill next block for jmp/cjmp
var nextBlock = linearIRBlock.getSuccessors().get(0);
for (var ref : linearIRBlock.getJmpRefMap()){
if (ref instanceof JMP jmp) {
logger.debug(" %s is next for %s".formatted(nextBlock,linearIRBlock));
jmp.setNext(nextBlock);

} else if (ref instanceof CJMP cjmp) {
logger.debug(" %s is else-case for %s".formatted(nextBlock,linearIRBlock));
cjmp.setElseBlock(nextBlock);
}
}
Expand Down

0 comments on commit 336925e

Please sign in to comment.