summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h4
-rw-r--r--src/cfg/Relooper.cpp2
-rw-r--r--src/dataflow/graph.h2
-rw-r--r--src/ir/memory-utils.h4
-rw-r--r--src/passes/PostAssemblyScript.cpp2
-rw-r--r--src/support/debug.cpp4
-rw-r--r--src/support/debug.h10
-rw-r--r--src/support/threads.h3
-rw-r--r--src/wasm-binary.h4
9 files changed, 29 insertions, 6 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 637c4ec3b..24e9ddc76 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -139,13 +139,13 @@ Name EMSCRIPTEN_DEBUGINFO("emscripten_debuginfo");
// Utilities
-static void abort_on(std::string why, Ref element) {
+static WASM_NORETURN void abort_on(std::string why, Ref element) {
std::cerr << why << ' ';
element->stringify(std::cerr);
std::cerr << '\n';
abort();
}
-static void abort_on(std::string why, IString element) {
+static WASM_NORETURN void abort_on(std::string why, IString element) {
std::cerr << why << ' ' << element.str << '\n';
abort();
}
diff --git a/src/cfg/Relooper.cpp b/src/cfg/Relooper.cpp
index 3acb2a2bf..d46b39a8e 100644
--- a/src/cfg/Relooper.cpp
+++ b/src/cfg/Relooper.cpp
@@ -785,9 +785,11 @@ struct Optimizer : public RelooperRecursor {
}
} else {
// If the block has no switch, the branches must not as well.
+#ifndef NDEBUG
for (auto& iter : ParentBlock->BranchesOut) {
assert(!iter.second->SwitchValues);
}
+#endif
}
}
return Worked;
diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h
index a243b0fff..2d9b87873 100644
--- a/src/dataflow/graph.h
+++ b/src/dataflow/graph.h
@@ -652,9 +652,11 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
// Merge local state for multiple control flow paths, creating phis as needed.
void merge(std::vector<FlowState>& states, Locals& out) {
// We should only receive reachable states.
+#ifndef NDEBUG
for (auto& state : states) {
assert(!isInUnreachable(state.locals));
}
+#endif
Index numStates = states.size();
if (numStates == 0) {
// We were unreachable, and still are.
diff --git a/src/ir/memory-utils.h b/src/ir/memory-utils.h
index 39914a95a..c6b2fad18 100644
--- a/src/ir/memory-utils.h
+++ b/src/ir/memory-utils.h
@@ -120,7 +120,6 @@ inline bool ensureLimitedSegments(Module& module) {
// check if we have too many dynamic data segments, which we can do nothing
// about
- auto num = numConstant + numDynamic;
if (numDynamic + 1 >= WebLimitations::MaxDataSegments) {
return false;
}
@@ -128,7 +127,8 @@ inline bool ensureLimitedSegments(Module& module) {
// we'll merge constant segments if we must
if (numConstant + numDynamic >= WebLimitations::MaxDataSegments) {
numConstant = WebLimitations::MaxDataSegments - numDynamic - 1;
- num = numConstant + numDynamic;
+ auto num = numConstant + numDynamic;
+ WASM_UNUSED(num);
assert(num == WebLimitations::MaxDataSegments - 1);
}
diff --git a/src/passes/PostAssemblyScript.cpp b/src/passes/PostAssemblyScript.cpp
index eb2b1bfb4..4e41c8f08 100644
--- a/src/passes/PostAssemblyScript.cpp
+++ b/src/passes/PostAssemblyScript.cpp
@@ -101,6 +101,7 @@ static bool isRetain(LocalSet* expr) {
return false;
}
+#ifndef NDEBUG
// Tests if the given location is that of a full retain pattern.
static bool isRetainLocation(Expression** expr) {
if (expr != nullptr) {
@@ -110,6 +111,7 @@ static bool isRetainLocation(Expression** expr) {
}
return false;
}
+#endif
// Tests if the given call calls release. Note that this differs from what we
// consider a full release pattern, which must also get a local.
diff --git a/src/support/debug.cpp b/src/support/debug.cpp
index 15b708d5e..da006e9c0 100644
--- a/src/support/debug.cpp
+++ b/src/support/debug.cpp
@@ -20,6 +20,8 @@
#include <set>
#include <string>
+#ifndef NDEBUG
+
static bool debugEnabled = false;
static std::set<std::string> debugTypesEnabled;
@@ -49,3 +51,5 @@ void wasm::setDebugEnabled(const char* types) {
start += type_size + 1;
}
}
+
+#endif
diff --git a/src/support/debug.h b/src/support/debug.h
index 960082d1a..edb19ebda 100644
--- a/src/support/debug.h
+++ b/src/support/debug.h
@@ -44,14 +44,20 @@ void setDebugEnabled(const char* types);
#else
+// We have an option to build with assertions disabled
+// BYN_ASSERTIONS_ENABLED=OFF, but we currently don't recommend using and we
+// don't test with it.
+#error "binaryen is currently designed to be built with assertions enabled."
+#error "remove these #errors if you want to build without them anyway."
+
#define BYN_DEBUG_WITH_TYPE(...) \
do { \
} while (false)
#define BYN_TRACE_WITH_TYPE(...) \
do { \
} while (false)
-#define isDebugEnabled() (false)
-#define setDebugEnabled()
+#define isDebugEnabled(type) (false)
+#define setDebugEnabled(types)
#endif
diff --git a/src/support/threads.h b/src/support/threads.h
index 8cfa79c87..8a04f78bd 100644
--- a/src/support/threads.h
+++ b/src/support/threads.h
@@ -29,6 +29,8 @@
#include <thread>
#include <vector>
+#include "compiler-support.h"
+
namespace wasm {
// The work state of a helper thread - is there more to do,
@@ -124,6 +126,7 @@ public:
void verify() {
auto before = created.fetch_add(1);
+ WASM_UNUSED(before);
assert(before == 0);
}
};
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index a901142b2..ec95470ad 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -205,6 +205,7 @@ public:
}
BufferWithRandomAccess& operator<<(U32LEB x) {
size_t before = -1;
+ WASM_UNUSED(before);
BYN_DEBUG(before = size(); std::cerr << "writeU32LEB: " << x.value
<< " (at " << before << ")"
<< std::endl;);
@@ -216,6 +217,7 @@ public:
}
BufferWithRandomAccess& operator<<(U64LEB x) {
size_t before = -1;
+ WASM_UNUSED(before);
BYN_DEBUG(before = size(); std::cerr << "writeU64LEB: " << x.value
<< " (at " << before << ")"
<< std::endl;);
@@ -227,6 +229,7 @@ public:
}
BufferWithRandomAccess& operator<<(S32LEB x) {
size_t before = -1;
+ WASM_UNUSED(before);
BYN_DEBUG(before = size(); std::cerr << "writeS32LEB: " << x.value
<< " (at " << before << ")"
<< std::endl;);
@@ -238,6 +241,7 @@ public:
}
BufferWithRandomAccess& operator<<(S64LEB x) {
size_t before = -1;
+ WASM_UNUSED(before);
BYN_DEBUG(before = size(); std::cerr << "writeS64LEB: " << x.value
<< " (at " << before << ")"
<< std::endl;);