summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-12-01 09:07:36 -0800
committerGitHub <noreply@github.com>2021-12-01 09:07:36 -0800
commit1e659e373d46a588938b80db4efc5c9c05067b11 (patch)
treefac58031cfaeb0d21af4d703c9b3ef0fd5fd34d4 /src/passes/OptimizeInstructions.cpp
parent5f6911f1f1fcae058bf77720f04e1166bafca8e3 (diff)
downloadbinaryen-1e659e373d46a588938b80db4efc5c9c05067b11.tar.gz
binaryen-1e659e373d46a588938b80db4efc5c9c05067b11.tar.bz2
binaryen-1e659e373d46a588938b80db4efc5c9c05067b11.zip
[NFC] Avoid some unnecessary copies of PassOptions (#4361)
PassOptions is a fairly large structure and even includes a std::map. I also have plans to add further fields there to make it even larger. Before doing that I noticed that in some places we copy it instead of being consistent and taking it by reference, which this PR fixes.
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 2cbb28c66..ecc5d4488 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -1129,7 +1129,7 @@ struct OptimizeInstructions
// Otherwise, if this is not a tee, then no value falls through. The
// ref.as_non_null acts as a null check here, basically. If we are
// ignoring such traps, we can remove it.
- auto passOptions = getPassOptions();
+ auto& passOptions = getPassOptions();
if (passOptions.ignoreImplicitTraps || passOptions.trapsNeverHappen) {
curr->value = as->value;
}
@@ -1540,7 +1540,7 @@ struct OptimizeInstructions
}
Builder builder(*getModule());
- auto passOptions = getPassOptions();
+ auto& passOptions = getPassOptions();
auto fallthrough =
Properties::getFallthrough(curr->ref, getPassOptions(), *getModule());
@@ -1869,7 +1869,7 @@ private:
// assume things like local.get's of the same index being identical. (It is
// also ok to have side effects here, if we can remove them, as we are also
// checking if we can remove the two inputs anyhow.)
- auto passOptions = getPassOptions();
+ auto& passOptions = getPassOptions();
if (EffectAnalyzer(passOptions, *getModule(), left)
.hasUnremovableSideEffects() ||
EffectAnalyzer(passOptions, *getModule(), right)
@@ -3292,7 +3292,7 @@ private:
}
Expression* optimizeMemoryCopy(MemoryCopy* memCopy) {
- PassOptions options = getPassOptions();
+ auto& options = getPassOptions();
if (options.ignoreImplicitTraps || options.trapsNeverHappen) {
if (ExpressionAnalyzer::equal(memCopy->dest, memCopy->source)) {
@@ -3371,7 +3371,7 @@ private:
return nullptr;
}
- PassOptions options = getPassOptions();
+ auto& options = getPassOptions();
Builder builder(*getModule());
auto* csize = memFill->size->cast<Const>();