Skip to content

Commit 48c038a

Browse files
sbc100github-actions[bot]
authored andcommitted
Automerge: [lld][WebAssembly] Allow --no-stack-first in addition to --stack-first (#166384)
This paves the way to make `--stack-first` the default. See: #151015
2 parents 8c97ee5 + e29ee27 commit 48c038a

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

lld/test/wasm/stack-first.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/stack-first.
88
RUN: wasm-ld -z stack-size=512 --stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
99
RUN: obj2yaml %t.wasm | FileCheck %s
1010

11+
; Check `--no-stack-first`
12+
RUN: wasm-ld -z stack-size=512 --stack-first --no-stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
13+
RUN: obj2yaml %t.wasm | FileCheck %s --check-prefix=NOT-FIRST
14+
15+
; Check that the default is no-stack-first
16+
RUN: wasm-ld -z stack-size=512 --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o
17+
RUN: obj2yaml %t.wasm | FileCheck %s --check-prefix=NOT-FIRST
18+
19+
1120
CHECK: - Type: GLOBAL
1221
CHECK-NEXT: Globals:
1322
CHECK-NEXT: - Index: 0
@@ -51,3 +60,19 @@ CHECK-NEXT: Index: 2
5160
CHECK-NEXT: - Name: __heap_base
5261
CHECK-NEXT: Kind: GLOBAL
5362
CHECK-NEXT: Index: 3
63+
64+
NOT-FIRST: - Type: GLOBAL
65+
NOT-FIRST-NEXT: Globals:
66+
NOT-FIRST-NEXT: - Index: 0
67+
NOT-FIRST-NEXT: Type: I32
68+
NOT-FIRST-NEXT: Mutable: true
69+
NOT-FIRST-NEXT: InitExpr:
70+
NOT-FIRST-NEXT: Opcode: I32_CONST
71+
NOT-FIRST-NEXT: Value: 1552
72+
NOT-FIRST-NEXT: - Index: 1
73+
NOT-FIRST-NEXT: Type: I32
74+
NOT-FIRST-NEXT: Mutable: false
75+
NOT-FIRST-NEXT: InitExpr:
76+
NOT-FIRST-NEXT: Opcode: I32_CONST
77+
NOT-FIRST-NEXT: Value: 1024
78+

lld/wasm/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static void readConfigs(opt::InputArgList &args) {
595595
ctx.arg.shlibSigCheck = !args.hasArg(OPT_no_shlib_sigcheck);
596596
ctx.arg.stripAll = args.hasArg(OPT_strip_all);
597597
ctx.arg.stripDebug = args.hasArg(OPT_strip_debug);
598-
ctx.arg.stackFirst = args.hasArg(OPT_stack_first);
598+
ctx.arg.stackFirst = args.hasFlag(OPT_stack_first, OPT_no_stack_first, false);
599599
ctx.arg.trace = args.hasArg(OPT_trace);
600600
ctx.arg.thinLTOCacheDir = args.getLastArgValue(OPT_thinlto_cache_dir);
601601
ctx.arg.thinLTOCachePolicy = CHECK(

lld/wasm/Options.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ def no_entry: FF<"no-entry">,
250250
def no_shlib_sigcheck: FF<"no-shlib-sigcheck">,
251251
HelpText<"Do not check signatures of functions defined in shared libraries.">;
252252

253-
def stack_first: FF<"stack-first">,
254-
HelpText<"Place stack at start of linear memory rather than after data">;
253+
defm stack_first: B<"stack-first",
254+
"Place stack at start of linear memory",
255+
"Place the stack after static data refion (default)">;
255256

256257
def table_base: JJ<"table-base=">,
257258
HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;

0 commit comments

Comments
 (0)