aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-19 21:51:37 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-19 21:51:37 -0800
commited65cfdcf12ed1187813ded47b578adcac1b9c67 (patch)
treee0afc42caa3301c711666df7ba9b718034af8b9d
parent0d3ef7fc935804229b530b8e8769ccd998e9390e (diff)
move fastcomp simplification code into emcc, and simplify it
-rwxr-xr-xemcc6
-rwxr-xr-xemscripten.py48
2 files changed, 10 insertions, 44 deletions
diff --git a/emcc b/emcc
index 6d8cccb6..60469601 100755
--- a/emcc
+++ b/emcc
@@ -1704,6 +1704,12 @@ try:
assert len(input_files) == 1
if DEBUG and save_bc: save_intermediate('ll', 'll')
+ # Simplify LLVM bitcode for fastcomp
+ if os.environ.get('EMCC_FAST_COMPILER'):
+ logging.debug('simplifying LLVM IR for fastcomp')
+ shared.Building.llvm_opt(final, ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt'])
+ if DEBUG: save_intermediate('simple', 'bc')
+
if AUTODEBUG:
logging.debug('autodebug')
execute([shared.PYTHON, shared.AUTODEBUGGER, final, final + '.ad.ll'])
diff --git a/emscripten.py b/emscripten.py
index b5e7f6c7..42db0803 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -733,60 +733,20 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
# * Run compiler.js on the metadata to emit the shell js code, pre/post-ambles,
# JS library dependencies, etc.
- if DEBUG: logging.debug('emscript: llvm backend')
-
- # TODO: proper temp files
- # TODO: use a single LLVM toolchain instead of normal for source, pnacl for simplification, custom for js backend
-
- if DEBUG: shutil.copyfile(infile, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp0.ll'))
-
- extra_opt_args = []
- #if DEBUG: extra_opt_args.append('-time-passes')
-
- if DEBUG: t = time.time()
-
- if DEBUG: logging.debug(' ..1..')
- temp1 = temp_files.get('.1.bc').name
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'opt'), infile, '-pnacl-abi-simplify-preopt', '-o', temp1] + extra_opt_args))
- assert os.path.exists(temp1)
- if DEBUG:
- shutil.copyfile(temp1, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp1.bc'))
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'llvm-dis'), 'temp1.bc', '-o', 'temp1.ll']))
-
- #if DEBUG: logging.debug(' ..2..')
- #temp2 = temp_files.get('.2.bc').name
- #shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'opt'), temp1, '-O3', '-o', temp2]))
- #assert os.path.exists(temp2)
- #if DEBUG:
- # shutil.copyfile(temp2, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp2.bc'))
- # shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'llvm-dis'), 'temp2.bc', '-o', 'temp2.ll']))
- temp2 = temp1 # XXX if we optimize the bc, we remove some pnacl clutter, but it also makes varargs stores be 8-byte aligned
-
- if DEBUG: logging.debug(' ..3..')
- temp3 = temp_files.get('.3.bc').name
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'opt'), temp2, '-pnacl-abi-simplify-postopt', '-o', temp3] + extra_opt_args))
- #'-print-after-all'
- assert os.path.exists(temp3)
- if DEBUG:
- shutil.copyfile(temp3, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp3.bc'))
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'llvm-dis'), 'temp3.bc', '-o', 'temp3.ll']))
-
if DEBUG:
- logging.debug(' emscript: ir simplification took %s seconds' % (time.time() - t))
+ logging.debug('emscript: llvm backend')
t = time.time()
- if DEBUG: logging.debug(' ..4..')
- temp4 = temp_files.get('.4.js').name
+ temp_js = temp_files.get('.4.js').name
backend_compiler = os.path.join(shared.LLVM_ROOT, 'llc')
- shared.jsrun.timeout_run(subprocess.Popen([backend_compiler, temp3, '-march=js', '-filetype=asm', '-o', temp4], stdout=subprocess.PIPE))
- if DEBUG: shutil.copyfile(temp4, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp4.js'))
+ shared.jsrun.timeout_run(subprocess.Popen([backend_compiler, infile, '-march=js', '-filetype=asm', '-o', temp_js], stdout=subprocess.PIPE))
if DEBUG:
logging.debug(' emscript: llvm backend took %s seconds' % (time.time() - t))
t = time.time()
# Split up output
- backend_output = open(temp4).read()
+ backend_output = open(temp_js).read()
#if DEBUG: print >> sys.stderr, backend_output
start_funcs_marker = '// EMSCRIPTEN_START_FUNCTIONS'