Skip to content
Closed
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
48 changes: 39 additions & 9 deletions src/passes/Asyncify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@
// some indirect calls that *do* need to be instrumented, or if you will
// do some later transform of the code that adds more call paths, etc.
//
// --pass-arg=asyncify-propagate-addlist
//
// The default behaviour of the addlist does not propagate instrumentation
// status. If this option is set then functions which call a function in
// the addlist will also be instrumented, and those that call them and so
// on.
//
// --pass-arg=asyncify-onlylist@name1,name2,name3
//
// If the "only-list" is provided, then *only* the functions in the list
Expand Down Expand Up @@ -488,6 +495,7 @@ class PatternMatcher {
class ModuleAnalyzer {
Module& module;
bool canIndirectChangeState;
bool propagateAddList;

struct Info
: public ModuleUtils::CallGraphPropertyAnalysis<Info>::FunctionInfo {
Expand Down Expand Up @@ -519,6 +527,7 @@ class ModuleAnalyzer {
bool canIndirectChangeState,
const String::Split& removeListInput,
const String::Split& addListInput,
bool propagateAddList,
const String::Split& onlyListInput,
bool asserts,
bool verbose)
Expand Down Expand Up @@ -664,6 +673,22 @@ class ModuleAnalyzer {
module.removeFunction(name);
}

if (propagateAddList) {
if (!addListInput.empty()) {
for (auto& func : module.functions) {
if (!func->imported() && addList.match(func->name)) {
auto& info = map[func.get()];
if (verbose && !info.canChangeState) {
std::cout << "[asyncify] " << func->name
<< " is in the add-list, add\n";
}
info.canChangeState = true;
info.addedFromList = true;
}
}
}
}

scanner.propagateBack([](const Info& info) { return info.canChangeState; },
[](const Info& info) {
return !info.isBottomMostRuntime &&
Expand Down Expand Up @@ -700,16 +725,18 @@ class ModuleAnalyzer {
}
}

if (!addListInput.empty()) {
for (auto& func : module.functions) {
if (!func->imported() && addList.match(func->name)) {
auto& info = map[func.get()];
if (verbose && !info.canChangeState) {
std::cout << "[asyncify] " << func->name
<< " is in the add-list, add\n";
if (!propagateAddList) {
if (!addListInput.empty()) {
for (auto& func : module.functions) {
if (!func->imported() && addList.match(func->name)) {
auto& info = map[func.get()];
if (verbose && !info.canChangeState) {
std::cout << "[asyncify] " << func->name
<< " is in the add-list, add\n";
}
info.canChangeState = true;
info.addedFromList = true;
}
info.canChangeState = true;
info.addedFromList = true;
}
}
}
Expand Down Expand Up @@ -1425,6 +1452,8 @@ struct Asyncify : public Pass {
String::trim(read_possible_response_file(
runner->options.getArgumentOrDefault("asyncify-addlist", ""))),
",");
auto propagateAddList =
runner->options.getArgumentOrDefault("asyncify-propagate-addlist", "");
std::string onlyListInput =
runner->options.getArgumentOrDefault("asyncify-onlylist", "");
if (onlyListInput.empty()) {
Expand Down Expand Up @@ -1467,6 +1496,7 @@ struct Asyncify : public Pass {
ignoreNonDirect,
removeList,
addList,
propagateAddList,
onlyList,
asserts,
verbose);
Expand Down