Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/cfg/cfg-traversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ struct CFGWalker : public ControlFlowWalker<SubType, VisitorType> {
doEndThrowingInst(self, currp);
if (!self->unwindCatchStack.empty()) {
// exception not thrown. link to the continuation BB
self->link(self->currBasicBlock, self->startBasicBlock());
auto* last = self->currBasicBlock;
self->link(last, self->startBasicBlock());
}
}

Expand Down Expand Up @@ -477,7 +478,8 @@ struct CFGWalker : public ControlFlowWalker<SubType, VisitorType> {
generateDebugIds();
for (auto& block : basicBlocks) {
assert(debugIds.count(block.get()) > 0);
std::cout << " block " << debugIds[block.get()] << ":\n";
std::cout << " block " << debugIds[block.get()] << " (" << block.get()
<< "):\n";
block->contents.dump(static_cast<SubType*>(this)->getFunction());
for (auto& in : block->in) {
assert(debugIds.count(in) > 0);
Expand Down
21 changes: 21 additions & 0 deletions test/passes/coalesce-locals_all-features.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(module
(type $none_=>_i32 (func (result i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(export "foo" (func $1))
(func $bar (result i32)
(i32.const 1984)
)
(func $1 (param $0 i32) (result i32)
(try $try
(do
(local.set $0
(call $bar)
)
)
(catch_all
(unreachable)
)
)
(local.get $0)
)
)
19 changes: 19 additions & 0 deletions test/passes/coalesce-locals_all-features.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(module
(func $bar (result i32)
(i32.const 1984)
)
(func "foo" (param $0 i32) (result i32)
(local $1 i32)
(try
(do
(local.set $1
(call $bar) ;; the call may or may not throw, so we may reach the get of $1
)
)
(catch_all
(unreachable)
)
)
(local.get $1)
)
)