diff options
-rw-r--r-- | src/analyzer.js | 19 | ||||
-rw-r--r-- | tests/cases/uadd_overflow.ll | 7 | ||||
-rw-r--r-- | tests/cases/uadd_overflow.txt | 1 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index cbede04e..bfb2dd7b 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -121,7 +121,7 @@ function analyzer(data, sidePass) { // Legalization if (USE_TYPED_ARRAYS == 2) { function getLegalVars(base, bits) { - assert(!isNumber(base)); + if (isNumber(base)) return getLegalLiterals(base, bits); var ret = new Array(Math.ceil(bits/32)); var i = 0; while (bits > 0) { @@ -463,6 +463,23 @@ function analyzer(data, sidePass) { i++; continue; } + case 'insertvalue': { + bits = getBits(value.type); + var toAdd = []; + var elements = getLegalVars(item.assignTo, bits); + var sourceElements = getLegalVars(item.ident, bits); + var modifiedIndex = value.indexes[0][0].text; + for (var j = 0; j < elements.length; j++) { + toAdd.push({ + intertype: 'value', + assignTo: elements[j].ident, + type: 'i' + elements[j].bits, + ident: j == modifiedIndex ? item.value.ident : sourceElements[j].ident + }); + } + i += removeAndAdd(label.lines, i, toAdd); + continue; + } case 'bitcast': { var inType = item.type2; var outType = item.type; diff --git a/tests/cases/uadd_overflow.ll b/tests/cases/uadd_overflow.ll index a808b9de..dfbf199b 100644 --- a/tests/cases/uadd_overflow.ll +++ b/tests/cases/uadd_overflow.ll @@ -15,6 +15,13 @@ entry: %a1 = extractvalue { i32, i1 } %uadd1, 1 %a2 = zext i1 %a1 to i32 call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %a0, i32 %a2) ; [#uses=0] + %buadd1prepre = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %mul7, i32 %shl10) + %buadd1pre = insertvalue { i32, i1 } %buadd1prepre, i1 0, 1 + %buadd1 = insertvalue { i32, i1 } %buadd1pre, i32 5177, 0 + %ba0 = extractvalue { i32, i1 } %buadd1, 0 + %ba1 = extractvalue { i32, i1 } %buadd1, 1 + %ba2 = zext i1 %ba1 to i32 + call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %ba0, i32 %ba2) ; [#uses=0] ret i32 1 } diff --git a/tests/cases/uadd_overflow.txt b/tests/cases/uadd_overflow.txt index dcda9240..6e65c896 100644 --- a/tests/cases/uadd_overflow.txt +++ b/tests/cases/uadd_overflow.txt @@ -1 +1,2 @@ *3319578,1* +*5177,0* |