aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/eliminator/eliminator-test-output.js8
-rw-r--r--tools/eliminator/eliminator-test.js12
-rw-r--r--tools/js-optimizer.js2
-rw-r--r--tools/shared.py14
4 files changed, 30 insertions, 6 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js
index ede34103..01f092d5 100644
--- a/tools/eliminator/eliminator-test-output.js
+++ b/tools/eliminator/eliminator-test-output.js
@@ -6132,4 +6132,12 @@ function _mallocNoU($bytes) {
return $mem_0;
return null;
}
+function phi() {
+ if (wat()) {
+ var $10 = 1;
+ } else {
+ var $10 = (_init_mparams() | 0) != 0;
+ }
+ var $10;
+}
diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js
index e44f28ad..8b376305 100644
--- a/tools/eliminator/eliminator-test.js
+++ b/tools/eliminator/eliminator-test.js
@@ -8828,5 +8828,15 @@ function _mallocNoU($bytes) {
return $mem_0;
return null;
}
-// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU"]
+function phi() {
+ if (wat()) {
+ var $10 = 1;
+ } else {
+ var $7=_init_mparams();
+ var $8=(($7)|0)!=0;
+ var $10 = $8;
+ }
+ var $10;
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi"]
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 29aecdcf..62161738 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1464,7 +1464,7 @@ function eliminate(ast, memSafe) {
for (var name in locals) {
if (definitions[name] == 1 && uses[name] == 1) {
potentials[name] = 1;
- } else if (uses[name] == 0) {
+ } else if (uses[name] == 0 && (!definitions[name] || definitions[name] <= 1)) { // no uses, no def or 1 def (cannot operate on phis, and the llvm optimizer will remove unneeded phis anyhow)
var hasSideEffects = false;
if (values[name]) {
traverse(values[name], function(node, type) {
diff --git a/tools/shared.py b/tools/shared.py
index 86a5ba77..fdcdbbda 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -92,7 +92,7 @@ else:
node = 'node'
try:
node = Popen(['which', 'node'], stdout=PIPE).communicate()[0].replace('\n', '') or \
- Popen(['which', 'nodejs'], stdout=PIPE).communicate()[0].replace('\n', '')
+ Popen(['which', 'nodejs'], stdout=PIPE).communicate()[0].replace('\n', '') or node
except:
pass
config_file = config_file.replace('{{{ NODE }}}', node)
@@ -749,21 +749,26 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
contents = filter(os.path.exists, map(os.path.abspath, contents))
added_contents = set()
added = True
+ #print >> sys.stderr, ' initial undef are now ', unresolved_symbols, '\n'
while added: # recursively traverse until we have everything we need
+ #print >> sys.stderr, ' running loop of archive including for', f
added = False
for content in contents:
if content in added_contents: continue
new_symbols = Building.llvm_nm(content)
# Link in the .o if it provides symbols, *or* this is a singleton archive (which is apparently an exception in gcc ld)
#print >> sys.stderr, 'need', content, '?', unresolved_symbols, 'and we can supply', new_symbols.defs
+ #print >> sys.stderr, content, 'DEF', new_symbols.defs, '\n'
if new_symbols.defs.intersection(unresolved_symbols) or len(files) == 1:
if Building.is_bitcode(content):
- #print >> sys.stderr, ' adding object', content
+ #print >> sys.stderr, ' adding object', content, '\n'
resolved_symbols = resolved_symbols.union(new_symbols.defs)
unresolved_symbols = unresolved_symbols.union(new_symbols.undefs.difference(resolved_symbols)).difference(new_symbols.defs)
+ #print >> sys.stderr, ' undef are now ', unresolved_symbols, '\n'
actual_files.append(content)
added_contents.add(content)
added = True
+ #print >> sys.stderr, ' done running loop of archive including for', f
finally:
os.chdir(cwd)
try_delete(target)
@@ -785,6 +790,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
seen_symbols = seen_symbols.union(symbols.defs)
# Finish link
+ if DEBUG: print >>sys.stderr, 'emcc: llvm-linking:', actual_files
output = Popen([LLVM_LINK] + actual_files + ['-o', target], stdout=PIPE).communicate()[0]
assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output + '\nemcc: If you get duplicate symbol errors, try --remove-duplicates'
for temp_dir in temp_dirs:
@@ -1053,7 +1059,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
Building._is_ar_cache[filename] = sigcheck
return sigcheck
except Exception, e:
- print 'shared.Building.is_ar failed to test whether file \'%s\' is a llvm archive file! Failed on exception: %s' % (filename, e)
+ print >> sys.stderr, 'shared.Building.is_ar failed to test whether file \'%s\' is a llvm archive file! Failed on exception: %s' % (filename, e)
return False
@staticmethod
@@ -1073,7 +1079,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
assert os.path.exists(test_ll)
try_delete(test_ll)
except Exception, e:
- print 'shared.Building.is_bitcode failed to test whether file \'%s\' is a llvm bitcode file! Failed on exception: %s' % (filename, e)
+ print >> sys.stderr, 'shared.Building.is_bitcode failed to test whether file \'%s\' is a llvm bitcode file! Failed on exception: %s' % (filename, e)
return False
# look for magic signature