Skip to content

Commit b70399f

Browse files
authored
Fix settings.js doc for INLINING_LIMIT (#13757)
This option was created as a numeric scale but currently what only matters is if it is 0 or not, effectively making this a boolean switch. This PR fixes the comment for `INLINING_LIMIT` in settings.js and converts uses of `INLINING_LIMIT` options in tests that use values greater than 1 to use 1.
1 parent 77bed6b commit b70399f

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

emcc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,11 +2555,11 @@ def consume_arg_file():
25552555
if options.requested_level == 's':
25562556
options.requested_level = 2
25572557
shared.Settings.SHRINK_LEVEL = 1
2558-
settings_changes.append('INLINING_LIMIT=50')
2558+
settings_changes.append('INLINING_LIMIT=1')
25592559
elif options.requested_level == 'z':
25602560
options.requested_level = 2
25612561
shared.Settings.SHRINK_LEVEL = 2
2562-
settings_changes.append('INLINING_LIMIT=25')
2562+
settings_changes.append('INLINING_LIMIT=1')
25632563
shared.Settings.OPT_LEVEL = validate_arg_level(options.requested_level, 3, 'Invalid optimization level: ' + arg, clamp=True)
25642564
elif check_arg('--js-opts'):
25652565
logger.warning('--js-opts ignored when using llvm backend')

src/settings.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,9 @@ var IGNORE_CLOSURE_COMPILER_ERRORS = 0;
290290
// [link]
291291
var DECLARE_ASM_MODULE_EXPORTS = 1;
292292

293-
// A limit on inlining. If 0, we will inline normally in LLVM and closure. If
294-
// greater than 0, we will *not* inline in LLVM, and we will prevent inlining of
295-
// functions of this size or larger in closure. 50 is a reasonable setting if
296-
// you do not want inlining
297-
// [compile+link]
293+
// If 0, prevents inlining if set to 1. If 0, we will inline normally in LLVM.
294+
// This does not affect the inlining policy in Binaryen.
295+
// [compile]
298296
var INLINING_LIMIT = 0;
299297

300298
// If set to 1, perform acorn pass that converts each HEAP access into a

tests/test_core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ def test_loop(self):
765765
self.do_core_test('test_loop.c')
766766

767767
def test_stack(self):
768-
self.set_setting('INLINING_LIMIT', 50)
768+
self.set_setting('INLINING_LIMIT')
769769
# some extra coverage in all test suites for stack checks
770770
self.set_setting('STACK_OVERFLOW_CHECK', 2)
771771

@@ -1238,7 +1238,7 @@ def test_exceptions_3(self):
12381238
def test_exceptions_allowed(self):
12391239
self.set_setting('EXCEPTION_CATCHING_ALLOWED', ["_Z12somefunctionv"])
12401240
# otherwise it is inlined and not identified
1241-
self.set_setting('INLINING_LIMIT', 50)
1241+
self.set_setting('INLINING_LIMIT')
12421242

12431243
self.do_core_test('test_exceptions_allowed.cpp')
12441244
size = os.path.getsize('test_exceptions_allowed.js')
@@ -1622,7 +1622,7 @@ def test_stack_varargs(self):
16221622
# of the program directory influences how much stack we need, and so
16231623
# long random temp dir names can lead to random failures. The stack
16241624
# size was increased here to avoid that.
1625-
self.set_setting('INLINING_LIMIT', 50)
1625+
self.set_setting('INLINING_LIMIT')
16261626
self.set_setting('TOTAL_STACK', 8 * 1024)
16271627

16281628
self.do_core_test('test_stack_varargs.c')
@@ -1708,7 +1708,7 @@ def test_stack_varargs2(self):
17081708

17091709
def test_stack_void(self):
17101710
self.emcc_args.append('-Wno-format-extra-args')
1711-
self.set_setting('INLINING_LIMIT', 50)
1711+
self.set_setting('INLINING_LIMIT')
17121712
self.do_core_test('test_stack_void.c')
17131713

17141714
def test_life(self):
@@ -2286,7 +2286,7 @@ def test_functionpointer_libfunc_varargs(self):
22862286
self.do_core_test('test_functionpointer_libfunc_varargs.c')
22872287

22882288
def test_structbyval(self):
2289-
self.set_setting('INLINING_LIMIT', 50)
2289+
self.set_setting('INLINING_LIMIT')
22902290

22912291
# part 1: make sure that normally, passing structs by value works
22922292

@@ -6016,7 +6016,7 @@ def test_sqlite(self):
60166016
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free'])
60176017
if '-g' in self.emcc_args:
60186018
print("disabling inlining") # without registerize (which -g disables), we generate huge amounts of code
6019-
self.set_setting('INLINING_LIMIT', 50)
6019+
self.set_setting('INLINING_LIMIT')
60206020

60216021
# newer clang has a warning for implicit conversions that lose information,
60226022
# which happens in sqlite (see #9138)

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6579,7 +6579,7 @@ def test_disable_inlining(self):
65796579
}
65806580
''')
65816581

6582-
# Without the 'INLINING_LIMIT=1', -O2 inlines foo()
6582+
# Without the 'INLINING_LIMIT', -O2 inlines foo()
65836583
cmd = [EMCC, '-c', 'test.c', '-O2', '-o', 'test.o', '-s', 'INLINING_LIMIT', '-flto']
65846584
self.run_process(cmd)
65856585
# If foo() had been wrongly inlined above, internalizing foo and running

0 commit comments

Comments
 (0)