Skip to content

Commit 2a437e0

Browse files
committed
Remove fastc-only ELIMINATE_DUPLICATE_FUNCTIONS option. See #11860
1 parent aa130a4 commit 2a437e0

File tree

8 files changed

+1
-475
lines changed

8 files changed

+1
-475
lines changed

emcc.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,9 +1869,6 @@ def include_and_export(name):
18691869
shared.Settings.WASM_BINARY_FILE = shared.JS.escape_for_js_string(os.path.basename(wasm_binary_target))
18701870
shared.Settings.ASMJS_CODE_FILE = shared.JS.escape_for_js_string(os.path.basename(asm_target))
18711871
shared.Settings.ASM_JS = 2 # when targeting wasm, we use a wasm Memory, but that is not compatible with asm.js opts
1872-
if shared.Settings.ELIMINATE_DUPLICATE_FUNCTIONS:
1873-
diagnostics.warning('emcc', 'for wasm there is no need to set ELIMINATE_DUPLICATE_FUNCTIONS, the binaryen optimizer does it automatically')
1874-
shared.Settings.ELIMINATE_DUPLICATE_FUNCTIONS = 0
18751872
if options.js_opts and not options.force_js_opts:
18761873
options.js_opts = None
18771874
logger.debug('asm.js opts not forced by user or an option that depends them, and we do not intend to run the asm.js, so disabling and leaving opts to the binaryen optimizer')
@@ -2695,12 +2692,6 @@ def get_eliminate():
26952692
else:
26962693
optimizer.queue += ['registerize']
26972694

2698-
# NOTE: Important that this comes after registerize/registerizeHarder
2699-
if shared.Settings.ELIMINATE_DUPLICATE_FUNCTIONS and shared.Settings.OPT_LEVEL >= 2:
2700-
optimizer.flush()
2701-
building.eliminate_duplicate_funcs(final)
2702-
save_intermediate('dfe')
2703-
27042695
if shared.Settings.EVAL_CTORS and options.memory_init_file and not use_source_map(options) and not shared.Settings.WASM:
27052696
optimizer.flush()
27062697
building.eval_ctors(final, memfile)

