diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-14 21:58:52 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-14 21:58:52 -0800 |
commit | 149b9ea5747d610d2ebfb41bc87e8bb96f498359 (patch) | |
tree | a08fc9b33d9aac1baa436a0a4896a103b24702bb /tools/shared.py | |
parent | 757f28b777303a90fe2992d0e2f82ce0958f12f2 (diff) |
emit ll from llvm opt directly, to skip writing and reading all the bitcode
Diffstat (limited to 'tools/shared.py')
-rw-r--r-- | tools/shared.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/shared.py b/tools/shared.py index e2c6e89f..5b165b8b 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1110,14 +1110,16 @@ 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): + def llvm_opt(filename, opts, out=None): if type(opts) is int: opts = Building.pick_llvm_opts(opts) #opts += ['-debug-pass=Arguments'] logging.debug('emcc: LLVM opts: ' + str(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) + target = out or (filename + '.opt.bc') + output = Popen([LLVM_OPT, filename] + opts + ['-o', target], stdout=PIPE).communicate()[0] + assert os.path.exists(target), 'Failed to run llvm optimizations: ' + output + if not out: + shutil.move(filename + '.opt.bc', filename) @staticmethod def llvm_opts(filename): # deprecated version, only for test runner. TODO: remove |