aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-23 14:11:41 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-23 14:11:41 -0800
commit71360ca6a75bfa2f3c9bdb09ad14817c88507a8b (patch)
tree0f483c430e0d5fbedea90653ae3243c06789972c
parentff69c85ed7d4228b71b712e161c9bbb7464271c5 (diff)
simplify llvm opt picking code, and allow up to level 3
-rwxr-xr-xemcc4
-rwxr-xr-xtests/runner.py4
-rw-r--r--tools/shared.py9
3 files changed, 9 insertions, 8 deletions
diff --git a/emcc b/emcc
index 5bfee46e..3576b462 100755
--- a/emcc
+++ b/emcc
@@ -77,7 +77,7 @@ import os, sys, shutil, tempfile
from subprocess import Popen, PIPE, STDOUT
from tools import shared
-MAX_LLVM_OPT_LEVEL = 2
+MAX_LLVM_OPT_LEVEL = 3
DEBUG = os.environ.get('EMCC_DEBUG')
TEMP_DIR = os.environ.get('EMCC_TEMP_DIR')
@@ -520,7 +520,7 @@ try:
# Optimize, if asked to
if llvm_opts > 0 and opt_level > 0 and not LEAVE_INPUTS_RAW:
if DEBUG: print >> sys.stderr, 'emcc: LLVM opts'
- shared.Building.llvm_opt(in_temp(target_basename + '.bc'), min(opt_level, MAX_LLVM_OPT_LEVEL), safe=shared.Settings.USE_TYPED_ARRAYS != 2)
+ shared.Building.llvm_opt(in_temp(target_basename + '.bc'), min(opt_level, MAX_LLVM_OPT_LEVEL))
else:
# If possible, remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
if not LEAVE_INPUTS_RAW and not shared.Settings.BUILD_AS_SHARED_LIB and not shared.Settings.LINKABLE:
diff --git a/tests/runner.py b/tests/runner.py
index 502b1fb5..201db38c 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -126,7 +126,7 @@ process(sys.argv[1])
# Build JavaScript code from source code
def build(self, src, dirname, filename, output_processor=None, main_file=None, additional_files=[], libraries=[], includes=[], build_ll_hook=None, extra_emscripten_args=[], post_build=None):
- Building.pick_llvm_opts(3, safe=Building.LLVM_OPTS != 2) # pick llvm opts here, so we include changes to Settings in the test case code
+ Building.pick_llvm_opts(3) # pick llvm opts here, so we include changes to Settings in the test case code
# Copy over necessary files for compiling the source
if main_file is None:
@@ -5274,7 +5274,7 @@ class %s(T):
else:
Settings.I64_MODE = 0
- Building.pick_llvm_opts(3, safe=Building.LLVM_OPTS != 2)
+ Building.pick_llvm_opts(3)
TT = %s
''' % (fullname, fullname, fullname, compiler, str(emcc_args), llvm_opts, embetter, quantum_size, typed_arrays, fullname))
diff --git a/tools/shared.py b/tools/shared.py
index 472bfe57..81c7fcf8 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -440,9 +440,9 @@ class Building:
# @param opt Either an integer, in which case it is the optimization level (-O1, -O2, etc.), or a list of raw
# optimization passes passed to llvm opt
@staticmethod
- def llvm_opt(filename, opts, safe=True):
+ def llvm_opt(filename, opts):
if type(opts) is int:
- opts = Building.pick_llvm_opts(opts, safe)
+ opts = Building.pick_llvm_opts(opts)
output = Popen([LLVM_OPT, filename] + opts + ['-o=' + filename + '.opt.bc'], stdout=PIPE).communicate()[0]
assert os.path.exists(filename + '.opt.bc'), 'Failed to run llvm optimizations: ' + output
shutil.move(filename + '.opt.bc', filename)
@@ -528,7 +528,7 @@ class Building:
return filename + '.o.js'
@staticmethod
- def pick_llvm_opts(optimization_level, safe=True):
+ def pick_llvm_opts(optimization_level):
'''
It may be safe to use nonportable optimizations (like -OX) if we remove the platform info from the .ll
(which we do in do_ll_opts) - but even there we have issues (even in TA2) with instruction combining
@@ -539,8 +539,9 @@ class Building:
llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments
'''
+ safe = Settings.USE_TYPED_ARRAYS != 2 or Settings.BUILD_AS_SHARED_LIB or Settings.LINKABLE
+ print 'LLVM opts, safe?', safe
opts = []
- assert safe or Settings.USE_TYPED_ARRAYS == 2, 'Cannot do unsafe LLVM opts without typed arrays in mode 2'
if optimization_level > 0:
if not safe:
opts.append('-disable-inlining') # we prefer to let closure compiler do our inlining, to avoid overly aggressive inlining