aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/call_i64_noret.ll17
-rw-r--r--tests/cases/uadd_overflow_64_ta2.ll30
-rw-r--r--tests/cases/uadd_overflow_64_ta2.txt2
-rw-r--r--tests/cases/uadd_overflow_ta2.ll6
-rw-r--r--tests/cases/uadd_overflow_ta2.txt1
-rwxr-xr-xtests/runner.py41
-rw-r--r--tests/unistd/misc.out2
7 files changed, 81 insertions, 18 deletions
diff --git a/tests/cases/call_i64_noret.ll b/tests/cases/call_i64_noret.ll
new file mode 100644
index 00000000..a8a30fc0
--- /dev/null
+++ b/tests/cases/call_i64_noret.ll
@@ -0,0 +1,17 @@
+; ModuleID = 'tests/hello_world.bc'
+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-S128"
+target triple = "i386-pc-linux-gnu"
+
+@.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 i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i64 0) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
diff --git a/tests/cases/uadd_overflow_64_ta2.ll b/tests/cases/uadd_overflow_64_ta2.ll
new file mode 100644
index 00000000..a4f3e40b
--- /dev/null
+++ b/tests/cases/uadd_overflow_64_ta2.ll
@@ -0,0 +1,30 @@
+; ModuleID = 'tests/hello_world.bc'
+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-S128"
+target triple = "i386-pc-linux-gnu"
+
+@.str2 = private constant [11 x i8] c"*%llx,%d*\0A\00", align 1 ; [#uses=1]
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %uadd1 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 18446744073709551606, i64 9999)
+ %a0 = extractvalue { i64, i1 } %uadd1, 0
+ %a1 = extractvalue { i64, i1 } %uadd1, 1
+ %a2 = zext i1 %a1 to i32
+ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str2, i32 0, i32 0), i64 %a0, i32 %a2) ; [#uses=0]
+
+ %uadd2 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 18446744073709, i64 9999)
+ %b0 = extractvalue { i64, i1 } %uadd2, 0
+ %b1 = extractvalue { i64, i1 } %uadd2, 1
+ %b2 = zext i1 %b1 to i32
+ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str2, i32 0, i32 0), i64 %b0, i32 %b2) ; [#uses=0]
+
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
+
+declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
+declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
+
diff --git a/tests/cases/uadd_overflow_64_ta2.txt b/tests/cases/uadd_overflow_64_ta2.txt
new file mode 100644
index 00000000..f5711309
--- /dev/null
+++ b/tests/cases/uadd_overflow_64_ta2.txt
@@ -0,0 +1,2 @@
+*2705,1*
+*10c6f7a0dcfc,0*
diff --git a/tests/cases/uadd_overflow_ta2.ll b/tests/cases/uadd_overflow_ta2.ll
index 81a76bcd..feac60e3 100644
--- a/tests/cases/uadd_overflow_ta2.ll
+++ b/tests/cases/uadd_overflow_ta2.ll
@@ -33,6 +33,12 @@ entry:
%64ba2 = zext i1 %64ba1 to i32
call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %64ba0, i32 %64ba2) ; [#uses=0]
+ %zbuadd1 = insertvalue { i32, i1 } { i32 undef, i1 false }, i32 10, 0 ; undef and explicit
+ %zba0 = extractvalue { i32, i1 } %zbuadd1, 0
+ %zba1 = extractvalue { i32, i1 } %zbuadd1, 1
+ %zba2 = zext i1 %ba1 to i32
+ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %zba0, i32 %zba2) ; [#uses=0]
+
ret i32 1
}
diff --git a/tests/cases/uadd_overflow_ta2.txt b/tests/cases/uadd_overflow_ta2.txt
index bcd04599..81513080 100644
--- a/tests/cases/uadd_overflow_ta2.txt
+++ b/tests/cases/uadd_overflow_ta2.txt
@@ -1,3 +1,4 @@
*3319578,1*
*5177,0*
*9875,1*
+*10,0*
diff --git a/tests/runner.py b/tests/runner.py
index fa984f05..db5ba108 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -266,11 +266,11 @@ process(sys.argv[1])
if output_processor is not None:
output_processor(open(filename + '.o.js').read())
- if self.emcc_args is not None:
+ if self.emcc_args is not None and 'ASM_JS=1' in self.emcc_args:
if '--memory-init-file' in self.emcc_args:
memory_init_file = int(self.emcc_args[self.emcc_args.index('--memory-init-file')+1])
else:
- memory_init_file = 1
+ memory_init_file = 0
if memory_init_file:
assert '/* memory initializer */' not in open(filename + '.o.js').read()
else:
@@ -735,7 +735,8 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
uint64_t a = 5;
double b = 6.8;
uint64_t c = a * b;
- printf("*prod:%llu*\n*%d,%d,%d*\n", c, (int)&a, (int)&b, (int)&c); // printing addresses prevents optimizations
+ if (truthy()) printf("*%d,%d,%d*\n", (int)&a, (int)&b, (int)&c); // printing addresses prevents optimizations
+ printf("*prod:%llu*\n", c);
}
// Basic (rounded, for now) math. Just check compilation.
@@ -745,6 +746,14 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
b++; if (truthy()) b--; // confuse optimizer
printf("*%Ld,%Ld,%Ld,%Ld*\n", (a+b)/5000, (a-b)/5000, (a*3)/5000, (a/5)/5000);
+ a -= 17; if (truthy()) a += 5; // confuse optimizer
+ b -= 17; if (truthy()) b += 121; // confuse optimizer
+ printf("*%Lx,%Lx,%Lx,%Lx*\n", b - a, b - a/2, b/2 - a, b - 20);
+
+ if (truthy()) a += 5/b; // confuse optimizer
+ if (truthy()) b += 121*(3+a/b); // confuse optimizer
+ printf("*%Lx,%Lx,%Lx,%Lx*\n", a - b, a - b/2, a/2 - b, a - 20);
+
return 0;
}
'''
@@ -764,7 +773,10 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
'*-1,34359738367,4294967295,1073741823*\n' +
'*-1,-1,-1,-1*\n' +
'*-1,34359738367,4294967295,1073741823*\n' +
- '*prod:34*')
+ '*prod:34*\n' +
+ '*524718382041609,49025451137,787151111239120,52476740749274*\n' +
+ '*ffff210edd000002,91990876ea283be,f6e5210edcdd7c45,1234000000450765*\n' +
+ '*def122fffffe,91adef1232283bb,f6e66f78915d7c42,1234def123450763*\n')
src = r'''
#include <stdio.h>
@@ -2486,7 +2498,6 @@ Exception execution path of first function! 1
''')
def test_exceptions(self):
- if Settings.ASM_JS: return self.skip('no exceptions support in asm')
if Settings.QUANTUM_SIZE == 1: return self.skip("we don't support libcxx in q1")
if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly')
@@ -2576,7 +2587,6 @@ Exception execution path of first function! 1
self.do_run(src, 'Throw...Construct...Catched...Destruct...Throw...Construct...Copy...Catched...Destruct...Destruct...')
def test_white_list_exception(self):
- if Settings.ASM_JS: return self.skip('no exceptions support in asm')
Settings.DISABLE_EXCEPTION_CATCHING = 2
Settings.EXCEPTION_CATCHING_WHITELIST = ["__Z12somefunctionv"]
Settings.INLINING_LIMIT = 50 # otherwise it is inlined and not identified
@@ -2608,9 +2618,7 @@ Exception execution path of first function! 1
Settings.DISABLE_EXCEPTION_CATCHING = 0
Settings.EXCEPTION_CATCHING_WHITELIST = []
-
def test_uncaught_exception(self):
- if Settings.ASM_JS: return self.skip('no exceptions support in asm')
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')
Settings.DISABLE_EXCEPTION_CATCHING = 0
@@ -2650,7 +2658,6 @@ Exception execution path of first function! 1
self.do_run(src, 'success')
def test_typed_exceptions(self):
- if Settings.ASM_JS: return self.skip('no exceptions support in asm')
Settings.DISABLE_EXCEPTION_CATCHING = 0
Settings.SAFE_HEAP = 0 # Throwing null will cause an ignorable null pointer access.
src = open(path_from_root('tests', 'exceptions', 'typed.cpp'), 'r').read()
@@ -2658,7 +2665,6 @@ Exception execution path of first function! 1
self.do_run(src, expected)
def test_multiexception(self):
- if Settings.ASM_JS: return self.skip('no exceptions support in asm')
Settings.DISABLE_EXCEPTION_CATCHING = 0
src = r'''
#include <stdio.h>
@@ -8079,11 +8085,11 @@ def process(filename):
shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgo.js'))
pgo_output = run_js(self.in_dir('pgo.js')).split('\n')[1]
- open('pgo_data', 'w').write(pgo_output)
+ open('pgo_data.rsp', 'w').write(pgo_output)
# with response file
- self.emcc_args += ['@pgo_data']
+ self.emcc_args += ['@pgo_data.rsp']
self.do_run(src, output)
self.emcc_args.pop()
shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed.js'))
@@ -8996,7 +9002,7 @@ TT = %s
# asm.js
exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1"])')
- exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "0"])')
+ exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "1"])')
# Make custom runs with various options
for compiler, quantum, embetter, typed_arrays, llvm_opts in [
@@ -10979,12 +10985,13 @@ elif 'browser' in str(sys.argv):
self.run_browser('page.html', '', '/report_result?1')
def test_sdl_image(self):
- # load an image file, get pixel data. Also O2 coverage for --preload-file
+ # load an image file, get pixel data. Also O2 coverage for --preload-file, and memory-init
shutil.copyfile(path_from_root('tests', 'screenshot.jpg'), os.path.join(self.get_dir(), 'screenshot.jpg'))
open(os.path.join(self.get_dir(), 'sdl_image.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_image.c')).read()))
- Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '-O2', '--preload-file', 'screenshot.jpg', '-o', 'page.html']).communicate()
- self.run_browser('page.html', '', '/report_result?600')
+ for mem in [0, 1]:
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '-O2', '--preload-file', 'screenshot.jpg', '-o', 'page.html', '--memory-init-file', str(mem)]).communicate()
+ self.run_browser('page.html', '', '/report_result?600')
def test_sdl_image_jpeg(self):
shutil.copyfile(path_from_root('tests', 'screenshot.jpg'), os.path.join(self.get_dir(), 'screenshot.jpeg'))
@@ -12090,7 +12097,7 @@ elif 'benchmark' in str(sys.argv):
try_delete(final_filename)
output = Popen([PYTHON, EMCC, filename, #'-O3',
'-O2', '-s', 'INLINING_LIMIT=0', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',# '-s', 'EXPLICIT_ZEXT=1',
- '-s', 'ASM_JS=1', '-s', 'USE_MATH_IMUL=1', '--llvm-lto', '1',
+ '-s', 'ASM_JS=1', '-s', 'USE_MATH_IMUL=1', '--llvm-lto', '1', '--memory-init-file', '0',
'-s', 'TOTAL_MEMORY=128*1024*1024', '-s', 'FAST_MEMORY=10*1024*1024',
'-o', final_filename] + shared_args + emcc_args, stdout=PIPE, stderr=self.stderr_redirect).communicate()
assert os.path.exists(final_filename), 'Failed to compile file: ' + output[0]
diff --git a/tests/unistd/misc.out b/tests/unistd/misc.out
index 810da215..a872a258 100644
--- a/tests/unistd/misc.out
+++ b/tests/unistd/misc.out
@@ -29,7 +29,7 @@ alarm: 0, errno: 0
ualarm: 0, errno: 0
fork: -1, errno: 11
vfork: -1, errno: 11
-crypt: 0, errno: 38
+crypt: (null), errno: 38
encrypt, errno: 38
getgid: 0, errno: 0
getegid: 0, errno: 0