diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-31 19:09:32 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-31 19:09:32 -0800 |
commit | 1204c42f4f7f5b5658fce74e0e29e0f09ca44029 (patch) | |
tree | d57a7991baea412aebfb3bb354808c7ca1d6cf09 | |
parent | 88c3f163048d7f9107f314c98fc94abc9271d641 (diff) |
fix usage of llvm opt level in emcc, and test_emcc fixes
-rwxr-xr-x | emcc | 14 | ||||
-rwxr-xr-x | tests/runner.py | 20 | ||||
-rw-r--r-- | tools/shared.py | 2 |
3 files changed, 24 insertions, 12 deletions
@@ -153,8 +153,10 @@ Options that are modified or new in %s include: --typed-arrays <mode> 0: No typed arrays 1: Parallel typed arrays 2: Shared (C-like) typed arrays (default) - --llvm-opts <on> 0: No LLVM optimizations (default in -O0) - 1: LLVM optimizations (default in -O1 +) + --llvm-opts <level> 0: No LLVM optimizations (default in -O0) + 1: -O1 LLVM optimizations (default in -O1) + 2: -O2 LLVM optimizations + 3: -O3 LLVM optimizations (default in -O2+) --closure <on> 0: No closure compiler (default in -O0, -O1) 1: Run closure compiler (default in -O2, -O3) --js-transform <cmd> <cmd> will be called on the generated code @@ -348,7 +350,7 @@ try: newargs[i+1] = '' newargs = [ arg for arg in newargs if arg is not '' ] - if llvm_opts is None: llvm_opts = 1 if opt_level >= 1 else 0 + if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level] if closure is None: closure = 1 if opt_level >= 2 else 0 if compress_whitespace is None: compress_whitespace = closure # if closure is run, compress whitespace @@ -561,9 +563,9 @@ try: if not LEAVE_INPUTS_RAW: save_intermediate('basebc', 'bc') # Optimize, if asked to - if llvm_opts > 0 and opt_level > 0 and not LEAVE_INPUTS_RAW: - if DEBUG: print >> sys.stderr, 'emcc: LLVM -O%d' % LLVM_OPT_LEVEL[opt_level] - shared.Building.llvm_opt(in_temp(target_basename + '.bc'), LLVM_OPT_LEVEL[opt_level]) + if llvm_opts > 0 and not LEAVE_INPUTS_RAW: + if DEBUG: print >> sys.stderr, 'emcc: LLVM -O%d' % llvm_opts + shared.Building.llvm_opt(in_temp(target_basename + '.bc'), llvm_opts) if DEBUG: save_intermediate('opt', 'bc') # Do LTO in a separate pass to work around LLVM bug XXX (see failure e.g. in cubescript) if not shared.Settings.BUILD_AS_SHARED_LIB and not shared.Settings.LINKABLE: diff --git a/tests/runner.py b/tests/runner.py index 02041ed4..bedd19df 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5352,9 +5352,14 @@ TT = %s class other(RunnerCore): def test_emcc(self): + emcc_debug = os.environ.get('EMCC_DEBUG') + def clear(): for name in os.listdir(self.get_dir()): try_delete(name) + if emcc_debug: + for name in os.listdir(EMSCRIPTEN_TEMP_DIR): + try_delete(os.path.join(EMSCRIPTEN_TEMP_DIR, name)) for compiler in [EMCC, EMXX]: shortcompiler = os.path.basename(compiler) @@ -5396,7 +5401,7 @@ Options that are modified or new in %s include: self.assertNotContained('IOError', output[1]) # no python stack self.assertNotContained('Traceback', output[1]) # no python stack self.assertContained('error: invalid preprocessing directive', output[1]) - self.assertContained('''error: use of undeclared identifier 'cheez''', output[1]) + self.assertContained("error: use of undeclared identifier 'cheez", output[1]) self.assertContained('2 errors generated', output[1]) assert output[1].split('2 errors generated.')[1].replace('\n', '') == 'emcc: compiler frontend failed to generate LLVM bitcode, halting' @@ -5497,9 +5502,9 @@ Options that are modified or new in %s include: # XXX find a way to test this: assert ('& 255' in generated or '&255' in generated) == (opt_level <= 2), 'corrections should be in opt <= 2' assert ('(__label__)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' assert ('assert(STACKTOP < STACK_MAX' in generated) == (opt_level == 0), 'assertions should be in opt == 0' - assert 'var $i;' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated, 'micro opts should always be on' + assert 'var $i;' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated or 'var $i_04;' in generated, 'micro opts should always be on' if opt_level >= 1: - assert 'HEAP8[HEAP32[' in generated or 'HEAP8[$vla1 + $storemerge4 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($storemerge4 / 2 | 0)]' in generated, 'eliminator should create compound expressions, and fewer one-time vars' + assert 'HEAP8[HEAP32[' in generated or 'HEAP8[$vla1 + $storemerge4 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($storemerge4 / 2 | 0)]' in generated or 'HEAP8[$vla1 + $i_04 / 2 | 0]' in generated or 'HEAP8[$vla1 + ($i_04 / 2 | 0)]' in generated, 'eliminator should create compound expressions, and fewer one-time vars' assert ('_puts(' in generated) == (opt_level >= 1), 'with opt >= 1, llvm opts are run and they should optimize printf to puts' assert ('function _malloc(bytes) {' in generated) == (not has_malloc), 'If malloc is needed, it should be there, if not not' assert 'function _main() {' in generated, 'Should be unminified, including whitespace' @@ -6128,10 +6133,14 @@ elif 'sanity' in str(sys.argv): assert not os.path.exists(EMCC_CACHE) try_delete('a.out.js') + basebc_name = os.path.join(EMSCRIPTEN_TEMP_DIR, 'emcc-0-basebc.bc') + dcebc_name = os.path.join(EMSCRIPTEN_TEMP_DIR, 'emcc-1-dce.bc') + # Building a file that *does* need dlmalloc *should* trigger cache generation, but only the first time for filename, libname in [('hello_malloc.cpp', 'dlmalloc'), ('hello_libcxx.cpp', 'libcxx')]: for i in range(3): - try_delete(os.path.join(EMSCRIPTEN_TEMP_DIR, 'emcc-0-bc.bc')) # we might need to check this file later + try_delete(basebc_name) # we might need to check this file later + try_delete(dcebc_name) # we might need to check this file later output = self.do([EMCC, path_from_root('tests', filename)]) assert INCLUDING_MESSAGE.replace('X', libname) in output if libname == 'dlmalloc': @@ -6144,7 +6153,8 @@ elif 'sanity' in str(sys.argv): assert os.path.exists(os.path.join(EMCC_CACHE, libname + '.bc')) if libname == 'libcxx': assert os.stat(os.path.join(EMCC_CACHE, libname + '.bc')).st_size > 4000000, 'libc++ is big' - assert os.stat(os.path.join(EMSCRIPTEN_TEMP_DIR, 'emcc-0-bc.bc')).st_size < 2000000, 'Dead code elimination must remove most of libc++' + assert os.stat(basebc_name).st_size > 4000000, 'libc++ is indeed big' + assert os.stat(dcebc_name).st_size < 2000000, 'Dead code elimination must remove most of libc++' finally: if emcc_debug: os.environ['EMCC_DEBUG'] = emcc_debug diff --git a/tools/shared.py b/tools/shared.py index 1f184de7..2436c02d 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -553,7 +553,7 @@ class Building: opts.append('-O%d' % optimization_level) else: opts.append('-std-compile-opts') - print '[unsafe: %s]' % ','.join(opts) + #print '[unsafe: %s]' % ','.join(opts) else: allow_nonportable = not safe optimize_size = True |