@@ -92,8 +92,8 @@ Result<> parseDefs(Ctx& ctx,
92
92
}
93
93
94
94
void propagateDebugLocations (Module& wasm) {
95
- // Copy debug locations from parents to children that do not already have
96
- // their own debug locations.
95
+ // Copy debug locations from parents or previous siblings to expressions that
96
+ // do not already have their own debug locations.
97
97
struct Propagator : WalkerPass<ExpressionStackWalker<Propagator>> {
98
98
using Super = WalkerPass<ExpressionStackWalker<Propagator>>;
99
99
bool isFunctionParallel () override { return true ; }
@@ -112,11 +112,12 @@ void propagateDebugLocations(Module& wasm) {
112
112
113
113
static void doPreVisit (Propagator* self, Expression** currp) {
114
114
Super::doPreVisit (self, currp);
115
+ auto * curr = *currp;
115
116
auto & locs = self->getFunction ()->debugLocations ;
116
117
auto & parentDefaults = self->parentDefaults ;
117
- if (auto it = locs.find (*currp ); it != locs.end ()) {
118
+ if (auto it = locs.find (curr ); it != locs.end ()) {
118
119
// Children will inherit this location.
119
- parentDefaults[*currp ] = it->second ;
120
+ parentDefaults[curr ] = it->second ;
120
121
if (auto * parent = self->getParent ()) {
121
122
// Subsequent siblings will inherit this location.
122
123
parentDefaults[parent] = it->second ;
@@ -127,7 +128,7 @@ void propagateDebugLocations(Module& wasm) {
127
128
if (auto defaultIt = parentDefaults.find (parent);
128
129
defaultIt != parentDefaults.end ()) {
129
130
// We have a default to inherit. Our children will inherit it, too.
130
- locs[*currp ] = parentDefaults[*currp ] = defaultIt->second ;
131
+ locs[curr ] = parentDefaults[curr ] = defaultIt->second ;
131
132
}
132
133
}
133
134
}
0 commit comments