Skip to content

Comments

Make MaxCombinedBinarySize configurable#7820

Merged
kripken merged 1 commit intoWebAssembly:mainfrom
yamt:max-combined-size
Aug 18, 2025
Merged

Make MaxCombinedBinarySize configurable#7820
kripken merged 1 commit intoWebAssembly:mainfrom
yamt:max-combined-size

Conversation

@yamt
Copy link
Contributor

@yamt yamt commented Aug 13, 2025

Use case: I want to avoid generating "huge" (eg. 50KB) functions,
which can involve certain kind of text relocations in aot-compiled
binaries for my target. (WAMR, xtensa, l32r+jx target address)

@yamt yamt force-pushed the max-combined-size branch from 67ed9a6 to 43902cc Compare August 13, 2025 08:05
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Makes sense to add, sounds good.

You will need to run ./scripts/update_help_checks.py to update the help expecations for the new flag.

Also please add a test for this, something like setting a very low max size that prevents an inlining. For an example test, see test/lit/passes/inlining-const-args.wat - like there, the test can use RUN with several different flag values, to show the different results.

Name inlinedName = inlinedFunction->name;
if (!isUnderSizeLimit(func->name, inlinedName)) {
if (!isUnderSizeLimit(
func->name, inlinedName, getPassRunner()->options)) {
Copy link
Member

Choose a reason for hiding this comment

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

It might be simpler to not pass in the options, and call getPassRunner() in the called function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. i reverted this part. thank you.

@yamt yamt force-pushed the max-combined-size branch from 43902cc to c54184f Compare August 14, 2025 03:17
@yamt
Copy link
Contributor Author

yamt commented Aug 14, 2025

Makes sense to add, sounds good.

You will need to run ./scripts/update_help_checks.py to update the help expecations for the new flag.

Also please add a test for this, something like setting a very low max size that prevents an inlining. For an example test, see test/lit/passes/inlining-const-args.wat - like there, the test can use RUN with several different flag values, to show the different results.

thank you. i added a test.

@yamt yamt force-pushed the max-combined-size branch from c54184f to 8e5d57c Compare August 14, 2025 03:29
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Looks good aside from minor comments on the test.

@@ -0,0 +1,735 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
Copy link
Member

Choose a reason for hiding this comment

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

The name of the testcase has a typo:

test/lit/passes/inlining-max-comibned-size.wat

should be

test/lit/passes/inlining-max-combined-size.wat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, fixed.

;; RUN: foreach %s %t wasm-opt -O3 -S -o - | filecheck %s --check-prefix=default
;; RUN: foreach %s %t wasm-opt -O3 --inline-max-combined-binary-size=96 -S -o - | filecheck %s --check-prefix=imcbs96
;; RUN: foreach %s %t wasm-opt -O3 --inline-max-combined-binary-size=90 -S -o - | filecheck %s --check-prefix=imcbs90
;; RUN: foreach %s %t wasm-opt -O3 --inline-max-combined-binary-size=0 -S -o - | filecheck %s --check-prefix=imcbs0
Copy link
Member

Choose a reason for hiding this comment

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

Check-prefixes should be in all-caps, just as a convention, so IMCBS0 etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. fixed.

;; RUN: foreach %s %t wasm-opt -O3 --inline-max-combined-binary-size=0 -S -o - | filecheck %s --check-prefix=imcbs0

(module
;; small: (type $0 (func (param i32 i32 i32)))
Copy link
Member

Choose a reason for hiding this comment

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

is small leftover from an earlier version perhaps? I don't see a RUN line for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops. fixed. thank you.

;; RUN: foreach %s %t wasm-opt -O3 --inline-max-combined-binary-size=90 -S -o - | filecheck %s --check-prefix=imcbs90
;; RUN: foreach %s %t wasm-opt -O3 --inline-max-combined-binary-size=0 -S -o - | filecheck %s --check-prefix=imcbs0

(module
Copy link
Member

Choose a reason for hiding this comment

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

Please add a toplevel comment explaining what to look for here. Something like: "Functions X,Y get inlined in IMCBS0 and Z but not W, because then the size would [..]" etc. With such comments in the tests, it's easy to understand what is being tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i added a comment.

@yamt yamt force-pushed the max-combined-size branch 2 times, most recently from e2fbee5 to bd73d83 Compare August 15, 2025 02:44
Use case: I want to avoid generating "huge" (eg. 50KB) functions,
which can involve certain kind of text relocations in aot-compiled
binaries for my target. (WAMR, xtensa, l32r+jx target address)
@yamt yamt force-pushed the max-combined-size branch from bd73d83 to 2880f9c Compare August 15, 2025 02:45
@kripken kripken merged commit 2ffe187 into WebAssembly:main Aug 18, 2025
16 checks passed
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