Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Jul 10, 2024

Normally we use it when optimizing (above a certain level). This lets the user
prevent it from being used even then.

Also add optimization options to wasm-metadce so that this is possible
there as well and not just in wasm-opt (this also opens the door to running
more passes in metadce, which may be useful later).

A use case for this is Emscripten, which runs wasm-opt more than once.
We do not want to use StackIR in the earlier invocations, but only in the
last, for efficiency and also to avoid corner cases with the fixups for stacky
code ending up requiring more optimization work (see
emscripten-core/emscripten#22196, which will be fixed by this + another PR in
emscripten to use this).

Comment on lines +6 to +10
;; As above, but disallow it later. This does not optimize.
;; RUN: wasm-opt %s --generate-stack-ir --optimize-stack-ir -all --no-stack-ir --print-stack-ir | filecheck %s --check-prefix=DISALLOWD

;; As above, but flip it, so we allow it after disallowing. This optimizes.
;; RUN: wasm-opt %s --no-stack-ir --generate-stack-ir --optimize-stack-ir -all --print-stack-ir | filecheck %s --check-prefix=REALLOWED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how these commands end up with different results? I am baffled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • --no-stack-ir says "disable it"
  • --optimize-stack-ir says "enable it"

And the last one on the commandline wins, just like -fno-exceptions -fexceptions etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, --optimize-stack-ir is handled in ToolOptions 👍

@kripken kripken merged commit 37a86d5 into WebAssembly:main Jul 10, 2024
@kripken kripken deleted the stackir.disallow branch July 10, 2024 19:15
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants