diff options
author | Dannii Willis <curiousdannii@gmail.com> | 2024-04-09 03:24:15 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 10:24:15 -0700 |
commit | f0dd9941de2df62e0a29f2faeadf007e37a425a9 (patch) | |
tree | a8fb878d404284eb86eac5321113f3e8e9c6bb59 /src/ir/module-utils.h | |
parent | 98f08effb18a94618ef12f25134c289836fc316e (diff) | |
download | binaryen-f0dd9941de2df62e0a29f2faeadf007e37a425a9.tar.gz binaryen-f0dd9941de2df62e0a29f2faeadf007e37a425a9.tar.bz2 binaryen-f0dd9941de2df62e0a29f2faeadf007e37a425a9.zip |
Asyncify-verbose: Show all reasons why a function is instrumented (#6457)
Helps emscripten-core/emscripten#17380 by logging all the reasons why we
instrument a function, and not just the first as we did before.
Diffstat (limited to 'src/ir/module-utils.h')
-rw-r--r-- | src/ir/module-utils.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index eabcd036c..190191cd7 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -390,11 +390,13 @@ template<typename T> struct CallGraphPropertyAnalysis { // // hasProperty() - Check if the property is present. // canHaveProperty() - Check if the property could be present. - // addProperty() - Adds the property. This receives a second parameter which - // is the function due to which we are adding the property. + // addProperty() - Adds the property. + // logVisit() - Log each visit of the propagation. This is called before + // we check if the function already has the property. void propagateBack(std::function<bool(const T&)> hasProperty, std::function<bool(const T&)> canHaveProperty, - std::function<void(T&, Function*)> addProperty, + std::function<void(T&)> addProperty, + std::function<void(const T&, Function*)> logVisit, NonDirectCalls nonDirectCalls) { // The work queue contains items we just learned can change the state. UniqueDeferredQueue<Function*> work; @@ -402,17 +404,23 @@ template<typename T> struct CallGraphPropertyAnalysis { if (hasProperty(map[func.get()]) || (nonDirectCalls == NonDirectCallsHaveProperty && map[func.get()].hasNonDirectCall)) { - addProperty(map[func.get()], func.get()); + addProperty(map[func.get()]); work.push(func.get()); } } while (!work.empty()) { auto* func = work.pop(); for (auto* caller : map[func].calledBy) { - // If we don't already have the property, and we are not forbidden - // from getting it, then it propagates back to us now. - if (!hasProperty(map[caller]) && canHaveProperty(map[caller])) { - addProperty(map[caller], func); + // Skip functions forbidden from getting this property. + if (!canHaveProperty(map[caller])) { + continue; + } + // Log now, even if the function already has the property. + logVisit(map[caller], func); + // If we don't already have the property, then add it now, and propagate + // further. + if (!hasProperty(map[caller])) { + addProperty(map[caller]); work.push(caller); } } |