コード例 #1
0
def optimize(filepath):
  """Runs LLVM's optimization passes on a given bitcode file.

  Args:
    filepath: The path to the bitcode file to optimize.

  Returns:
    The path to the optimized file.
  """
  command = [shared.LLVM_OPT, '-o=-', filepath] + shared.pick_llvm_opts(3, True)
  with get_temp_file('.bc') as out: ret = subprocess.call(command, stdout=out)
  if ret != 0: raise RuntimeError('Could not optimize %s.' % filepath)
  return out.name
コード例 #2
0
ファイル: make.py プロジェクト: EgoIncarnate/Broadway264
print 'Build'

env = os.environ.copy()
env['CC'] = env['CXX'] = env['RANLIB'] = env['AR'] = emscripten.EMMAKEN
env['LINUX'] = '1'
env['EMMAKEN_CFLAGS'] = '-U__APPLE__ -DJS'

Popen(['make', '-j', '4'], env=env).communicate()

if 0:
  print 'LLVM optimizations'

  shutil.move('avc.bc', 'avc.orig.bc')
  output = Popen([emscripten.LLVM_OPT, 'avc.orig.bc'] +
                 emscripten.pick_llvm_opts(3, handpicked=False) +
                 ['-o=avc.bc'], stdout=PIPE, stderr=STDOUT).communicate()[0]
  assert os.path.exists('avc.bc'), 'Failed to run llvm optimizations: ' + output

print 'LLVM binary => LL assembly'

print Popen([emscripten.LLVM_DIS] + emscripten.LLVM_DIS_OPTS + ['avc.bc', '-o=avc.ll']).communicate()

if 0:
  print '[Autodebugger]'

  shutil.move('avc.ll', 'avc.orig.ll')
  output = Popen(['python', emscripten.AUTODEBUGGER, 'avc.orig.ll', 'avc.ll'], stdout=PIPE, stderr=STDOUT).communicate()[0]
  assert 'Success.' in output, output

  shutil.move('avc.bc', 'avc.orig.bc')