summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-03-04 14:35:00 -0800
committerGitHub <noreply@github.com>2024-03-04 14:35:00 -0800
commite6cd45629860d43f9c8ab34c81c6b3b4455ec49d (patch)
treeb2b2a399742cadfd285ddd1b88eb6bc393f49959
parent88108efb180d6059417c26af6ff6123cde26eba3 (diff)
downloadbinaryen-e6cd45629860d43f9c8ab34c81c6b3b4455ec49d.tar.gz
binaryen-e6cd45629860d43f9c8ab34c81c6b3b4455ec49d.tar.bz2
binaryen-e6cd45629860d43f9c8ab34c81c6b3b4455ec49d.zip
OptimizeAddedConstants: Replace an assert with a proper error (#6375)
See #6373
-rw-r--r--src/passes/OptimizeAddedConstants.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/passes/OptimizeAddedConstants.cpp b/src/passes/OptimizeAddedConstants.cpp
index 696aeaa1c..934fe8be8 100644
--- a/src/passes/OptimizeAddedConstants.cpp
+++ b/src/passes/OptimizeAddedConstants.cpp
@@ -285,8 +285,11 @@ struct OptimizeAddedConstants
}
void doWalkFunction(Function* func) {
- // This pass is only valid under the assumption of unused low memory.
- assert(getPassOptions().lowMemoryUnused);
+ if (!getPassOptions().lowMemoryUnused) {
+ Fatal() << "OptimizeAddedConstants can only be run when the "
+ << "--low-memory-unused flag is set.";
+ }
+
// Multiple passes may be needed if we have x + 4 + 8 etc. (nested structs
// in C can cause this, but it's rare). Note that we only need that for the
// propagation case (as 4 + 8 would be optimized directly if it were