From 4348ec6be55cea62e5b762087b49cfd85daa743c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 22 Oct 2015 16:09:05 -0700 Subject: [PATCH 1/2] move to legalization in the JS backend --- emcc | 36 +++++------------------------------- emscripten.py | 11 +++++++++++ tools/shared.py | 1 + 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/emcc b/emcc index 60534fb75d442..d7b61a66aac86 100755 --- a/emcc +++ b/emcc @@ -870,8 +870,6 @@ try: # Set ASM_JS default here so that we can override it from the command line. shared.Settings.ASM_JS = 1 if opt_level > 0 else 2 - pre_fastcomp_opts = [] - # Apply -s settings in newargs here (after optimization levels, so they can override them) for change in settings_changes: key, value = change.split('=') @@ -902,20 +900,6 @@ try: logging.error('Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended, see http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html') raise e - fastcomp_opts = [] - if shared.Settings.NO_EXIT_RUNTIME: - pre_fastcomp_opts += ['-emscripten-no-exit-runtime'] - if not llvm_lto: fastcomp_opts += ['-globalopt', '-globaldce'] - fastcomp_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt'] - if shared.Settings.DISABLE_EXCEPTION_CATCHING != 1: - fastcomp_opts += ['-enable-emscripten-cxx-exceptions'] - if shared.Settings.DISABLE_EXCEPTION_CATCHING == 2: - fastcomp_opts += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST or ['fake'])] - if shared.Settings.ASYNCIFY: - fastcomp_opts += ['-emscripten-asyncify'] - fastcomp_opts += ['-emscripten-asyncify-functions=' + ','.join(shared.Settings.ASYNCIFY_FUNCTIONS)] - fastcomp_opts += ['-emscripten-asyncify-whitelist=' + ','.join(shared.Settings.ASYNCIFY_WHITELIST)] - assert not shared.Settings.PGO, 'cannot run PGO in ASM_JS mode' if shared.Settings.SAFE_HEAP and not js_opts: @@ -1278,7 +1262,7 @@ try: if not shared.Settings.ASSERTIONS: link_opts += ['-disable-verify'] - if llvm_lto >= 2: + if llvm_lto >= 2 and llvm_opts > 0: logging.debug('running LLVM opts as pre-LTO') final = shared.Building.llvm_opt(final, llvm_opts, DEFAULT_FINAL) if DEBUG: save_intermediate('opt', 'bc') @@ -1289,9 +1273,8 @@ try: # add a manual internalize with the proper things we need to be kept alive during lto link_opts += shared.Building.get_safe_internalize() + ['-std-link-opts'] # execute it now, so it is done entirely before we get to the stage of legalization etc. - final = shared.Building.llvm_opt(final, pre_fastcomp_opts + link_opts, DEFAULT_FINAL) + final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL) if DEBUG: save_intermediate('lto', 'bc') - pre_fastcomp_opts = [] link_opts = [] else: # At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it) @@ -1303,15 +1286,11 @@ try: final = shared.Building.llvm_opt(final, link_opts, get_final() + '.link.ll') if DEBUG: save_intermediate('linktime', 'll') else: - if not save_bc: - # Simplify LLVM bitcode for fastcomp - link_opts = pre_fastcomp_opts + link_opts + fastcomp_opts - final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL) - if DEBUG: save_intermediate('linktime', 'bc') + if len(link_opts) > 0: + final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL) + if DEBUG: save_intermediate('linktime', 'bc') if save_bc: shutil.copyfile(final, save_bc) - final = shared.Building.llvm_opt(final, fastcomp_opts, get_final() + '.adsimp.bc') - if DEBUG: save_intermediate('adsimp', 'bc') # Prepare .ll for Emscripten if LEAVE_INPUTS_RAW: @@ -1325,11 +1304,6 @@ try: final = next if DEBUG: save_intermediate('autodebug', 'll') - # Simplify bitcode after autodebug - if AUTODEBUG or LEAVE_INPUTS_RAW: - final = shared.Building.llvm_opt(final, fastcomp_opts, get_final() + '.adsimp.bc') - if DEBUG: save_intermediate('adsimp', 'bc') - assert type(final) == str, 'we must have linked the final files, if linking was deferred, by this point' log_time('post-link') diff --git a/emscripten.py b/emscripten.py index 1e9e6b0ae8872..fea47ef6053ae 100755 --- a/emscripten.py +++ b/emscripten.py @@ -83,6 +83,17 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, elif settings['GLOBAL_BASE'] >= 0: backend_args += ['-emscripten-global-base=%d' % settings['GLOBAL_BASE']] backend_args += ['-O' + str(settings['OPT_LEVEL'])] + if settings['DISABLE_EXCEPTION_CATCHING'] != 1: + backend_args += ['-enable-emscripten-cxx-exceptions'] + if settings['DISABLE_EXCEPTION_CATCHING'] == 2: + backend_args += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(settings['EXCEPTION_CATCHING_WHITELIST'] or ['fake'])] + if settings['ASYNCIFY']: + backend_args += ['-emscripten-asyncify'] + backend_args += ['-emscripten-asyncify-functions=' + ','.join(settings['ASYNCIFY_FUNCTIONS'])] + backend_args += ['-emscripten-asyncify-whitelist=' + ','.join(settings['ASYNCIFY_WHITELIST'])] + if settings['NO_EXIT_RUNTIME']: + backend_args += ['-emscripten-no-exit-runtime'] + if DEBUG: logging.debug('emscript: llvm backend: ' + ' '.join(backend_args)) t = time.time() diff --git a/tools/shared.py b/tools/shared.py index e11e77b8bf002..43f7fb32c9b06 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1472,6 +1472,7 @@ def llvm_opt(filename, opts, out=None): assert out, 'must provide out if llvm_opt on a list of inputs' if type(opts) is int: opts = Building.pick_llvm_opts(opts) + assert len(opts) > 0, 'should not call opt with nothing to do' opts = opts[:] #opts += ['-debug-pass=Arguments'] if get_clang_version() >= '3.4': From e41b2a964b57a0f43fe1d385183589edd148f29d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 26 Oct 2015 18:04:33 -0700 Subject: [PATCH 2/2] 1.35.4 --- emscripten-version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emscripten-version.txt b/emscripten-version.txt index 3a4a1b8deeebb..e69f596946e09 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1,2 +1,2 @@ -"1.35.3" +"1.35.4"