diff options
64 files changed, 162 insertions, 369 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index b1f0b585..1a752305 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -338,7 +338,7 @@ function analyzer(data, sidePass) { if (subItem != item && (!(subItem.intertype in UNUNFOLDABLE) || (subItem.intertype == 'value' && isNumber(subItem.ident) && isIllegalType(subItem.type)))) { if (item.intertype == 'phi') { - assert(subItem.intertype == 'value' || subItem.intertype == 'structvalue', 'We can only unfold illegal constants in phis'); + assert(subItem.intertype == 'value' || subItem.intertype == 'structvalue' || subItem.intertype in PARSABLE_LLVM_FUNCTIONS, 'We can only unfold some expressions in phis'); // we must handle this in the phi itself, if we unfold normally it will not be pushed back with the phi } else { var tempIdent = '$$etemp$' + (tempId++); diff --git a/src/library.js b/src/library.js index 7978e9cb..85d1d13f 100644 --- a/src/library.js +++ b/src/library.js @@ -7844,7 +7844,7 @@ LibraryManager.library = { inet_pton__deps: ['__setErrNo', '$ERRNO_CODES', 'inet_addr'], inet_pton: function(af, src, dst) { // int af, const char *src, void *dst - if ((af ^ {{{ cDefine("AF_INET") }}}) !== 0) { ___setErrNo(ERRNO_CODES.EAFNOSUPPORT); return -1; } + if ((af ^ {{{ cDefine('AF_INET') }}}) !== 0) { ___setErrNo(ERRNO_CODES.EAFNOSUPPORT); return -1; } var ret = _inet_addr(src); if (ret == -1 || isNaN(ret)) return 0; setValue(dst, ret, 'i32'); @@ -7932,7 +7932,7 @@ LibraryManager.library = { var aliasesBuf = _malloc(4); setValue(aliasesBuf, 0, 'i8*'); setValue(ret+___hostent_struct_layout.h_aliases, aliasesBuf, 'i8**'); - setValue(ret+___hostent_struct_layout.h_addrtype, {{{ cDefine("AF_INET") }}}, 'i32'); + setValue(ret+___hostent_struct_layout.h_addrtype, {{{ cDefine('AF_INET') }}}, 'i32'); setValue(ret+___hostent_struct_layout.h_length, 4, 'i32'); var addrListBuf = _malloc(12); setValue(addrListBuf, addrListBuf+8, 'i32*'); diff --git a/src/library_gl.js b/src/library_gl.js index 737db8cf..8c724245 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1323,7 +1323,7 @@ var LibraryGL = { GLEmulation.fogColor = new Float32Array(4); // Add some emulation workarounds - Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work'); + Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work. (If you do not want this, build with -s DISABLE_GL_EMULATION=1)'); #if GL_UNSAFE_OPTS == 0 Module.printErr('WARNING: using emscripten GL emulation unsafe opts. If weirdness happens, try -s GL_UNSAFE_OPTS=0'); #endif diff --git a/src/utility.js b/src/utility.js index 9cc8d3a3..7d122cef 100644 --- a/src/utility.js +++ b/src/utility.js @@ -312,6 +312,12 @@ function setUnion(x, y) { return ret; } +function setSize(x) { + var ret = 0; + for (var xx in x) ret++; + return ret; +} + function invertArray(x) { var ret = {}; for (var i = 0; i < x.length; i++) { diff --git a/system/include/sys/sendfile.h b/system/include/sys/sendfile.h new file mode 100644 index 00000000..1f58f0dd --- /dev/null +++ b/system/include/sys/sendfile.h @@ -0,0 +1,16 @@ +#ifndef _SYS_SENDFILE_H +#define _SYS_SENDFILE_H + +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tests/cases/structphiparam.ll b/tests/cases/structphiparam.ll new file mode 100644 index 00000000..117bdf77 --- /dev/null +++ b/tests/cases/structphiparam.ll @@ -0,0 +1,36 @@ +; ModuleID = '/dev/shm/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" + +@.str = private unnamed_addr constant [15 x i8] c"hello, %d %d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] +@_dispatchTable = internal global i64 0 + +define i32 @doit(i32 %x, { i32, i32 } %y) { + %y0 = extractvalue { i32, i32 } %y, 0 + %y1 = extractvalue { i32, i32 } %y, 1 + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %y0, i32 %y1) ; [#uses=0 type=i32] [debug line = 5:13] + ret i32 0 +} + +define i32 @main(i32 %argc) { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + %myi64 = alloca i64, align 4 + %comp = alloca { i32, i32 }, align 4 ; [#uses=1] + store i32 0, i32* %retval + %should = icmp ne i32 %argc, 1337 + br i1 %should, label %cond.end, label %cond.null + +cond.null: + br label %cond.end + +cond.end: ; preds = %cond.false, %cond.true + %cond = phi { i32, i32 } [ { i32 zext (i8 111 to i32), i32 6 }, %entry ], [ zeroinitializer, %cond.null ] ; [#uses=1] + store { i32, i32 } %cond, { i32, i32 }* %comp + %call = call i32 (i32, { i32, i32 })* @doit(i32 1, { i32, i32 } %cond) ; + ret i32 0 ; [debug line = 6:13] +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + diff --git a/tests/cases/structphiparam.txt b/tests/cases/structphiparam.txt new file mode 100644 index 00000000..f5af49f1 --- /dev/null +++ b/tests/cases/structphiparam.txt @@ -0,0 +1 @@ +hello, 111 6! diff --git a/tests/cube_explosion.c b/tests/cube_explosion.c index 3f55b3c6..0c6eb674 100644 --- a/tests/cube_explosion.c +++ b/tests/cube_explosion.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -230,8 +216,6 @@ int main(int argc, char *argv[]) glDeleteTextures(1, &texture); assert(!glIsTexture(texture)); // but not anymore - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cube_explosion.png b/tests/cube_explosion.png Binary files differnew file mode 100644 index 00000000..58a16f2b --- /dev/null +++ b/tests/cube_explosion.png diff --git a/tests/cubegeom.c b/tests/cubegeom.c index 787b8373..949a1f9a 100644 --- a/tests/cubegeom.c +++ b/tests/cubegeom.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { int temp; // testing @@ -308,9 +294,7 @@ int main(int argc, char *argv[]) // END SDL_GL_SwapBuffers(); - - verify(); - + #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom.png b/tests/cubegeom.png Binary files differnew file mode 100644 index 00000000..1c6a7fd5 --- /dev/null +++ b/tests/cubegeom.png diff --git a/tests/cubegeom_color.png b/tests/cubegeom_color.png Binary files differnew file mode 100644 index 00000000..a1d15438 --- /dev/null +++ b/tests/cubegeom_color.png diff --git a/tests/cubegeom_color2.c b/tests/cubegeom_color2.c index 5294329d..76d71d00 100644 --- a/tests/cubegeom_color2.c +++ b/tests/cubegeom_color2.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -287,8 +273,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_color2.png b/tests/cubegeom_color2.png Binary files differnew file mode 100644 index 00000000..ee78eb63 --- /dev/null +++ b/tests/cubegeom_color2.png diff --git a/tests/cubegeom_fog.c b/tests/cubegeom_fog.c index 9c04a55d..cae6ca2d 100644 --- a/tests/cubegeom_fog.c +++ b/tests/cubegeom_fog.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -295,8 +281,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_fog.png b/tests/cubegeom_fog.png Binary files differnew file mode 100644 index 00000000..c88e5a14 --- /dev/null +++ b/tests/cubegeom_fog.png diff --git a/tests/cubegeom_glew.c b/tests/cubegeom_glew.c index 22ef5d74..a3d86a40 100644 --- a/tests/cubegeom_glew.c +++ b/tests/cubegeom_glew.c @@ -19,20 +19,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { int temp; // testing @@ -297,8 +283,7 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - + #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_mt.c b/tests/cubegeom_mt.c index 464de7cc..b4ad28a7 100644 --- a/tests/cubegeom_mt.c +++ b/tests/cubegeom_mt.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -288,8 +274,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_mt.png b/tests/cubegeom_mt.png Binary files differnew file mode 100644 index 00000000..47649cdc --- /dev/null +++ b/tests/cubegeom_mt.png diff --git a/tests/cubegeom_normal.c b/tests/cubegeom_normal.c index d128fef2..02655edf 100644 --- a/tests/cubegeom_normal.c +++ b/tests/cubegeom_normal.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -283,8 +269,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_normal.png b/tests/cubegeom_normal.png Binary files differnew file mode 100644 index 00000000..7e3b35d1 --- /dev/null +++ b/tests/cubegeom_normal.png diff --git a/tests/cubegeom_normal_dap.c b/tests/cubegeom_normal_dap.c index f811c586..752911a8 100644 --- a/tests/cubegeom_normal_dap.c +++ b/tests/cubegeom_normal_dap.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -279,8 +265,7 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - + #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_normal_dap_far.c b/tests/cubegeom_normal_dap_far.c index f954b3c7..35a068d9 100644 --- a/tests/cubegeom_normal_dap_far.c +++ b/tests/cubegeom_normal_dap_far.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -277,8 +263,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_normal_dap_far_glda.c b/tests/cubegeom_normal_dap_far_glda.c index a4b4975b..849245b8 100644 --- a/tests/cubegeom_normal_dap_far_glda.c +++ b/tests/cubegeom_normal_dap_far_glda.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -268,8 +254,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_normal_dap_far_glda.png b/tests/cubegeom_normal_dap_far_glda.png Binary files differnew file mode 100644 index 00000000..815efeb9 --- /dev/null +++ b/tests/cubegeom_normal_dap_far_glda.png diff --git a/tests/cubegeom_normal_dap_far_glda_quad.c b/tests/cubegeom_normal_dap_far_glda_quad.c index aa6383b8..93c157a4 100644 --- a/tests/cubegeom_normal_dap_far_glda_quad.c +++ b/tests/cubegeom_normal_dap_far_glda_quad.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -268,8 +254,6 @@ int main(int argc, char *argv[]) SDL_GL_SwapBuffers(); - verify(); - #if !EMSCRIPTEN SDL_Delay(1500); #endif diff --git a/tests/cubegeom_normal_dap_far_glda_quad.png b/tests/cubegeom_normal_dap_far_glda_quad.png Binary files differnew file mode 100644 index 00000000..8683b0ed --- /dev/null +++ b/tests/cubegeom_normal_dap_far_glda_quad.png diff --git a/tests/cubegeom_normal_dap_far_range.c b/tests/cubegeom_normal_dap_far_range.c index eb54c22a..17691ce9 100644 --- a/tests/cubegeom_normal_dap_far_range.c +++ b/tests/cubegeom_normal_dap_far_range.c @@ -29,20 +29,6 @@ REDISTRIBUTION OF THIS SOFTWARE. #include <string.h> #include <assert.h> -void verify() { - int width = 640, height = 480; - unsigned char *data = (unsigned char*)malloc(width*height*4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - int sum = 0; - for (int x = 0; x < width*height*4; x++) { - if (x % 4 != 3) sum += x * data[x]; - } -#if EMSCRIPTEN - int result = sum; - REPORT_RESULT(); -#endif -} - int main(int argc, char *argv[]) { SDL_Surface *screen; @@ -277,8 +263,6 @@ int main(int argc, char *argv[]) SDL_GL_Sw |