site/source/docs/optimizing/Optimizing-Code.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ The following compiler settings can help (see ``src/settings.js`` for more detai
8686
- Disable inlining when possible, using ``-s INLINING_LIMIT=1``. Compiling with -Os or -Oz generally avoids inlining too. (Inlining can make code faster, though, so use this carefully.)
8787
- You can use the ``-s FILESYSTEM=0`` option to disable bundling of filesystem support code (the compiler should optimize it out if not used, but may not always succeed). This can be useful if you are building a pure computational library, for example.
8888
- The ``ENVIRONMENT`` flag lets you specify that the output will only run on the web, or only run in node.js, etc. This prevents the compiler from emitting code to support all possible runtime environments, saving ~2KB.
89-
- You can use ``ELIMINATE_DUPLICATE_FUNCTIONS`` to remove duplicate functions, which C++ templates often create. (This is already done by default for wasm, in ``-O1`` and above.)
9089

9190
LTO
9291
===

src/settings.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,19 +1412,6 @@ var PTHREADS_DEBUG = 0;
14121412
// If true, building against Emscripten's asm.js/wasm heap memory profiler.
14131413
var MEMORYPROFILER = 0;
14141414

1415-
// Duplicate function elimination. This coalesces function bodies that are
1416-
// identical, which can happen e.g. if two methods have different C/C++ or LLVM
1417-
// types, but end up identical at the asm.js level (all pointers are the same as
1418-
// int32_t in asm.js, for example).
1419-
//
1420-
// This option is quite slow to run, as it processes and hashes all methods in
1421-
// the codebase in multiple passes.
1422-
//
1423-
// [fastcomp-only]
1424-
var ELIMINATE_DUPLICATE_FUNCTIONS = 0; // disabled by default
1425-
var ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS = 0;
1426-
var ELIMINATE_DUPLICATE_FUNCTIONS_PASSES = 5;
1427-
14281415
// This tries to evaluate global ctors at compile-time, applying their effects
14291416
// into the mem init file. This saves running code during startup, and also
14301417
// allows removing the global ctor functions and other code that only they used,

tests/fuzz/25.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,8 +1785,3 @@ XXX max block depth: 5
17851785
XXX percentage a fresh-made variable is used: 17.8
17861786
XXX percentage an existing variable is used: 82.2
17871787
********************* end of statistics **********************/
1788-
1789-
1790-
// /usr/bin/python /Users/achoudhury/Code/emscripten/emscripten/emcc -Oz --llvm-opts 1 /Users/achoudhury/Code/emscripten/emscripten/tests/fuzz/temp_fuzzcode28225_.cpp -o /Users/achoudhury/Code/emscripten/emscripten/tests/fuzz/fuzz.cpp -I /usr/local/Cellar/csmith/2.2.0/include/csmith-2.2.0/runtime -s ELIMINATE_DUPLICATE_FUNCTIONS=1 --emit-symbol-map -w -s MAIN_MODULE=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_WHITELIST=["_main"]
1791-
1792-

tests/test_core.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,6 @@ class TestCoreBase(RunnerCore):
264264
def is_wasm2js(self):
265265
return self.is_wasm_backend() and not self.get_setting('WASM')
266266

267-
# whether the test mode supports duplicate function elimination in js
268-
def supports_js_dfe(self):
269-
# wasm does this when optimizing anyhow, and the wasm backend always
270-
# optimizes the wasm even if it does wasm2js later
271-
if self.is_wasm() or self.is_wasm_backend():
272-
return False
273-
supported_opt_levels = ['-O2', '-O3', '-Oz', '-Os']
274-
for opt_level in supported_opt_levels:
275-
if opt_level in self.emcc_args:
276-
return True
277-
return False
278-
279267
# Use closure in some tests for some additional coverage
280268
def maybe_closure(self):
281269
if '-g' not in self.emcc_args and ('-O2' in self.emcc_args or '-Os' in self.emcc_args):
@@ -6258,14 +6246,6 @@ def test():
62586246

62596247
test()
62606248

6261-
if self.supports_js_dfe():
6262-
print("Testing poppler with ELIMINATE_DUPLICATE_FUNCTIONS set to 1", file=sys.stderr)
6263-
num_original_funcs = self.count_funcs('src.cpp.o.js')
6264-
self.set_setting('ELIMINATE_DUPLICATE_FUNCTIONS', 1)
6265-
test()
6266-
# Make sure that DFE ends up eliminating more than 200 functions (if we can view source)
6267-
assert (num_original_funcs - self.count_funcs('src.cpp.o.js')) > 200
6268-
62696249
@needs_make('make')
62706250
@is_slow_test
62716251
def test_openjpeg(self):
@@ -8290,14 +8270,6 @@ def test(assert_returncode=0):
82908270
print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
82918271
test()
82928272

8293-
def test_dfe(self):
8294-
if not self.supports_js_dfe():
8295-
self.skipTest('dfe-only')
8296-
self.set_setting('ELIMINATE_DUPLICATE_FUNCTIONS', 1)
8297-
self.do_run_in_out_file_test('tests', 'core', 'test_hello_world')
8298-
self.emcc_args += ['-g2'] # test for issue #6331
8299-
self.do_run_in_out_file_test('tests', 'core', 'test_hello_world')
8300-
83018273
def test_postrun_exception(self):
83028274
# verify that an exception thrown in postRun() will not trigger the
83038275
# compilation failed handler, and will be printed to stderr.

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9035,7 +9035,7 @@ def test_minimal_runtime_code_size(self):
90359035
'-DNDEBUG',
90369036
'-ffast-math']
90379037

9038-
asmjs = ['-s', 'WASM=0', '--separate-asm', '-s', 'ELIMINATE_DUPLICATE_FUNCTIONS=1', '--memory-init-file', '1']
9038+
asmjs = ['-s', 'WASM=0', '--separate-asm', '-s', '--memory-init-file', '1']
90399039
wasm2js = ['-s', 'WASM=0', '--memory-init-file', '1']
90409040

90419041
hello_world_sources = [path_from_root('tests', 'small_hello_world.c'),

tools/building.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,6 @@ def eval_ctors(js_file, binary_file, binaryen_bin='', debug_info=False):
986986
check_call(cmd)
987987

988988

989-
def eliminate_duplicate_funcs(filename):
990-
from . import duplicate_function_eliminator
991-
duplicate_function_eliminator.eliminate_duplicate_funcs(filename)
992-
993-
994989
def calculate_reachable_functions(infile, initial_list, can_reach=True):
995990
with ToolchainProfiler.profile_block('calculate_reachable_functions'):
996991
from . import asm_module

0 commit comments

Comments
 (0)