aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/i64toi8star.ll2
-rw-r--r--tests/cases/inttoptr.ll2
-rw-r--r--tests/cases/lifetime.ll42
-rw-r--r--tests/cases/lifetime.py6
-rw-r--r--tests/lifetime.ll37
-rwxr-xr-xtests/runner.py68
6 files changed, 92 insertions, 65 deletions
diff --git a/tests/cases/i64toi8star.ll b/tests/cases/i64toi8star.ll
index 53a31d02..d4a39340 100644
--- a/tests/cases/i64toi8star.ll
+++ b/tests/cases/i64toi8star.ll
@@ -27,6 +27,6 @@ entry:
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%5 = call i32 @PyLong_FromVoidPtr(i8* null) nounwind ; [#uses=0]
%13 = call i32 @PyLong_FromVoidPtr(i8* inttoptr (i64 1 to i8*)) nounwind ; [#uses=0]
- %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %1 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
ret i32 0
}
diff --git a/tests/cases/inttoptr.ll b/tests/cases/inttoptr.ll
index c70904c8..b0711672 100644
--- a/tests/cases/inttoptr.ll
+++ b/tests/cases/inttoptr.ll
@@ -15,6 +15,6 @@ entry:
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%sz.i7 = inttoptr i32 64 to i32* ; [#uses=1 type=i32*]
store i32 184, i32* %sz.i7, align 8, !tbaa !1610
- %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %1 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
ret i32 0
}
diff --git a/tests/cases/lifetime.ll b/tests/cases/lifetime.ll
deleted file mode 100644
index dc6d471d..00000000
--- a/tests/cases/lifetime.ll
+++ /dev/null
@@ -1,42 +0,0 @@
-; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
-
-%struct.vec2 = type { float, float }
-
-@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00" ; [#uses=1]
-
-; [#uses=1]
-declare i32 @printf(i8* noalias, ...)
-
-define linkonce_odr float @vec2Length(%struct.vec2* %this) nounwind align 2 {
-entry:
- %__first.addr.i = alloca %struct.b2Pair.5*, align 4 ; [#uses=3 type=%struct.b2Pair.5**]
- %__last.addr.i = alloca %struct.b2Pair.5*, align 4 ; [#uses=3 type=%struct.b2Pair.5**]
- %__comp.addr.i = alloca %struct.b2Pair.5*, align 4 ; [#uses=2 type=%struct.b2Pair.5**]
- %13 = bitcast %struct.vec2** %__first.addr.i to i8* ; [#uses=1 type=i8*]
- call void @llvm.lifetime.start(i64 -1, i8* %13)
- %14 = bitcast %struct.vec2** %__last.addr.i to i8* ; [#uses=1 type=i8*]
- call void @llvm.lifetime.start(i64 -1, i8* %14)
- %15 = bitcast i1 (%struct.vec2*, %struct.vec2*)** %__comp.addr.i to i8* ; [#uses=1 type=i8*]
- call void @llvm.lifetime.start(i64 -1, i8* %15)
- store %struct.vec2* %10, %struct.vec2** %__first.addr.i, align 4
- store %struct.vec2* %add.ptr, %struct.vec2** %__last.addr.i, align 4
- %18 = bitcast %struct.vec2** %__first.addr.i to i8* ; [#uses=1 type=i8*]
- call void @llvm.lifetime.end(i64 -1, i8* %18)
- %19 = bitcast %struct.vec2** %__last.addr.i to i8* ; [#uses=1 type=i8*]
- call void @llvm.lifetime.end(i64 -1, i8* %19)
- %20 = bitcast i1 (%struct.vec2*, %struct.vec2*)** %__comp.addr.i to i8* ; [#uses=1 type=i8*]
- call void @llvm.lifetime.end(i64 -1, i8* %20)
-}
-
-define i32 @main() {
-entry:
- %retval = alloca i32, align 4 ; [#uses=1]
- store i32 0, i32* %retval
- %b = getelementptr inbounds i32* %retval, i32 0, i32 1 ; [#uses=1] ; force __stackBase__ to appear!
- %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- call i32 (i32)* @nonexistant(i32 %b) ; keep %b alive
- ret i32 0
-}
-
diff --git a/tests/cases/lifetime.py b/tests/cases/lifetime.py
deleted file mode 100644
index 3bb9cbac..00000000
--- a/tests/cases/lifetime.py
+++ /dev/null
@@ -1,6 +0,0 @@
-if Settings.MICRO_OPTS:
- assert '__stackBase__' in generated, 'There should be some stack activity (without which, we cannot do the next checks)'
- assert '__stackBase__+4' not in generated, 'All variables should have been nativized'
- assert '__stackBase__+8' not in generated, 'All variables should have been nativized'
- assert 'comp_addr' not in generated, 'This variable should have been eliminated during analysis'
-
diff --git a/tests/lifetime.ll b/tests/lifetime.ll
new file mode 100644
index 00000000..058d6b4a
--- /dev/null
+++ b/tests/lifetime.ll
@@ -0,0 +1,37 @@
+; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+%struct.vec2 = type { float, float }
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00" ; [#uses=1]
+
+; [#uses=1]
+declare i32 @printf(i8* noalias, ...)
+
+define linkonce_odr i32 @vec2Length(%struct.vec2* %this) nounwind align 2 {
+entry:
+ %__first.addr.i = alloca %struct.vec2*, align 4 ; [#uses=3 type=%struct.vec2**]
+ %__last.addr.i = alloca %struct.vec2*, align 4 ; [#uses=3 type=%struct.vec2**]
+ %__comp.addr.i = alloca %struct.vec2*, align 4 ; [#uses=2 type=%struct.vec2**]
+ %a13 = bitcast %struct.vec2** %__first.addr.i to i8* ; [#uses=1 type=i8*]
+ call void @llvm.lifetime.start(i64 -1, i8* %a13)
+ %a14 = bitcast %struct.vec2** %__last.addr.i to i8* ; [#uses=1 type=i8*]
+ call void @llvm.lifetime.start(i64 -1, i8* %a14)
+ %a18 = bitcast %struct.vec2** %__first.addr.i to i8* ; [#uses=1 type=i8*]
+ call void @llvm.lifetime.end(i64 -1, i8* %a18)
+ %a19 = bitcast %struct.vec2** %__last.addr.i to i8* ; [#uses=1 type=i8*]
+ call void @llvm.lifetime.end(i64 -1, i8* %a19)
+ ret i32 0
+}
+
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1]
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ ret i32 0
+}
+
+declare void @llvm.lifetime.start(i64, i8*)
+declare void @llvm.lifetime.end(i64, i8*)
+
diff --git a/tests/runner.py b/tests/runner.py
index 1cd94111..ac422e9e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -428,6 +428,8 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
self.do_run(src, output, force_c=True)
def test_i64(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2')
+
for i64_mode in [0,1]:
if i64_mode == 0 and Settings.USE_TYPED_ARRAYS != 0: continue # Typed arrays truncate i64
if i64_mode == 1 and Settings.QUANTUM_SIZE == 1: continue # TODO: i64 mode 1 for q1
@@ -1547,6 +1549,25 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
self.do_run(src, '*11,74,32,1012*\n*11*\n*22*')
def test_dynamic_cast(self):
+ src = r'''
+ #include <stdio.h>
+
+ struct Support {
+ virtual void f() {
+ printf("f()\n");
+ }
+ };
+
+ struct Derived : Support {
+ };
+
+ int main() {
+ Support * p = new Derived;
+ dynamic_cast<Derived*>(p)->f();
+ }
+ '''
+ self.do_run(src, 'f()\n')
+
src = '''
#include <stdio.h>
@@ -3290,6 +3311,7 @@ at function.:blag
self.do_run(src, expected)
def test_parseInt(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2')
if Settings.QUANTUM_SIZE == 1: return self.skip('Q1 and I64_1 do not mix well yet')
Settings.I64_MODE = 1 # Necessary to prevent i64s being truncated into i32s, but we do still get doubling
# FIXME: The output here is wrong, due to double rounding of i64s!
@@ -3298,7 +3320,7 @@ at function.:blag
self.do_run(src, expected)
def test_printf(self):
- if Settings.QUANTUM_SIZE == 1: return self.skip('Q1 and I64_1 do not mix well yet')
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2')
Settings.I64_MODE = 1
self.banned_js_engines = [NODE_JS, V8_ENGINE] # SpiderMonkey and V8 do different things to float64 typed arrays, un-NaNing, etc.
src = open(path_from_root('tests', 'printf', 'test.c'), 'r').read()
@@ -3869,15 +3891,14 @@ def process(filename):
self.do_run(src, "1 2 3")
def test_readdir(self):
-
add_pre_run = '''
def process(filename):
src = open(filename, 'r').read().replace(
- '// {{PRE_RUN_ADDITIONS}}',
- "FS.createFolder('', 'test', true, true);\\nFS.createLazyFile( 'test', 'some_file', 'http://localhost/some_file', true, false);\\nFS.createFolder('test', 'some_directory', true, true);"
+ '// {{PRE_RUN_ADDITIONS}}',
+ "FS.createFolder('', 'test', true, true);\\nFS.createLazyFile( 'test', 'some_file', 'http://localhost/some_file', true, false);\\nFS.createFolder('test', 'some_directory', true, true);"
)
open(filename, 'w').write(src)
- '''
+'''
src = '''
#include <dirent.h>
@@ -4674,17 +4695,31 @@ def process(filename):
'hello python world!\n[0, 2, 4, 6]\n5\n22\n5.470000',
args=['-S', '-c' '''print "hello python world!"; print [x*2 for x in range(4)]; t=2; print 10-3-t; print (lambda x: x*2)(11); print '%f' % 5.47'''])
+ def test_lifetime(self):
+ if self.emcc_args is None: return self.skip('test relies on emcc opts')
+
+ try:
+ os.environ['EMCC_LEAVE_INPUTS_RAW'] = '1'
+
+ self.do_ll_run(path_from_root('tests', 'lifetime.ll'), 'hello, world!\n')
+ if '-O1' in self.emcc_args or '-O2' in self.emcc_args:
+ assert 'a18' not in open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read(), 'lifetime stuff and their vars must be culled'
+ else:
+ assert 'a18' in open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read(), "without opts, it's there"
+
+ finally:
+ del os.environ['EMCC_LEAVE_INPUTS_RAW']
+
# Test cases in separate files. Note that these files may contain invalid .ll!
# They are only valid enough for us to read for test purposes, not for llvm-as
# to process.
def test_cases(self):
- try:
- self.banned_js_engines = [NODE_JS] # node issue 1669, exception causes stdout not to be flushed
+ if Building.LLVM_OPTS: return self.skip("Our code is not exactly 'normal' llvm assembly")
+ try:
os.environ['EMCC_LEAVE_INPUTS_RAW'] = '1'
-
+ self.banned_js_engines = [NODE_JS] # node issue 1669, exception causes stdout not to be flushed
Settings.CHECK_OVERFLOWS = 0
- if Building.LLVM_OPTS: return self.skip("Our code is not exactly 'normal' llvm assembly")
for name in glob.glob(path_from_root('tests', 'cases', '*.ll')):
shortname = name.replace('.ll', '')
@@ -5563,6 +5598,9 @@ TT = %s
del T # T is just a shape for the specific subclasses, we don't test it itself
class other(RunnerCore):
+ def test_reminder(self):
+ assert 0, 'find appearances of i64 in src/, most are now unneeded'
+
def test_emcc(self):
emcc_debug = os.environ.get('EMCC_DEBUG')
@@ -5725,12 +5763,12 @@ Options that are modified or new in %s include:
for params, test, text in [
(['-s', 'INLINING_LIMIT=0'], lambda generated: 'function _dump' in generated, 'no inlining without opts'),
(['-O1', '-s', 'INLINING_LIMIT=0'], lambda generated: 'function _dump' not in generated, 'inlining'),
- (['-s', 'USE_TYPED_ARRAYS=0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'),
- (['-s', 'USE_TYPED_ARRAYS=1'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'),
+ (['-s', 'USE_TYPED_ARRAYS=0', '-s', 'I64_MODE=0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'),
+ (['-s', 'USE_TYPED_ARRAYS=1', '-s', 'I64_MODE=0'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'),
([], lambda generated: 'Module["_dump"]' not in generated, 'dump is not exported by default'),
(['-s', 'EXPORTED_FUNCTIONS=["_main", "_dump"]'], lambda generated: 'Module["_dump"]' in generated, 'dump is now exported'),
- (['--typed-arrays', '0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'),
- (['--typed-arrays', '1'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'),
+ (['--typed-arrays', '0', '-s', 'I64_MODE=0'], lambda generated: 'new Int32Array' not in generated, 'disable typed arrays'),
+ (['--typed-arrays', '1', '-s', 'I64_MODE=0'], lambda generated: 'IHEAPU = ' in generated, 'typed arrays 1 selected'),
(['--typed-arrays', '2'], lambda generated: 'new Uint16Array' in generated and 'new Uint32Array' in generated, 'typed arrays 2 selected'),
(['--llvm-opts', '1'], lambda generated: '_puts(' in generated, 'llvm opts requested'),
]:
@@ -5867,7 +5905,7 @@ f.close()
clear()
output = Popen([EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html',
'-DHAVE_BUILTIN_SINCOS',
- '-s', 'USE_TYPED_ARRAYS=0',
+ '-s', 'USE_TYPED_ARRAYS=0', '-s', 'I64_MODE=0',
'--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')],
stdout=PIPE, stderr=PIPE).communicate()
assert len(output[0]) == 0, output[0]
@@ -6079,7 +6117,7 @@ elif 'benchmark' in str(sys.argv):
'''
self.do_benchmark(src, [], 'final: 720.')
- def test_files(self):
+ def zzztest_files(self):
src = r'''
#include<stdio.h>
#include<stdlib.h>