diff --git a/emcc b/emcc index 8151d7c6a..06a000060 100755 --- a/emcc +++ b/emcc @@ -1055,6 +1055,14 @@ try: 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 shared.Building.can_build_standalone(): + # If we can LTO, do it before dce, since it opens up dce opportunities + if llvm_lto and shared.Building.can_use_unsafe_opts(): + if not shared.Building.can_inline(): link_opts.append('-disable-inlining') + link_opts += ['-std-link-opts', '-disable-internalize'] + if DEBUG: print >> sys.stderr, 'emcc: LLVM linktime:', link_opts + shared.Building.llvm_opt(in_temp(target_basename + '.bc'), link_opts) + if DEBUG: save_intermediate('linktime', 'bc') + link_opts = [] # At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it) exports = ','.join(map(lambda exp: exp[1:], shared.Settings.EXPORTED_FUNCTIONS)) # internalize carefully, llvm 3.2 will remove even main if not told not to @@ -1062,12 +1070,6 @@ try: if DEBUG: print >> sys.stderr, 'emcc: LLVM linktime:', link_opts shared.Building.llvm_opt(in_temp(target_basename + '.bc'), link_opts) if DEBUG: save_intermediate('dce', 'bc') - if llvm_lto and shared.Building.can_use_unsafe_opts(): - if not shared.Building.can_inline(): link_opts.append('-disable-inlining') - link_opts = ['-std-link-opts', '-disable-internalize'] - if DEBUG: print >> sys.stderr, 'emcc: LLVM linktime:', link_opts - shared.Building.llvm_opt(in_temp(target_basename + '.bc'), link_opts) - if DEBUG: save_intermediate('linktime', 'bc') # Prepare .ll for Emscripten if not LEAVE_INPUTS_RAW: