diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-07 18:36:42 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-07 18:36:42 -0800 |
commit | 6c5cc41f83eaadd347569951084856f3e3a01a62 (patch) | |
tree | abbbc2a715e38c2da0c73c8db1427fecefc20631 | |
parent | 5c02f40d3422617d0be4f0542b8b5281cae7883b (diff) |
do not do redundant llvm optimizations on bitcode; do them only when actually generating js
-rwxr-xr-x | emcc | 26 | ||||
-rw-r--r-- | tests/runner.py | 5 |
2 files changed, 17 insertions, 14 deletions
@@ -117,7 +117,10 @@ Options that are modified or new in %s include: optimizations, and no runtime assertions or C++ exception catching (to re-enable C++ exception catching, use - -s DISABLE_EXCEPTION_CATCHING=0 ) + -s DISABLE_EXCEPTION_CATCHING=0 ). + Note: Optimizations are only done when + compiling to JavaScript, not to intermediate + bitcode. -O2 As -O1, plus the relooper (loop recreation), plus closure compiler advanced opts Warning: Compiling with this takes a long time! @@ -397,18 +400,10 @@ try: if DEBUG: print >> sys.stderr, 'emcc: assembling assembly file: ', input_file shared.Building.llvm_as(input_file, in_temp(unsuffixed_basename(input_file) + '.o')) - # Optimize, if asked to - if llvm_opt_level > 0 and not LEAVE_INPUTS_RAW: - if DEBUG: print >> sys.stderr, 'emcc: LLVM opts' - for input_file in input_files: - try: - shared.Building.llvm_opt(in_temp(unsuffixed_basename(input_file) + '.o'), LLVM_INTERNAL_OPT_LEVEL, safe=llvm_opt_level < 2) - except: - # This might be an invalid input, which will get ignored during linking later anyhow - print >> sys.stderr, 'emcc: warning: LLVM opt failed to run on %s, continuing without optimization' % input_file - # If we were just asked to generate bitcode, stop there if final_suffix not in ['js', 'html']: + if llvm_opt_level > 0: + print >> sys.stderr, 'emcc: warning: -Ox flags ignored, since not generating JavaScript' if not specified_target: for input_file in input_files: shutil.move(in_temp(unsuffixed_basename(input_file) + '.o'), unsuffixed_basename(input_file) + '.' + final_suffix) @@ -428,7 +423,7 @@ try: ## Continue on to create JavaScript - if DEBUG: print >> sys.stderr, 'emcc: generating JavaScript' + if DEBUG: print >> sys.stderr, 'emcc: will generate JavaScript' extra_files_to_link = [] @@ -473,10 +468,15 @@ try: if not LEAVE_INPUTS_RAW: shutil.move(in_temp(unsuffixed_basename(input_files[0]) + '.o'), in_temp(target_basename + '.bc')) + # Optimize, if asked to + if llvm_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'), LLVM_INTERNAL_OPT_LEVEL, safe=llvm_opt_level < 2) + # Emscripten try: if shared.Settings.RELOOP: - print >> sys.stderr, 'Warning: The relooper optimization can be very slow.' + print >> sys.stderr, 'emcc: warning: The relooper optimization can be very slow.' except: pass diff --git a/tests/runner.py b/tests/runner.py index 34071a91..0f81d26d 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -5311,6 +5311,7 @@ Options that are modified or new in %s include: (['-o', 'something.bc'], 1, ['-O1'], 0, 0), (['-o', 'something.bc'], 2, ['-O2'], 1, 0), (['-o', 'something.bc'], 3, ['-O3'], 1, 0), + (['-O1', '-o', 'something.bc'], 0, [], 0, 0), # -Ox is ignored and warned about ]: #print params, opt_level, bc_params, closure clear() @@ -5318,10 +5319,12 @@ Options that are modified or new in %s include: stdout=PIPE, stderr=PIPE).communicate() assert len(output[0]) == 0, output[0] if bc_params is not None: + if '-O1' in params and 'something.bc' in params: + assert 'warning: -Ox flags ignored, since not generating JavaScript' in output[1] assert os.path.exists('something.bc'), output[1] output = Popen([compiler, 'something.bc', '-o', 'something.js'] + bc_params, stdout=PIPE, stderr=PIPE).communicate() assert os.path.exists('something.js'), output[1] - assert ('Warning: The relooper optimization can be very slow.' in output[1]) == (opt_level >= 2), 'relooper warning should appear in opt >= 2' + assert ('warning: The relooper optimization can be very slow.' in output[1]) == (opt_level >= 2), 'relooper warning should appear in opt >= 2' assert ('Warning: Applying some potentially unsafe optimizations!' in output[1]) == (opt_level >= 3), 'unsafe warning should appear in opt >= 3' self.assertContained('hello, world!', run_js('something.js')) |