Skip to content

Commit 6fe62c1

Browse files
committed
--llvm-lto 2 option
1 parent 74671cd commit 6fe62c1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

emcc

+12-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Options that are modified or new in %s include:
139139
-s DOUBLE_MODE=0
140140
-s PRECISE_I64_MATH=0
141141
--closure 1
142-
--llvm-lto 1
142+
--llvm-lto 2
143143
144144
This is not recommended at all. A better idea
145145
is to try each of these separately on top of
@@ -215,11 +215,14 @@ Options that are modified or new in %s include:
215215
2: -O2 LLVM optimizations
216216
3: -O3 LLVM optimizations (default in -O2+)
217217
218-
--llvm-lto <level> 0: No LLVM LTO (default in -O2 and below)
219-
1: LLVM LTO (default in -O3)
218+
--llvm-lto <level> 0: No LLVM LTO (default)
219+
1: LLVM LTO is performed
220220
Note: If LLVM optimizations are not run
221221
(see --llvm-opts), setting this to 1 has no
222222
effect.
223+
2: LLVM LTO is performed, and we supplement it
224+
with pre-running LLVM opt -O3 on the full
225+
combined bitcode
223226
224227
--closure <on> 0: No closure compiler (default in -O2 and below)
225228
1: Run closure compiler. This greatly reduces
@@ -879,7 +882,7 @@ try:
879882
newargs = newargs + [default_cxx_std]
880883

881884
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
882-
if llvm_lto is None: llvm_lto = opt_level >= 3
885+
if llvm_lto is None and opt_level >= 3: llvm_lto = 2
883886
if opt_level == 0: debug_level = 4
884887
if closure is None and opt_level == 3: closure = True
885888

@@ -1419,6 +1422,11 @@ try:
14191422
if not LEAVE_INPUTS_RAW:
14201423
link_opts = [] if debug_level >= 4 else ['-strip-debug'] # remove LLVM debug if we are not asked for it
14211424

1425+
if llvm_lto >= 2:
1426+
logging.debug('running LLVM opt -O3 as pre-LTO')
1427+
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), ['-O3'])
1428+
if DEBUG: save_intermediate('opt', 'bc')
1429+
14221430
if shared.Building.can_build_standalone():
14231431
# If we can LTO, do it before dce, since it opens up dce opportunities
14241432
if llvm_lto and shared.Building.can_use_unsafe_opts():

tests/runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13419,7 +13419,7 @@ def process(filename):
1341913419
try_delete(final_filename)
1342013420
output = Popen([PYTHON, EMCC, filename, #'-O3',
1342113421
'-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',
13422-
'--llvm-lto', '1', '--memory-init-file', '0', '--js-transform', 'python hardcode.py',
13422+
'--llvm-lto', '2', '--memory-init-file', '0', '--js-transform', 'python hardcode.py',
1342313423
'-s', 'TOTAL_MEMORY=128*1024*1024',
1342413424
'--closure', '1',
1342513425
#'-g',

0 commit comments

Comments
 (0)