From e488da5adbef2613c08fe205db5b79b1765a4af3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 28 Jun 2017 22:05:05 -0700 Subject: Code folding (#1076) Adds a pass that folds code, i.e. merges it when possible. See details in comment in the pass implementation cpp. This is enabled by default in -Os and -Oz. Seems risky to enable anywhere else, as it does add branches - likely predictable ones so maybe no slowdown, but still some risk. Code size numbers: wasm-backend: 196331 + binaryen -Os (before): 182598 + binaryen -Os (with folding): 181943 asm2wasm -Os (before): 172463 asm2wasm -Os (with folding): 168774 So this reduces wasm-backend output by an additional 0.5% than it could before. Mainly this is because the wasm backend already has code folding, whereas on asm2wasm output, where we didn't have folding before, this saves over 2%. The 0.5% improvement on the wasm backend's output might be because this can fold more types of code than LLVM can (it can fold nested control flow, in particular). --- src/pass.h | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/pass.h') diff --git a/src/pass.h b/src/pass.h index 198d5dcb5..21836ebf9 100644 --- a/src/pass.h +++ b/src/pass.h @@ -237,29 +237,6 @@ public: // but registering them here in addition allows them to communicate // e.g. through PassRunner::getLast -// Handles names in a module, in particular adding names without duplicates -class NameManager : public WalkerPass> { - public: - Name getUnique(std::string prefix); - // TODO: getUniqueInFunction - - // visitors - void visitBlock(Block* curr); - void visitLoop(Loop* curr); - void visitBreak(Break* curr); - void visitSwitch(Switch* curr); - void visitCall(Call* curr); - void visitCallImport(CallImport* curr); - void visitFunctionType(FunctionType* curr); - void visitFunction(Function* curr); - void visitImport(Import* curr); - void visitExport(Export* curr); - -private: - std::set names; - size_t counter = 0; -}; - // Prints out a module class Printer : public Pass { protected: -- cgit v1.2.3