Skip to content

Commit 353c2ee

Browse files
committed
Merge remote-tracking branch 'origin/legalize-in-backend' into incoming
2 parents dc847c0 + 4348ec6 commit 353c2ee

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

emcc

+5-31
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,6 @@ try:
873873
# Set ASM_JS default here so that we can override it from the command line.
874874
shared.Settings.ASM_JS = 1 if opt_level > 0 else 2
875875

876-
pre_fastcomp_opts = []
877-
878876
# Apply -s settings in newargs here (after optimization levels, so they can override them)
879877
for change in settings_changes:
880878
key, value = change.split('=')
@@ -905,20 +903,6 @@ try:
905903
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')
906904
raise e
907905

908-
fastcomp_opts = []
909-
if shared.Settings.NO_EXIT_RUNTIME:
910-
pre_fastcomp_opts += ['-emscripten-no-exit-runtime']
911-
if not llvm_lto: fastcomp_opts += ['-globalopt', '-globaldce']
912-
fastcomp_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
913-
if shared.Settings.DISABLE_EXCEPTION_CATCHING != 1:
914-
fastcomp_opts += ['-enable-emscripten-cxx-exceptions']
915-
if shared.Settings.DISABLE_EXCEPTION_CATCHING == 2:
916-
fastcomp_opts += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST or ['fake'])]
917-
if shared.Settings.ASYNCIFY:
918-
fastcomp_opts += ['-emscripten-asyncify']
919-
fastcomp_opts += ['-emscripten-asyncify-functions=' + ','.join(shared.Settings.ASYNCIFY_FUNCTIONS)]
920-
fastcomp_opts += ['-emscripten-asyncify-whitelist=' + ','.join(shared.Settings.ASYNCIFY_WHITELIST)]
921-
922906
assert not shared.Settings.PGO, 'cannot run PGO in ASM_JS mode'
923907

924908
if shared.Settings.SAFE_HEAP and not js_opts:
@@ -1281,7 +1265,7 @@ try:
12811265
if not shared.Settings.ASSERTIONS:
12821266
link_opts += ['-disable-verify']
12831267

1284-
if llvm_lto >= 2:
1268+
if llvm_lto >= 2 and llvm_opts > 0:
12851269
logging.debug('running LLVM opts as pre-LTO')
12861270
final = shared.Building.llvm_opt(final, llvm_opts, DEFAULT_FINAL)
12871271
if DEBUG: save_intermediate('opt', 'bc')
@@ -1292,9 +1276,8 @@ try:
12921276
# add a manual internalize with the proper things we need to be kept alive during lto
12931277
link_opts += shared.Building.get_safe_internalize() + ['-std-link-opts']
12941278
# execute it now, so it is done entirely before we get to the stage of legalization etc.
1295-
final = shared.Building.llvm_opt(final, pre_fastcomp_opts + link_opts, DEFAULT_FINAL)
1279+
final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL)
12961280
if DEBUG: save_intermediate('lto', 'bc')
1297-
pre_fastcomp_opts = []
12981281
link_opts = []
12991282
else:
13001283
# At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
@@ -1306,15 +1289,11 @@ try:
13061289
final = shared.Building.llvm_opt(final, link_opts, get_final() + '.link.ll')
13071290
if DEBUG: save_intermediate('linktime', 'll')
13081291
else:
1309-
if not save_bc:
1310-
# Simplify LLVM bitcode for fastcomp
1311-
link_opts = pre_fastcomp_opts + link_opts + fastcomp_opts
1312-
final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL)
1313-
if DEBUG: save_intermediate('linktime', 'bc')
1292+
if len(link_opts) > 0:
1293+
final = shared.Building.llvm_opt(final, link_opts, DEFAULT_FINAL)
1294+
if DEBUG: save_intermediate('linktime', 'bc')
13141295
if save_bc:
13151296
shutil.copyfile(final, save_bc)
1316-
final = shared.Building.llvm_opt(final, fastcomp_opts, get_final() + '.adsimp.bc')
1317-
if DEBUG: save_intermediate('adsimp', 'bc')
13181297

13191298
# Prepare .ll for Emscripten
13201299
if LEAVE_INPUTS_RAW:
@@ -1328,11 +1307,6 @@ try:
13281307
final = next
13291308
if DEBUG: save_intermediate('autodebug', 'll')
13301309

1331-
# Simplify bitcode after autodebug
1332-
if AUTODEBUG or LEAVE_INPUTS_RAW:
1333-
final = shared.Building.llvm_opt(final, fastcomp_opts, get_final() + '.adsimp.bc')
1334-
if DEBUG: save_intermediate('adsimp', 'bc')
1335-
13361310
assert type(final) == str, 'we must have linked the final files, if linking was deferred, by this point'
13371311

13381312
log_time('post-link')

emscripten.py

+11
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
8383
elif settings['GLOBAL_BASE'] >= 0:
8484
backend_args += ['-emscripten-global-base=%d' % settings['GLOBAL_BASE']]
8585
backend_args += ['-O' + str(settings['OPT_LEVEL'])]
86+
if settings['DISABLE_EXCEPTION_CATCHING'] != 1:
87+
backend_args += ['-enable-emscripten-cxx-exceptions']
88+
if settings['DISABLE_EXCEPTION_CATCHING'] == 2:
89+
backend_args += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(settings['EXCEPTION_CATCHING_WHITELIST'] or ['fake'])]
90+
if settings['ASYNCIFY']:
91+
backend_args += ['-emscripten-asyncify']
92+
backend_args += ['-emscripten-asyncify-functions=' + ','.join(settings['ASYNCIFY_FUNCTIONS'])]
93+
backend_args += ['-emscripten-asyncify-whitelist=' + ','.join(settings['ASYNCIFY_WHITELIST'])]
94+
if settings['NO_EXIT_RUNTIME']:
95+
backend_args += ['-emscripten-no-exit-runtime']
96+
8697
if DEBUG:
8798
logging.debug('emscript: llvm backend: ' + ' '.join(backend_args))
8899
t = time.time()

tools/shared.py

+1
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ def llvm_opt(filename, opts, out=None):
14721472
assert out, 'must provide out if llvm_opt on a list of inputs'
14731473
if type(opts) is int:
14741474
opts = Building.pick_llvm_opts(opts)
1475+
assert len(opts) > 0, 'should not call opt with nothing to do'
14751476
opts = opts[:]
14761477
#opts += ['-debug-pass=Arguments']
14771478
if get_clang_version() >= '3.4':

0 commit comments

Comments
 (0)