diff options
author | Alon Zakai <azakai@google.com> | 2020-11-13 17:02:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 17:02:52 -0800 |
commit | dd618f11660fc6f89211b864a3bd9dcbd14bb013 (patch) | |
tree | 914233a726cc77ca59c6147af89d5f21495477a6 /src | |
parent | 75e61204b67e921464af14fd13ff768d88755e8c (diff) | |
download | binaryen-dd618f11660fc6f89211b864a3bd9dcbd14bb013.tar.gz binaryen-dd618f11660fc6f89211b864a3bd9dcbd14bb013.tar.bz2 binaryen-dd618f11660fc6f89211b864a3bd9dcbd14bb013.zip |
Rename Indirect to NonDirect in CallGraphPropertyAnalysis in preparation for CallRef (#3355)
This is in preparation for CallRef, which takes a reference to a function
and calls it.
CallGraphPropertyAnalysis needs to be aware of anything that is not a
direct call, and "NonDirect" is meant to cover both CallIndirect and
CallRef.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/module-utils.h | 14 | ||||
-rw-r--r-- | src/passes/Asyncify.cpp | 10 | ||||
-rw-r--r-- | src/passes/PostEmscripten.cpp | 4 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 62a9dd921..a2d256073 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -308,7 +308,9 @@ template<typename T> struct CallGraphPropertyAnalysis { struct FunctionInfo { std::set<Function*> callsTo; std::set<Function*> calledBy; - bool hasIndirectCall = false; + // A non-direct call is any call that is not direct. That includes + // CallIndirect and CallRef. + bool hasNonDirectCall = false; }; typedef std::map<Function*, T> Map; @@ -331,7 +333,7 @@ template<typename T> struct CallGraphPropertyAnalysis { } void visitCallIndirect(CallIndirect* curr) { - info.hasIndirectCall = true; + info.hasNonDirectCall = true; } private: @@ -354,7 +356,7 @@ template<typename T> struct CallGraphPropertyAnalysis { } } - enum IndirectCalls { IgnoreIndirectCalls, IndirectCallsHaveProperty }; + enum NonDirectCalls { IgnoreNonDirectCalls, NonDirectCallsHaveProperty }; // Propagate a property from a function to those that call it. // @@ -365,13 +367,13 @@ template<typename T> struct CallGraphPropertyAnalysis { void propagateBack(std::function<bool(const T&)> hasProperty, std::function<bool(const T&)> canHaveProperty, std::function<void(T&, Function*)> addProperty, - IndirectCalls indirectCalls) { + NonDirectCalls nonDirectCalls) { // The work queue contains items we just learned can change the state. UniqueDeferredQueue<Function*> work; for (auto& func : wasm.functions) { if (hasProperty(map[func.get()]) || - (indirectCalls == IndirectCallsHaveProperty && - map[func.get()].hasIndirectCall)) { + (nonDirectCalls == NonDirectCallsHaveProperty && + map[func.get()].hasNonDirectCall)) { addProperty(map[func.get()], func.get()); work.push(func.get()); } diff --git a/src/passes/Asyncify.cpp b/src/passes/Asyncify.cpp index 3cf0a76d2..a05c9293c 100644 --- a/src/passes/Asyncify.cpp +++ b/src/passes/Asyncify.cpp @@ -677,7 +677,7 @@ public: } info.canChangeState = true; }, - scanner.IgnoreIndirectCalls); + scanner.IgnoreNonDirectCalls); map.swap(scanner.map); @@ -1408,8 +1408,10 @@ struct Asyncify : public Pass { bool allImportsCanChangeState = stateChangingImports == "" && ignoreImports == ""; String::Split listedImports(stateChangingImports, ","); - auto ignoreIndirect = runner->options.getArgumentOrDefault( - "asyncify-ignore-indirect", "") == ""; + // TODO: consider renaming asyncify-ignore-indirect to + // asyncify-ignore-nondirect, but that could break users. + auto ignoreNonDirect = runner->options.getArgumentOrDefault( + "asyncify-ignore-indirect", "") == ""; std::string removeListInput = runner->options.getArgumentOrDefault("asyncify-removelist", ""); if (removeListInput.empty()) { @@ -1462,7 +1464,7 @@ struct Asyncify : public Pass { // Scan the module. ModuleAnalyzer analyzer(*module, canImportChangeState, - ignoreIndirect, + ignoreNonDirect, removeList, addList, onlyList, diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index da482d70a..d57d849da 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -86,12 +86,12 @@ struct PostEmscripten : public Pass { } }); - // Assume an indirect call might throw. + // Assume a non-direct call might throw. analyzer.propagateBack( [](const Info& info) { return info.canThrow; }, [](const Info& info) { return true; }, [](Info& info, Function* reason) { info.canThrow = true; }, - analyzer.IndirectCallsHaveProperty); + analyzer.NonDirectCallsHaveProperty); // Apply the information. struct OptimizeInvokes : public WalkerPass<PostWalker<OptimizeInvokes>> { |