summaryrefslogtreecommitdiff
path: root/src/passes/ConstHoisting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/ConstHoisting.cpp')
-rw-r--r--src/passes/ConstHoisting.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/passes/ConstHoisting.cpp b/src/passes/ConstHoisting.cpp
index 11188a9ba..f67a48645 100644
--- a/src/passes/ConstHoisting.cpp
+++ b/src/passes/ConstHoisting.cpp
@@ -32,10 +32,10 @@
#include <map>
-#include <wasm.h>
#include <pass.h>
#include <wasm-binary.h>
#include <wasm-builder.h>
+#include <wasm.h>
namespace wasm {
@@ -66,16 +66,14 @@ struct ConstHoisting : public WalkerPass<PostWalker<ConstHoisting>> {
if (!prelude.empty()) {
Builder builder(*getModule());
// merge-blocks can optimize this into a single block later in most cases
- curr->body = builder.makeSequence(
- builder.makeBlock(prelude),
- curr->body
- );
+ curr->body = builder.makeSequence(builder.makeBlock(prelude), curr->body);
}
}
private:
bool worthHoisting(Literal value, Index num) {
- if (num < MIN_USES) return false;
+ if (num < MIN_USES)
+ return false;
// measure the size of the constant
Index size = 0;
switch (value.type) {
@@ -112,8 +110,7 @@ private:
return after < before;
}
- template<typename T>
- Index getWrittenSize(const T& thing) {
+ template<typename T> Index getWrittenSize(const T& thing) {
BufferWithRandomAccess buffer;
buffer << thing;
return buffer.size();
@@ -125,10 +122,7 @@ private:
auto type = (*(vec[0]))->type;
Builder builder(*getModule());
auto temp = builder.addVar(getFunction(), type);
- auto* ret = builder.makeSetLocal(
- temp,
- *(vec[0])
- );
+ auto* ret = builder.makeSetLocal(temp, *(vec[0]));
for (auto item : vec) {
*item = builder.makeGetLocal(temp, type);
}
@@ -136,8 +130,6 @@ private:
}
};
-Pass *createConstHoistingPass() {
- return new ConstHoisting();
-}
+Pass* createConstHoistingPass() { return new ConstHoisting(); }
} // namespace wasm