Skip to content

🍒 [WebAssembly] Define local sp if llvm.stacksave is used #7563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Oct 3, 2023

Cherry-pick: da0ca5d
Resolves: rdar://116374985


Usually llvm.stacksave/stackrestore are used together with alloca but they can appear without it (e.g. alloca can be optimized away). WebAssembly's function local physical user sp register, which is referenced by llvm.stacksave is created while frame lowering and replaced with virtual register. However the sp register was not created when llvm.stacksave is used without alloca, and it led MIR verification failure about use-before-def of sp virtual register.

@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@kateinoigakukun kateinoigakukun changed the title [WebAssembly] Define local sp if llvm.stacksave is used 🍒 [WebAssembly] Define local sp if llvm.stacksave is used Oct 3, 2023
@MaxDesiatov MaxDesiatov requested a review from al45tair October 3, 2023 22:15
Copy link

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Comparing the cherry-pick to the original commit, this looks clean to me 👍

@MaxDesiatov MaxDesiatov self-requested a review October 3, 2023 22:22
@MaxDesiatov
Copy link

Should this target a different branch though? stable/20221013 is quite old, I'm not sure if it corresponds to the current Swift branch

Usually `llvm.stacksave/stackrestore` are used together with `alloca`
but they can appear without it (e.g. `alloca` can be optimized away).
WebAssembly's function local physical user sp register, which is
referenced by `llvm.stacksave` is created while frame lowering and
replaced with virtual register.
However the sp register was not created when `llvm.stacksave` is used
without `alloca`, and it led MIR verification failure about
use-before-def of sp virtual register.

Resolves llvm#62235
@kateinoigakukun kateinoigakukun changed the base branch from stable/20221013 to stable/20230725 October 3, 2023 23:53
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

Copy link

@al45tair al45tair left a comment

Choose a reason for hiding this comment

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

LGTM.

@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@kateinoigakukun kateinoigakukun merged commit 332fa4c into swiftlang:stable/20230725 Oct 9, 2023
@kateinoigakukun kateinoigakukun deleted the yt/wasm-stacksave-dom branch October 9, 2023 19:55
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.

3 participants