aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/lifetime.ll42
-rw-r--r--tests/cases/lifetime.py6
-rw-r--r--tests/runner.py7
3 files changed, 54 insertions, 1 deletions
diff --git a/tests/cases/lifetime.ll b/tests/cases/lifetime.ll
new file mode 100644
index 00000000..dc6d471d
--- /dev/null
+++ b/tests/cases/lifetime.ll
@@ -0,0 +1,42 @@
+; 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
new file mode 100644
index 00000000..3bb9cbac
--- /dev/null
+++ b/tests/cases/lifetime.py
@@ -0,0 +1,6 @@
+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/runner.py b/tests/runner.py
index c8f23237..e908d294 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -3895,7 +3895,7 @@ at function.:blag
for name in glob.glob(path_from_root('tests', 'cases', '*.ll')):
shortname = name.replace('.ll', '')
- #if 'break' not in shortname: continue
+ if '' not in shortname: continue
print "Testing case '%s'..." % shortname
output_file = path_from_root('tests', 'cases', shortname + '.txt')
if Settings.QUANTUM_SIZE == 1:
@@ -3908,6 +3908,11 @@ at function.:blag
output = 'hello, world!'
if output.rstrip() != 'skip':
self.do_ll_run(path_from_root('tests', 'cases', name), output)
+ # Optional source checking, a python script that gets a global generated with the source
+ src_checker = path_from_root('tests', 'cases', shortname + '.py')
+ if os.path.exists(src_checker):
+ generated = open('src.cpp.o.js').read()
+ exec(open(src_checker).read())
# Autodebug the code
def do_autodebug(self, filename):