Skip to content

Commit

Permalink
Add fewer source blocks
Browse files Browse the repository at this point in the history
Summary: If the split-off block already has a source block in the beginning, don't add another synthetic source block

Reviewed By: jimmycFB

Differential Revision: D57007595

fbshipit-source-id: 14c99ddd90a61980faa4fd6b1aded62788babae9
  • Loading branch information
itang00 authored and facebook-github-bot committed May 6, 2024
1 parent 18bf461 commit 06a7d9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions service/dedup-blocks/DedupBlocks.cpp
Expand Up @@ -870,7 +870,10 @@ class DedupBlocksImpl {
auto fwd_ir_it = IRList::iterator(std::prev(it.base()));
split_block = cfg.split_block(block, fwd_ir_it);
}
copy_over_source_block(block, split_block);
// add a source block in the beginning if there isn't one already
if (split_block->begin()->type != MFLOW_SOURCE_BLOCK) {
copy_over_source_block(block, split_block);
}
continue;
}

Expand All @@ -897,10 +900,13 @@ class DedupBlocksImpl {
}

auto cfg_it = block->to_cfg_instruction_iterator(fwd_it);
// Split the block
// Split the block and add a source block in the beginning if there
// isn't one already
auto split_block = cfg.split_block(cfg_it);
if (split_block->begin()->type != MFLOW_SOURCE_BLOCK) {
copy_over_source_block(block, split_block);
}

copy_over_source_block(block, split_block);
TRACE(DEDUP_BLOCKS, 4,
"split_postfix: split block : old = %zu, new = %zu", block->id(),
split_block->id());
Expand Down
2 changes: 1 addition & 1 deletion test/integ/SourceBlocksDedupTest.cpp
Expand Up @@ -536,7 +536,7 @@ TEST_F(SourceBlocksDedupTest, source_blocks_chain) {
succs: (goto B6)\n\
Block B6:\n\
preds: (goto B3) (goto B4) (goto B5)\n\
SOURCE-BLOCKS: Lcom/facebook/redextest/SourceBlocksDedupTest;.useSwitch:()I@4294967295() Lcom/facebook/redextest/SourceBlocksDedupTest;.useSwitch:()I@100() "
SOURCE-BLOCKS: Lcom/facebook/redextest/SourceBlocksDedupTest;.useSwitch:()I@100() "
"Lcom/facebook/redextest/SourceBlocksDedupTest;.useSwitch:()I@100() Lcom/facebook/redextest/SourceBlocksDedupTest;.useSwitch:()I@100()\n\
POSITION: Lcom/facebook/redextest/SourceBlocksDedupTest;.useSwitch:()I(SourceBlocksDedupTest.java:22)\n\
OPCODE: INVOKE_VIRTUAL v4, Lcom/facebook/redextest/SourceBlocksDedupTest;.someFunc:()V\n\
Expand Down

0 comments on commit 06a7d9d

Please sign in to comment.