diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-27 17:51:39 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-27 17:51:39 -0800 |
commit | 49d7f0d857192ff18291e9a87997d3b6015fc4e3 (patch) | |
tree | 9393c97e4e6dc31295a48d03442d23314bc3920a /src | |
parent | c540f3f36a4297187aab59dd0dd8cf08fbbb7867 (diff) |
properly handle illegal phi literals
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 15d66285..a1c009f2 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -221,11 +221,16 @@ function analyzer(data, sidePass) { // accessible through ident$x, and not constants we need to parse then and there) if (subItem != item && (!(subItem.intertype in UNUNFOLDABLE) || (subItem.intertype == 'value' && isNumber(subItem.ident) && isIllegalType(subItem.type)))) { - var tempIdent = '$$emscripten$temp$' + (tempId++); - subItem.assignTo = tempIdent; - unfolded.unshift(subItem); - fixUnfolded(subItem); - return { intertype: 'value', ident: tempIdent, type: subItem.type }; + if (item.intertype == 'phi') { + assert(subItem.intertype == 'value', 'We can only unfold illegal constants 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 = '$$emscripten$temp$' + (tempId++); + subItem.assignTo = tempIdent; + unfolded.unshift(subItem); + fixUnfolded(subItem); + return { intertype: 'value', ident: tempIdent, type: subItem.type }; + } } else if (subItem.intertype == 'switch' && isIllegalType(subItem.type)) { subItem.switchLabels.forEach(function(switchLabel) { if (switchLabel.value[0] != '$') { @@ -370,6 +375,12 @@ function analyzer(data, sidePass) { var toAdd = []; var elements = getLegalVars(item.assignTo, bits); var j = 0; + var literalValues = {}; // special handling of literals - we cannot unfold them normally + value.params.map(function(param) { + if (isNumber(param.value.ident)) { + literalValues[param.value.ident] = getLegalLiterals(param.value.ident, bits); + } + }); elements.forEach(function(element) { toAdd.push({ intertype: 'phi', @@ -381,7 +392,7 @@ function analyzer(data, sidePass) { label: param.label, value: { intertype: 'value', - ident: param.value.ident + '$' + j, + ident: (param.value.ident in literalValues) ? literalValues[param.value.ident][j].ident : (param.value.ident + '$' + j), type: 'i' + element.bits, } }; |