summaryrefslogtreecommitdiff
path: root/src/passes/param-utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/param-utils.cpp')
-rw-r--r--src/passes/param-utils.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/passes/param-utils.cpp b/src/passes/param-utils.cpp
index ded96a826..ae641fd26 100644
--- a/src/passes/param-utils.cpp
+++ b/src/passes/param-utils.cpp
@@ -62,15 +62,24 @@ bool removeParameter(const std::vector<Function*>& funcs,
// Check if none of the calls has a param with side effects that we cannot
// remove (as if we can remove them, we will simply do that when we remove the
// parameter). Note: flattening the IR beforehand can help here.
+ auto hasBadEffects = [&](ExpressionList& operands) {
+ return EffectAnalyzer(runner->options, *module, operands[index])
+ .hasUnremovableSideEffects();
+ };
bool callParamsAreValid =
std::none_of(calls.begin(), calls.end(), [&](Call* call) {
- auto* operand = call->operands[index];
- return EffectAnalyzer(runner->options, *module, operand)
- .hasUnremovableSideEffects();
+ return hasBadEffects(call->operands);
});
if (!callParamsAreValid) {
return false;
}
+ bool callRefParamsAreValid =
+ std::none_of(callRefs.begin(), callRefs.end(), [&](CallRef* call) {
+ return hasBadEffects(call->operands);
+ });
+ if (!callRefParamsAreValid) {
+ return false;
+ }
// The type must be valid for us to handle as a local (since we
// replace the parameter with a local).