!16934 Insert StackOps for the condition param of labelswitch

From: @liangzelang
Reviewed-by: @kisnwang,@jjfeing
Signed-off-by: @jjfeing
This commit is contained in:
mindspore-ci-bot 2021-05-27 09:14:18 +08:00 committed by Gitee
commit ae6ec6b151
1 changed files with 8 additions and 0 deletions

View File

@ -172,6 +172,9 @@ struct CallSite {
// True if this is a tail call.
bool tail = false;
// True if this call is a disable tail-opt call.
bool disable_tail = false;
};
struct ReturnPoint {
@ -408,6 +411,7 @@ class CallInfoFinder {
auto &call_info = entry.second;
if (call_info.recursive && !call_info.call_sites.empty()) {
call_info.call_sites.back().tail = false;
call_info.call_sites.back().disable_tail = true;
}
}
}
@ -539,6 +543,10 @@ class CallInfoFinder {
call_info.label_param = context_.CreateParameter(abs);
// Add label index for the first call site.
call_info.return_points.front().call_site->label_indexes.emplace(call_info.label_param, 0);
// Judge the last call_site whether is loop, set recursive attr if yes.
if (!call_info.call_sites.empty() && call_info.call_sites.back().disable_tail) {
SearchRecursiveCall(callee, &call_info.call_sites.back());
}
}
// Add label index for the current call site.
auto label_index = static_cast<uint32_t>(call_info.return_points.size() - 1);