diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-22 17:21:19 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-23 16:03:06 -0700 |
commit | 2a0f90ac5964f73e5e5b8bee35a8962ba9cca4a2 (patch) | |
tree | ea3d0d2c57f10b1e2555ff7279d6fa2f048c8c24 | |
parent | 46aac5343e53225f1e9bc74c584ecb9b6afd74a1 (diff) |
asm coerce in atomicrmw; fixes #1637
-rw-r--r-- | src/jsifier.js | 4 | ||||
-rw-r--r-- | tests/cases/atomicrmw_unaligned.emcc | 1 | ||||
-rw-r--r-- | tests/cases/atomicrmw_unaligned.ll | 21 | ||||
-rw-r--r-- | tests/cases/atomicrmw_unaligned.txt | 1 | ||||
-rw-r--r-- | tests/test_core.py | 7 |
5 files changed, 32 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index a8c8d32d..05dd256c 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1237,8 +1237,8 @@ function JSify(data, functionsOnly, givenFunctions) { var param1 = finalizeLLVMParameter(item.params[0]); var param2 = finalizeLLVMParameter(item.params[1]); switch (item.op) { - case 'add': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, 'tempValue+' + param2, type, null, null, null, null, ',') + ',tempValue)'; - case 'sub': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, 'tempValue-' + param2, type, null, null, null, null, ',') + ',tempValue)'; + case 'add': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, asmCoercion('tempValue+' + param2, type), type, null, null, null, null, ',') + ',tempValue)'; + case 'sub': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, asmCoercion('tempValue-' + param2, type), type, null, null, null, null, ',') + ',tempValue)'; case 'or': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, 'tempValue|' + param2, type, null, null, null, null, ',') + ',tempValue)'; case 'and': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, 'tempValue&' + param2, type, null, null, null, null, ',') + ',tempValue)'; case 'xor': return '(tempValue=' + makeGetValue(param1, 0, type) + ',' + makeSetValue(param1, 0, 'tempValue^' + param2, type, null, null, null, null, ',') + ',tempValue)'; diff --git a/tests/cases/atomicrmw_unaligned.emcc b/tests/cases/atomicrmw_unaligned.emcc new file mode 100644 index 00000000..9faeda24 --- /dev/null +++ b/tests/cases/atomicrmw_unaligned.emcc @@ -0,0 +1 @@ +["-s", "UNALIGNED_MEMORY=1"] diff --git a/tests/cases/atomicrmw_unaligned.ll b/tests/cases/atomicrmw_unaligned.ll new file mode 100644 index 00000000..fe479dce --- /dev/null +++ b/tests/cases/atomicrmw_unaligned.ll @@ -0,0 +1,21 @@ +; 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, %d,%d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +; [#uses=0] +define i32 @main() { +entry: + %t = alloca i32, align 4 ; [#uses=2 type=i32**] + store i32 50, i32* %t, align 4 + %0 = load i32* %t + %1 = atomicrmw add i32* %t, i32 3 seq_cst, ; [#uses=0 type=i32] [debug line = 21:12] + %2 = load i32* %t + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %0, i32 %2) ; [#uses=0 type=i32] + %3 = atomicrmw volatile add i32* %t, i32 3 seq_cst, ; [#uses=0 type=i32] [debug line = 21:12] + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) diff --git a/tests/cases/atomicrmw_unaligned.txt b/tests/cases/atomicrmw_unaligned.txt new file mode 100644 index 00000000..45d16fb1 --- /dev/null +++ b/tests/cases/atomicrmw_unaligned.txt @@ -0,0 +1 @@ +hello, 50,53! diff --git a/tests/test_core.py b/tests/test_core.py index 4c17a942..0b6528e7 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8937,6 +8937,8 @@ def process(filename): def test_cases(self): if Building.LLVM_OPTS: return self.skip("Our code is not exactly 'normal' llvm assembly") + emcc_args = self.emcc_args + try: os.environ['EMCC_LEAVE_INPUTS_RAW'] = '1' Settings.CHECK_OVERFLOWS = 0 @@ -8950,6 +8952,10 @@ def process(filename): if '_noasm' in shortname and Settings.ASM_JS: print self.skip('case "%s" not relevant for asm.js' % shortname) continue + if os.path.exists(shortname + '.emcc'): + self.emcc_args = emcc_args + if not self.emcc_args: continue + self.emcc_args += json.loads(open(shortname + '.emcc').read()) print >> sys.stderr, "Testing case '%s'..." % shortname output_file = path_from_root('tests', 'cases', shortname + '.txt') if Settings.QUANTUM_SIZE == 1: @@ -8970,6 +8976,7 @@ def process(filename): finally: del os.environ['EMCC_LEAVE_INPUTS_RAW'] + self.emcc_args = emcc_args def test_fuzz(self): if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2') |