From dfcae55bd02747cb1eaf8410c02ac4d53ee1fd01 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 31 Jan 2024 14:29:53 -0800 Subject: StringGathering pass (#6257) This pass finds all string.const and creates globals for them. After this transform, no string.const appears anywhere but in a global, and each string appears in one global which is then global.get-ed everywhere. This avoids overhead in VMs where executing a string.const is an allocation, and is also a good step towards imported strings. For that, this pass will be extended from gathering to a full lowering pass, which will first gather into globals as this pass does, and then turn each of those globals with a string.const into an imported externref. (For that reason this pass is in a file called StringLowering, as the two passes will share much of their code, and the larger pass should decide the name I think.) This pass runs in -O2 and above. Repeated executions have no downside (see details in code). --- test/lit/help/wasm-opt.test | 2 ++ test/lit/help/wasm2js.test | 2 ++ 2 files changed, 4 insertions(+) (limited to 'test/lit/help') diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index fc33fce8d..8732f5e27 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -467,6 +467,8 @@ ;; CHECK-NEXT: --stack-check enforce limits on llvm's ;; CHECK-NEXT: __stack_pointer global ;; CHECK-NEXT: +;; CHECK-NEXT: --string-gathering gathers wasm strings to globals +;; CHECK-NEXT: ;; CHECK-NEXT: --strip deprecated; same as strip-debug ;; CHECK-NEXT: ;; CHECK-NEXT: --strip-debug strip debug info (including the diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index 7db564101..40d608857 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -426,6 +426,8 @@ ;; CHECK-NEXT: --stack-check enforce limits on llvm's ;; CHECK-NEXT: __stack_pointer global ;; CHECK-NEXT: +;; CHECK-NEXT: --string-gathering gathers wasm strings to globals +;; CHECK-NEXT: ;; CHECK-NEXT: --strip deprecated; same as strip-debug ;; CHECK-NEXT: ;; CHECK-NEXT: --strip-debug strip debug info (including the -- cgit v1.2.3