Skip to content

Commit 4a976ea

Browse files
committed
fix: add the block expression to the correct basic block contents
1 parent 047d629 commit 4a976ea

17 files changed

+20
-31
lines changed

instrumentation/BasicBlockWalker.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void BasicBlockWalker::basicBlockWalk() noexcept {
2020
}
2121

2222
void BasicBlockWalker::visitExpression(wasm::Expression *curr) noexcept {
23-
if (currBasicBlock == nullptr) {
23+
if (currBasicBlock == nullptr || curr->is<wasm::Block>()) {
2424
return;
2525
}
2626
// push information
@@ -33,6 +33,14 @@ void BasicBlockWalker::visitExpression(wasm::Expression *curr) noexcept {
3333
}
3434
}
3535

36+
void BasicBlockWalker::doEndBlock(BasicBlockWalker *self, wasm::Expression **currp) {
37+
wasm::CFGWalker<BasicBlockWalker, wasm::UnifiedExpressionVisitor<BasicBlockWalker>,
38+
BasicBlockInfo>::doEndBlock(self, currp);
39+
if (self->currBasicBlock != nullptr) {
40+
self->currBasicBlock->contents.exprs.push_back(*currp);
41+
}
42+
}
43+
3644
static bool
3745
isBasicBlockContainUnreachable(BasicBlockWalker::BasicBlock &block,
3846
std::set<BasicBlockWalker::BasicBlock *> unreachableBlocks) {

instrumentation/BasicBlockWalker.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class BasicBlockWalker final
120120
///@param curr Current expression
121121
void visitExpression(wasm::Expression *const curr) noexcept;
122122

123+
static void doEndBlock(BasicBlockWalker* self, wasm::Expression** currp);
124+
123125
///
124126
///@brief Inherit from CFGWalker for function visitor
125127
///

tests/cpp/lit/covInstrument/do_while_break.wast.debug.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
[0, 7, 18]
2727
],
2828
[[0, 4, 2]],
29-
[[0, 4, 2]],
3029
[[0, 8, 9]]
3130
]
3231
}

tests/cpp/lit/covInstrument/do_while_break.wast.run.log

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ basic block entry trace to: function=0, basic block=3
1111
basic block entry trace to: function=0, basic block=1
1212
basic block entry trace to: function=0, basic block=2
1313
basic block entry trace to: function=0, basic block=5
14-
basic block entry trace to: function=0, basic block=6

tests/cpp/lit/covInstrument/do_while_continue.wast.debug.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"debugInfos": {
44
"main": {
55
"branchInfo": [
6-
[1, 2],
76
[1, 3],
8-
[4, 5],
9-
[4, 1]
7+
[1, 2],
8+
[3, 4],
9+
[3, 1]
1010
],
1111
"index": 0,
1212
"lineInfo": [
@@ -21,7 +21,6 @@
2121
[0, 6, 16]
2222
],
2323
[[0, 6, 19]],
24-
[[0, 4, 2]],
2524
[
2625
[0, 7, 10],
2726
[0, 7, 18]

tests/cpp/lit/covInstrument/do_while_continue.wast.run.log

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ make directly call to function index=0
22
basic block entry trace to: function=0, basic block=0
33
basic block entry trace to: function=0, basic block=1
44
basic block entry trace to: function=0, basic block=3
5-
basic block entry trace to: function=0, basic block=4
65
basic block entry trace to: function=0, basic block=1
76
basic block entry trace to: function=0, basic block=2
87
basic block entry trace to: function=0, basic block=3
98
basic block entry trace to: function=0, basic block=4
109
basic block entry trace to: function=0, basic block=5
11-
basic block entry trace to: function=0, basic block=6

tests/cpp/lit/covInstrument/do_while_once.wast.debug.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@
2929
[0, 8, 16]
3030
],
3131
[[0, 8, 20]],
32-
[
33-
[0, 4, 2],
34-
[0, 9, 4]
35-
],
32+
[[0, 9, 4]],
3633
[[0, 10, 11]],
3734
[[0, 4, 2]],
38-
[[0, 4, 2]],
3935
[
4036
[0, 11, 9],
4137
[0, 11, 17]

tests/cpp/lit/covInstrument/do_while_once.wast.run.log

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ basic block entry trace to: function=0, basic block=4
66
basic block entry trace to: function=0, basic block=6
77
basic block entry trace to: function=0, basic block=7
88
basic block entry trace to: function=0, basic block=8
9-
basic block entry trace to: function=0, basic block=9

tests/cpp/lit/covInstrument/for_loop_break.wast.debug.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
[0, 6, 13]
3131
],
3232
[[0, 4, 19]],
33-
[[0, 4, 19]],
3433
[[0, 8, 9]]
3534
]
3635
}

tests/cpp/lit/covInstrument/for_loop_break.wast.run.log

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ basic block entry trace to: function=0, basic block=1
2222
basic block entry trace to: function=0, basic block=2
2323
basic block entry trace to: function=0, basic block=3
2424
basic block entry trace to: function=0, basic block=6
25-
basic block entry trace to: function=0, basic block=7

0 commit comments

Comments
 (0)