aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-24 12:11:44 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-24 12:14:55 -0700
commit067a60d649a5f8a1af76d4a15dee31c81fe0f384 (patch)
tree8d7676614bb7ff531de45aa8b892ce2a6e4c8761
parent50ee300ffabb6c5e5c6a2d4b4762343822ea1dc2 (diff)
handle empty inline asms; fixes #1729
-rw-r--r--src/intertyper.js14
-rw-r--r--tests/cases/emptyasm_le32.ll16
-rw-r--r--tests/test_core.py3
3 files changed, 27 insertions, 6 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 96db6966..d3640889 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -672,12 +672,14 @@ function intertyper(lines, sidePass, baseLineNums) {
assert((item.tokens[5].text.match(/=/g) || []).length <= 1, 'we only support at most 1 exported variable from inline js: ' + item.ident);
var i = 0;
var params = [], args = [];
- splitTokenList(tokensLeft[3].tokens).map(function(element) {
- var ident = toNiceIdent(element[1].text);
- var type = element[0].text;
- params.push('$' + (i++));
- args.push(ident);
- });
+ if (tokensLeft[3].tokens) {
+ splitTokenList(tokensLeft[3].tokens).map(function(element) {
+ var ident = toNiceIdent(element[1].text);
+ var type = element[0].text;
+ params.push('$' + (i++));
+ args.push(ident);
+ });
+ }
if (item.assignTo) item.ident = 'return ' + item.ident;
item.ident = '(function(' + params + ') { ' + item.ident + ' })(' + args + ');';
return { forward: null, ret: item, item: item };
diff --git a/tests/cases/emptyasm_le32.ll b/tests/cases/emptyasm_le32.ll
new file mode 100644
index 00000000..e123d3d5
--- /dev/null
+++ b/tests/cases/emptyasm_le32.ll
@@ -0,0 +1,16 @@
+; ModuleID = 'tests/hello_world.bc'
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ call void asm sideeffect "", "~{memory}"() nounwind, !srcloc !0
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
diff --git a/tests/test_core.py b/tests/test_core.py
index 69fb31f3..dd5b1e39 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -9044,6 +9044,9 @@ def process(filename):
if '_noasm' in shortname and Settings.ASM_JS:
print self.skip('case "%s" not relevant for asm.js' % shortname)
continue
+ if '_le32' in shortname and not self.is_le32():
+ print self.skip('case "%s" not relevant for non-le32 target' % shortname)
+ continue
self.emcc_args = emcc_args
if os.path.exists(shortname + '.emcc'):
if not self.emcc_args: continue