-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[lld][WebAssembly] Allow --no-stack-first in addition to --stack-first
#166384
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
Merged
+29
−3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@llvm/pr-subscribers-lld-wasm @llvm/pr-subscribers-lld Author: Sam Clegg (sbc100) ChangesThis paves the way to make See: #151015 Full diff: https://github.com/llvm/llvm-project/pull/166384.diff 2 Files Affected:
diff --git a/lld/test/wasm/stack-first.test b/lld/test/wasm/stack-first.test
index 72e1a006d5700..33f5e6a14b564 100644
--- a/lld/test/wasm/stack-first.test
+++ b/lld/test/wasm/stack-first.test
@@ -8,6 +8,15 @@ RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/stack-first.
RUN: wasm-ld -z stack-size=512 --stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
RUN: obj2yaml %t.wasm | FileCheck %s
+; Check `--no-stack-first`
+RUN: wasm-ld -z stack-size=512 --no-stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
+RUN: obj2yaml %t.wasm | FileCheck %s --check-prefix=NOT-FIRST
+
+; Check that the default
+RUN: wasm-ld -z stack-size=512 --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
+RUN: obj2yaml %t.wasm | FileCheck %s --check-prefix=NOT-FIRST
+
+
CHECK: - Type: GLOBAL
CHECK-NEXT: Globals:
CHECK-NEXT: - Index: 0
@@ -51,3 +60,19 @@ CHECK-NEXT: Index: 2
CHECK-NEXT: - Name: __heap_base
CHECK-NEXT: Kind: GLOBAL
CHECK-NEXT: Index: 3
+
+NOT-FIRST: - Type: GLOBAL
+NOT-FIRST-NEXT: Globals:
+NOT-FIRST-NEXT: - Index: 0
+NOT-FIRST-NEXT: Type: I32
+NOT-FIRST-NEXT: Mutable: true
+NOT-FIRST-NEXT: InitExpr:
+NOT-FIRST-NEXT: Opcode: I32_CONST
+NOT-FIRST-NEXT: Value: 1552
+NOT-FIRST-NEXT: - Index: 1
+NOT-FIRST-NEXT: Type: I32
+NOT-FIRST-NEXT: Mutable: false
+NOT-FIRST-NEXT: InitExpr:
+NOT-FIRST-NEXT: Opcode: I32_CONST
+NOT-FIRST-NEXT: Value: 1024
+
diff --git a/lld/wasm/Options.td b/lld/wasm/Options.td
index 2f699e2f68350..3c9d29cd2bb6a 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -250,8 +250,9 @@ def no_entry: FF<"no-entry">,
def no_shlib_sigcheck: FF<"no-shlib-sigcheck">,
HelpText<"Do not check signatures of functions defined in shared libraries.">;
-def stack_first: FF<"stack-first">,
- HelpText<"Place stack at start of linear memory rather than after data">;
+defm stack_first: B<"stack-first",
+ "Place stack at start of linear memory",
+ "Place the stack after static data refion (default)">;
def table_base: JJ<"table-base=">,
HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;
|
2795116 to
e31e761
Compare
…first` This paves the way to make `--stack-first` the default. See: llvm#151015
e31e761 to
b911ede
Compare
bakkot
reviewed
Nov 4, 2025
| HelpText<"Place stack at start of linear memory rather than after data">; | ||
| defm stack_first: B<"stack-first", | ||
| "Place stack at start of linear memory", | ||
| "Place the stack after static data refion (default)">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| "Place the stack after static data refion (default)">; | |
| "Place the stack after static data region (default)">; |
(I assume)
dschuff
approved these changes
Nov 4, 2025
Co-authored-by: Derek Schuff <dschuff@chromium.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This paves the way to make
--stack-firstthe default.See: #151015